<?PHP
function lookup($hport,$comment,$who) {
$fp = fsockopen($who, $hport, &$errno, &$errstr, 4);
if (!$fp) {
$data = "$comment ($hport): -neodpov&#xED;d&#xE1;";
}
else {
$data = "$comment ($hport): -aktivn&#xED;";
fclose($fp);
}
return $data;
}
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<template>
<do type="prev" label="Zp&#x011B;t"><prev/></do>
<do type="accept" label="Hlavn&#xED;"><go href="index.php"/></do>
</template>
<card id="srvstat" title="ServerStat">
<p>
<?PHP if (empty($addr)) { ?>
Adresa serveru <input type="text" name="addr" title="Adresa"/><br/>
Vlastn&#xED; slu&#x017E;ba <input type="text" name="myport" emptyok="true" title="Vlastn&#xED; port"/><br/>
<anchor>Spustit<go href="srvstat.php" method="get">
<postfield name="myport" value="$(myport)"/>
<postfield name="addr" value="$(addr)"/>
</go></anchor><br/>
<?PHP } else {
echo StrToUpper($addr)."<br/><small>\n";
echo lookup("80","HTTP","$addr")."<br/>\n";
echo lookup("21","FTP","$addr")."<br/>\n";
echo lookup("22","SSH","$addr")."<br/>\n";
echo lookup("443","SSL","$addr")."<br/>\n";
echo lookup("25","SMTP","$addr")."<br/>\n";
echo lookup("110","POP3","$addr")."<br/>\n";
echo lookup("143","IMAP4","$addr")."<br/>\n";
echo lookup("139","NetBIOS","$addr")."<br/>\n";
echo lookup("389","LDAP","$addr")."<br/>\n";
echo lookup("23","Telnet","$addr")."<br/>\n";
echo lookup("3306","MySQL","$addr")."<br/>\n";
echo lookup("6667","IRC","$addr")."<br/>\n";
if (trim($myport)<>"")
echo lookup($myport,"vlastn&#xED;","$addr")."<br/>\n";
echo "</small>\n";
} 
?>
</p>
</card>
</wml>