|
Kontrola domn
$return_string = ""; function GetCurlPage ($pageSpec) { $ch = curl_init($pageSpec); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_COOKIEJAR, "cook"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cook"); $tmp = curl_exec ($ch); curl_close ($ch); return $tmp; } function PostCurlPage ($pageSpec, $data, $header, $follow) { $ch = curl_init($pageSpec); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow); curl_setopt($ch, CURLOPT_COOKIEFILE, "cook"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cook"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $tmp = curl_exec ($ch); curl_close ($ch); return $tmp; } function Rozrezat($str) { $MAX_WIDTH = 75; $delka = 0; $retezce = split("\n",$str); $str = ''; for ($i=0; $i < sizeof($retezce); $i++) { if (strlen($retezce[$i])<$MAX_WIDTH) { $str .= $retezce[$i]."\n"; /*$delka = strlen($retezce[$i]);*/ } else { $slova = split(' ',$retezce[$i]); $delka = 0; for ($j=0 ; $j < sizeof($slova); $j++) { if ($delka + strlen($slova[$j]) < $MAX_WIDTH) { $delka += strlen($slova[$j])+1; $str .= $slova[$j].' '; } else { $delka = strlen($slova[$j])+1; $str .= "\n" . $slova[$j].' '; } } $str .= "\n"; } } return $str; } function ConfirmDomain($domena, $postfix) { global $return_string; if ($domena == '') return 5; if (!eregi("^[a-z0-9_-]{2,}$", $domena)) { return -1; } // if ($postfix == 'eu') return 0; require("domainlist.php"); $open_whois_server = fsockopen($domain[$postfix][0], 43); if (!$open_whois_server) //Whois server was not opened { //Try second server $open_whois_server = fsockopen($domain[$posftix][2], 43); if (!$open_whois_server) //Whois server was not opened { //Try third server $open_whois_server = fsockopen($domain[$posftix][3], 43); } } if (!$open_whois_server) { return 0; //No whois server was opened } $send_query = fwrite($open_whois_server, "$domena.$postfix\r\n"); if (!$send_query) { fclose($open_whois_server); return 0; //An error occured while communicate with whois server } while(!feof($open_whois_server)) { $return_string .= fgets($open_whois_server, 128); } $return_string = Rozrezat ($return_string); if (eregi($domain[$postfix][1], $return_string)) { fclose($open_whois_server); return 1; //The domain is free } else { fclose($open_whois_server); return 2; //The domain is not free } } |