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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iSellJerseyShore
Forum Newbie
Posts: 2
Joined: Fri Aug 11, 2006 8:19 am

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

Post 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
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post 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.
iSellJerseyShore
Forum Newbie
Posts: 2
Joined: Fri Aug 11, 2006 8:19 am

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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 \
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply