Re: Testing if a server is running with almost no permissions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Testing if a server is running with almost no permissions

From: Al <alexrussell101@gmail.com>
Date: Thu Jan 12 2006 - 21:00:27 CET

As for the original question... If your server has cURL support, try
using that:
It works like fopen with URLs when that feature is disabled.

I stole this from a firefox XML feed ticker code but here's the basic
script:

<?php

function getResponse($url, $port, $timeout) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_PORT, $port);

    $data = curl_exec($ch);
    curl_close($ch);

    if ($data === NULL)
        return "Error"; // i assume this where you decide if the
server's down or whatever you wanted to do

    return $data;
}

$infoFromSite = getResponse("http://www.example.com/", 80, 25);

echo
"<html><head></head><body><pre>".htmlentities($infoFromSite)."</pre></body></html>";

?>
Received on Tue Jan 17 16:56:53 2006