예제 #1
0
function databaseBanUser($service_id, $username, $realm, $duration, $reason, $unban = false, $name_only = false, $ban_aliases = false)
{
    global $config;
    $link = databaseConnect($service_id);
    if (!$link) {
        return false;
    }
    $message = "";
    $username = escape(strtolower($username));
    $realm = escape($realm);
    $duration = escape(intval($duration) * 3600);
    $reason = escape($reason);
    $realms = databaseGetRealms($service_id);
    //find a realm to use by default that is not blank
    $default_realm = "";
    foreach ($realms as $i_realm) {
        if ($i_realm != "") {
            $default_realm = $i_realm;
            break;
        }
    }
    if ($realm != "") {
        $realms = array($realm);
    }
    foreach ($realms as $realm_it) {
        $where = "WHERE name = '{$username}' AND spoofedrealm = '{$realm_it}'";
        //unban the user if we're supposed to
        if ($unban) {
            $link->query("DELETE FROM bans WHERE name = '{$username}' AND server = '{$realm_it}'");
            $message .= "Unbanned {$username} on {$realm_it}<br />";
            continue;
        }
        //make sure user isn't already banned
        $result = $link->query("SELECT COUNT(*) FROM bans WHERE name = '{$username}' AND server = '{$realm_it}'");
        $row = $result->fetch_array();
        $result->close();
        if ($row[0] > 0) {
            $message .= "Skipping {$realm_it}: already banned!<br />";
            continue;
        }
        //last few IP addresses logged; limited to 15 addresses within the last 30 days
        $result = $link->query("SELECT DISTINCT ip FROM gameplayers LEFT JOIN games ON gameplayers.gameid = games.id {$where} AND datetime > DATE_SUB( NOW( ), INTERVAL 30 DAY) ORDER BY gameplayers.id DESC LIMIT 15");
        //only continue if both we have found some addresses and we don't want to just ban by name
        if (!$name_only && $result->num_rows > 0) {
            while ($row = $result->fetch_array()) {
                $ip = escape($row[0]);
                //if this is for non-spoofchecked users, ban on default realm
                $ban_realm = $realm_it;
                if ($ban_realm == "") {
                    $ban_realm = $default_realm;
                }
                if ($config['db_expiredate'] === false) {
                    $link->query("INSERT INTO bans (botid, server, name, ip, date, gamename, admin, reason) VALUES ('0', '{$ban_realm}', '{$username}', '{$ip}', CURDATE(), '', 'uxpanel', '{$reason}'");
                } else {
                    $link->query("INSERT INTO bans (botid, server, name, ip, date, gamename, admin, reason, {$config['db_expiredate']}) VALUES ('0', '{$ban_realm}', '{$username}', '{$ip}', CURDATE(), '', 'uxpanel', '{$reason}', DATE_ADD( NOW( ), INTERVAL {$duration} second ))");
                }
                $message .= "Banned used IP address [{$ip}] on {$realm_it}<br />";
            }
        } else {
            //no previous games found; ban by username only if this is an actual realm
            if ($realm_it != "") {
                if ($config['db_expiredate'] === false) {
                    $link->query("INSERT INTO bans (botid, server, name, ip, date, gamename, admin, reason VALUES ('0', '{$realm_it}', '{$username}', '', CURDATE(), '', 'uxpanel', '{$reason}')");
                } else {
                    $link->query("INSERT INTO bans (botid, server, name, ip, date, gamename, admin, reason, {$config['db_expiredate']}) VALUES ('0', '{$realm_it}', '{$username}', '', CURDATE(), '', 'uxpanel', '{$reason}', DATE_ADD( NOW( ), INTERVAL {$duration} second ))");
                }
                $message .= "Banned by name on {$realm_it}<br />";
            }
        }
        $result->close();
    }
    if ($ban_aliases) {
        $message .= "Banning aliases...<br />";
        $searchRealm = $realm;
        if ($searchRealm == "") {
            $searchRealm = $default_realm;
        }
        //get list of aliases and ban them on the default realm
        $array = array();
        databaseAliases($service_id, $username, $searchRealm, 1, $array);
        $players = array_keys($array);
        foreach ($players as $p_str) {
            $p_info = databaseGetPlayer($p_str);
            $aliasName = escape($p_info[0]);
            $aliasRealm = escape($p_info[1]);
            if ($aliasName == $username && $aliasRealm == $searchRealm) {
                continue;
            }
            $message .= databaseBanUser($service_id, $aliasName, $aliasRealm, $duration, $reason, false, true);
            $message .= "Banned alias {$aliasName}@{$aliasRealm}<br />";
        }
    }
    return $message;
}
예제 #2
0
<?php

include "../include/common.php";
include "../config.php";
include "../include/session.php";
include "../include/dbconnect.php";
include "../include/account.php";
include "../include/database.php";
if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_database'])) {
    $player = array("", "");
    if (isset($_REQUEST['player'])) {
        $player = databaseGetPlayer($_REQUEST['player']);
    }
    $array = array();
    databaseAliases($_REQUEST['id'], $player[0], $player[1], 2, $array);
    $players = array_keys($array);
    $playersNice = array();
    foreach ($players as $p_str) {
        $p_info = databaseGetPlayer($p_str);
        $playersNice[] = array($p_info[0], $p_info[1], databaseLastPlayed($_REQUEST['id'], $p_info[0]));
    }
    get_page("alias", "database", array('service_id' => $_REQUEST['id'], 'players' => $playersNice));
} else {
    header("Location: ../panel/");
}
예제 #3
0
<?php

include "../include/common.php";
include "../config.php";
include "../include/session.php";
include "../include/dbconnect.php";
include "../include/account.php";
include "../include/database.php";
if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_database'])) {
    $player = array("", "");
    if (isset($_REQUEST['player'])) {
        $player = databaseGetPlayer($_REQUEST['player']);
    }
    $ips = databaseIPLookup($_REQUEST['id'], $player[0], $player[1]);
    get_page("iplookup", "database", array('service_id' => $_REQUEST['id'], 'ips' => $ips));
} else {
    header("Location: ../panel/");
}