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 page on free hosting
i want this php page should work like this if some one open my website this php page should check if my server is online than it should open the page from my website if not than it should redirect the user the to this Page "Sorry The Server is Down"
i m using dot.tk Domain My website URL is <snip>
my website loads it from my Computer. So please help me & tell me how i can make it possible?
I have Script but its not working i dont know why i m gonna show it to you here
<?php
//Web Server Status v 1.4, Copyright 2002 By Ryan Schwiebert
//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
//Location of the live or dead server images
//Please change to your server specifications
$live = "ftp://greeny.example.com:13000/live.gif";
$dead = "http://example2.com/albums/aa149/greeeeny/dead.gif";
//The status checking script
//meddle at your own risk!
//check for port number, default is 80
$link = $_GET['link'].":";
$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;
}
?>
-------------------------------------------------------------------------
$live = "ftp://greeny.example.com:13000/live.gif"; <<<< this picture loads from my PC
$dead = "http://example2.com/albums/aa149/greeeeny/dead.gif"; <<< its free image hosting website
problem is when i stop My IIS 7 & check it it does not show Dead.gif on page
now i want you guys to give me solution if it cannot loads image i mean if my server is stopped so it should show this page "The Server is Down" text on that page" so please me out ....
thanks in advance =)
[edited by: eelixduppy at 6:58 am (utc) on Dec. 22, 2009]
[edit reason] removed specifics [/edit]
What might be possible is to have a PhP redirect script on your free hosting and have your domain pointed at that, and if your PC is on users get redirected to your PC, so in pseudo code terms:
<?php
if(hosting1 = available) {
header('Location: hosting1/index.php');
}
else {
echo 'content';
}
?> Not sure what the argument for the if statement would actually be though, one of the pro's here will need to supply that.
[EDIT]
Also, you'll need to make sure that your free hosting supports PhP if this is to work. I've never used PhP on free hosting before, so I couldn't offer the names of any suitable providers I'm afraid.
If you have a file on your main hosting called something like redirect.php, with the following content:
<?php
header('Location: hosting1/index.php');
?> and then on your free hosting, you have index.php with the following code:
<?php
include 'http://hosting1/redirect.php';
echo 'content';
?> Then if your server is up, there will be a file for it to pull, which will automatically redirect users to your server; and if it is down, then there will be no redirect for it to run.
header('Location: ...'); needs to be the very first line in the document to work, and so it would be the first thing to be run. <?php
if(http://hosting1/index.php) {
header('Location: http://example.com/index.php');
}
else {
echo 'content';
}
?> [edited by: eelixduppy at 8:36 pm (utc) on Feb 16, 2010]
[edit reason] switched to example.com [/edit]
==================================
FREE HOSTING (http://greeny.example.com/index.php)
<?php
include 'http://greeny.example.com/redirect.php';
echo 'Hi FRIENDS!
Greenyz Sharing Server is Down right Now, Please Wait for Greeny when he will be online this Website will Work. Because the contents of this website loads from his Computer He share Data Directly from his Computer You can make request aswel if you want Movies, Songs , Mobile Applications, Tutorials & much more. =) You Can add him on your facebook [facebook.com...] if you want or you can email him if you want to make request manually greeny@example.com Thank you.';
?>
============================================
redirect.php
================================================================
<?php
header('Location: [greeny.example.com...]
?>
[edited by: greeny at 5:05 pm (utc) on Dec. 22, 2009]
[edited by: eelixduppy at 5:16 pm (utc) on Dec. 22, 2009]
[edit reason] exemplified [/edit]
FREE HOSTING (http://greeny.example.com/index2.php)
its giving this error =(
Parse error: syntax error, unexpected ':' in /home/vhosts/greeny.example.com/index2.php on line 11
<?php
if(http://greeny.is-a-geek.net/wordpress) {
header('Location: [greeny.example.com...]
}
else {
echo 'Server is DowN';
}
?>
[edited by: eelixduppy at 5:16 pm (utc) on Dec. 22, 2009]
I am thinking something along the lines of:
<?php
echo '<p>Please wait, page is loading</p>';
$page = 'http://hosting1/index.php';
if(file_exists($page)) {
echo '<meta http-equiv="refresh" content="0;url=http://hosting1/index.php">;
} else {
echo '<meta http-equiv="refresh" content="0;url=http://hosting2/serverdown.php">';
}
?> Unfortunatley, my own testing (using just a plain text echo, rather than a meta to stop annoying local cache problems) is always echoing the "else" - and I'm not sure why, if one of the gurus could take a look, that'd be appreciated.
[edited by: eelixduppy at 8:38 pm (utc) on Feb 16, 2010]
<?php
echo '<p>Please wait, page is loading</p>';
$page = 'http://greeny.example.com/wordpress';
if(file_exists($page)) {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example.com/wordpress">;
} else {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example.com/serverdown.php">';
}
?>
And put ur ping ip codes in this
<?php
$str = exec("ping -n 1 -w 1 yourip",$input, $result);
if ($result == 0){
echo "ON";
}else{
echo "OFF";
}
?>
==========================================
my Auto ip DNS is: greeny.is-a-geek.net
my free hosting URL is: greeny.freetzi.com
plz put the values & send me the code i m realy sorry i m kinda dump in php but i realy want this solution =( ill be highly thaNkful of you guys from my heart...
thanks
[edited by: eelixduppy at 5:31 am (utc) on Dec. 23, 2009]
<?php
echo '<p>Please wait, page is loading</p>';
$page = 'http://greeny.example.com/wordpress';
if(file_exists($page)) {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example.com/wordpress">;
} else {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example.com/serverdown.php">';
}
?>
[edited by: eelixduppy at 5:31 am (utc) on Dec. 23, 2009]
// still have questions ?, don't hesitate to asq!
?>
[edited by: eelixduppy at 5:32 am (utc) on Dec. 23, 2009]
<?php
echo '<p align="center">Please wait, page is loading.</p>';
$str = exec('ping -n 1 -w 1 greeny.is-a-geek.net ',$input, $result);
if ($result == 0) {
echo '<meta http-equiv="refresh" content="0;url=http://hosting1/index.php">';
} else {
echo '<meta http-equiv="refresh" content="0;url=http://hosting2/serverdown.php">';
}
?> To borrow SuperDuck's (Cheers by the way Duck :)) code.
Regards,
Readie
host1 : [greeny.example.net...]
its still loading this page & IE Shows Page Cannot be displayed
Please you check it i upload it on my host2 :
[greeny.example2.com...]
=========================================================================
<?php
echo '<p align="center">Please wait, page is loading.</p>';
$str = exec('ping -n 1 -w 1 greeny.is-a-geek.net ',$input, $result);
if ($result == 0) {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example.net/wordpress">';
} else {
echo '<meta http-equiv="refresh" content="0;url=http://greeny.example2.com/serverdown.php">';
}
?>
=========================================================================
[edited by: eelixduppy at 5:33 am (utc) on Dec. 23, 2009]
i want you guys to test it
[edited by: eelixduppy at 5:33 am (utc) on Dec. 23, 2009]
If you have issues with this though, there is another method (returning to my second idea I posted)
====
HOST 1 redirect.php
====
<?php
echo '<meta http-equiv="refresh" content="0,url=http://hosting1/index.php">';
?> ====
HOST 2 index.php
====
<?php
echo '<meta http-equiv="refresh" content="60,url=http://hosting2/serverdown.php">
<p align="center">Pleas wait, page is loading</p>';
include 'http://hosting1/index.php';
?> Which will wait 60 seconds before giving up and sending you to your "server is down" page.
I advise only using this method if you experience problems with the method outlined by SuperDuck.
Regards,
Readie
====
HOST 1 redirect.php
====
<?php
echo '<meta http-equiv="refresh" content="0,url=http://hosting1/index.php">';
?>
====
HOST 2 index.php
====
<?php
echo '<meta http-equiv="refresh" content="60,url=http://hosting2/serverdown.php">
<p align="center">Pleas wait, page is loading</p>';
include 'http://hosting1/index.php';
?>