logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



PHP server online check

 
Post new topic   Reply to topic    Apache Forum Index -> Apache Webmaster Tools & Utilities



View previous topic :: View next topic  
Author Message
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Tue 29 Aug '06 12:26    Post subject: PHP server online check Reply with quote

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 Wink

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: 2580
Location: Hilversum, NL, EU

PostPosted: Tue 29 Aug '06 13:06    Post subject: Reply with quote

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: 6255
Location: Germany, Next to Hamburg

PostPosted: Tue 29 Aug '06 13:28    Post subject: Reply with quote

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: 2580
Location: Hilversum, NL, EU

PostPosted: Tue 29 Aug '06 18:45    Post subject: Reply with quote

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

PostPosted: Tue 17 Oct '06 5:28    Post subject: Reply with quote

Thanks for the script. It's very useful.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Apache Webmaster Tools & Utilities
Page 1 of 1