Exemple #1
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);
        }