Hi i have this really simple bit of code which i use to check to see if my home pc is online.
i want to use this on my website running wordpress to tell visitors I am online and then for them then to be able to click the text saying "yeah im online" or w/e and be able to IRC me.
The code im using to check if the host is alive is:
CODE
<?php
//Web Server Status v 1.4, Copyright 2002 By Ryan Schwiebert, visit http://www.schwebdesigns.com/
//This script may be freely distributed providing all copyright headers are kept intact.
//Concept from:
//Abax Server Status v1.04, Copyright 2002 By Nathan Dickman, visit http://www.NathanDickman.com/
//Location of the live or dead server images
//Please change to your server specifications
$live = "live.php";
$dead = "dead.php";
//The status checking script
//meddle at your own risk!
//check for port number, default is 80
$link = "62.31.82.214:42356";
$s_link = str_replace("::", ":", $link);
list($addr,$port)= explode (':',"$s_link");
if (empty($port)){
$port = 80;
}
//Test the server connection
$churl = @fsockopen(server($addr), $port, $errno, $errstr, 20);
if (!$churl){
//echo $errstr;
header ("location: $dead");
}
else {
header ("location: $live");
}
function server($addr){
if(strstr($addr,"/")){$addr = substr($addr, 0, strpos($addr, "/"));}
return $addr;
}
?>
inside the 2 output files the code is:
CODE
<?php
echo "yes im online";(and in the other file the same just "no im offline")
?>
This script was originally set to output an image file which isnt really what i want, i want it to check and then come back on the webpage with the text from either one of the output files.
So ive tried a few things, I just dumped the code in the wordpress page which did not work and i tried PHP include which also did not work and ive tried refrencing to the php file in a <script> tag in the header of the site.
So the only thing I could think of the could work would be an if statement on the website to go to the php doc and see which file it was outputting. So i wrote this:
CODE
<?php
$adres = "http://mattgooch.com/onlinestatus/status.php";
$picch = "live";
if ($adres == $picch)
{
echo "You win matt im online";
}
else
{
echo "your offline";
}
?>
That works in the sense that it doesn't return an error but doesn't work because it doesn't display the correct status.
This has been bugging me for a day now, and im a bit of a novice at php but ive been trying hard so if anyone could help me out I would really really appreciate it ! thanks