GENWiki

Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools


joomla:get_the_current_uk_terror_threat_level_from_mi5
    $mi5="https://www.mi5.gov.uk/UKThreatLevel/UKThreatLevel.xml";
    $xml=simplexml_load_file($mi5);
 
    //print_r($xml);
 
    $title=$xml->channel->title;
    $threat=$xml->channel->item->description;
    $updated=$xml->channel->item->pubDate;
    $ukthreat=explode(".",$threat);
    $ukthreat=str_replace(" from international terrorism","",$ukthreat[0]);
    $ukthreat=Trim(str_replace("The current","",$ukthreat));
 
    if(strpos($ukthreat,"LOW")!==false) { $FC="#00FF00"; }
    if(strpos($ukthreat,"MODERATE")!==false) { $FC="#D7DF01"; }
    if(strpos($ukthreat,"SUBSTANTIAL")!==false) { $FC="#FFBF00"; }
    if(strpos($ukthreat,"SEVERE")!==false) { $FC="#FF0040"; }
    if(strpos($ukthreat,"CRITICAL")!==false) { $FC="#DF01D7"; }
 
    echo "<span style=\"color:".$FC."\"><strong>".$ukthreat."</strong></span>";

MI5 expose an API to capture the current UK Terror Threat Level, this short PHP snipped grabs that status and output's it to the web page. If your using Joomla and want to include this little snippet then we strongly recommend RegularLabs Sourcer which will allow you to embed this into a custom HTML Module and stick it anywhere. If your more experienced with Joomla development then you'll be able to quickly knock up a module.

Besides having the status on your website, you can of course use the status to display selected content depending on the level. This can be done in sourcer, with a php header set OR in a module/component.

/data/webs/external/dokuwiki/data/pages/joomla/get_the_current_uk_terror_threat_level_from_mi5.txt · Last modified: 2019/05/20 10:13 by genadmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki