finger.php
<?php require ('xajax_core/xajax.inc.php'); $xajax = new xajax(); $xajax->configure('javascript URI', '/'); function get_domain($domain) { $pdolist = array('at', 'co.at', 'or.at'); foreach ($pdolist as $pdo) { $d = $domain.'.'.$pdo; $r = finger($d); $text = ( $r == 0 ) ? "occupied" : "free" ; $ret .= sprintf("<br> %s [%s]", $d, $text); } $objResponse = new xajaxResponse(); $objResponse->assign('domain_label', 'innerHTML', $ret); return $objResponse; } function finger($domain) { $fp = fsockopen('finger.nic.at', 79); $domain .= "\n"; fputs($fp, $domain, strlen($domain)); $text = fgets($fp); fclose($fp); $ret = preg_match ('/NO domain data/', $text) ? 1 : 0; return $ret; } $req_get_domain =& $xajax->registerFunction('get_domain'); $req_get_domain->setParameter(0, XAJAX_INPUT_VALUE, 'domainname'); $xajax->processRequest(); ?> <html> <head> <title>finger</title> <?php $xajax->printJavascript(); ?> </head> <body> Domain: <input name="domainname" id="domainname" type="text" size="30" maxlength="60" onkeyup='<?php $req_get_domain->printScript(); ?>;'> <div id="domain_label"></div><br /> </body> </html>