Podgląd pliku: / jacekk.info / time.phps


<?php
/**************************************************
 *             Czas z serwera daytime             *
 **************************************************
 * Wersja: 1.0                                    *
 * Autor: Jacek Kowalski (http://jacekk.info)     *
 *                                                *
 * Strona WWW: http://jacekk.info/scripts/time    *
 *                                                *
 * Utwór rozprowadzany na licencji                *
 * http://creativecommons.org/licenses/by-nc/2.5/ *
 **************************************************/

/* Kodowanie znaków UTF-8 */

include('imieniny.php');

Header('Pragma: no-cache');
$serv = array(
    
'132.163.4.102',
    
'132.163.4.103',
    
'128.138.140.44',
    
'131.107.1.10',
    
'132.163.4.101',
    
'216.200.93.8',
    
'208.184.49.9'
);

shuffle($serv);

$len count($serv);
for(
$i=0$i<$len$i++) {
    if(
$fp = @fsockopen($serv[$i], '13'$e1$e22)) {
        break;
    }
}

unset(
$serv$len$i);

if(
$fp) {
    
fwrite($fp"\n");
    
$tc fread($fp2048);
    
fclose($fp);

    
$eg explode(' '$tc);
    
$gt explode(':'$eg[2]);
    
$gd explode('-'$eg[1]);

    
$st mktime($gt[0], $gt[1], $gt[2], $gd[1], $gd[2], $gd[0]);
    
$st $st+3600+(date('I')*3600);
    unset(
$tc$eg$gt$gd$fp);
}
else
{
    
$st mktime();
}

$st explode(','date('w,d,n,Y,H,i,s'$st));
?>
<html>
<head>
<style type="text/css">
* {    font-family: 10px Verdana,sans-serif;
    text-align: center;}
#hm {    color: #888;
    font: bold 35px inherit;}
#s {    color: #888;
    font: bold inherit;}
#day {color: #000;font-size:12px;}
small {    color: #CCC;
    font-size: 9px;}
a {    color: #222;
    font-size: 9px;
    text-decoration: none;}
</style>
<script type="text/javascript">
<?php
echo 'h = '.$st[4].';
m = '
.$st[5].';
s = '
.$st[6].';

'
;
?>
function dtim() {
    if(s==60) {s=0;m=m+1;}
    if(m==60) {m=0;h=h+1;}
    if(h==24) {window.refresh();}

    document.getElementById('hm').innerHTML = h+':'+((m>9) ? m : '0'+m);
    document.getElementById('s').innerHTML = (s>9) ? ':'+s : ':0'+s;

    s=s+1;
    setTimeout("dtim()", 1000);
}
</script>
</head>
<body onLoad="javascript:dtim();">
<?php
$months 
= array('''stycznia''lutego''marca''kwietnia''maja''czerwca''lipca''sierpnia''września''października''listopada''grudnia');
$days = array('niedziela''poniedziałek''wtorek''środa''czwartek''piątek''sobota');

echo 
'<span id="hm">'.$st[4].':'.$st[5].'</span><span id="s">:'.$st[6].'</span><br/>
<span id="day">'
.$days[$st[0]].', '.$st[1].' '.$months[$st[2]].' '.$st[3].'<br/>
Imieniny: '
.$imieniny[$st[2]][(int)$st[1]].'</span><br/>
'
;
if(
date('I')==1) {
    echo 
'<small>UTC+0200 (Polska, czas letni)</small>';
}
else
{
    echo 
'<small>UTC+0100 (Polska, czas zimowy)</small>';
}
?>
<hr/>
<a href="http://jacekk.info">&copy; by Jacek Kowalski</a>
</body>
</html>

Browse Code © 2010 by Jacek Kowalski