// Ignore any Rank Data in SnapShot as this could mess up current data
        $playerinfoData1["rank_{$x}"] = $row['rank'];
    }
    // Calculate rank change
    $chng = $decr = 0;
    if ($playerinfoData1["rank_{$x}"] != $row['rank']) {
        if ($playerinfoData1["rank_{$x}"] > $row['rank']) {
            $chng = 1;
        } else {
            $decr = 1;
        }
    }
    // Update information
    $query = "UPDATE player SET\n\t\t\t\t\tname = '" . $playerinfoData1["name_{$x}"] . "',\n\t\t\t\t\tcountry = '{$country}',\n\t\t\t\t\ttime = `time` + " . $playerinfoData1["ctime_{$x}"] . ",\n\t\t\t\t\trounds = `rounds` + {$complete},\n\t\t\t\t\tip = '" . $playerinfoData1["ip_{$x}"] . "',\n\t\t\t\t\tscore = `score` + " . $playerinfoData1["rs_{$x}"] . ",\n\t\t\t\t\tcmdscore = `cmdscore` + " . $playerinfoData1["cs_{$x}"] . ",\n\t\t\t\t\tskillscore = `skillscore` + " . $playerinfoData1["ss_{$x}"] . ",\n\t\t\t\t\tteamscore = `teamscore` + " . $playerinfoData1["ts_{$x}"] . ",\n\t\t\t\t\tkills = `kills` + " . $playerinfoData1["kills_{$x}"] . ",\n\t\t\t\t\tdeaths = `deaths` + " . $playerinfoData1["deaths_{$x}"] . ",\n\t\t\t\t\tcaptures = `captures` + " . $playerinfoData1["cpc_{$x}"] . ",\n\t\t\t\t\tneutralizes = `neutralizes` + " . $playerinfoData1["cpn_{$x}"] . ",\n\t\t\t\t\tcaptureassists = `captureassists` + " . $playerinfoData1["cpa_{$x}"] . ",\n\t\t\t\t\tneutralizeassists = `neutralizeassists` + " . $playerinfoData1["cpna_{$x}"] . ",\n\t\t\t\t\tdefends = `defends` + " . $playerinfoData1["cpd_{$x}"] . ",\n\t\t\t\t\tdamageassists = `damageassists` + " . $playerinfoData1["ka_{$x}"] . ",\n\t\t\t\t\theals = `heals` + " . $playerinfoData1["he_{$x}"] . ",\n\t\t\t\t\trevives = `revives` + " . $playerinfoData1["rev_{$x}"] . ",\n\t\t\t\t\tammos = `ammos` + " . $playerinfoData1["rsp_{$x}"] . ",\n\t\t\t\t\trepairs = `repairs` + " . $playerinfoData1["rep_{$x}"] . ",\n\t\t\t\t\ttargetassists = `targetassists` + " . $playerinfoData1["tre_{$x}"] . ",\n\t\t\t\t\tdriverspecials = `driverspecials` + " . $playerinfoData1["drs_{$x}"] . ",\n\t\t\t\t\tdriverassists = `driverassists` + " . $playerinfoData1["dra_{$x}"] . ",\n\t\t\t\t\tpassengerassists = `passengerassists` + " . $playerinfoData1["pa_{$x}"] . ",\n\t\t\t\t\tteamkills = `teamkills` + " . $playerinfoData1["tmkl_{$x}"] . ",\n\t\t\t\t\tteamdamage = `teamdamage` + " . $playerinfoData1["tmdg_{$x}"] . ",\n\t\t\t\t\tteamvehicledamage = `teamvehicledamage` + " . $playerinfoData1["tmvd_{$x}"] . ",\n\t\t\t\t\tsuicides = `suicides` + " . $playerinfoData1["su_{$x}"] . ",\n\t\t\t\t\tkillstreak = {$killstreak},\n\t\t\t\t\tdeathstreak = {$deathstreak},\n\t\t\t\t\trank = " . $playerinfoData1["rank_{$x}"] . ",\n\t\t\t\t\tbanned = `banned` + " . $playerinfoData1["ban_{$x}"] . ",\n\t\t\t\t\tkicked = `kicked` + " . $playerinfoData1["kck_{$x}"] . ",\n\t\t\t\t\tcmdtime = `cmdtime` + " . $playerinfoData1["tco_{$x}"] . ",\n\t\t\t\t\tsqltime = `sqltime` + " . $playerinfoData1["tsl_{$x}"] . ",\n\t\t\t\t\tsqmtime = `sqmtime` + " . $playerinfoData1["tsm_{$x}"] . ",\n\t\t\t\t\tlwtime = `lwtime` + " . $playerinfoData1["tlw_{$x}"] . ",\n\t\t\t\t\twins = `wins` + {$wins},\n\t\t\t\t\tlosses = `losses` + {$losses},\n\t\t\t\t\trndscore = {$rndscore},\n\t\t\t\t\tlastonline = " . time() . ",\n\t\t\t\t\tmode0 = `mode0` + " . $globals['mode0'] . ",\n\t\t\t\t\tmode1 = `mode1` + " . $globals['mode1'] . ",\n\t\t\t\t\tmode2 = `mode2` + " . $globals['mode2'] . ",\n\t\t\t\t\tchng = {$chng},\n\t\t\t\t\tdecr = {$decr}\n\t\t\t\t\tWHERE id = " . $playerinfoData1["pID_{$x}"] . "\n\t\t\t\t";
    $result = mysql_query($query);
    checkSQLResult($result, $query);
}
function parsePlayerInfo($data)
{
    $playerdata = array();
    if (count($data) > 0) {
        // put header and data in arrays
        $i = 0;
        foreach ($data as $line) {
            if ($i == 3) {
                $H = explode(chr(9), trim($line));
            }
            if ($i == 4) {
                $D = explode(chr(9), trim($line));
            }
            $i++;
function checkBackendAwards()
{
    global $data, $x, $awardsdata;
    $medals_array = array();
    foreach ($data as $medal_name => $value) {
        if (preg_match("/^medal/", $medal_name)) {
            preg_match_all("/medal(\\w+)_(\\d+)/", $medal_name, $test);
            $pawd = $test[1][0];
            $awpid = $test[2][0];
            if (isset($awardsdata[$pawd])) {
                $medals_array[$data['pid_' . $awpid]][$pawd] = $value;
            }
        }
    }
    foreach ($medals_array as $awpid => $pawards) {
        foreach ($pawards as $paward_name => $paward_value) {
            preg_match_all("/(\\d)(\\d+)/", $awardsdata[$paward_name][0], $test2);
            $atype = $test2[1][0];
            $aid = $test2[2][0];
            $alvl = $paward_value;
            // Check if Player already has Award
            if ($atype == 1) {
                $qbage = "AND (alvl = {$alvl})";
            } else {
                $qbage = "";
            }
            $query = "SELECT * FROM awards WHERE (pid = {$awpid}) AND (atype = {$atype}) AND (aid = {$aid}) " . $qbage;
            //echo $query;
            $awdresult = mysql_query($query);
            checkSQLResult($awdresult, $query);
            // Check if player has award
            //print_r($awardsdata);
            // Recieveing these awards multiple times is NOT supported...yet!
            if (!mysql_num_rows($awdresult) or $awardsdata[$paward_name][1] == 1) {
                // NEW or UPDATE multiple//
                if ($awardsdata[$paward_name][1] == 1 and mysql_num_rows($awdresult) > 0) {
                    $rowawd = mysql_fetch_array($awdresult);
                    $query = "UPDATE awards SET alvl=(alvl+1), earned = " . time() . " WHERE (pid = {$awpid}) AND (atype = {$atype}) AND (aid = {$aid})";
                } else {
                    $query = "INSERT INTO awards SET pid = {$awpid}, atype = {$atype}, aid = {$aid}, earned = " . time() . ", first = " . time() . "";
                }
            } else {
                $rowawd = mysql_fetch_array($awdresult);
                $query = "UPDATE awards SET alvl=(alvl+1), earned = " . $mapdate . " WHERE (pid = {$awpid}) AND (atype = {$atype}) AND (aid = {$aid})";
            }
            if ($allow_db_changes) {
                $result = mysql_query($query);
            } else {
                if ($allow_db_show) {
                    echo '<br />' . $query . '<br />===<br />';
                }
            }
            checkSQLResult($result, $query);
        }
    }
}
Пример #3
0
$query = "SELECT ip, dnshost, gport, port FROM servers WHERE bydnsname=1";
$result = mysql_query($query);
checkSQLResult($result, $query);
if (!mysql_num_rows($result)) {
    //	ErrorLog("Player (".$data["pid_$x"].") not found in `subaccounts`.",3);
    exit;
}
while ($data = mysql_fetch_assoc($result)) {
    $newip = "";
    $newip = gethostbyname($data['dnshost']);
    if ($newip != $data['dnshost']) {
        if ($newip == $data['ip']) {
            //ErrorLog("NOT CHANGE ".$data['dnshost']." == ".$data['ip'],3);
        } else {
            $query1 = "SELECT id FROM servers WHERE ip='" . $newip . "' AND gport='" . $data['gport'] . "' AND port='" . $data['port'] . "'";
            $result1 = mysql_query($query1);
            checkSQLResult($result1, $query1);
            if (mysql_num_rows($result1)) {
                while ($data1 = mysql_fetch_assoc($result1)) {
                    $query1a = "DELETE FROM servers WHERE id='" . $data1['id'] . "'";
                    $result1a = mysql_query($query1a);
                    checkSQLResult($result1a, $query1a);
                }
            }
            ErrorLog("CHANGE " . $data['dnshost'] . " == " . $data['ip'] . " => " . $newip, 3);
            $query2 = "UPDATE servers VALUE SET ip='" . $newip . "' WHERE dnshost='" . $data['dnshost'] . "'";
            $result2 = mysql_query($query2);
            checkSQLResult($result2, $query2);
        }
    }
}
Пример #4
0
function genCheck()
{
    global $cfg;
    $players = array();
    $query = "SELECT id, score FROM player WHERE rank >= 20 AND ip <> '127.0.0.1'";
    $result = mysql_query($query);
    checkSQLResult($result, $query);
    if (mysql_num_rows($result)) {
        while ($row = mysql_fetch_array($result)) {
            $players[$row['id']] = $row['score'];
        }
        arsort($players);
        $id = key($players);
        // Check for old
        $query = "SELECT id, earned FROM awards WHERE awd = 6666667";
        $result = mysql_query($query);
        checkSQLResult($result, $query);
        if (mysql_num_rows($result)) {
            $row = mysql_fetch_array($result);
            // Check for same and determine if minimum tenure servred
            $mintenure = $row['earned'] + $cfg->get('stats_rank_tenure') * 24 * 60 * 60;
            if ($id != $row['id'] && time() >= $mintenure) {
                $query = "DELETE FROM awards WHERE (id = " . $row['id'] . ") AND (awd = 6666667)";
                $result = mysql_query($query);
                checkSQLResult($result, $query);
                $query = "UPDATE player SET rank = 20, chng = 0, decr = 1 WHERE id = " . $row['id'];
                $result = mysql_query($query);
                checkSQLResult($result, $query);
                // Award new
                $query = "INSERT INTO awards SET\r\n\t\t\t\t\tid = {$id},\r\n\t\t\t\t\tawd = 6666667,\r\n\t\t\t\t\tearned = " . time() . "\r\n\t\t\t\t";
                $result = mysql_query($query);
                checkSQLResult($result, $query);
                $query = "UPDATE player SET rank = 21, chng = 1, decr = 0 WHERE id = {$id}";
                $result = mysql_query($query);
                checkSQLResult($result, $query);
            }
        } else {
            // Award new
            $query = "INSERT INTO awards SET\r\n\t\t\t\tid = {$id},\r\n\t\t\t\tawd = 6666667,\r\n\t\t\t\tearned = " . time() . "\t\t\t\t\t\r\n\t\t\t";
            $result = mysql_query($query);
            checkSQLResult($result, $query);
            $query = "UPDATE player SET rank = 21, chng = 1, decr = 0 WHERE id = {$id}";
            $result = mysql_query($query);
            checkSQLResult($result, $query);
        }
    }
}