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 function.
Code:
$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
Bookmarks