Forum Moderators: coopster
thing is that i made IIS 7 Server on my PC & some time i turn off my PC ill upload this PHP file on free hosting my domain name.
when some1 open page this PHP page loads itself & check if My PC is on than it should show my IIS 7 Pages if not than it will redirect to this page Sorry the Server is dowN
i have DNS Service for my IIS 7 all i need is pHP script who check this status & do this function
[edited by: eelixduppy at 7:45 pm (utc) on Dec. 21, 2009]
[edit reason] removed specifies [/edit]
On the somehost.com, you would need a page like the following:
<?php
$request = $_SERVER['REQUEST_URI'];
$homeURL = "http://www.homepc.com{$request}";
$contents = file_get_contents("$homeURL");
if ($contents===false)
{
/*do nothing or add code as needed. at this stage, it means the home site is unavailable. so you could have content below this code or you could redirect to other content, etc.*/
}
else
{
/*Basically content can now be retrieved from your home PC. You can either redirect the user to your home PC server with PHP header calls, ie:*/
header("Location: {$homeURL}");
exit();
/*Or you could even "print out" the retrieved contents, ie:*/
echo $contents;
exit();
}
?> To be honest, I have not tried this and am not sure if the get_file_contents() function will handle as I anticipate because I have never done anything like this with PHP. But I presume that if you request the file off your home PC, and it is not available (file contents cannot be retrieved), then the function should output boolean false. If you get this as output, you know the home PC is down. But if you do content back, you'll know the home PC is up and running so you can either redirect the user or even use coding to pull content off the home PC and display it directly to the user on the hosted site.