본문
<?
/*
해당 서버의 시간 알아오기
*/
$host=$_GET['host'];
$host=ereg_replace("^.*//", "", $host);
?>
<html>
<head>
<title>서버시간 확인하기</title>
<style>
body, input, td, div
{
font-family : arial,굴림;
font-size : 9pt;
}
.button
{
border-width : 1px;
border-style : solid;
border-color : #9F3515;
background : #FF754B;
color : #ffffff;
height : 20px;
font-weight : bold;
padding : 2px 1px 0px 1px;
}
.input
{
border-width : 1px;
border-style : solid;
border-color : #777777;
background : #ffffff;
color : #000000;
height : 20px;
padding : 1px 1px 0px 1px;
}
</style>
</head>
<body>
<table align="center" bgcolor="#FFE241" border="0" cellpadding="15" cellspacing="1" width="100%">
<tr>
<td bgcolor="#FDF7D5"> 시간을 확인할 서버의 도메인(또는 IP address)을 입력하세요. (예:ebs.co.kr)<br><br>
<form style="display:inline">http://
<input class="input" name="host" size="30" type="text" value="<?=$host?>">
<input class="button" type="submit" value="확인">
</form>
</td>
</tr>
</table>
<?
if($host)
{
$fp=@fsockopen($host, 80, $errno, $errstr, 3);
if($fp)
{
$gap=time();
fputs($fp, "GET /test_request HTTP/1.0n");
fputs($fp,"n");
$data='';
while(! feof ($fp))
{
$data .=fgets ($fp, 1024);
}
fclose ($fp);
$data=explode("Date: ", $data);
$data=explode(" GMT", $data[1]);
$data=strtotime($data[0]) + 9 * 3600;
$data=(int)$data;
if(!$data)
{
echo "<br><br>서버 접속에 실패하였습니다.";
}
else
{
$gap=time() - $gap;
$data=$data + $gap;
?>
<br><br><font style="font-size:20pt"><b><?=$host ?></b>의 현재시간은...<br><b><div id="timeArea" style="display:inline; font-size:20pt"></div></b>입니다.</font>
<script language="javascript">
var timePass = 0;
function showTime()
{
var now = new Date();
var timeStamp = (<?=$data?> + timePass) * 1000;
now.setTime(timeStamp);
var yy = now.getFullYear();
var mm = now.getMonth() + 1;
var dd = now.getDate();
var hh = now.getHours();
var ii = now.getMinutes();
var ss = now.getSeconds();
document.getElementById('timeArea').innerHTML = yy + "년 " + mm + "월 " + dd + "일 " + hh + "시 " + ii + "분 " + ss + "초";
timePass++;
setTimeout("showTime()", 1000);
}
showTime();
</script>
<?
}
}
else
{
echo "<br><br>서버 접속에 실패하였습니다.";
}
}
?>
</body>
</html>
관련링크
- http://seobangnim.com/zbxe/3878 1562회 연결
댓글목록
등록된 댓글이 없습니다.