dd2f1d | 1999-11-17 | Per Hedbor | | #include <config.h>
|
cf2dec | 2000-07-11 | Martin Nilsson | |
|
dd2f1d | 1999-11-17 | Per Hedbor | | int __lt;
string describe_time(int t)
{
int full;
if(localtime(__lt)->yday != localtime(t)->yday)
{
__lt = t;
full=1;
}
if(full)
|
b9a702 | 2000-07-15 | Andreas Lange | | return capitalize(roxen->language(roxen.locale->get(),"date")(t));
|
dd2f1d | 1999-11-17 | Per Hedbor | | else
return sprintf("%02d:%02d",localtime(t)->hour,localtime(t)->min);
}
|
8ba182 | 2002-06-15 | Martin Nilsson | | string units(string unit, int num)
|
3e3bab | 2001-01-19 | Per Hedbor | | {
|
715d3c | 2000-07-11 | Martin Nilsson | | if(num==1) return "one "+unit;
return num+" "+unit+"s";
}
|
dd2f1d | 1999-11-17 | Per Hedbor | | string describe_interval(int i)
{
|
715d3c | 2000-07-11 | Martin Nilsson | | switch(i) {
case 0..50:
|
8ba182 | 2002-06-15 | Martin Nilsson | | return units("second", i);
|
715d3c | 2000-07-11 | Martin Nilsson | | case 51..3560:
|
8ba182 | 2002-06-15 | Martin Nilsson | | return units("minute", ((i+20)/60));
|
715d3c | 2000-07-11 | Martin Nilsson | | default:
|
8ba182 | 2002-06-15 | Martin Nilsson | | return units("hour", ((i+300)/3600));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
}
string describe_times(array (int) times)
{
__lt=0;
if(sizeof(times) < 6)
|
8ba182 | 2002-06-15 | Martin Nilsson | | return String.implode_nicely(map(times, describe_time));
|
dd2f1d | 1999-11-17 | Per Hedbor | |
int d, every=1;
int ot = times[0];
foreach(times[1..], int t)
if(d)
{
if(abs(t-ot-d)>(d/4))
{
every=0;
break;
}
ot=t;
} else
d = t-ot;
if(every && (times[-1]+d) >= time(1)-10)
|
8ba182 | 2002-06-15 | Martin Nilsson | | return ("every "
+describe_interval(d)+" since "+
|
dd2f1d | 1999-11-17 | Per Hedbor | | describe_time(times[0]));
return String.implode_nicely(map(times[..4], describe_time)+({"..."})+
|
8ba182 | 2002-06-15 | Martin Nilsson | | map(times[sizeof(times)-3..], describe_time));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
string fix_err(string s)
{
sscanf(reverse(s), "%*[ \t\n]%s", s);
s=reverse(s);
if(s=="")
return s;
if(!(<'.','!','?'>)[s[-1]]) s+=".";
|
715d3c | 2000-07-11 | Martin Nilsson | | return Roxen.html_encode_string(capitalize(s));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
int last_time;
|
c60cae | 2000-02-02 | Johan Sundström | | string describe_error(string err, array (int) times,
string lang, int|void no_links)
|
dd2f1d | 1999-11-17 | Per Hedbor | | {
int code, nt;
|
c60cae | 2000-02-02 | Johan Sundström | | string links = "", reference, server;
|
8ba182 | 2002-06-15 | Martin Nilsson | | array(string) codetext = ({ "Notice",
"Warning",
"Error" });
|
c60cae | 2000-02-02 | Johan Sundström | |
|
dd2f1d | 1999-11-17 | Per Hedbor | | if(sizeof(times)==1 && times[0]/60==last_time) nt=1;
last_time=times[0]/60;
|
c60cae | 2000-02-02 | Johan Sundström | | sscanf(err, "%d,%[^,],%s", code, reference, err);
switch(no_links)
{
Configuration conf;
RoxenModule module;
case 2:
sscanf(reference, "%[^/]", server);
if(conf = roxen->find_configuration( server ))
links += sprintf("<a href=\"%s\">%s</a> : ",
@get_conf_url_to_virtual_server( conf, lang ));
case 1:
|
715d3c | 2000-07-11 | Martin Nilsson | | if(module = Roxen.get_module( reference ))
|
c60cae | 2000-02-02 | Johan Sundström | | links += sprintf("<a href=\"%s\">%s</a> : ",
@get_conf_url_to_module( module, lang ));
}
|
2bf336 | 2000-02-16 | Martin Nilsson | | return "<table><tr><td valign=\"top\"><img src=&usr.err-"+code+"; \n"
"alt=\"" + codetext[code-1] + "\" />"
"</td><td>" + links + (nt?"":describe_times(times)+"<br />") +
replace(fix_err(err), "\n", "<br />\n") + "</table>";
|
c60cae | 2000-02-02 | Johan Sundström | | }
|
3e3bab | 2001-01-19 | Per Hedbor | | array(string) get_conf_url_to_module(string|RoxenModule m, string|void lang)
{
|
c60cae | 2000-02-02 | Johan Sundström | |
|
715d3c | 2000-07-11 | Martin Nilsson | | RoxenModule module = stringp(m) ? Roxen.get_module(m) : m;
|
c60cae | 2000-02-02 | Johan Sundström | | Configuration conf = module->my_configuration();
string url_modname = replace(conf->otomod[module], "#", "!"),
url_confname = conf->name;
|
9d477e | 2001-05-16 | Per Hedbor | | return ({ sprintf("/sites/site.html/%s/-!-/%s/?section=Information",
Roxen.http_encode_string(url_confname),
Roxen.http_encode_string(url_modname)),
|
715d3c | 2000-07-11 | Martin Nilsson | | Roxen.get_modfullname(module) });
|
c60cae | 2000-02-02 | Johan Sundström | | }
|
3e3bab | 2001-01-19 | Per Hedbor | | array(string) get_conf_url_to_virtual_server(string|Configuration conf,
|
51bfad | 2000-04-04 | Johan Sundström | | string|void lang)
|
3e3bab | 2001-01-19 | Per Hedbor | | {
|
c60cae | 2000-02-02 | Johan Sundström | | string url_confname;
if(stringp(conf))
conf = roxen->find_configuration(url_confname = conf);
else
url_confname = conf->name;
|
9d477e | 2001-05-16 | Per Hedbor | | return ({ sprintf("/sites/site.html/%s/",
Roxen.http_encode_string(url_confname)), conf->query_name() });
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
|
9d477e | 2001-05-16 | Per Hedbor | |
|