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
|
// This is a Clock Module.
string cvs_version = "$Id: clock.pike,v 1.2 1996/12/01 19:18:48 per Exp $";
// One of the first modules written for Spinner, here for nostalgical
// reasons. It could be used as an example of how to write a simple
// location module.
#include <module.h>
inherit "module";
inherit "roxenlib";
void create()
{
defvar("modification", 0, "Time modification", TYPE_INT,
"Time difference in seconds from system clock.");
defvar("mountpoint", "/clock/", "Mount point", TYPE_LOCATION,
"Clock location in filesystem.");
}
mixed *register_module()
{
return ({
MODULE_LOCATION,
"Explicit clock",
"This is the Clock Module.",
});
}
string query_location() { return query("mountpoint"); }
int my_time() { return time(1)+query("modification"); }
mapping find_file( string f )
{
if((int)f)
return http_string_answer("<title>And the time is...</title>"+
"<h1>Local time: "+ctime((int)f)+
"</h1><h1>GMT: "+http_date((int)f)+"</h1>");
return http_string_answer("<html><head><title>" + ctime(my_time())
+"</title></head><body><h1>"
+ctime(time(1))+"</h1></body></html>\n")
+ ([ "extra_heads":
([
"Expires": http_date(time(1)+5),
"Refresh":5-time(1)%5,
"Last-Modified":http_date(time(1)-1)
])
]);
}
string query_name()
{
return query("mountpoint")+" ("+ctime(my_time())[11..15]+")";
}
|