public bool isBanned(string ipAddress, string machineID, out string Reason)
        {
            Reason = "";
            Database Database = new Database(false, true);
            Database.addParameterWithValue("ip", ipAddress);
            Database.addParameterWithValue("machineid", machineID);
            Database.Open();
            if (Database.Ready)
            {
                Reason = Database.getString("SELECT reason FROM moderation_bans WHERE ip = @ip OR machineid = @machineid AND expires > NOW() LIMIT 1");
            }

            return (Reason.Length > 0);
        }
Exemple #2
0
        /// <summary>
        /// Retrieves the username of a user, when only the user ID is known.
        /// </summary>
        /// <param name="userID">The user ID of the user to get the username of.</param>
        public string getUsername(int userID)
        {
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.Open();

            return Database.getString("SELECT username FROM users WHERE id = @userid");
        }
        /// <summary>
        /// Returns true if the given user is (still) banned. If so, then the ban reason is passed through the out Reason string.
        /// </summary>
        /// <param name="userID">The database ID of the user to check.</param>
        /// <param name="Reason">A string that should be passed with the out parameter and which will contain the banreason if banned.</param>
        public bool isBanned(int userID, out string Reason)
        {
            Reason = "";
            Database Database = new Database(false, true);
            Database.addParameterWithValue("userid", userID);
            Database.Open();
            if (Database.Ready)
            {
                Reason = Database.getString("SELECT reason FROM moderation_bans WHERE userid = @userid AND expires > NOW() LIMIT 1");
            }

            return (Reason.Length > 0);
        }