Show admin.php syntax highlighted
<?php
define("VALID_PAGE", 1);
require(dirname(__FILE__) . "/includes/common.php");
// valid admin pages
$validpages = array('home','weapons','awards','roles','db','misc','icons');
// Valid fields
$validfields = array('a');
globalize($validfields);
globalize(array('submit','cancel','themefile'));
if (get_magic_quotes_gpc()) { // remove slashes from all valid variables
foreach ($validfields as $field) {
$$field = stripslashes($$field);
}
}
// remove extra whitespace from all variables
foreach ($validfields as $field) {
$$field = trim($$field);
}
if (empty($themefile) or !$conf['allowthemechange']) $themefile = 'admin';
if (empty($a) or !in_array($a, $validpages)) $a = 'home';
// If we're not logged in redirect the user to the login page, which will inturn redirect them back here after logging in
if (!user_logged_on()) {
gotopage(URLROOT . "login.php?ref=" . urlencode($_SERVER['REQUEST_URI']));
}
// If the user clicked 'cancel' we'll redirect back to the previous page or index.php
if ($cancel) previouspage();
if (!is_numeric($plrid)) $plrid = $user['plrid'];
$iconlist = load_icons();
$errors = array();
$success = "";
// If the user is NOT an admin show FATAL ERROR
if (!user_is_admin()) {
$smarty = new Theme($theme);
$smarty->assign(array(
'user_logged_on' => user_logged_on(),
'errors' => array("fatal" => $lang->trans("You do not have permission to access this page")),
));
$smarty->parse('admin_fatal.html');
$smarty->showpage();
include(DOCROOT . "/includes/footer.php");
exit();
}
// ---------------------------------------------------------------------------------------------------------
// Load the table information so we can calculate how large the DB is
function gatherdata($extended=0) {
global $data, $ps;
$tables = $ps->table_status($conf['dbname']);
$dbsize = 0;
$datasize = 0;
$indexsize = 0;
$totalrecords = 0;
foreach ($tables as $t) {
$dbsize += doubleval($t['Data_length']) + doubleval($t['Index_length']);
$datasize += doubleval($t['Data_length']);
$indexsize += doubleval($t['Index_length']);
$totalrecords += $t['Rows'];
}
$data['dbinfo']['tables'] = $tables;
$data['dbinfo']['totalsize'] = $dbsize;
$data['dbinfo']['totalrecords'] = $totalrecords;
$data['dbinfo']['datasize'] = $datasize;
$data['dbinfo']['indexsize'] = $indexsize;
$data['dbinfo']['totaltables'] = count($tables);
$data['dbinfo']['maxstatdate'] = $ps->max($ps->tblmapshistory, 'UNIX_TIMESTAMP(statdate)');
$data['dbinfo']['minstatdate'] = $ps->min($ps->tblmapshistory, 'UNIX_TIMESTAMP(statdate)');
$data['dbinfo']['statdatedays'] = $ps->count($ps->tblmapshistory, 'DISTINCT statdate');
$data['dbinfo']['totalplayers'] = $ps->count($ps->tblplr);
$data['dbinfo']['totalrankedplayers'] = $ps->count($ps->tblplr, '*', 'allowrank');
if ($extended) {
$data['dbinfo']['maxstatdate'] = $ps->max($ps->tblmapshistory, 'UNIX_TIMESTAMP(statdate)');
$data['dbinfo']['minstatdate'] = $ps->min($ps->tblmapshistory, 'UNIX_TIMESTAMP(statdate)');
$data['dbinfo']['statdatedays'] = $ps->count($ps->tblmapshistory, 'DISTINCT statdate');
$data['dbinfo']['totalpasswords'] = $ps->count($ps->tblplrprofile, '*', "`password` != ''");
$data['dbinfo']['totalusernames'] = $ps->count($ps->tblplrprofile, '*', "`username` != ''");
$data['dbinfo']['totaladmins'] = $ps->count($ps->tblplrprofile, '*', "`accesslevel` >= " . ACL_ADMIN);
$data['dbinfo']['totalclanadmins'] = $ps->count($ps->tblplrprofile, '*', "`accesslevel` >= " . ACL_CLANADMIN . " AND `accesslevel` < " . ACL_ADMIN);
$data['dbinfo']['totalplrlogos'] = $ps->count($ps->tblplrprofile, '*', "`plrlogo` != ''");
$data['dbinfo']['totalclanlogos'] = $ps->count($ps->tblclansprofile, '*', "`clanlogo` != ''");
}
}
// ---------------------------------------------------------------------------------------------------------
// Load the theme and display it
$data = array(
'adminpage' => $a, // this will make the proper ADMIN page appear
'a' => $a,
'iconlist' => $iconlist,
'errors' => $errors,
'success' => $success,
);
$data['dbinfo'] = $ps->server_info();
$data['dbinfo']['dbname'] = $conf['dbname'];
$data['dbinfo']['dbhost'] = $conf['dbhost'];
//$adminfile = dirname(__FILE__) . DIRSLASH . "admin_$a.php";
$adminfile = "admin_$a.php";
if (file_exists(DOCROOT . $adminfile)) {
include(DOCROOT . $adminfile);
} else {
$errors['fatal'] = sprintf($lang->trans("Invalid admin file (%s) specified."), $a);
}
foreach ($validfields as $field) $data[$field] = $$field; // insert variables into theme $data array
$smarty->assign($data);
$smarty->parse($themefile);
$smarty->showpage();
include(DOCROOT . "includes/footer.php");
?>
See more files for this project here