/
CDC-1.2b/
CDC-1.2b/src/
parent $utilities
object $motd

var $root dbref 'motd
var $root child_index 0
var $root fertile 0
var $root manager $motd
var $root owned [$motd]
var $root owners [$motd]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $root inited 1
var $root info ["The Message of the Day object.  Called by $old_connection and $fingerd.", "This builds a motd from different parameters, called by $motd.build().", "Parameters can be:", "", "     'long             -- long title.", "     'short            -- short title.", "     'title            -- server title.", "     'name             -- server name.", "     'notes            -- connection notes.", "     'quote            -- random quote.", "     'admins           -- list of admins.", "     'connected        -- currently connected users.", "     'version          -- ColdMUD driver version."]
var $motd server_name "the Cold Dark"
var $motd notes []
var $motd server_title "Virtual Environment Server"
var $motd connect_help ["Connection HELP", "===============", "", "Connecting as a guest:    'connect guest <name> <email>'", "              Example:    'connect guest John Doe johnd@site.usa.com'", "", "Connecting as a user:     'connect <name> <password>'", "             Example:     'connect John Doe mypassword'", "", "Quitting (this screen):   '@quit'   or   'quit'", "", "Connected User's Listing: '@who'    or   'who'"]

method build
    arg [args];
    var output, out;
    
    output = [];
    if (!args)
        args = ['long, 'quote];
    if ((args[1]) == 'default)
        args = ['name, "", 'title, "", "", 'quote, "", 'notes, "", 'admins, 'connected, 'core_version, 'driver_version];
    while (args) {
        if (type(args[1]) == 'string) {
            output = output + [""];
        } else {
            switch (args[1]) {
                case 'long:
                    args = delete(args, 1);
                    args = ['title, 'long_name] + args;
                    continue;
                case 'short:
                    args = delete(args, 1);
                    args = ['title, 'name] + args;
                    continue;
                case 'title:
                    out = $string.center(server_title, 79);
                    output = output + [out];
                case 'name:
                    out = $string.center(("+ " + server_name) + " +", 79);
                    output = output + [out];
                case 'notes:
                    out = $list.center_lines(notes, 79);
                    output = output + out;
                case 'quote:
                    out = $list.center_lines($code.random_quote(), 79);
                    output = output + out;
                case 'admins:
                    out = (| $list.to_english($list.map($sys.admins(), 'namef)) |) || "none");
                    out = $string.center("Administrators: " + out, 79);
                    output = output + [out];
                case 'connected:
                    out = "Currently Connected users: ";
                    out = out + tostr(listlen($user_db.connected()));
                    out = $string.center(out, 79);
                    output = output + [out];
                case 'version:
                    args = delete(args, 1);
                    args = ['driver_version, 'core_version] + args;
                    continue;
                case 'driver_version:
                    out = "Driver: " + ($sys.server_info('driver_version, 'long));
                    output = output + [$string.center(out, 79)];
                case 'core_version:
                    out = "Core: " + ($sys.server_info('core_version, 'long));
                    output = output + [$string.center(out, 79)];
            }
        }
        args = delete(args, 1);
    }
    return output;
.

method set_motd
    arg what, value;
    
    .perms(sender());
    if (!(what in (.parameters())))
        throw(~motd, (toliteral(what) + " is not a valid motd parameter, try one of: ") + toliteral(.parameters()));
    if (!(type(value) in ['string, 'list]))
        throw(~motd, "Value must be sent as a string or a list of strings.");
    set_var(what, value);
.

method build_html
    arg [args];
    var output, out;
    
    output = [("<head><title>" + server_name) + "</title></head>", "<body>"];
    if (!args)
        args = ['name, 'title, 'quote, "", 'notes, 'admins, 'connected, 'core_version, 'driver_version, 'help];
    while (args) {
        if (type(args[1]) == 'string) {
            output = output + ["<br>"];
        } else {
            switch (args[1]) {
                case 'title:
                    output = output + ["<h3>", server_title, "</h3>"];
                case 'name:
                    output = output + ["<img src=\"http://sticky.usu.edu/~brandon/tCD.gif\" alt=\"The Cold Dark\">"];
                case 'notes:
                    output = (output + notes) + ["<br>"];
                case 'quote:
                    output = output + ["<tt>", @$code.random_quote(), "</tt>"];
                case 'admins:
                    out = $list.to_english($list.map($sys.admins(), 'namef));
                    output = output + [("Administrators: " + out) + "<br>"];
                case 'connected:
                    out = "<a href=\"/bin/who\">Currently Connected users</a>: ";
                    out = out + tostr(listlen($user_db.connected()));
                    output = output + [out + "<br>"];
                case 'driver_version:
                    out = "ColdX (a derivitive of <a href=\"http://www.declab.usu.edu:8080/ColdMUD/\">ColdMUD</a>) Version " + ($sys.server_info('driver_version));
                    output = output + [out + "<br>"];
                case 'core_version:
                    out = $sys.server_info('core_version, 'long);
                    output = output + [out + "<br>"];
                case 'help:
                    out = "</center><hr width=50% align=center><center>Click <a href=\"telnet://recumbent.declab.usu.edu:1138\"><b>here</b></a> to enter <a href=\"telnet://recumbent.declab.usu.edu:1138\">the Cold Dark</a>.";
                    output = output + [out];
            }
        }
        args = delete(args, 1);
    }
    return ["<center>", @output, "</center>", "</body>"];
.

method server_name
    return server_name;
.

method server_title
    return server_title;
.

method connect_help
    return connect_help;
.

method set_connect_help
    arg text;
    
    (> .perms(sender(), 'manager) <);
    connect_help = text;
.