Exemple #1
0
        // Range: -1 Access: 0 Flags: ( 0, 4, 255 )
        public static void New(  )
        {
            string date_string = null;

            GlobalVars.map_ready         = true;
            date_string                  = String13.formatTime(Game13.realtime, "YYYY/MM-Month/DD-Day");
            GlobalVars.href_logfile      = new File("data/logs/" + date_string + " hrefs.htm");
            GlobalVars.diary             = new File("data/logs/" + date_string + ".log");
            GlobalVars.diaryofmeanpeople = new File("data/logs/" + date_string + " Attack.log");
            ((dynamic)GlobalVars.diary).write("\n\nStarting up. " + String13.formatTime(Game13.timeofday, "hh:mm.ss") + "\n---------------------");
            ((dynamic)GlobalVars.diaryofmeanpeople).write("\n\nStarting up. " + String13.formatTime(Game13.timeofday, "hh:mm.ss") + "\n---------------------");
            GlobalVars.changelog_hash = Num13.md5("html/changelog.html");
            GlobalFuncs.make_datum_references_lists();
            Game13.load_configuration();
            Game13.load_mode();
            Game13.load_motd();
            GlobalFuncs.load_admins();
            if (GlobalVars.config.usewhitelist)
            {
                GlobalFuncs.load_whitelist();
            }
            GlobalFuncs.appearance_loadbanfile();
            GlobalFuncs.LoadBans();
            GlobalFuncs.investigate_reset();
            if (GlobalVars.config != null && GlobalVars.config.server_name != null && GlobalVars.config.server_suffix && Game13.port > 0)
            {
                GlobalVars.config.server_name += " #" + Game13.port % 1000 / 100;
            }
            GlobalVars.timezoneOffset = String13.parseNumber(String13.formatTime(0, "hh")) * 36000;
            if (GlobalVars.config.sql_enabled)
            {
                if (!GlobalFuncs.setup_database_connection())
                {
                    ((dynamic)Game13.log).write("Your server failed to establish a connection with the database.");
                }
                else
                {
                    ((dynamic)Game13.log).write("Database connection established.");
                }
            }
            GlobalVars.data_core = new Datacore();
            Task13.schedule(-1, (Task13.Closure)(() => {
                GlobalVars.Master.Setup();
                return;
            }));
            GlobalFuncs.process_teleport_locs();
            GlobalFuncs.SortAreas();
            GlobalVars.map_name = "" + "Box Station";
            return;
        }
Exemple #2
0
        // Range: -1 Access: 0 Flags: ( 0, 4, 255 )
        public static dynamic IsBanned(dynamic key = null, dynamic address = null, dynamic computer_id = null)
        {
            dynamic _default   = null;
            bool    admin      = false;
            dynamic ckey       = null;
            string  ckeytext   = null;
            string  ipquery    = null;
            string  cidquery   = null;
            DBQuery query      = null;
            dynamic pckey      = null;
            dynamic ackey      = null;
            dynamic reason     = null;
            dynamic expiration = null;
            dynamic duration   = null;
            dynamic bantime    = null;
            dynamic bantype    = null;
            string  expires    = null;
            string  desc       = null;

            if (!Lang13.Bool(key) || !Lang13.Bool(address) || !Lang13.Bool(computer_id))
            {
                GlobalFuncs.log_access("Failed Login (invalid data): " + key + " " + address + "-" + computer_id);
                return(new ByTable()
                       .set("reason", "invalid login data")
                       .set("desc", "Error: Could not check ban status, Please try again. Error message: Your computer provided invalid or blank information to the server on connection (byond username, IP, and Computer ID.) Provided information for reference: Username:'******' IP:'" + address + "' Computer ID:'" + computer_id + "'. (If you continue to get this error, please restart byond or contact byond support.)")
                       );
            }
            if (String13.parseNumber(computer_id) == 2147483648)
            {
                GlobalFuncs.log_access("Failed Login (invalid cid): " + key + " " + address + "-" + computer_id);
                return(new ByTable().set("reason", "invalid login data").set("desc", "Error: Could not check ban status, Please try again. Error message: Your computer provided an invalid Computer ID.)"));
            }
            admin = false;
            ckey  = String13.ckey(key);
            if (GlobalVars.admin_datums.contains(ckey) || GlobalVars.deadmins.contains(ckey))
            {
                admin = true;
            }
            if (GlobalFuncs.IsGuestKey(key))
            {
                if (!GlobalVars.guests_allowed)
                {
                    GlobalFuncs.log_access("Failed Login: "******" - Guests not allowed");
                    return(new ByTable().set("reason", "guest").set("desc", "\nReason: Guests not allowed. Please sign in with a byond account."));
                }
                if (GlobalVars.config.panic_bunker && GlobalVars.dbcon != null && GlobalVars.dbcon.IsConnected())
                {
                    GlobalFuncs.log_access("Failed Login: "******" - Guests not allowed during panic bunker");
                    return(new ByTable()
                           .set("reason", "guest")
                           .set("desc", "\nReason: Sorry but the server is currently not accepting connections from never before seen players or guests. If you have played on this server with a byond account before, please log in to the byond account you have played from.")
                           );
                }
            }
            if (GlobalVars.config.extreme_popcap != 0 && GlobalFuncs.living_player_count() >= GlobalVars.config.extreme_popcap && !admin)
            {
                GlobalFuncs.log_access("Failed Login: "******" - Population cap reached");
                return(new ByTable().set("reason", "popcap").set("desc", "\nReason: " + GlobalVars.config.extreme_popcap_message));
            }
            if (GlobalVars.config.ban_legacy_system)
            {
                _default = GlobalFuncs.CheckBan(String13.ckey(key), computer_id, address);
                if (Lang13.Bool(_default))
                {
                    if (admin)
                    {
                        GlobalFuncs.log_admin("The admin " + key + " has been allowed to bypass a matching ban on " + _default["key"]);
                        GlobalFuncs.message_admins("<span class='adminnotice'>The admin " + key + " has been allowed to bypass a matching ban on " + _default["key"] + "</span>");
                        GlobalFuncs.addclientmessage(ckey, "<span class='adminnotice'>You have been allowed to bypass a matching ban on " + _default["key"] + "</span>");
                    }
                    else
                    {
                        GlobalFuncs.log_access("Failed Login: "******" " + computer_id + " " + address + " - Banned " + _default["reason"]);
                        return(_default);
                    }
                }
            }
            else
            {
                ckeytext = String13.ckey(key);
                if (!GlobalFuncs.establish_db_connection())
                {
                    ((dynamic)Game13.log).write("Ban database connection failure. Key " + ckeytext + " not checked");
                    ((dynamic)GlobalVars.diary).write("Ban database connection failure. Key " + ckeytext + " not checked");
                    return(_default);
                }
                ipquery  = "";
                cidquery = "";
                if (Lang13.Bool(address))
                {
                    ipquery = " OR ip = '" + address + "' ";
                }
                if (Lang13.Bool(computer_id))
                {
                    cidquery = " OR computerid = '" + computer_id + "' ";
                }
                query = GlobalVars.dbcon.NewQuery("SELECT ckey, ip, computerid, a_ckey, reason, expiration_time, duration, bantime, bantype FROM " + GlobalFuncs.format_table_name("ban") + " WHERE (ckey = '" + ckeytext + "' " + ipquery + " " + cidquery + ") AND (bantype = 'PERMABAN' OR bantype = 'ADMIN_PERMABAN' OR ((bantype = 'TEMPBAN' OR bantype = 'ADMIN_TEMPBAN') AND expiration_time > Now())) AND isnull(unbanned)");
                query.Execute();
                while (query.NextRow())
                {
                    pckey      = query.item[1];
                    ackey      = query.item[4];
                    reason     = query.item[5];
                    expiration = query.item[6];
                    duration   = query.item[7];
                    bantime    = query.item[8];
                    bantype    = query.item[9];
                    if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
                    {
                        if (pckey != ckey)
                        {
                            continue;
                        }
                    }
                    if (admin)
                    {
                        if (bantype == "ADMIN_PERMABAN" || bantype == "ADMIN_TEMPBAN")
                        {
                            GlobalFuncs.log_admin("The admin " + key + " is admin banned, and has been disallowed access");
                            GlobalFuncs.message_admins("<span class='adminnotice'>The admin " + key + " is admin banned, and has been disallowed access</span>");
                        }
                        else
                        {
                            GlobalFuncs.log_admin("The admin " + key + " has been allowed to bypass a matching ban on " + pckey);
                            GlobalFuncs.message_admins("<span class='adminnotice'>The admin " + key + " has been allowed to bypass a matching ban on " + pckey + "</span>");
                            GlobalFuncs.addclientmessage(ckey, "<span class='adminnotice'>You have been allowed to bypass a matching ban on " + pckey + "</span>");
                            continue;
                        }
                    }
                    expires = "";
                    if (String13.parseNumber(duration) > 0)
                    {
                        expires = " The ban is for " + duration + " minutes and expires on " + expiration + " (server time).";
                    }
                    else
                    {
                        expires = " The is a permanent ban.";
                    }
                    desc     = "\nReason: You, or another user of this computer or connection (" + pckey + ") is banned from playing here. The ban reason is:\n" + reason + "\nThis ban was applied by " + ackey + " on " + bantime + ", " + expires;
                    _default = new ByTable().set("reason", "" + bantype).set("desc", "" + desc);
                    GlobalFuncs.log_access("Failed Login: "******" " + computer_id + " " + address + " - Banned " + _default["reason"]);
                    return(_default);
                }
            }
            _default = Game13._internal_IsBanned(key, address, computer_id);
            if (Lang13.Bool(_default))
            {
                if (admin)
                {
                    GlobalFuncs.log_admin("The admin " + key + " has been allowed to bypass a matching host/sticky ban");
                    GlobalFuncs.message_admins("<span class='adminnotice'>The admin " + key + " has been allowed to bypass a matching host/sticky ban</span>");
                    GlobalFuncs.addclientmessage(ckey, "<span class='adminnotice'>You have been allowed to bypass a matching host/sticky ban</span>");
                    return(null);
                }
                else
                {
                    GlobalFuncs.log_access("Failed Login: "******" " + computer_id + " " + address + " - Banned " + _default["message"]);
                }
            }
            return(_default);
        }
Exemple #3
0
        // Range: -1 Access: 0 Flags: ( 0, 4, 255 )
        public static dynamic Reboot(dynamic reason = null, string feedback_c = null, string feedback_r = null, int?time = null)
        {
            double? delay = null;
            dynamic C     = null;

            if (reason == 1)
            {
                if (Task13.user != null)
                {
                    GlobalFuncs.log_admin("" + GlobalFuncs.key_name(Task13.user) + " Has requested an immediate world restart via client side debugging tools");
                    GlobalFuncs.message_admins("" + GlobalFuncs.key_name_admin(Task13.user) + " Has requested an immediate world restart via client side debugging tools");
                }
                Game13.write("<span class='boldannounce'>Rebooting World immediately due to host request</span>");
                return(Game13._internal_Reboot(1, feedback_c, feedback_r, time));
            }
            if (Lang13.Bool(time))
            {
                delay = time;
            }
            else
            {
                delay = GlobalVars.config.round_end_countdown * 10;
            }
            if (GlobalVars.ticker.delay_end)
            {
                Game13.write("<span class='boldannounce'>An admin has delayed the round end.</span>");
                return(null);
            }
            Game13.write("<span class='boldannounce'>Rebooting World in " + (delay ?? 0) / 10 + " " + ((delay ?? 0) > 10 ? "seconds" : "second") + ". " + reason + "</span>");
            Task13.sleep(((int)(delay)));
            if (GlobalVars.blackbox != null)
            {
                GlobalVars.blackbox.save_all_data_to_sql();
            }
            if (GlobalVars.ticker.delay_end)
            {
                Game13.write("<span class='boldannounce'>Reboot was cancelled by an admin.</span>");
                return(null);
            }
            GlobalFuncs.feedback_set_details("" + feedback_c, "" + feedback_r);
            GlobalFuncs.log_game("<span class='boldannounce'>Rebooting World. " + reason + "</span>");
            GlobalFuncs.kick_clients_in_lobby("<span class='boldannounce'>The round came to an end with you in the lobby.</span>", 1);
            Task13.schedule(0, (Task13.Closure)(() => {
                if (GlobalVars.ticker != null && Lang13.Bool(GlobalVars.ticker.round_end_sound))
                {
                    Game13.write(new Sound(GlobalVars.ticker.round_end_sound));
                }
                else
                {
                    Game13.write(new Sound(Rand13.pick(new object [] { "sound/AI/newroundsexy.ogg", "sound/misc/apcdestroyed.ogg", "sound/misc/bangindonk.ogg", "sound/misc/leavingtg.ogg" })));
                }
                return;
            }));
            C = null;
            foreach (dynamic _a in GlobalVars.clients)
            {
                C = _a;
                if (!Lang13.Bool(((dynamic)typeof(Client)).IsInstanceOfType(C)))
                {
                    continue;
                }
                if (Lang13.Bool(GlobalVars.config.server))
                {
                    Interface13.link(C, "byond://" + GlobalVars.config.server);
                }
            }
            ;
            Game13._internal_Reboot(0, feedback_c, feedback_r, time);
            return(null);
        }