| px | top | add code | search | signup | login | help |
<?php
## Examine Server for PHP4 ##
## add your own links to this array ##
$links = array(
"PHP\" => \"www.php.net\",
\"Apache\" => \"www.apache.org\",
\"IIS\" => \"www.microsoft.com\",
\"Lotus\" => \"www.lotus.com\"
);
function linkUp($string){
global $links;
foreach($links as $key => $value) {
$string = (strstr($string, $key))?str_replace($key, \"<a href=\\\"http://$value\\\">$key</a>\", $string):$string;
}
return $string;
}
function examine($domain){
if($domain){
set_time_limit(45);
if($fp = fsockopen($domain, 80, &$errno, &$errstr, 30)){
fputs($fp, \"GET / HTTP/1.0\\r\\n\\r\\n\");
$x = 0;
while(!feof($fp)) {
$data[$x] .= fgets($fp, 128);
$x++;
}
fclose ($fp);
}
}
for($x=0; $x<7; $x++) {
$result = (strstr(strtolower($data[$x]), \"server:\"))?$data[$x]:$result;
}
$result = str_replace(\"server:\", \"Server:\", $result);
$result .= (strstr($data[3], \"X-Powered-By\"))?\"<br>\".$data[3]:\"\";
$result = ($domain && !$result)?\"<b>ERROR:</b> connection could not be established with \".stripslashes($domain):$result;
return linkUp($result);
}
?>
<html>
<head>
<title>Examine Server</title>
<meta http-equiv=\"EXPIRES\" content=\"0\">
<meta http-equiv=\"Pragma\" content=\"no-cache\">
<style>
h2 {font-size: 12pt; font-weight: bold; font-style: normal; font-family: Verdana, Arial, Helvetica, sans-serif}
td {font-size: 8pt; font-weight: normal; font-style: normal; font-family: Verdana, Arial, Helvetica, sans-serif}
p {font-size: 10pt; font-weight: normal; font-style: normal; font-family: Verdana, Arial, Helvetica, sans-serif}
input {font-size: 8pt; font-family: Verdana, \'sans-serif\'}
</style>
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<h2>Examine Server</h2>
<form action=\"<?php echo $PHP_SELF; ?>\" method=\"get\">
<p>Enter a domain name to examine their server:
<input type=\"text\" name=\"domain\" value=\"<?php echo stripslashes($domain); ?>\">
<input type=\"submit\" value=\"Go\"></p>
</form>
<hr width=\"100%\" size=1 color=\"#000000\">
<p>
<?php
$result = examine(stripslashes($domain));
if(!strstr($result, \"ERROR\")) echo \"<a href=\\\"http://$domain\\\">$domain</a> is running:<br><br>\\n\";
echo $result;
?>
</p>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.