Example #1
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']) && isset($_REQUEST['gid']) && is_numeric($_REQUEST['gid'])) {
    $gid = $_REQUEST['gid'];
    $game = databaseGetGame($_REQUEST['id'], $gid);
    $replayBase = getServiceParam($_REQUEST['id'], 'replay_base');
    get_page("game", "database", array('service_id' => $_REQUEST['id'], 'game' => $game, 'gid' => $gid, 'replay_base' => $replayBase));
} else {
    header("Location: ../panel/");
}
Example #2
0
function databaseSearchUser($service_id, $username, $realm)
{
    global $config;
    $link = databaseConnect($service_id);
    if (!$link) {
        return array();
    }
    $username = escape($username);
    $realm = escape($realm);
    $realms = databaseGetRealms($service_id);
    if ($realm != "") {
        $realms = array($realm);
    }
    $array = array();
    foreach ($realms as $realm_it) {
        $where = "WHERE name = '{$username}'";
        if ($realm_it != "*") {
            $where .= " AND spoofedrealm = '{$realm_it}'";
        }
        //grab general statistics
        if ($config['db_gametrack']) {
            $where = "WHERE name='{$username}'";
            if ($realm_it != "*") {
                $where .= " AND realm = '{$realm_it}'";
            }
            $result = $link->query("SELECT time_created, time_active, num_games, (total_leftpercent / num_games)*100, lastgames FROM gametrack {$where}");
        } else {
            $result = $link->query("SELECT MIN(DATE(datetime)), MAX(DATE(datetime)), COUNT(*), AVG(`left`/duration)*100, '' FROM  gameplayers LEFT JOIN games ON games.id = gameplayers.gameid {$where}");
        }
        $row = $result->fetch_array();
        $firstgame = $row[0];
        $lastgame = $row[1];
        $totalgames = $row[2];
        $leftpercent = $row[3];
        $lastgames = explode(",", $row[4]);
        $array[$realm_it] = array('firstgame' => $firstgame, 'lastgame' => $lastgame, 'totalgames' => $totalgames, 'leftpercent' => $leftpercent, 'lastgames' => array(), 'bans' => array());
        foreach ($lastgames as $gid) {
            if ($gid != 0) {
                $array[$realm_it]['lastgames'][$gid] = databaseGetGame($service_id, $gid, true);
            }
        }
        if ($totalgames != 0) {
            //ban history
            if ($config['db_expiredate'] === false) {
                $result = $link->query("SELECT admin, reason, gamename, date, NOW( ) FROM ban_history WHERE name = '{$username}' AND server = '{$realm_it}' ORDER BY id DESC LIMIT 6");
            } else {
                $result = $link->query("SELECT admin, reason, gamename, date, {$config['db_expiredate']} FROM ban_history WHERE name = '{$username}' AND server = '{$realm_it}' ORDER BY id DESC LIMIT 6");
            }
            while ($row = $result->fetch_array()) {
                $array[$realm_it]['bans'][] = array('admin' => $row[0], 'reason' => $row[1], 'gamename' => $row[2], 'date' => $row[3], 'expiredate' => $row[4]);
            }
        }
    }
    return $array;
}