View Full Version : Server Status Request (Php)

01-27-2008, 03:08 AM
I am wondering if there is a script that would check my computer/another computer to see if a server (IRCd) is online/offline and display the result on the hompage.

I am also wondering if it would be possible to check if a client (my bot) is connected to the server and what channels it is on. Possibly using the script to query the IRC server with a whois and reporting back part of the raw data.

01-27-2008, 07:39 PM
The first part, checking if the server is online, is pretty easy. You'd have to hunt around for the second part, as I don't know anything about how you'd do that.

For the first part you'd use the fsockopen (http://us.php.net/fsockopen) function.

$server_host = "irc.example.com";
$server_port = 6667;

$conn = @fsockopen($server_host, $server_port, $errno, $err_string, 3);
if($conn === false) {
// server is offline
else {
// server is online

If you want to go more in depth into PHP & IRC, I found this article: Connecting to an IRC server with PHP (http://codingforums.com/showthread.php?t=91765)

01-27-2008, 08:46 PM
Hehe, thanks ^_^

I should really take it upon myself to learn php properly. The second part would be nice tho but I will search around for it. I have seen it done before with eggdrop shells.