web server #90

Parent #1Owner #361Flags readSource hellcore/hellcore.db

Aliases: Spinward Marches Web Server, web

32 verbs · 31 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
startupthis none thisrx#9019
shutdownthis none thisrx#9014
do_login_commandthis none thisrx#90145
getthis none thisrx#9025
postthis none thisrxd#9032
welcome_messagethis none thisrx#904
authorizethis none thisrx#9017
get_remotethis none thisrx#9034
proxythis none thisrx#9080
find_objectthis none thisrx#9013
who_html post_whoany none anyrx#90147
login_htmlany none anyrxd#9012
logthis none thisrx#9012
user_disconnected user_client_disconnectedthis none thisrx#9012
www_huhthis none thisrx#904
get_from_filesthis none thisrx#9012
http_responsethis none thisrx#9014
get_referer get_user_agent get_accepts get_connectionthis none thisrxd#9015
do_login_command_binarythis none thisrx#90102
clean_postthis none thisrxd#905
push_notifythis none thisrxd#9016
holdthis none thisrxd#9017
push_closethis none thisrxd#9011
help_htmlany none anyrxd#905
get_help_topicthis none thisrx#9050
handle_uncaught_error handle_task_timeoutthis none thisrx#9024
page_htmlany none anyrx#9010
access_logthis none thisrxd#909
timestrthis none thisrxd#904
get_connection_hostnamethis none thisrxd#9010
uudecodethis none thisrxd#9025
ascii_subthis none thisrxd#9013

Properties

PropertyDefinerFlagsOwnerValue
port#90r#298080
active#90r#291
default_port#90r#298080
welcome_message#90r#29
list of 9{"<title>Welcome to BayWeb 1.5!</title>", "<h1>Welcome!</h1>", "Thank-you for using BayWeb version 1.5. Please send email to <a href=\"mailto:phantom@baymoo.sfsu.edu\">phantom@baymoo.sfsu.edu</a> for more information.<p>", "This is still in alpha testing at the moment.", "<hr>", "<h2>Demo Pages:</h2><ul>", "<li><a href=\"who\">who_html</a>, a listing of who is online.", "<li><a href=\"login\">login_html</a>, a sample login verb.", "</ul>"}
version#90r#29"1.5"
debug#90rc#3611
debugger#90rc#361#38
logfile#90r#29{"html", "connects"}
html_dir#90r#29"html/login"
page_html#90rc#361
list of 5{"<TITLE>Page a player on BayMOO</TITLE>", "<H1>Paging players</H1>", "You can send a one line message to players on BayMOO if they choose to listen to connections from the web.", "You need to be <a href=\"/login\">logged in</a> first before you can use it.", "<P>"}
trusts#90rc#361{#95, #2}
files_prefix#90rc#361"local"
help_form#90rc#361"<hr><FORM METHOD=\"POST\" ACTION=\"/help\"><b>Please enter help search topic here:</b><BR><INPUT TYPE=\"text\" NAME=\"topic\" SIZE=\"50\"><BR><INPUT TYPE=\"submit\" VALUE=\"Find topic\">"
help_html#90r#29{"<h1>BayMOO Help</h1>", "Type in the topic you wish to search for help on.<p>"}
server_options#90rc#361#30072
connect_timeout#90rc#36186400
timezone#90rc#361"-0500"
base64#90rc#361"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
temp_log#90#29{}
holds#90#29{}
calls#90rc#361{}
aliases#1rc#361{"Spinward Marches Web Server", "web"}
description#1rc#361"A three foot orb of polished copper with a complex map pattern carved into its surface. It is bisected into two hemispheres at the equator which move independently of each other, guided by internal clockworks. Twelve bands of titanium encircle it at seemingly random chords, circling it in random directions relative to its center, and revolving independently at the same time. Occasionally, it opens across the equator and its massive complex clockworks can be seen, spinning and keeping time. The entire assembly floats about two feet off of the floor."
object_size#1r#29{36087, 1298433965}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#3611000000
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #1 root

Children: none

Call graph

calls n90_0 #90:startup n90_1 #90:shutdown n90_0->n90_1 n90_2 #90:do_login_command n90_8 #90:proxy n90_2->n90_8 n90_6 #90:authorize n90_2->n90_6 n90_12 #90:log n90_2->n90_12 n48_8 #48:suspend_if_needed n90_2->n48_8 n90_21 #90:hold n90_2->n90_21 n20_38 #20:explode n90_8->n20_38 n66_2 #66:open n90_8->n66_2 n90_30 #90:uudecode n90_6->n90_30 n30_1 #30:find_exact n90_6->n30_1 n20_5 #20:from_list n90_12->n20_5 n90_3 #90:get n90_3->n20_38 n90_9 #90:find_object n90_3->n90_9 n90_5 #90:welcome_message n90_3->n90_5 n90_15 #90:get_from_files n90_3->n90_15 n20_16 #20:literal_object n90_9->n20_16 n30_0 #30:find n90_9->n30_0 n90_4 #90:post n90_4->n20_38 n90_4->n90_9 n90_19 #90:clean_post n90_4->n90_19 n91_3 #91:ascii_sub n90_19->n91_3 n90_7 #90:get_remote n90_7->n20_38 n90_7->n66_2 n90_10 #90:who_html n90_10->n48_8 n47_23 #47:sort_alist n90_10->n47_23 n20_0 #20:space n90_10->n20_0 n20_1 #20:left n90_10->n20_1 n20_8 #20:from_seconds n90_10->n20_8 n48_7 #48:running_out_of_time n90_10->n48_7 n4_25 #4:is_lagging n90_10->n4_25 n90_11 #90:login_html n90_11->n20_5 n90_18 #90:do_login_command_binary n90_18->n90_8 n90_18->n90_6 n90_18->n90_12 n90_18->n90_21 n90_23 #90:help_html n90_24 #90:get_help_topic n90_23->n90_24 n90_24->n48_8 n51_32 #51:help_db_list n90_24->n51_32 n51_33 #51:help_db_search n90_24->n51_33 n17_15 #17:missed_help n90_24->n17_15 n20_4 #20:columnize n90_24->n20_4 n24_2 #24:sort_topics n90_24->n24_2 n90_25 #90:handle_uncaught_error n90_17 #90:get_referer n90_25->n90_17 n90_28 #90:timestr n35_12 #35:mmddyy n90_28->n35_12 n35_11 #35:time_sub n90_28->n35_11 n90_29 #90:get_connection_hostname n90_29->n90_17 n20_53 #20:connection_hostname n90_29->n20_53 n90_31 #90:ascii_sub n18_27 #18:base_conversion n90_31->n18_27

Source

startup

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1if (!caller_perms().wizard)
2return E_PERM;
3elseif (this.active)
4this:shutdown();
5endif
6if (length(args) > 0)
7port = args[1];
8else
9port = this.default_port;
10endif
11result = listen(this, port);
12if (typeof(result) == ERR)
13return result;
14endif
15this.active = 1;
16this.port = port;
17return result;
18"LMB #6216 10/31/96";
19"LCB: Aleksandr' (#95) Wed Jul 12 12:40:10 2000 EDT";

shutdown

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1if (!caller_perms().wizard)
2return E_PERM;
3elseif (!this.active)
4return E_QUOTA;
5endif
6result = unlisten(this.port);
7if (typeof(result) == ERR)
8return result;
9endif
10this.active = 0;
11this.port = -1;
12return result;
13"LMB #6216 10/31/96";
14"LCB: Aleksandr' (#95) Wed Jul 12 12:40:28 2000 EDT";

do_login_command

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1if (callers())
2return E_PERM;
3endif
4if (!args)
5return;
6elseif (!(args[1] in {"GET", "POST"}))
7this.debug && notify(this.debugger, tostr("HTTP request: ", toliteral(args)));
8notify(player, "HTTP/1.1 501 Not Implimented");
9notify(conn, "Server: BayWeb/" + this.version);
10notify(conn, "WWW-Authenticate: Basic realm=\"baymoo\"");
11boot_player(player);
12return;
13endif
14$handle_task();
15this.debug && notify(this.debugger, ("***HTTP REQUEST from " + connection_name(player)) + "***");
16this.debug && notify(this.debugger, toliteral(args));
17if (args[2][1..7] == "http://")
18this.debug && notify(this.debugger, "Using proxy...");
19return this:proxy(@args);
20endif
21content_length = authorization = 0;
22read = 1;
23hold = 0;
24accepts = {};
25agent = "";
26while (read = read(player))
27if (read[1..9] == "Referer: ")
28referer = read[10..$];
29elseif (read[1..8] == "Accept: ")
30accepts = listappend(accepts, read[9..$]);
31elseif (read[1..21] == "Authorization: Basic ")
32authorization = read[22..$];
33elseif (read[1..12] == "User-agent: ")
34agent = read[13..$];
35endif
36endwhile
37conn = player;
38user = this:authorize(authorization);
39this.debug && notify(this.debugger, tostr("Authorizing as ", user.name, " (", user, ")..."));
40player = user;
41this:log(conn, args[1], args[2], referer, agent, accepts);
42info = this:(args[1])(args[2], conn);
43" MONKEY CUSTOM CODE FOR FAKING CROSSDOMAIN.XML";
44turd = 0;
45type = "text/html";
46if (args[2] == "/crossdomain.xml")
47cdxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><allow-access-from domain=\"*.chumby.com\" /><allow-access-from domain=\"*.adobe.com\" /></cross-domain-policy>";
48turd = 1;
49endif
50if ((info == E_PERM) || (info[1] == E_PERM))
51notify(conn, "HTTP/1.0 401 Unauthorized");
52notify(conn, "Server: BayWeb/" + this.version);
53notify(conn, "Content-type: text/html");
54notify(conn, "WWW-Authenticate: Basic realm=\"baymoo\"");
55notify(conn, "Content-type: text/html");
56notify(conn, "");
57if (length(info) > 1)
58for line in (info[2..$])
59notify(conn, line);
60endfor
61else
62notify(conn, "<HEAD><title>401 Unauthorized</title></head>");
63notify(conn, "<BODY><h1>401 Unauthorized</h1>");
64notify(conn, "Sorry, you need to <a href=\"login\">login</a> first before you can gain access to this URL.</BODY>");
65endif
66elseif ((info == E_INVARG) || (info[1] == E_INVARG))
67if (turd == 0)
68notify(conn, "HTTP/1.0 404 Not Found - Document Not Available");
69notify(conn, "Server: BayWeb/" + this.version);
70notify(conn, "Content-type: text/html");
71notify(conn, "");
72if (!(length(info) > 1))
73info = {"", "<HEAD><TITLE>404 Not Found</TITLE></HEAD>", "<BODY><H1>404 Object Not Found</H1>", ("The requested object " + args[2]) + " was not found on this server.</BODY>"};
74endif
75elseif (turd == 1)
76info = cdxml;
77type = "application/xml";
78for line in (info)
79content_length = (content_length + length(line)) + 2;
80endfor
81notify(conn, "<HEAD>HTTP/1.0 200 OK");
82notify(conn, "Server: BayWeb/" + this.version);
83notify(conn, "Content-type: " + type);
84notify(conn, "Content-length: " + tostr(content_length)) + "</HEAD>";
85notify(conn, "");
86notify(conn, info);
87endif
88for line in (info[2..$])
89notify(conn, line);
90endfor
91elseif ((info == E_NONE) || (info[1] == E_NONE))
92hold = 1;
93else
94if (!info)
95info = {"Sorry - but the World Wide Web server isn't responding to that request."};
96endif
97"  THIS IS CUSTOM CODE TO CHECK IF OBJECT IS #137247, Monkey's RSS Feed for DJBooth";
98crap = 0;
99turd = 0;
100poop = tostr(args[2]);
101shit = "#" + poop[2..$];
102if (shit == "#137247")
103crap = 1;
104elseif (shit == "#254221")
105crap = 1;
106endif
107if (crap == 0)
108info = listinsert(info, "<HTML>");
109info = listappend(info, "</HTML>");
110endif
111for line in (info)
112content_length = (content_length + length(line)) + 2;
113$cu:sin();
114endfor
115notify(conn, "HTTP/1.0 200 OK");
116notify(conn, "Server: BayWeb/" + this.version);
117notify(conn, "Content-type: text/html");
118notify(conn, "Content-length: " + tostr(content_length));
119notify(conn, "");
120current_length = 0;
121for line in (info)
122if ((len = length(line)) > 3000)
123raise("Error", "HTML line too long");
124elseif (len > (3000 - current_length))
125while (buffered_output_length(conn))
126suspend(1);
127endwhile
128current_length = 0;
129endif
130notify(conn, line);
131current_length = (current_length + len) + 2;
132$cu:sin();
133endfor
134endif
135if (!hold)
136boot_player(conn);
137else
138this:hold();
139notify(conn, "HTTP/1.0 200 OK");
140notify(conn, "Server: BayWeb/" + this.version);
141notify(conn, "");
142endif
143$release_task();
144"LMB #6216 06/10/97";
145"LCB: Aleksandr' (#95) Fri Sep 15 00:55:44 2000 EDT";

get

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1if (0)
2if (caller != this)
3return E_PERM;
4endif
5endif
6if (valid(this.location))
7this.location:announce_all(this.name, " clicks.");
8endif
9parts = $string_utils:explode(args[1], "/");
10set_task_perms(player);
11if (parts[1] && (typeof(dobj = this:find_object(parts[1])) == OBJ))
12return dobj:_www(@parts);
13elseif (parts == {})
14return this:welcome_message();
15elseif ((verb_args(this, parts[1] + "_html") == {"any", "none", "any"}) && index(verb_info(this, parts[1] + "_html")[2], "x"))
16return this:(parts[1] + "_html")(@parts);
17elseif (index(property_info(this, parts[1] + "_html"), "r"))
18return this.(parts[1] + "_html");
19elseif ((page = this:get_from_files(parts)) != 0)
20return page;
21else
22return E_INVARG;
23endif
24"LMB #6216 11/07/96";
25"LCB: Aleksandr' (#95) Tue Sep 19 15:21:13 2000 EDT";

post

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1if (caller != this)
2return E_PERM;
3endif
4where = args[1];
5if (where[1] == "/")
6where = where[2..$];
7endif
8where = $string_utils:explode(where, "/");
9"conn = this:get_connection();";
10conn = args[2];
11postage = read(conn);
12postage = $string_utils:explode(postage, "&");
13for line in [1..length(postage)]
14postage[line] = this:clean_post(postage[line]);
15endfor
16"Convert   field=value to {field, value} ";
17for field in [1..length(postage)]
18value = postage[field];
19postage[field] = {value[1..(equals = index(value, "=")) - 1], value[equals + 1..$]};
20endfor
21if (typeof(what = this:find_object(where[1])) == OBJ)
22if (valid(what))
23set_task_perms(player);
24return what:_www_post(where, postage);
25endif
26elseif (verb_args(this, "post_" + what) == {"any", "none", "any"})
27return this:("post_" + what)(where, postage);
28else
29return {"Document not available."};
30endif
31"LMB #6216 11/23/96";
32"LCB: Aleksandr' (#95) Wed Jul 12 12:43:20 2000 EDT";

welcome_message

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1docroot = "htdocs";
2page = call_function("fileread", docroot, "index.html");
3return page;
4"LCB: Aleksandr' (#95) Tue Sep 19 15:38:11 2000 EDT";

authorize

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1if (caller != this)
2return E_PERM;
3endif
4user = $no_one;
5if (authorization = args[1])
6authorization = this:uudecode(authorization);
7login = authorization[1..(i = index(authorization, ":")) - 1];
8password = authorization[i + 1..length(authorization)];
9if (valid(login = $player_db:find_exact(login)))
10if (login.password == crypt(password, login.password[1..2]))
11user = login;
12endif
13endif
14endif
15return user;
16"LMB #6216 10/31/96";
17"LCB: Aleksandr' (#95) Fri Sep 15 00:39:56 2000 EDT";

get_remote

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1if ((caller != this) && (!caller_perms().wizard))
2return E_PERM;
3endif
4url = args[1][8..$];
5done = 0;
6i = 1;
7while (!done)
8if (url[i] == "/")
9address = $string_utils:explode(url[1..i - 1], ":");
10address[2] ? address[2] = tonum(address[2]) | (address = {@address, 80});
11done = 1;
12elseif (i == length(url))
13url = url + "/";
14else
15i = i + 1;
16endif
17endwhile
18request = url[i..$];
19connection = $network:open(@address);
20if (typeof(connection) == ERR)
21return {"Unable to open connection: ", tostr(connection), "."};
22endif
23notify(connection, ("GET " + request) + " HTTP/1.0");
24for line in (this.header)
25notify(connection, line);
26endfor
27notify(connection, "");
28page = {};
29while (typeof(line = read(connection)) != ERR)
30page = {@page, line};
31endwhile
32return page;
33"LMB #6216 11/12/96";
34"LCB: Aleksandr' (#95) Wed Jul 12 12:44:36 2000 EDT";

proxy

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1"Proxy Disabled";
2if (caller != this)
3return E_PERM;
4endif
5notify(player, "HTTP/1.1 200 OK");
6notify(player, "Server: BayWeb/" + this.version);
7notify(player, "");
8notify(player, "<head><title>Proxy Disabled</title></head>");
9notify(player, "<body><h1>Proxy Disabled</h1>Sorry, the proxy on this copy of BayWeb was disabled.  You'll have to use something else as your proxy.  Cheers!<p></body>");
10boot_player(player);
11return;
12headers = {};
13while (read = read(player))
14this.debug && notify(this.debugger, read);
15headers = listappend(headers, read);
16endwhile
17url = args[2][8..$];
18done = 0;
19i = 1;
20while (!done)
21if (url[i] == "/")
22address = $string_utils:explode(url[1..i - 1], ":");
23address[2] ? address[2] = tonum(address[2]) | (address = {@address, 80});
24done = 1;
25elseif (i == length(url))
26url = url + "/";
27else
28i = i + 1;
29endif
30endwhile
31request = url[i..$];
32connection = $network:open(@address);
33if (typeof(connection) == ERR)
34notify(player, "Unable to open page: ");
35notify(player, tostr(connection));
36boot_player(player);
37endif
38this.debug && notify(this.debugger, ((("[sending]: " + args[1]) + " ") + request) + " HTTP/1.0");
39notify(connection, ((args[1] + " ") + request) + " HTTP/1.0");
40for line in (headers)
41this.debug && notify(this.debugger, "[sending]: " + line);
42notify(connection, line);
43endfor
44this.debug && notify(this.debugger, "[sending]:");
45notify(connection, "");
46if (args[1] == "POST")
47line = read(player);
48this.debug && notify(this.debugger, "[sending]: " + line);
49notify(connection, line);
50endif
51set_connection_option(connection, "hold-input", 1);
52set_connection_option(connection, "binary", 1);
53set_connection_option(player, "binary", 1);
54page = encode_binary("");
55while (typeof(line = read(connection)) != ERR)
56this.debug && notify(this.debugger, "[reading]: " + line);
57page = page + line;
58endwhile
59while (l = length(page) > 0)
60space = buffered_output_length() - buffered_output_length(player);
61if (space == 0)
62part = "";
63elseif (l > space)
64part = page[1..space];
65page = page[space + 1..l];
66else
67part = page;
68page = encode_binary("");
69endif
70if (part)
71notify(player, part);
72endif
73suspend(0);
74endwhile
75while (buffered_output_length(player))
76suspend(0);
77endwhile
78boot_player(player);
79"LMB #6216 11/12/96";
80"LCB: Aleksandr' (#95) Wed Jul 12 12:46:00 2000 EDT";

find_object

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1if (valid(find = $string_utils:literal_object("#" + args[1])))
2return find;
3elseif ((who = args[1])[1] == "~")
4return $player_db:find(who[2..length(who)]);
5elseif ((who[1] == "$") && valid(#0.(who[2..length(who)])))
6return #0.(who[2..length(who)]);
7elseif (valid(result = $http_db:find(who)[1]))
8return result;
9else
10return args[1];
11endif
12"LMB #6216 04/22/97";
13"LCB: Aleksandr' (#95) Wed Jul 12 12:46:17 2000 EDT";

who_html post_who

Spec any none anyFlags rxOwner #29Definer #90

Referenced by

none

Source

1args[1] = connected_players();
2idles = itimes = offs = otimes = {};
3text = {"<META HTTP-EQUIV=\"Refresh\" CONTENT=30> <BODY bgcolor = \"#000000\" text = \"#CCCCCC\">  <PRE>"};
4for p in (args[2])
5if (!valid(p))
6text = {@text, tostr(p, " <invalid>")};
7elseif (typeof(t = p.last_disconnect_time) == NUM)
8if (!(p in offs))
9offs = {@offs, p};
10otimes = {@otimes, {-t, -t, p}};
11endif
12elseif (is_player(p))
13text = {@text, tostr("<A HREF=\"/", tonum(tostr(p)), "\">", p.name, "</A>", (t == E_PROPNF) ? "is not a $player." | "has a garbled .last_disconnect_time.")};
14else
15text = {@text, tostr("<A HREF=\"/", p, "\">", p.name, "</A> is not a player.")};
16endif
17endfor
18for p in (args[1])
19if (p in offs)
20elseif (!valid(p))
21caller:notify(tostr(p, " <invalid>"));
22elseif (typeof(i = idle_seconds(p)) != ERR)
23if (!(p in idles))
24idles = {@idles, p};
25itimes = {@itimes, {i, connected_seconds(p), p}};
26endif
27elseif (typeof(t = p.last_disconnect_time) == NUM)
28offs = {@offs, p};
29otimes = {@otimes, {-t, -t, p}};
30elseif (is_player(p))
31caller:notify(tostr(p.name, " (", p, ") not logged in.", (t == E_PROPNF) ? "Not a $player." | "  Garbled .last_disconnect_time."));
32else
33caller:notify(tostr(p.name, " (", p, ") is not a player."));
34endif
35endfor
36if (!(idles || offs))
37return 0;
38endif
39idles = $list_utils:sort_alist(itimes);
40offs = $list_utils:sort_alist(otimes);
41"...";
42"... calculate widths...";
43"...";
44headers = {"Player name", @idles ? {"Connected", "Idle time"} | {"Last disconnect time", ""}, "Location"};
45total_width = 79;
46max_name = total_width / 4;
47name_width = length(headers[1]);
48names_differ = names_html = locations_differ = locations_html = {};
49for lst in ({@idles, @offs})
50$command_utils:suspend_if_needed(0);
51p = lst[3];
52ps = tostr(p);
53ps = ps[2..length(ps)];
54namestr = tostr(p.name[1..min(max_name, length(p.name))]);
55name_width = max(length(namestr), name_width);
56html_part = ("<A HREF=\"http:/" + ps) + "\">";
57names_differ = {@names_differ, length(html_part) + 4};
58names_html = {@names_html, (html_part + namestr) + "</A>"};
59if (typeof(wlm = p.location:who_location_msg(p)) != STR)
60wlm = valid(p.location) ? p.location.name | tostr("** Nowhere ** (", p.location, ")");
61endif
62pl = tostr(p.location);
63pl = pl[2..length(pl)];
64html_part = ("<A HREF=\"http:/" + pl) + "\">";
65locations_differ = {@locations_differ, length(html_part) + 4};
66locations_html = {@locations_html, (html_part + wlm) + "</A>"};
67endfor
68time_width = 3 + (offs ? 12 | length("59 minutes"));
69before = {0, w1 = 3 + name_width, w2 = w1 + time_width, w2 + time_width};
70"...";
71"...print headers...";
72"...";
73su = $string_utils;
74tell1 = headers[1];
75tell2 = su:space(tell1, "-");
76for j in [2..4]
77tell1 = su:left(tell1, before[j]) + headers[j];
78tell2 = su:left(tell2, before[j]) + su:space(headers[j], "-");
79endfor
80text = {@text, tell1[1..min(length(tell1), total_width)]};
81text = {@text, tell2[1..min(length(tell2), total_width)]};
82"...";
83"...print lines...";
84"...";
85active = 0;
86for i in [1..total = (ilen = length(idles)) + length(offs)]
87if (i <= ilen)
88lst = idles[i];
89if (lst[1] < (5 * 60))
90active = active + 1;
91endif
92l_html = {names_html[i], su:from_seconds(lst[2]), su:from_seconds(lst[1]), locations_html[i]};
93else
94lct = offs[i - ilen][3].last_connect_time;
95ldt = offs[i - ilen][3].last_disconnect_time;
96ctime = caller:ctime(ldt) || ctime(ldt);
97l_html = {names_html[i], (lct <= time()) ? ctime | "Never", "", locations_html[i]};
98if ((i == (ilen + 1)) && idles)
99text = {@text, su:space(before[2]) + "------- Disconnected -------"};
100endif
101endif
102l_differ = {names_differ[i], 0, 0, locations_differ[i]};
103tell1 = l_html[1];
104before1 = before[1];
105for j in [2..4]
106tell1 = su:left(tell1, (before1 + before[j]) + l_differ[j - 1]) + l_html[j];
107before1 = before1 + l_differ[j - 1];
108endfor
109text = {@text, tell1};
110"[1..min(length(tell1), total_width)]}";
111if ($command_utils:running_out_of_time())
112if ($login:is_lagging())
113"Check lag two ways---global lag, but we might still fail due to individual lag of the queue this runs in, so check again later.";
114text = {@text, tostr("Plus ", total - i, " other players (", total, "total; out of time and lag is high).")};
115text = {@text, "</PRE>"};
116return text;
117endif
118now = time();
119suspend(0);
120if ((time() - now) > 10)
121text = {@text, tostr("Plus ", total - i, " other players (", total, "total; out of time and lag is high).")};
122text = {@text, "</PRE>"};
123return text;
124endif
125endif
126endfor
127"...";
128"...epilogue...";
129"...";
130text = {@text, ""};
131if (total == 1)
132active_str = ", who has" + ((active == 1) ? "" | " not");
133else
134if (active == total)
135active_str = (active == 2) ? "s, both" | "s, all";
136elseif (active == 0)
137active_str = "s, none";
138else
139active_str = tostr("s, ", active);
140endif
141active_str = tostr(active_str, " of whom ha", (active == 1) ? "s" | "ve");
142endif
143text = {@text, tostr("Total: ", total, " player", active_str, " been active recently.")};
144text = {@text, "</PRE>"};
145return text;
146"LMB #6216 10/31/96";
147"LCB: Aleksandr' (#95) Fri Sep 15 01:13:01 2000 EDT";

login_html

Spec any none anyFlags rxdOwner #361Definer #90

Referenced by

none

Source

1if (caller_perms() == $no_one)
2return E_PERM;
3endif
4this.debug && this.debugger:notify("login called, args=" + toliteral(args));
5redirect = tostr("http://", $network.site, ":", $http.port, "/", $string_utils:from_list(args[2..$], "/"));
6page = {("<HEAD><title>Login Succeeded</title> <META HTTP-EQUIV=\"Refresh\" Content=\"5; URL=" + redirect) + "\"></HEAD>"};
7page = listappend(page, "<BODY><h1>Login Succeeded</h1>");
8page = listappend(page, ("You are now logged in to " + player.name) + ".<p>");
9page = listappend(page, "To logout, you must reset your web browser.  On most browsers, to do this, you have to close the brouser.</BODY>");
10return page;
11"LMB #6216 05/25/98";
12"LCB: Aleksandr' (#95) Wed Jul 12 12:49:04 2000 EDT";

log

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1if (caller_perms() == $no_one)
2return E_PERM;
3endif
4this.debug && this.debugger:notify("login called, args=" + toliteral(args));
5redirect = tostr("http://", $network.site, ":", $http.port, "/", $string_utils:from_list(args[2..$], "/"));
6page = {("<HEAD><title>Login Succeeded</title> <META HTTP-EQUIV=\"Refresh\" Content=\"5; URL=" + redirect) + "\"></HEAD>"};
7page = listappend(page, "<BODY><h1>Login Succeeded</h1>");
8page = listappend(page, ("You are now logged in to " + player.name) + ".<p>");
9page = listappend(page, "To logout, you must reset your web browser.  On most browsers, to do this, you have to close the brouser.</BODY>");
10return page;
11"LMB #6216 05/25/98";
12"LCB: Aleksandr' (#95) Wed Jul 12 12:49:29 2000 EDT";

user_disconnected user_client_disconnected

Spec this none thisFlags rxOwner #29Definer #90

Referenced by

none

Source

1if (callers())
2return E_PERM;
3endif
4for i in [1..length(this.temp_log)]
5if (this.temp_log[i][2] == args[1])
6this.temp_log = listdelete(this.temp_log, i);
7break;
8endif
9endfor
10this.holds = setremove(this.holds, args[1]);
11"LMB #6216 11/06/96";
12"LCB: Aleksandr' (#95) Wed Jul 12 12:49:45 2000 EDT";

www_huh

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1"Insert last chance document hunting here.  Returns E_NONE if nothing could be found.";
2return E_INVARG;
3"LMB #6216 10/31/96";
4"LCB: Aleksandr' (#95) Wed Jul 12 12:49:53 2000 EDT";

get_from_files

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1docroot = "htdocs";
2for i in [1..length(this.temp_log)]
3if (this.temp_log[i][2] == args[1])
4this.temp_log = listdelete(this.temp_log, i);
5break;
6endif
7endfor
8this.holds = setremove(this.holds, args[1]);
9page = call_function("fileread", docroot, args[1][1]);
10return page;
11"LMB #6216 11/06/96";
12"LCB: Aleksandr' (#95) Mon Sep 18 12:14:44 2000 EDT";

http_response

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1set_task_perms(caller_perms());
2{conn, status, headers, body, binary} = args;
3notify(conn, "HTTP/1.1 " + status);
4notify(conn, "Server: BayWeb" + this.version);
5for header in (headers)
6notify(conn, header);
7endfor
8notify(conn, "");
9for line in (body)
10notify(conn, line);
11(ticks_left() < 100) && suspend(0);
12endfor
13"LMB #6216 10/31/96";
14"LCB: Aleksandr' (#95) Fri Sep 15 00:13:38 2000 EDT";

get_referer get_user_agent get_accepts get_connection

Spec this none thisFlags rxdOwner #29Definer #90

Referenced by

Source

1id = task_id();
2found = 0;
3for entry in (this.temp_log)
4if (entry[1] == id)
5found = 1;
6break;
7endif
8endfor
9if (!found)
10return E_INVARG;
11endif
12i = index("o  esc", verb[6]);
13return entry[i + 1];
14"LMB #6216 11/04/96";
15"LCB: Aleksandr' (#95) Wed Jul 12 12:50:42 2000 EDT";

do_login_command_binary

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

none

Source

1if (callers())
2return E_PERM;
3endif
4if (!args)
5return;
6elseif (!(args[1] in {"GET", "POST"}))
7this.debug && notify(this.debugger, tostr("HTTP request: ", toliteral(args)));
8notify(player, "HTTP/1.1 501 Not Implimented");
9notify(conn, "Server: BayWeb/" + this.version);
10boot_player(player);
11return;
12endif
13this.debug && notify(this.debugger, "***HTTP REQUEST***");
14this.debug && notify(this.debugger, toliteral(args));
15if (args[2][1..7] == "http://")
16this.debug && notify(this.debugger, "Using proxy...");
17return this:proxy(@args);
18endif
19content_length = authorization = 0;
20read = 1;
21hold = 0;
22accepts = {};
23agent = "";
24while (read = read(player))
25if (read[1..9] == "Referer: ")
26referer = read[10..$];
27elseif (read[1..8] == "Accept: ")
28accepts = listappend(accepts, read[9..$]);
29elseif (read[1..21] == "Authorization: Basic ")
30authorization = read[22..$];
31elseif (read[1..12] == "User-agent: ")
32agent = read[13..$];
33endif
34endwhile
35conn = player;
36user = this:authorize(authorization);
37player = user;
38this:log(conn, args[1], args[2], referer, agent, accepts);
39try
40info = this:(args[1])(args[2]);
41except v (ANY)
42info = {"An error occoured while trying to access the document:<p>", "<PRE>"};
43tb = v[4];
44top = tb[1];
45info = {@info, tostr(top[1], ":", top[2], ", line ", top[6], ":", v[2])};
46for fr in (tb[2..$])
47info = {@info, tostr("... called from ", fr[1], ":", fr[2], ", line ", fr[6])};
48endfor
49info = {@info, "(End of traceback)", "</PRE>"};
50endtry
51if ((info == E_PERM) || (info[1] == E_PERM))
52notify(conn, "HTTP/1.0 401 Unauthorized");
53notify(conn, "Server: BayWeb/" + this.version);
54notify(conn, "Content-type: text/html");
55if (length(info) > 1)
56for line in (info[2..$])
57notify(conn, line);
58endfor
59endif
60elseif ((info == E_INVARG) || (info[1] == E_INVARG))
61notify(conn, "HTTP/1.0 404 Not Found - Document Not Available");
62notify(conn, "Server: BayWeb/" + this.version);
63notify(conn, "Content-type: text/html");
64notify(conn, "");
65if (length(info) > 1)
66for line in (info[2..$])
67notify(conn, line);
68endfor
69endif
70elseif ((info == E_NONE) || (info[1] == E_NONE))
71hold = 1;
72else
73for line in (info)
74content_length = (content_length + length(line)) + 1;
75endfor
76notify(conn, "HTTP/1.0 200 OK");
77notify(conn, "Server: BayWeb/" + this.version);
78notify(conn, "Content-type: text/html");
79notify(conn, "Content-length: " + tostr(content_length));
80notify(conn, "");
81notify(conn, "<HTML>");
82if (info)
83set_connection_option(conn, "binary", 1);
84for line in (info)
85notify(conn, line + "~0A");
86endfor
87set_connection_option(conn, "binary", 0);
88else
89notify(conn, "Sorry - but the World Wide Web server isn't responding to that request.");
90endif
91notify(conn, "</HTML>");
92endif
93if (!hold)
94boot_player(conn);
95else
96this:hold();
97notify(conn, "HTTP/1.0 200 OK");
98notify(conn, "Server: BayWeb/" + this.version);
99notify(conn, "");
100endif
101"LMB #6216 10/31/96";
102"LCB: Aleksandr' (#95) Wed Jul 12 12:52:28 2000 EDT";

clean_post

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

Source

1line = strsub(args[1], "+", " ");
2line = $html:ascii_sub(line);
3return line;
4"LMB #6216 11/05/96";
5"LCB: Aleksandr' (#95) Wed Jul 12 12:52:36 2000 EDT";

push_notify

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1"Usage: push_notify(#conn, {line 1, line 2, etc})";
2"";
3"Sends the text to the given connection, if the connection specified by #conn is \"held\", returns E_INVARG if not.  Requires wiz or trust perms.";
4"NOTE:  This feature is officially unsupported and may be changed or removed at any time and without warning or notice.";
5if (!((c = caller_perms()).wizard || (c in this.trusts)))
6return E_PERM;
7endif
8{conn, text} = args;
9if (!(conn in this.holds))
10return E_INVARG;
11endif
12for line in (args[2])
13notify(conn, tostr(line));
14endfor
15"LMB #6216 11/07/96";
16"LCB: Aleksandr' (#95) Wed Jul 12 12:52:55 2000 EDT";

hold

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

Source

1if (caller != this)
2return E_PERM;
3endif
4id = task_id();
5found = 0;
6for entry in (this.temp_log)
7if (entry[1] == id)
8found = 1;
9break;
10endif
11endfor
12if (!found)
13return E_INVARG;
14endif
15this.holds = listappend(this.holds, entry[2]);
16"LMB #6216 11/06/96";
17"LCB: Aleksandr' (#95) Wed Jul 12 12:53:15 2000 EDT";

push_close

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1"Usage: push_close(#conn) closes the connection #conn if it had been held.  If not, it returns E_INVARG.";
2{conn} = args;
3c = caller_perms();
4if (!(c.wizard || (c in this.trusts)))
5return E_PERM;
6elseif (!(found = conn in this.holds))
7return E_INVARG;
8endif
9boot_player(found);
10"LMB #6216 05/21/99";
11"LCB: Aleksandr' (#95) Wed Jul 12 12:53:29 2000 EDT";

help_html

Spec any none anyFlags rxdOwner #361Definer #90

Referenced by

none

Source

1page = {"<head><title>BayMOO Help</title></head><BODY>", @this.help_html, "<hr>", @this:get_help_topic("")};
2page = {@page, this.help_form};
3return page;
4"LMB #6216 11/12/96";
5"LCB: Aleksandr' (#95) Wed Jul 12 12:53:38 2000 EDT";

get_help_topic

Spec this none thisFlags rxOwner #361Definer #90

Referenced by

Source

1"Copied from World Wide Web Server (#4716):get_help_topic by Dr.J (#656) Tue Nov 12 15:33:34 1996 PST";
2"Copied from generic player (#6):help by ArchJanitor (#2) Sat Feb 11 23:24:23 1995 PST";
3"Modified for use in WWW by Phantom (#6216) Sat Feb 11, 1995";
4html = $html;
5page = {};
6"...this code explicitly relies on being !d in several places...";
7what = tostr(@args);
8"...find a db that claims to know about `what'...";
9dblist = $code_utils:help_db_list();
10suspend(0);
11result = $code_utils:help_db_search(what, dblist);
12if (!result)
13"... note: all of the last-resort stuff...";
14"... is now located on $help:find_topics/get_topic...";
15$wiz_utils:missed_help(what, result);
16page = {@page, html:make_header(1, "Sorry!"), ("Sorry, but no help is available on `" + what) + "'."};
17elseif (result[1] == $ambiguous_match)
18$wiz_utils:missed_help(what, result);
19page = {@page, html:make_header(1, "Sorry!"), ("Sorry, but the topic-name `" + what) + "' is ambiguous.  We don't know which of the following topics you mean:<ul>"};
20for x in ($string_utils:columnize($help:sort_topics(result[2]), 3, 60))
21page = {@page, tostr("<li> ", x)};
22endfor
23page = {@page, "</ul>"};
24else
25help = result[1];
26topic = result[2];
27page = {@page, html:make_header(1, "Help: " + topic)};
28dblist = dblist[1 + (help in dblist)..length(dblist)];
29suspend(0);
30if (1 == (text = help:get_topic(topic, dblist)))
31"...get_topic took matters into its own hands...";
32elseif (text)
33"...these can get long...";
34page = {@page, "<hr>"};
35for line in ((typeof(text) == LIST) ? text | {text})
36if (typeof(line) != STR)
37page = {@page, "Odd results from help -- complain to a wizard.<p>"};
38else
39page = {@page, strsub(strsub(html:clean(line), "&LT;", "&LT;<I>"), "&GT;", "</I>&GT;"), "<br>"};
40endif
41$command_utils:suspend_if_needed(0);
42endfor
43else
44page = {@page, tostr("Help DB ", help, " thinks it knows about `", what, "' but something's messed up.<p>")};
45page = {@page, tostr("Tell ", help.owner.wizard ? "" | tostr(help.owner.name, " (", help.owner, ") or "), "a wizard.")};
46endif
47endif
48return page;
49"LMB #6216 11/12/96";
50"LCB: Aleksandr' (#95) Wed Jul 12 12:54:48 2000 EDT";

handle_uncaught_error handle_task_timeout

Spec this none thisFlags rxOwner #29Definer #90

Referenced by

none

Source

1if (caller != #0)
2return E_PERM;
3endif
4this.debugger:notify(tostr(this, ":", verb, " called."));
5isTimeout = index("ut", verb[8]) - 1;
6stack = isTimeout ? args[2] | args[4];
7conn = this:get_connection();
8top = stack[1];
9notify(conn, "HTTP/1.1 500 Internal Server Error");
10notify(conn, "Server: BayWeb/" + this.version);
11notify(conn, "Content-type: text/html");
12notify(conn, "");
13notify(conn, "<HEAD><title>500 Server Error</title></HEAD>");
14notify(conn, "<BODY><h1>500 Server Error</h1>");
15notify(conn, "An error occoured while trying to access the document:<p>");
16notify(conn, tostr(top[4], ":", top[2], @(top[1] != top[4]) ? {" (this == ", top[1], ")"} | {}, ", line ", top[6], ":  ", isTimeout ? "Task ran out of " + args[1] | args[2], "<br>"));
17for fr in (stack[2..$])
18notify(conn, tostr("... called from ", fr[4], ":", fr[2], @(fr[1] != fr[4]) ? {" (this == ", fr[1], ")"} | {}, ", line ", fr[6], "<br>"));
19endfor
20notify(conn, "(End of traceback)<br>");
21notify(conn, "</BODY>");
22boot_player(conn);
23"LMB #6216 06/03/97";
24"LCB: Aleksandr' (#95) Wed Jul 12 12:55:16 2000 EDT";

page_html

Spec any none anyFlags rxOwner #361Definer #90

Referenced by

none

Source

1who = args[2];
2text = this.page_html;
3text = {@text, tostr("<h2>Please enter the text to be sent to ", toobj(who).name, " (#", who, ").</h2>")};
4text = {@text, ("<FORM Method=\"POST\" Action=\"/" + who) + "/page\">"};
5text = {@text, $www_utils:form("text", "mesg", 80)};
6text = {@text, "<BR><B>Password:</b>"};
7text = {@text, $www_utils:form("submit", "Yehaw")};
8return text;
9"LMB #6216 04/21/97";
10"LCB: Aleksandr' (#95) Wed Jul 12 12:55:30 2000 EDT";

access_log

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1":access_log(#connection, #auth-player, time, \"request line\", status, bytes)";
2"";
3"Appends the information to the log file in NSCA httpd access_log format.";
4if (caller != this)
5return E_PERM;
6endif
7{conn, auth, time, request, status, bytes} = args;
8"LMB #6216 12/13/96";
9"LCB: Aleksandr' (#95) Wed Jul 12 12:55:42 2000 EDT";

timestr

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1":timestr(time) => the time string in the correct format for use in the access log.";
2return tostr($time_utils:ddmmyy(args[1])[1..2], "/", $time_utils:time_sub("$n/$Y:$H:$M:$S", args[1]), " ", this.timezone);
3"LMB #6216 12/13/96";
4"LCB: Aleksandr' (#95) Wed Jul 12 12:55:49 2000 EDT";

get_connection_hostname

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1"Returns the connection hostname of the current task, as returned by this:get_connection().  If the connection is logged in and (player != $no_one), it requires wiz perms.  If the connection is not logged in (player == $no_one), anyone can use it.  Returns E_PERM if a nonwizard tries to get the connection hostname of someone who's logged in.";
2if ((!caller_perms().wizard) && (player != $no_one))
3return E_PERM;
4elseif (typeof(c = this:get_connection()) == ERR)
5return c;
6else
7return $string_utils:connection_hostname(connection_name(c));
8endif
9"LMB #6216 05/01/97";
10"LCB: Aleksandr' (#95) Wed Jul 12 12:56:02 2000 EDT";

uudecode

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

Source

1"Usage: base64_decode(STR source) => STR decoded";
2"Decodes and returns the base64 source string.  Return value is encoded as a binary string.";
3"";
4"Copyright (c) 1999 Richard Connamacher.  Part of the Spinward Marches MOO/WWW server, originally from BayMOO.  Use only with permission.";
5b64 = this.base64;
6chars = args[1];
7result = "";
8i = -3;
9len = length(chars) - 4;
10while ((i = i + 4) <= len)
11c1 = index(b64, chars[i], 1) - 1;
12c2 = index(b64, chars[i + 1], 1) - 1;
13c3 = index(b64, chars[i + 2], 1) - 1;
14c4 = index(b64, chars[i + 3], 1) - 1;
15result = result + encode_binary((c1 * 4) + (c2 / 16), ((c2 % 16) * 16) + (c3 / 4), ((c3 % 4) * 64) + c4);
16endwhile
17c1 = index(b64, chars[i], 1) - 1;
18c2 = index(b64, chars[i + 1], 1) - 1;
19c3 = index(b64, chars[i + 2], 1) - 1;
20c4 = index(b64, chars[i + 3], 1) - 1;
21final = encode_binary((c1 * 4) + (c2 / 16));
22(c3 != 64) && (final = final + encode_binary(((c2 % 16) * 16) + (c3 / 4)));
23(c4 != 64) && (final = final + encode_binary(((c3 % 4) * 64) + (c4 % 64)));
24return result + final;
25"LCB: Aleksandr' (#95) Thu Sep 14 19:02:28 2000 EDT";

ascii_sub

Spec this none thisFlags rxdOwner #361Definer #90

Referenced by

none

Source

1text = args[1];
2while ((i = index(text, "%")) && (i < (length(text) - 1)))
3yield;
4c1 = text[i + 1];
5c2 = text[i + 2];
6cval = $math_utils:base_conversion(text[i + 1..i + 2], 16, 10);
7rtext = (length(text) > (i + 2)) ? text[i + 3..$] | "";
8text = (text[1..i - 1] + encode_binary(tonum(cval))) + rtext;
9endwhile
10while (i = index(text, "+"))
11text = strsub(text, "+", " ");
12endwhile
13return text;