纯php程序无数据,无数据库的详细域名查询程序PHP版(1)_PHP教程

$sp[1] = substr(strchr($unavail[$l],\".\"),1);

$sp[0] = substr($unavail[$l],0,strlen($unavail[$l])-strlen($sp[1])-1);

$unavail_s = $unavail_s.\"href=\\\"\".$script_name.\"?domain=\".$sp[0].\"&ext=\".$sp[1].\"\\\">\".$unavail[$l].\"

\";

}

$f = str_replace(\"[>AVAIL_LIST $f = str_replace(\"[>UNAVAIL_LIST $f = str_replace(\"[>SCRIPT_NAME $f = str_replace(\"[>EXT $f = str_replace(\"[>EXT_LIST\",$whois_exts),$f);

$f = str_replace(\"[>EXT_HTML_LIST

name=ext>\\n\".implode(\"\\n\",$whois_exts).\"\\n\",$f);

return $f;

}

// show the error page

function do_error()

{

global $use_global_templates;

global $template_header;

global $template_footer;

global $template_error;

global $domain;

global $titlebar;

global $error_title;

global $errormsg;

$titlebar = $error_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_error);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

// checks the domain is legal

function check_domain()

{

global $errormsg;

global $domain;

global $ext;

global $whois_exts;

if(isset($ext)){

if(!strlen($ext)){

$errormsg = \"没有选择域名后缀\";

return 0;

}

if(!my_in_array($ext,$whois_exts)){

$errormsg = \"不支持此域名后缀\";

return 0;

}

}

if(isset($domain)){

if(strlen($domain) < 2 || strlen($domain) > 57){

$errormsg = \"域名太长或太短\";

return 0;

}

if(strlen($domain) == 2 && !ereg(\"([0-9]){2}\",$domain)){

$errormsg = \"在2个字节的域名中不能包含有字母\";

return 0;

}

if(ereg(\"^-|-$\",$domain)){

$errormsg = \"域名前和域名后不能使用-,也不可以连续使用-\";

return 0;

}

if(!ereg(\"([a-z]|[A-Z]|[0-9]|-){\".strlen($domain).\"}\",$domain)){

$errormsg = \"域名只可以包含字母数字组合和-\";

return 0;

}

}

return 1;

}

// perform_whois function returns 0 if domain is available otherwise returns either the raw info or 1

function perform_whois($domainname,$ext,$raw)

{

global $errormsg;

global $whois_servers;

global $rawoutput;

global $whois_avail_strings;

$rawoutput = \"\";

if($raw)

return do_raw($domainname,$ext);

if(($ns = fsockopen($whois_servers[$ext],43)) == false){

$errormsg = \"无法连接到域名查询服务器 \".$whois_servers[$ext].\"\";

return -1;

}

fputs($ns,\"$domainname.$ext\\n\");

while(!feof($ns))

$rawoutput .= fgets($ns,128);

fclose($ns);

echo \"\\n\";

if(!ereg($whois_avail_strings[$whois_servers[$ext]], $rawoutput))

return 0;

return 1;

}

// this performs the whois lookup and then shows the data returned

function do_raw($domainname, $ext)

{

global $titlebar;

global $template_raw_output;

global $use_global_templates;

global $template_header;

global $template_footer;

global $raw_output_title;

global $whois_info_servers;

global $whois_servers;

global $rawoutput;

global $errormsg;

global $whois_info_servers_backup;

global $whois_avail_strings;

global $whois_server;

choose_info_server($domainname, $ext);

if(($ns = fsockopen($whois_server,43)) == false){

if(($ns = fsockopen($whois_info_servers[$ext],43)) == false){

if(($ns = fsockopen($whois_info_servers_backup[$ext], 43)) == false){

return -1;

} else {

$whois_server = $whois_info_servers_backup[$ext];

}

} else {

$whois_server = $whois_info_servers[$ext];

}

}

print \"\\n\";

fputs($ns,\"$domainname.$ext\\n\");

while(!feof($ns))

$rawoutput = $rawoutput.fgets($ns,128);

fclose($ns);

echo \"\";

// $pos = @strpos($rawoutput,$whois_avail_strings[$server]);

// if(is_string($pos) && !$pos){}

// else{

// if(!is_string($pos) || $pos){

// if(($ns = fsockopen($whois_info_servers_backup[$ext],43)) == false)

// return -1;

// else{

// $rawoutput = \"\";

// fputs($ns,\"$domainname.$ext\\n\");

// while(!feof($ns))

// $rawoutput = $rawoutput.fgets($ns,128);

// $pos = @strpos($rawoutput,$whois_avail_strings[$whois_info_servers_backup[$ext]]);

// if(!is_string($pos) || $pos){}

// else

// return -1;

// }

// }

$titlebar = $raw_output_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_raw_output);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_getsearch_mini()

{

global $template_search_mini;

echo make_changes($template_search_mini);

exit();

}

function do_getsearch()

{

global $template_footer;

global $template_header;

global $use_global_templates;

global $titlebar;

global $template_search;

global $search_title;

$titlebar = $search_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_search);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_avail()

{

global $template_footer;

global $template_header;

global $use_global_templates;

global $titlebar;

global $template_available;

global $available_title;

$titlebar = $available_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_available);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_taken()

{

global $template_footer;

global $template_header;

global $use_global_templates;

global $template_taken;

global $titlebar;

global $taken_title;

$titlebar = $taken_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_taken);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_exts()

{

global $template_footer;

global $template_header;

global $use_global_templates;

global $template_exts_list;

global $titlebar;

global $exts_list_title;

$titlebar = $exts_list_title;

if($use_global_templates)

echo make_changes($template_header);

echo make_changes($template_exts_list);

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_glob()

{

global $domain;

global $whois_exts;

global $avail;

global $unavail;

global $template_header;

global $template_footer;

global $use_global_templates;

global $titlebar;

global $global_title;

$titlebar = $global_title;

if($use_global_templates)

echo make_changes($template_header);

if(!isset($domain)){

global $template_global;

echo make_changes($template_global);

}

else{

global $template_global_results;

for($l=0; $lif(($r = perform_whois($domain,$whois_exts[$l],0)) != -1){

if(!$r)

$avail[] = $domain.\".\".$whois_exts[$l];

else

$unavail[] = $domain.\".\".$whois_exts[$l];

}

}

echo make_changes($template_global_results);

}

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

function do_wiz()

{

global $domain;

global $ext;

global $avail;

global $unavail;

global $template_header;

global $template_footer;

global $use_global_templates;

global $titlebar;

global $wizard_title;

global $errormsg;

global $keyword1;

global $keyword2;

global $company;

$titlebar = $wizard_title;

if($use_global_templates)

echo make_changes($template_header);

if(!isset($company) || !isset($keyword1) || !isset($keyword2)){

global $template_wizard;

echo make_changes($template_wizard);

}

else{

global $template_wizard_results;

$domains = array(

$company,

$company.$keyword1,

$company.\"-\".$keyword1,

$keyword1.$company,

$keyword1.\"-\".$company,

$company.$keyword2,

$company.\"-\".$keyword2,

$keyword2.$company,

$keyword2.\"-\".$company,

$keyword1,

$keyword2,

$keyword1.$keyword2,

$keyword2.$keyword1,

$keyword1.\"-\".$keyword2,

$keyword2.\"-\".$keyword1

);

for($l=0; $l$domain = strtolower(str_replace(\" \",\"\",$domains[$l]));

if(check_domain()){

if(($r = perform_whois($domain,$ext,0)) != -1){

if(!$r)

$avail[] = $domain.\".\".$ext;

else

$unavail[] = $domain.\".\".$ext;

}

}

}

echo make_changes($template_wizard_results);

}

if($use_global_templates)

echo make_changes($template_footer);

exit();

}

load_server_info();

if(!check_domain())

do_error();

if(isset($do_wizard))

do_wiz();

if(isset($do_global))

do_glob();

if(isset($list_exts))

do_exts();

if(isset($do_mini_search))

do_getsearch_mini();

if(!isset($domain))

do_getsearch();

if(isset($show_raw)){

if(perform_whois($domain,$ext,1) != -1)

$errormsg = \"MWhois域名查询内部错误\";

do_error();

}

$ret = perform_whois($domain,$ext,0);

if($ret == -1)

do_error();

if(!$ret)

do_taken();

else

do_avail();

?>

http://www.bkjia.com/PHPjc/315524.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/315524.htmlTechArticle文件一:index.php ?php echo !-- Powered by MWhois written by Matt Wilson matt@mattsscripts.co.uk --\\n\; /* #####################################################################...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值