logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


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

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Webmaster Tools & Utilities View previous topic :: View next topic
Reply to topic   Topic: PHP server online check
Author
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
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: 3047
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: 7288
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: 3047
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


Reply to topic   Topic: PHP server online check View previous topic :: View next topic
Post new topic   Forum Index -> Webmaster Tools & Utilities