parent $utilities object $http var $root dbref 'http var $root child_index 0 var $root fertile 0 var $root manager $http var $root owned [$http] var $root owners [$http] var $root writable [] var $root readable ['parameters, 'methods, 'code] var $root inited 1 var $http errors #[[400, ["<head><title>400 Bad Request</title></head>", "<body>", "<center><h1>400 Bad Request</h1></center>", "%s", "</body>"]], [403, ["<head><title>403 Permission Denied</title></head>", "<body>", "<center><h1>403 Permission Denied</h1></center>", "%s", "</body>"]], [404, ["<head><title>404 Not Found</title></head>", "<center><h1>404 Not Found</h1></center>", "%s", "</body>"]]] method set_error arg error, lines; (> .perms(sender(), 'manager) <); errors = dict_add(errors, error, lines); . method del_error arg error, lines; (> .perms(sender(), 'manager) <); errors = dict_del(errors, error); . method get_error arg error, str; var lines, x; lines = (| errors[error] |) || ["Oops, server just broke."]; for x in [1 .. listlen(lines)] lines = replace(lines, x, strsub(lines[x], "%s", str)); return lines; . method make_href_string arg obj, [name]; var line; if (!name) name = [obj.dbref()]; line = ("<tt><a href=\"/objects/" + tostr(obj.dbref('symbol))) + "/\">"; return (line + (name[1])) + "</a></tt>"; . method bin_show arg [args]; var out, obj; if (!args) return .get_error(400, "Must specify an object"); obj = (| $object.to_dbref(args[1]) |); if (!obj) return .get_error(404, ("Unable to find object \"" + (args[1])) + "\""); return ["<pre>", @obj.show_in_html(), "</pre>"]; . method make_method_href arg m; return ((((((("<a href=\"/bin/list_method?" + ((m[1]).dbref())) + ".") + tostr(m[2])) + "()\">") + tostr(m[2])) + "(") + (m[3])) + ")</a>"; . method make_object_href arg obj, [name]; var line; if (!name) name = [obj.dbref()]; line = ("<tt><a href=\"/objects/" + tostr(obj.dbref('symbol))) + "/\">"; return (line + (name[1])) + "</a></tt>"; . method bin_list_method arg [args]; var ref, str_ref, name, obj, code, anc, out, line, x; if (!args) return .get_error(400, "Must specify a method reference"); catch any { ref = $parse.reference(args[1]); name = tosym(ref[2]); obj = $object.to_dbref(ref[1]); anc = obj.find_method(name); code = anc.list_method(name); code = .filter_text(code); for x in [1 .. listlen(code)] line = " " + (code[x]); str_ref = (((obj.dbref()) + ".") + tostr(name)) + "()"; out = [("<head><title>" + str_ref) + "</title></head>"]; out = [@out, ("<body><center><h1>" + str_ref) + "</h1></center>"]; out = [@out, "<hr>", "<pre><code>", "@program " + str_ref]; out = [@out, @code, ".", "</code></pre>"]; } with handler { switch (error()) { case ~methodnf: line = (((obj.dbref()) + ".") + tostr(name)) + "()"; out = $http.get_error(400, line + " not found."); default: out = $http.get_error(400, (traceback()[1])[2]); } } return out; . method bin_who arg [args]; var out, obj; // will have to spiff this up later. out = ["<head><title>Who is connected to the Cold Dark?</title></head>"]; out = [@out, "<body><pre>", @$code.generate_listing($user_db.connected())]; return out + ["</pre>"]; . method filter_text arg text; var x, line; // embed's characters ('>' becomes '>' etc) for x in [1 .. listlen(text)] { line = strsub(text[x], "&", "&"); line = strsub(line, "<", "<"); line = strsub(line, ">", ">"); text = replace(text, x, line); } return text; .