How do I enable/install this script on my site?
Posted: Fri Aug 11, 2006 8:25 am
I am interested in adding this PHP script to my site. I have followed the instructions provided on the following link.
http://www.ofhills.com/blog/index.ph...or_alert_level
Where do I actually insert the PHP script?
I am trying to achieve the same result as the example on that site...
I have created the alert.dat file and chmod to 777, the alert graphics have also been uploaded to my server.
Any help would be greatly appreciated!
-iSellJerseyShore
http://www.ofhills.com/blog/index.ph...or_alert_level
Where do I actually insert the PHP script?
I am trying to achieve the same result as the example on that site...
Code: Select all
<?
$myCheckInt = (60*60*4); //time between checking DHS = 4 hours
$filename = "alert.dat"; //put this empty file in directory, chmod 777
$myURL = "http://www.dhs.gov/dhspublic/display?theme=29&content=320";
$file_last_modified = filemtime($filename);
$currentTime = time();
$f_pointer = fopen($filename, "r");
$f_read = fread($f_pointer, filesize($filename));
fclose($f_pointer);
if (($currentTime - $file_last_modified) > $myCheckInt || $f_read =="")
{
if (!($siteContent = file($myURL)))
die ("failed to access info!");
foreach($siteContent as $line)
{
if (preg_match("/img name="dhsadvisory"/", $line))
$theLine = $line;
}
$f_pointer = fopen($filename, "w");
fwrite($f_pointer, $theLine);
fclose($f_pointer);
} else {
$theLine = $f_read;}
if (preg_match("/alt="Red Advisory"/", $theLine))
{
echo "Red Advisory: Severe risk of terrorist attacks.<br><br>";
echo "<img height="40" width="125" border="0" src="dhs-advisory-severe.gif">";
echo "<body bgcolor="#CC0000">";
}
if (preg_match("/alt="Orange Advisory"/", $theLine))
{
echo "Orange Advisory: High risk of terrorist attacks.<br><br>";
echo "<img height="40" width="125" border="0" src="dhs-advisory-high.gif">";
echo "<body bgcolor="#FF9900">";
}
if (preg_match("/alt="Yellow Advisory"/", $theLine))
{
echo "Yellow Advisory: Elevated condition; Significant risk of terrorist attacks.<br><br>";
echo "<img height="40" width="125" border="0" src="dhs-advisory-elevated.gif">";
echo "<body bgcolor="#FFFF00">";
}
if (preg_match("/alt="Blue Advisory"/", $theLine))
{
echo "Blue Advisory: Guarded condition; General risk of terrorist attack.<br><br>";
echo "<img height="40" width="125" border="0" src="dhs-advisory-guarded.gif">";
echo "<body bgcolor="#0033CC">";
}
if (preg_match("/alt="Green Advisory"/", $theLine))
{
echo "Blue Advisory: Low risk of terrorist attacks.<br><br>";
echo "<img height="40" width="125" border="0" src="dhs-advisory-low.gif">";
echo "<body bgcolor="#009900">";
}
?>Any help would be greatly appreciated!
-iSellJerseyShore