User Tools

Site Tools


finger_with_sajax

finger.php

<?php 
require("Sajax.php");

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);
	}
	return $ret;
}

function finger($domain) {
  $fp = fsockopen('finger.nic.at', 79);
  $domain .= "\n";
  fputs($fp, $domain, strlen($domain));
  $text = fgets($fp);
  fclose($fp);
  if (preg_match  ('/NO domain data/', $text)) {
     return 1;
   } else {
     return 0;
   }
}
	sajax_init();
//	$sajax_debug_mode = 1;
	sajax_export("get_domain");
	sajax_handle_client_request();

?>
<html>
<head>
	<title>finger</title>
	<script>
	<?
	sajax_show_javascript();
	?>
	
	
	function set_result(domainname) {
		document.getElementById('domain_label').innerHTML = domainname;		
	}
		
	function get_domain() {
		// get the folder name
		var domainname;		
		domainname =  document.getElementById("domainname").value;	
		x_get_domain(domainname, set_result);
	}
	</script>
	
</head>
<body>
  
	Domain: <input name="domainname" id="domainname" type="text" size="30" maxlength="60" 
	 onkeyup="get_domain(); return false;"> 
		
	<div id="domain_label"></div><br />		
		
</body>
</html>
finger_with_sajax.txt · Last modified: 2014/09/10 21:22 (external edit)