* Import database class ***************************************************************/ include 'includes/db/class.database.php'; $DB = new Database($cfg->get('db_host'), $cfg->get('db_port'), $cfg->get('db_user'), $cfg->get('db_pass'), $cfg->get('db_name')); /*************************************************************** * Check for login / logout requests ***************************************************************/ if ($_POST['action'] == 'login') { processLogin(); } elseif ($_POST['action'] == 'logout' || $_GET['action'] == 'logout') { processLogout(); } /*************************************************************** * Check database version ***************************************************************/ $dbver = getDbVer(); if ($cfg->get('db_expected_ver') == $dbver) { $dbver_txt = $dbver; } else { $dbver_txt = "<font color=\"red\"><b>" . $dbver . "</b></font>"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>BF2 - Private Stats Admin</title> <link rel="stylesheet" href="images/bf2admin.css" type="text/css"/> <script type='text/javascript' src='includes/admin.script.js'></script>
function processUpgradeDB() { // Update Scheme to Include EF & AF Booster Pack Info $cfg = new Config(); // Store New/Changed config items showLog("Saving Config..."); foreach ($_POST as $item => $val) { $key = explode('__', $item); if ($key[0] == 'cfg') { showLog(" -> Found Key: '{$key[1]}' => '" . (is_array($cfg->get($key[1])) ? str_replace("\r\n", ",", $val) : $val) . "' (Old: " . (is_array($cfg->get($key[1])) ? implode(',', $cfg->get($key[1])) : $cfg->get($key[1])) . ")..."); $cfg->set($key[1], $val); } } $cfg->Save(); // Get DB Version $curdbver = verCmp(getDbVer()); // Open Database connection $connection = @mysql_connect($cfg->get('db_host'), $cfg->get('db_user'), $cfg->get('db_pass')); @mysql_select_db($cfg->get('db_name'), $connection) or die("Database Error: " . mysql_error()); // Upgrade Schema require 'includes/db/sql.dbupgrade.php'; showLog("Upgrading Database Schema"); foreach ($sqlupgrade as $query) { if ($curdbver < verCmp($query[1])) { if (mysql_query($query[2])) { showLog(" -> " . $query[0] . " Success"); } else { showLog(" -> <font color='red'>ERROR:</font> " . $query[0] . " *FAILED*: " . mysql_error()); } } else { showLog(" -> <font color='blue'>Skipping:</font> " . $query[0]); } } // Close database connection @mysql_close($connection); showLog("Done! :)"); }
$errmsg = "SNAPSHOT Data Complete ({$mapname}:{$mapdate})"; ErrorLog($errmsg, 3); // Create SNAPSHOT backup file if ($data['import'] != 1) { $file = @fopen(chkPath($cfg->get('stats_logs')) . $stats_filename, 'wb'); @fwrite($file, $rawdata); @fclose($file); $errmsg = "SNAPSHOT Data Logged (" . chkPath($cfg->get('stats_logs')) . $stats_filename . ")"; ErrorLog($errmsg, 3); // Tell the game server that the snapshot has been received $out = "O\n" . "H\tresponse\tmapname\tmapstart\n" . "D\tOK\t{$mapname}\t{$data['mapstart']}\n"; echo $out . "\$\tOK\t\$"; flush(); } // Check Database Version $curdbver = getDbVer(); if ($curdbver != $cfg->get('db_expected_ver')) { $errmsg = "Database version expected: " . $cfg->get('db_expected_ver') . ", Found: {$curdbver}"; ErrorLog($errmsg, 1); die; } else { $errmsg = "Database version expected: " . $cfg->get('db_expected_ver') . ", Found: {$curdbver}"; ErrorLog($errmsg, 3); } // Open database connection $connection = @mysql_connect($cfg->get('db_host'), $cfg->get('db_user'), $cfg->get('db_pass')); @mysql_select_db($cfg->get('db_name'), $connection); // Global variables $globals = array(); //Determine Round Time $globals['roundtime'] = $data[mapend] - $data[mapstart];