Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: PHP server online check |
|
Author |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 29 Aug '06 12:26 Post subject: PHP server online check |
|
|
To check if your server and services like apache, stmp, etc it is usefull to put this script on a different server than your own
Code: |
<h1>server check</h1>
<p><?php
function server2($server, $port, $name) {
preg_match("/^(http:\/\/)?([^\/]+)/i", "$server", $match);
$host = $match[2];
preg_match_all("/\.([^\.\/]+)/",$host, $match);
$matches[0][0] = $matches[1][0];
$host = trim($host);
$socket = "";
@$socket = fsockopen("$host", $port, $errno, $errstr, 2);
if(!$socket) {
$socket = print("\n<br /><font color=\"red\">No responce from $name $host!</font>");
} else {
fclose($socket);
$socket = print("\n<br /><font color=\"green\">$host $name OK!</font>");
}
}
$server=$_GET['server'];
if($server!=""){
server2($server,"21","ftp");
server2($server,"22","ssh");
server2($server,"23","telnet");
server2($server,"25","smtp");
server2($server,"80","http");
server2($server,"110","pop3");
server2($server,"443","https");
server2($server,"3306","MySQL");
server2($server,"8080","http_proxy");
}
else
{
$a=$_SERVER['PHP_SELF'];
?>
<form action="<?php echo $a; ?>" method="get">
<input type="text" name="server" value="">Server-url<br />
<input type="submit" value="check">
</form>
<?php
}
?>
|
Last edited by James Blond on Tue 29 Aug '06 19:35; edited 3 times in total |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 29 Aug '06 13:06 Post subject: |
|
|
Get errors/warnings:
PHP Parse error: parse error, unexpected T_SL in E:\web\online.php on line 37
Steffen |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Tue 29 Aug '06 13:28 Post subject: |
|
|
I corrected that. Hm, after coping the source to the forum, post it and copy it back to the file. It didn't work.
The Forumsoftware make some strange things with the here doc style (echo), so I changed it. Now it should work correcly. |
|
Back to top |
|
Steffen Moderator
Joined: 15 Oct 2005 Posts: 3092 Location: Hilversum, NL, EU
|
Posted: Tue 29 Aug '06 18:45 Post subject: |
|
|
Works great now. Yep, seems that phpBB does not like the echo.
Little typo:
localhost stmp OK! must be localhost smtp OK!
Steffen |
|
Back to top |
|
Demoric
Joined: 23 Nov 2005 Posts: 9 Location: S.E. Kansas
|
Posted: Tue 17 Oct '06 5:28 Post subject: |
|
|
Thanks for the script. It's very useful. |
|
Back to top |
|
|
|
|
|
|