Re: unsure how to do this any help appreciated
| From: | Nick Stinemates | Date: | Wed, 20 Feb 2008 06:00:59 +0000 |
| Subject: | Re: unsure how to do this any help appreciated | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269694@lists.php.net to get a copy of this message | ||
Michael Seton wrote:
> To Whom this may Concern,
>
> Basically what im try to do is this.... (please bear with me im a php
> noob)
> require a remote file, if its blank then instead display a comment or
> another file (which ever is easier)
>
> Example:
> *_if
> "http://launcher.worldofwarcraft.com/alert" contains
> nothing or contains "Not Found" or "404 error", display " Sorry
> no updates at this time or No server notices at this time" or
> include blah.php, otherwise display
>
> _**_"http://launcher.worldofwarcraft.com/alert"._*
>
>
> Because the source is remotely updated, the information contained at
> this address is beyond my control, so i need this to control what is
> said on my end
> I'm not sure how to get this one to work
>
> Any help would be appreciated or a direction to where to find
> something that will help me,
>
> Pixmyster
>
> Guild Master
> Synergy Of Triumphalism
> Horde - Spinebreaker - US Realm
> World Of Warcraft Guild
> Website: www.synergyoftriumphalism.com
> Email: pixmyster@gmail.com
>
<?php
$fp = fsockopen("launcher.worldofwarcraft.com", 80, $errno, $errstr,
30); //open the socket
if (!$fp) // if the socket doesnt open, die
die("$errstr ($errno)<br />\n");
//construct http specific headers
$out = "GET /alert HTTP/1.1\r\n";
$out .= "Host: launcher.worldofwarcraft.com\r\n";
$out .= "Connection: Close\r\n\r\n";
$buff = ""; //generate a buffer to fille
fwrite($fp, $out); //send the headers
while (!feof($fp)) {
$buff .= fgets($fp, 128); //read the response
}
fclose($fp); //close the socket
if (strstr($buff, "404")) { //analyze.
echo "no alerts";
} else {
echo "alerts";
}
?>
--
==================
Nick Stinemates (nick@stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates@hotmail.com
Yahoo: nickstinemates@yahoo.com
==================