-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkDomain.php
81 lines (73 loc) · 2.48 KB
/
checkDomain.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
session_start(); //start session
include('api_pavietnam/api_config.php');
include('config.php');
include('functions.php');
/*INFO*/
$cmd = isset($_GET['cmd'])? $_GET['cmd'] : 'check_whois'; #cmd
$domain = isset($_GET['domain'])? $_GET['domain'] : ''; #domain name
if($cmd && valid_domain($domain)):
##check_whois
if($cmd == 'check_whois'){
$result = file_get_contents(API_URL."?username=".USERNAME."&apikey=".API_KEY."&cmd=$cmd&domain=".$domain);//Gọi link thực thi thật
$output['domain'] = $domain;
//domain name
if(isset($_POST['name']))
$output['name'] = $_POST['name'];
else{
$t=explode('.',$domain);
$output['name'] = reset($t);
$output['tld'] = str_replace($output['name'].'.','',$domain); //extract into tld
}
if(isset($_POST['tld'])) $output['tld'] = $_POST['tld'];
if($result == '0'){ //Tên miền đã được đăng ký
$output['result'] = 'avaiable';
}
elseif($result == '1')//Tên miền chưa đăng ký
{
$output['result'] = 'unavaiable';
}
else//Các trường hợp lỗi
{
$output['result'] = 'error';
$output['reason'] = $result;
}
if($output['result'] !== 'error' && isset($output['tld'])){
$output['prices']= get_tld_price($output['tld']);
}
HistoryDomains($output); //history this domain
echo json_encode($output);
}
##view whois
elseif($cmd == 'get_whois'){
if(!cacheWhoisDomain($domain))
$result = file_get_contents(API_URL."?username=".USERNAME."&apikey=".API_KEY."&cmd=get_whois&domain=".$domain);//Gọi link thực thi thật
else $result = cacheWhoisDomain($domain);
include('lib/SmartDOMDocument.class.php');
$whois_server = 'http://www.whois.com'; //whois url which used to get domain info
//$result = file_get_contents('http://www.whois.com/whois/'.$domain);
/*$content_doc = new SmartDOMDocument();
$content_doc->loadHTML($result);
try {
$parag1 = $content_doc->getElementById("registryBlk");
$parag2 = $content_doc->getElementById("registrarBlk");
for($i=0;$i<$parag1->getElementsByTagName()->count();$i++)
{
$img = $parag1->getElementsByTagName()->item($i);
$src = $whois_server.$img->getAttribute('src');
$img->setAttribute('src',$src);
}
$new = new SmartDOMDocument();
$new->appendChild($new->importNode($parag1, true));
$new->appendChild($new->importNode($parag2, true));
$result = $new->saveHTMLExact();
//_print($result);
//cache whois
cacheWhoisDomain($domain,$result);
echo $result;
} catch(Exception $e) { }*/
cacheWhoisDomain($domain,$result);
echo $result;
}
endif;
?>