Esempio n. 1
0
        // Function from file: world.dm
        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");
            GlobalVars.diary.WriteMsg("\n\nStarting up. " + String13.FormatTime(Game13.timeofday, "hh:mm.ss") + "\n---------------------");
            GlobalVars.diaryofmeanpeople.WriteMsg("\n\nStarting up. " + String13.FormatTime(Game13.timeofday, "hh:mm.ss") + "\n---------------------");
            GlobalVars.changelog_hash = Num13.Md5(File13.Read("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")) ?? 0) * 36000;

            if (GlobalVars.config.sql_enabled)
            {
                if (!GlobalFuncs.setup_database_connection())
                {
                    Game13.log.WriteMsg("Your server failed to establish a connection with the database.");
                }
                else
                {
                    Game13.log.WriteMsg("Database connection established.");
                }
            }
            GlobalVars.data_core = new Datacore();
            Task13.Schedule(10, (Task13.Closure)(() => {
                GlobalVars.Master.Setup();
                return;
            }));
            //GlobalFuncs.process_teleport_locs(); F**k this code.
            GlobalFuncs.SortAreas();
            GlobalVars.map_name = "Box Station";
        }
Esempio n. 2
0
        // Function from file: IsBanned.dm
        public static dynamic IsBanned(string key = null, dynamic address = null, string computer_id = null)
        {
            dynamic _default = null;

            bool    admin      = false;
            string  ckey       = null;
            string  ckeytext   = null;
            string  ipquery    = null;
            string  cidquery   = null;
            DBQuery query      = null;
            string  pckey      = null;
            dynamic ackey      = null;
            dynamic reason     = null;
            dynamic expiration = null;
            string  duration   = null;
            dynamic bantime    = null;
            string  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 (Lang13.Bool(GlobalVars.config.extreme_popcap) && GlobalFuncs.living_player_count() >= (GlobalVars.config.extreme_popcap ?? 0) && !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())
                {
                    Game13.log.WriteMsg("Ban database connection failure. Key " + ckeytext + " not checked");
                    GlobalVars.diary.WriteMsg("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) > 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);
        }
Esempio n. 3
0
        // Function from file: world.dm
        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.WriteMsg("<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 ?? 0) * 10;
            }

            if (GlobalVars.ticker.delay_end)
            {
                Game13.WriteMsg("<span class='boldannounce'>An admin has delayed the round end.</span>");
                return(null);
            }
            Game13.WriteMsg("<span class='boldannounce'>Rebooting World in " + (delay ?? 0) / 10 + " " + ((delay ?? 0) > 10 ? "seconds" : "second") + ". " + reason + "</span>");
            Task13.Sleep(((int)(delay ?? 0)));

            if (GlobalVars.blackbox != null)
            {
                GlobalVars.blackbox.save_all_data_to_sql();
            }

            if (GlobalVars.ticker.delay_end)
            {
                Game13.WriteMsg("<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.WriteMsg(new Sound(GlobalVars.ticker.round_end_sound));
                }
                else
                {
                    Game13.WriteMsg(new Sound(Rand13.Pick(new object [] { "sound/AI/newroundsexy.ogg", "sound/misc/apcdestroyed.ogg", "sound/misc/bangindonk.ogg", "sound/misc/leavingtg.ogg" })));
                }
                return;
            }));

            foreach (dynamic _a in Lang13.Enumerate(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);
        }