Page 1 of 1

How do I enable/install this script on my site?

Posted: Fri Aug 11, 2006 8:25 am
by iSellJerseyShore
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...

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">"; 
} 

?>
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

Posted: Fri Aug 11, 2006 8:31 am
by jamiel
Make a .php file wherever you want the script to be and paste the code in. Probably your webserver root where I presume you made the .dat file.

Posted: Fri Aug 11, 2006 11:36 am
by iSellJerseyShore
OK.... Well I created both a HTML file and a PHP file with the script in it. When I access them it reports the following error:
Parse error: syntax error, unexpected T_STRING in /home/mytestserver.com/terror/terror1.php on line 28

Any clues why it reports that?



Thanks!

-iSellJerseyShore

Posted: Fri Aug 11, 2006 11:48 am
by s.dot
It seems this line (along with other similar lines):

Code: Select all

if (preg_match("/alt="Red Advisory"/", $theLine))
should be

Code: Select all

if (preg_match("/alt=\"RedAdvisory\"/", $theLine))
The quotes weren't being escaped.

[edit] Actually, that script is full of parsing errors. All of the double quotes inside of the HTML need to be escaped with \