username = $_POST["authusername"]; $this->password = $_POST["authpassword"]; $this->savepass = $_POST["authsavepass"]; $this->sessionStart = 0; # clear POST vars so as not to confuse the receiving page $_POST = array(); $this->session = false; $this->checkPass(); } elseif ($_COOKIE["authusername"]) { $this->username = $_COOKIE["authusername"]; $this->password = $_COOKIE["authpassword"]; $this->savepass = $_COOKIE["authsavepass"]; $this->sessionStart = $_COOKIE["authsessionStart"]; $this->session = true; $this->checkPass(); } else { $this->ok = false; $this->error = false; $this->session = false; $this->printAuth(); } } function checkPass() { global $db; $db->query(" SELECT * FROM hlstats_Users WHERE username='$this->username' "); if ($db->num_rows() == 1) { // The username is OK $this->userdata = $db->fetch_array(); $db->free_result(); if (md5($this->password) == $this->userdata["password"]) { // The username and the password are OK $this->ok = true; $this->error = false; if ($this->sessionStart > (time()-3600)) { // Valid session, update session time & display the page $this->doCookies(); return true; } elseif ($this->sessionStart) { // A session exists but has expired if ($this->savepass) { // They selected 'Save my password' so we just // generate a new session and show the page. $this->doCookies(); return true; } else { $this->ok = false; $this->error = "Your session has expired. Please try again."; $this->password = ""; $this->printAuth(); return false; } } elseif (!$this->session) { // No session and no cookies, but the user/pass was // POSTed, so we generate cookies. $this->doCookies(); return true; } else { // No session, user/pass from a cookie, so we force auth $this->printAuth(); return false; } } else { // The username is OK but the password is wrong $this->ok = false; if ($this->session) { // Cookie without 'Save my password' - not an error $this->error = false; } else { $this->error = "The password you supplied is incorrect."; } $this->password = ""; $this->printAuth(); } } else { // The username is wrong $this->ok = false; $this->error = "The username you supplied is not valid."; $this->printAuth(); } } function doCookies() { setCookie("authusername", $this->username, time()+31536000, "", "", 0); if ($this->savepass) { setCookie("authpassword", $this->password, time()+31536000, "", "", 0); } else { setCookie("authpassword", $this->password, 0, "", "", 0); } setCookie("authsavepass", $this->savepass, time()+31536000, "", "", 0); setCookie("authsessionStart", time(), 0, "", "", 0); } function printAuth() { global $g_options; include(INCLUDE_PATH . "/adminauth.inc"); exit(); } } class AdminTask { var $title = ""; var $acclevel = 0; var $type = ""; var $description = ""; function AdminTask ($title, $acclevel, $type="general", $description="") { $this->title = $title; $this->acclevel = $acclevel; $this->type = $type; $this->description = $description; } } class EditList { var $columns; var $keycol; var $table; var $icon; var $showid; var $errors; var $newerror; function EditList ($keycol, $table, $icon, $showid=true) { $this->keycol = $keycol; $this->table = $table; $this->icon = $icon; $this->showid = $showid; } function update () { global $HTTP_POST_VARS, $db; $okcols = 0; foreach ($this->columns as $col) { $value = $HTTP_POST_VARS["new_$col->name"]; if ($value != "") { if ($col->type == "ipaddress" && !ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $value)) { $this->errors[] = "Column '$col->title' requires a valid IP address for new row"; $this->newerror = true; $okcols++; } else { if ($qcols) $qcols .= ", "; $qcols .= $col->name; if ($qvals) $qvals .= ", "; if ($col->type == "password") { $qvals .= "MD5('$value')"; } else { $qvals .= "'$value'"; } if ($col->type != "select" && $col->type != "hidden" && $value != $col->datasource) $okcols++; } } elseif ($col->required) { $this->errors[] = "Required column '$col->title' must have a value for new row"; $this->newerror = true; } } if ($okcols > 0 && !$this->errors) { $db->query(" INSERT INTO $this->table ( $qcols ) VALUES ( $qvals )", false ); if ($db->dberror()) { $this->errors[] = "DB Error: " . $db->dberror(); } } elseif ($okcols == 0) { $this->errors = array(); $this->newerror = false; } if (!is_array($HTTP_POST_VARS["rows"])) return true; foreach ($HTTP_POST_VARS["rows"] as $row) { $row = stripslashes($row); if ($HTTP_POST_VARS[$row . "_delete"]) { $db->query(" DELETE FROM $this->table WHERE $this->keycol='" . addslashes($row) . "' "); } else { $rowerror = false; $query = "UPDATE $this->table SET "; $i=0; foreach ($this->columns as $col) { $value = $HTTP_POST_VARS[$row . "_" . $col->name]; if ($col->type == "password" && $value == "(encrypted)") continue; if ($value == "" && $col->required) { $this->errors[] = "Required column '$col->title' must have a value for row '$row'"; $rowerror = true; } elseif ($col->type == "ipaddress" && !ereg("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$", $value)) { $this->errors[] = "Column '$col->title' requires a valid IP address for row '$row'"; $rowerror = true; } if ($i > 0) $query .= ", "; if ($col->type == "password") { $query .= $col->name . "=MD5('$value')"; } else { $query .= $col->name . "='$value'"; } $i++; } $query .= " WHERE $this->keycol='" . addslashes($row) . "'"; if (!$rowerror) { $db->query($query); } } } if ($this->error()) { return false; } else { return true; } } function draw ($result) { global $g_options, $HTTP_POST_VARS, $db; ?>
|
columns as $col) { if ($new) { $keyval = "new"; $rowdata[$col->name] = $rowdata["new_$col->name"]; if ($stripslashes) $rowdata[$col->name] = stripslashes($rowdata[$col->name]); } else { $keyval = $rowdata[$this->keycol]; if ($stripslashes) $keyval = stripslashes($keyval); } if ($col->type != "hidden") { echo "
\n\n", $this->errors);
}
else
{
return false;
}
}
}
class EditListColumn
{
var $name;
var $title;
var $width;
var $required;
var $type;
var $datasource;
var $maxlength;
function EditListColumn ($name, $title, $width=20, $required=false, $type="text", $datasource="", $maxlength=0)
{
$this->name = $name;
$this->title = $title;
$this->width = $width;
$this->required = $required;
$this->type = $type;
$this->datasource = $datasource;
$this->maxlength = intval($maxlength);
}
}
class PropertyPage
{
var $table;
var $keycol;
var $keyval;
var $propertygroups = array();
function PropertyPage ($table, $keycol, $keyval, $groups)
{
$this->table = $table;
$this->keycol = $keycol;
$this->keyval = $keyval;
$this->propertygroups = $groups;
}
function draw ($data)
{
foreach ($this->propertygroups as $group)
{
$group->draw($data);
}
}
function update ()
{
global $HTTP_POST_VARS, $db;
$setstrings = array();
foreach ($this->propertygroups as $group)
{
foreach ($group->properties as $prop)
{
$setstrings[] = $prop->name . "='" . $HTTP_POST_VARS[$prop->name] . "'";
}
}
$db->query("
UPDATE
" . $this->table . "
SET
" . implode(",\n", $setstrings) . "
WHERE
" . $this->keycol . "='" . $this->keyval . "'
");
}
}
class PropertyPage_Group
{
var $title = "";
var $properties = array();
function PropertyPage_Group ($title, $properties)
{
$this->title = $title;
$this->properties = $properties;
}
function draw ($data)
{
global $g_options;
?>
title; ?>
name = $name; $this->title = $title; $this->type = $type; $this->datasource = $datasource; } function draw ($value) { global $g_options; ?>
| $msg"; echo $g_options["fontend_normal"]; ?> |
"")); $selTask = $HTTP_GET_VARS["task"]; $selGame = $HTTP_GET_VARS["admingame"]; ?>
| type == "tool" || $admintasks[$selTask]->type == "subtool")
{
$task = $admintasks[$selTask];
$code = $selTask;
?>
$task)
{
if ($auth->userdata["acclevel"] >= $task->acclevel && $task->type == "general")
{
if ($selTask == $code)
{
?>
query("
SELECT
name,
code
FROM
hlstats_Games
");
while ($gamedata = $db->fetch_array($gamesresult))
{
$gamename = $gamedata["name"];
$gamecode = $gamedata["code"];
if ($gamecode == $selGame)
{
?>
$task)
{
if ($auth->userdata["acclevel"] >= $task->acclevel && $task->type == "game")
{
if ($selTask == $code)
{
?>
\n"; if (!$selTask || !$admintasks[$selTask]) { echo " | ";
echo $g_options["font_normal"];
?>
|