<?php
$pagetitle
=
'PHP域名查询程序'
;
$prompt_ip
=
'IP Address'
;
$prompt_dn
=
'Domain Name'
;
$lookupfail
=
'<span style="color:red;">* lookup failed *</span>'
;
$dn
= isset(
$_REQUEST
[
'dn'
]) ?
$_REQUEST
[
'dn'
] :
''
;
if
(
$dn
==
$prompt_dn
)
{
$dn
=
''
;
}
$ip
= isset(
$_REQUEST
[
'ip'
]) ?
$_REQUEST
[
'ip'
] :
''
;
if
(
$ip
==
$prompt_ip
)
{
$ip
=
''
;
}
if
(
$dn
)
{
if
(
$dn
==
'me'
)
{
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
}
else
{
$ip
= @
gethostbyname
(
$dn
);
if
(
$ip
==
$dn
)
{
$ip
=
$lookupfail
;
}
}
$message
=
$prompt_dn
.
' '
.
$dn
.
' :: '
.
$prompt_ip
.
' '
.
$ip
;
}
else
if
(
$ip
)
{
$dn
= @
gethostbyaddr
(
$ip
);
if
(
$dn
==
$ip
)
{
$dn
=
$lookupfail
;
}
$message
=
$prompt_ip
.
' '
.
$ip
.
' :: '
.
$prompt_dn
.
' '
.
$dn
;
}
else
{
$message
=
$prompt_dn
.
' '
.
$_SERVER
[
'HTTP_HOST'
]
.
' :: '
.
$prompt_ip
.
' '
.
$_SERVER
[
'SERVER_ADDR'
];
}
?>
<html>
<head>
<title><?php
echo
$pagetitle
;?></title>
</head>
<body style=
"background-color:#cfcfcf;font-family:Arial;sans-serif;font-size:12px;"
>
<h3 style=
"font-size:13px;margin-bottom:0px;"
><?php
echo
$pagetitle
;?></h3>
<hr />
<p style=
"margin-top:4px;margin-bottom:4px;font-size:12px;"
>
<?php
echo
$message
;?>
</p>
<form style=
"margin-top:4px;margin-bottom:4px;"
>
<input style=
"font-size:12px;"
type=
"text"
name=
"dn"
value=
"<?php echo $prompt_dn;?>"
size=
"30"
/>
<input style=
"font-size:12px;"
type=
"text"
name=
"ip"
value=
"<?php echo $prompt_ip;?>"
size=
"15"
/>
<input style=
"font-size:12px;"
type=
"submit"
value=
"Lookup"
/>
</form>
<hr />
<p style=
"margin:0px;font-size:9px;color:#666666;"
>
Copyright © 2003-<?php
echo
date
(
'Y'
);?>
by 程序员之家,欢迎您!
</p>
</body>
</html>