[PHP] Little Help Needed
Could someone tell me what I did wrong with this script. It should read the page http://www.mto.gov.on.ca/english/traveller/conditions/rdclosure.htm and only read between the 2 words in the script. And email any new stuff to the email address in the script. What did I do wrong that is causing this script to fail? ? # -- # Configuration # Directory on the remote server. Be sure to include leading and trailing slashes! $remotedir = /english/traveller/conditions/; # File on the remote server. No slashes! $remotefile = rdclosure.htm; # Keyword to check for in response. $keyword = Closed; # Remote server address. $remoteserver = www.mto.gov.on.ca; # E-mail recipient(s). Separate each address with a comma and a space. $emailrecip = [EMAIL PROTECTED]; # E-mail subject line. $emailsubject = MTO - TEST . date(' (G:i:s)'); # E-mail From name. $emailfromname = WxServer Roads; # E-mail From address. $emailfromaddr = [EMAIL PROTECTED]; # End Configuration # -- # Format the page for easy viewing. Header( Content-type: text/html); # Setup the request. $header .= GET . $remotedir . $remotefile . HTTP/1.0\r\n; $header .= Host: . $remoteserver . \r\n; $header .= User-Agent: Downloader\r\n\r\n; $fp = fsockopen ($remoteserver, 80, $errno, $errstr, 30); # Do the request. fputs ($fp, $header . $req) or die(Can't access the site!); while (!feof($fp)) { $res .= fgets ($fp, 128); } # Strip off the header info. $res = preg_replace(/[^]+/, , $res); $res = preg_replace(/Last Updated\:\s+?\d\d\d\d-\d\d-\d\d\s+?\d\d\:\d\d/, , $res); $res = preg_replace(/nbsp;/, , $res); $headerend = strpos($res,\r\n\r\n); if (is_bool($res)) { $result = $res; } else { $result = substr($res,$headerend+4,strlen($res) - ($headerend+4)); } fclose ($fp); # Start and end tags $startstr = Highways; $endstr = This; # Find start and end positions $startpos = strpos($result, $startstr) + strlen($startstr); $endpos = strpos($result, $endstr, $startpos); # Get string between 2 tags $result = substr($result, $startpos, $endpos-$startpos); echo ($new_res); # Check for keyword. if (!stristr($result, $keyword)) die(ERROR Code Word Not Found); # Read the file containing the last response. $filename = $remotefile . '.txt'; $fp = fopen($filename, r); $contents = fread($fp, filesize($filename)); fclose($fp); # Check for changes. if ($contents == $new_res) { # There has not been a change. echo (No Updates\r\n); } else { # There has been a change. echo (**UPDATES DETECTED**\r\n); # Write the new file. $filename = $remotefile . '.txt'; $fp = fopen($filename, w); $write = fputs($fp, $result); fclose($fp); # Send the e-mail. $recipient = $emailrecip; $subject = $emailsubject; $body_of_email = $result; $header = 'From: ' . $emailfromname . ' ' . $emailfromaddr . ''; mail ($recipient, $subject, $body_of_email, $header); echo (E-mail sent.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Little Help Needed
You should describe more specific what is going wrong with your script. What does the script output? Maybe you should post a vardump as well. /frank 2005-04-05 kl. 11.07 skrev Jason: Could someone tell me what I did wrong with this script. It should read the page http://www.mto.gov.on.ca/english/traveller/conditions/rdclosure.htm and only read between the 2 words in the script. And email any new stuff to the email address in the script. What did I do wrong that is causing this script to fail? ? # --- --- # Configuration # Directory on the remote server. Be sure to include leading and trailing slashes! $remotedir = /english/traveller/conditions/; # File on the remote server. No slashes! $remotefile = rdclosure.htm; # Keyword to check for in response. $keyword = Closed; # Remote server address. $remoteserver = www.mto.gov.on.ca; # E-mail recipient(s). Separate each address with a comma and a space. $emailrecip = [EMAIL PROTECTED]; # E-mail subject line. $emailsubject = MTO - TEST . date(' (G:i:s)'); # E-mail From name. $emailfromname = WxServer Roads; # E-mail From address. $emailfromaddr = [EMAIL PROTECTED]; # End Configuration # --- --- # Format the page for easy viewing. Header( Content-type: text/html); # Setup the request. $header .= GET . $remotedir . $remotefile . HTTP/1.0\r\n; $header .= Host: . $remoteserver . \r\n; $header .= User-Agent: Downloader\r\n\r\n; $fp = fsockopen ($remoteserver, 80, $errno, $errstr, 30); # Do the request. fputs ($fp, $header . $req) or die(Can't access the site!); while (!feof($fp)) { $res .= fgets ($fp, 128); } # Strip off the header info. $res = preg_replace(/[^]+/, , $res); $res = preg_replace(/Last Updated\:\s+?\d\d\d\d-\d\d-\d\d\s+?\d\d\:\d\d/, , $res); $res = preg_replace(/nbsp;/, , $res); $headerend = strpos($res,\r\n\r\n); if (is_bool($res)) { $result = $res; } else { $result = substr($res,$headerend+4,strlen($res) - ($headerend+4)); } fclose ($fp); # Start and end tags $startstr = Highways; $endstr = This; # Find start and end positions $startpos = strpos($result, $startstr) + strlen($startstr); $endpos = strpos($result, $endstr, $startpos); # Get string between 2 tags $result = substr($result, $startpos, $endpos-$startpos); echo ($new_res); # Check for keyword. if (!stristr($result, $keyword)) die(ERROR Code Word Not Found); # Read the file containing the last response. $filename = $remotefile . '.txt'; $fp = fopen($filename, r); $contents = fread($fp, filesize($filename)); fclose($fp); # Check for changes. if ($contents == $new_res) { # There has not been a change. echo (No Updates\r\n); } else { # There has been a change. echo (**UPDATES DETECTED**\r\n); # Write the new file. $filename = $remotefile . '.txt'; $fp = fopen($filename, w); $write = fputs($fp, $result); fclose($fp); # Send the e-mail. $recipient = $emailrecip; $subject = $emailsubject; $body_of_email = $result; $header = 'From: ' . $emailfromname . ' ' . $emailfromaddr . ''; mail ($recipient, $subject, $body_of_email, $header); echo (E-mail sent.); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Little help
Hi, I have a script that records the languange and time zone of every user that comes to the site. Currently I am testing this and need some people to just surf a couple pages in the site, from around the world. If you don't mind, please just see a page or two on this site. It doesn't matter anything else (you like it, do anything, etc) , I just need some browsers from outside the US to surf a page or two. www.basementideas.com/index.php TIA Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Little help please
I'm looking for a webbased interface that will allow me to managae mysql databases. However, phpmyadmin has been ruled out due to the fact it requires the username and password to be stored in the config file and that it doesn't have any security to protect the average joe from stumbling across it. So can anyone point me in the direction of a utility that requires a login that checks of the users database then throws that information into the config for the mysql management? I would be greatful for any help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Little help please
I'm looking for a webbased interface that will allow me to managae mysql databases. However, phpmyadmin has been ruled out due to the fact it requires the username and password to be stored in the config file No it doesn't. and that it doesn't have any security to protect the average joe from stumbling across it. Ummm... yes it does. Read the installation directions a little more carefully. So can anyone point me in the direction of a utility that requires a login that checks of the users database then throws that information into the config for the mysql management? How about PHPMyAdmin? You can configure it so that it checks the mysql.user table. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php