Home

hersto:  Source of ServerClock.php

 

Rant to the author:

    

Check for a response

Source of http://www.hersto.com/VRML_Tools/ServerClock.php

    
<?


/*
 * ServerClock.php
 *
 * The ServerClock.php script is copyright (C) by Herbert Stocker.
 * You can find the original version, the source code and the
 * corresponding VRML node at
 *
 *    http://devel.hersto.com/VRML_Tools/ServerClock.wrl
 *    http://devel.hersto.com/VRML_Tools/ServerClock.php
 *
 * Please keep this copyright info and the contact info
 * below along with any copy of this script.
 *
 *    Herbert Stocker
 *    hersto@hersto.de
 *    http://www.hersto.de/
 *
 * To make me happy, please send me a mail and tell me where you
 * use this script.
 *
 *
 * This script returns the current time on the server and adds
 * an optional offset to it. The time is returned as a VRML
 * node. An ExternProto definition at the above URL uses this
 * script to synchronize an internal clock with the time on the
 * server host.
 *
 * Thus, VRML worlds can simulate the day of time on any place on
 * earth without relying on the clock settings of the client
 * computer.
 * Other VRML worlds that don't correspond to a certain location
 * on earth can simulate time of day effects that are the same
 * for everybody viewing the world, regardless of their time zone
 * And acuracy of their computers clock.
 *
 * The time returned is simply the time of the host computer this
 * script runs on. To get at an acurate time, you should ensure
 * that this computer synchronizes its clock with some Internet
 * time server.
 *
 */






$NL"\n";


header("Content-type: model/vrml");
//header("Content-Type: text/plain");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Datum der Vergangenheit
//header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT"); // doesn't work in Netscape 4.75
//header ("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
//header ("Pragma: no-cache");                          // HTTP/1.0

echo "#VRML V2.0 utf8\n\n";







$Offset$HTTP_GET_VARS['offset']; // number of seconds to add to GMT.


if(is_null($User))
    
$TimeOffset0;



?>

# This file was generated by a PHP script.
# See http://www.hersto.de/VRML_Tools/ServerClock-Descr.php for a description
# of this script.



PROTO TimeFromServer
[
    exposedField SFInt32  year   0  # e.g. 1999
    exposedField SFInt32  month  0
    exposedField SFInt32  day    0
    exposedField SFInt32  hour   0
    exposedField SFInt32  min    0
    exposedField SFInt32  sec    0

    exposedField SFInt32  wday   0  # day of week [0 ..6]   (0 = Sun, 6 = Sat)
    exposedField SFInt32  yday   0  # day of the year  [0..365]
    exposedField SFInt32  week   0  # ISO-8601 week of year

    exposedField SFInt32  monlen 0  # number of days in the month [28..31]

    exposedField SFTime   now    0  # VRML timestamp
    exposedField SFString str    "" # RFC 822 string, e.g. "Fri, 29 Nov 2002 22:50:31 +0000"
]
  {  WorldInfo { } }


<?

function StripZeroes($Num)
{
    
// This is a quick hack that works only for numbers smaller than 10000.

return "10000$Num" 10000;
}



$Nowtime() + $Offset;


?>

TimeFromServer
{
    year   <?= StripZeroes(gmdate("Y"$Now)) ?>
    month  <?= StripZeroes(gmdate("n"$Now)) ?>
    day    <?= StripZeroes(gmdate("j"$Now)) ?>
    hour   <?= StripZeroes(gmdate("G"$Now)) ?>
    min    <?= StripZeroes(gmdate("i"$Now)) ?>
    sec    <?= StripZeroes(gmdate("s"$Now)) ?>

    wday   <?= StripZeroes(gmdate("w"$Now)) ?>
    yday   <?= StripZeroes(gmdate("z"$Now)) ?>
    week   <?= StripZeroes(gmdate("W"$Now)) ?>

    monlen <?= StripZeroes(gmdate("t"$Now)) ?>

    now    <?= $Now ?>
    str    "<?= gmdate("r"$Now?>"
}


__.-.__
end of document