Method code for $sys.do_shutdown()

[Turn on line numbering]
arg time, why;
var increments, line, name, mins, secs;

if (!$sys.is_admin(sender()) || definer() != this())
    throw(~perm, "Sender is not an admin.");
increments = [600, 300, 180, 60];
secs = time * 60;
while (increments && secs < increments[1])
    increments = increments.delete(1);
if (increments && secs > increments[1])
    increments = [secs] + increments;
name = sender().namef('xref);
.log("*** SHUTDOWN called by " + name + " ***");
if (why) {
    why = "*** REASON: " + why + " ***";
    .log(why);
}
while (1) {
    if (!increments) {
        $channel_ui._broadcast('All, "*** SYSTEM SHUTDOWN ***");
        if (why)
            $channel_ui._broadcast('All, why);
        break;
    }
    line = "*** SYSTEM SHUTDOWN IN ";
    mins = increments[1] / 60;
    line = line + tostr(mins) + " MINUTE" + (mins == 1 ? "" : "S");
    line = line + " CALLED BY " + name + " ***";
    $channel_ui._broadcast('All, line);
    if (why)
        $channel_ui._broadcast('All, why);
    if (increments.length() > 1)
        $scheduler.sleep(increments[1] - increments[2]);
    else
        $scheduler.sleep(increments[1]);
    increments = increments.delete(1);
}
pause();
pause();
return .shutdown();

["// Created 26-Mar-1995 as a part of ColdCore, see: @help Credit"]

the Cold Dark