Exemple #1
0
function lxEditAdministrator()
{
    global $DB, $C;
    VerifyAdministrator();
    $administrator = $DB->Row('SELECT * FROM lx_administrators WHERE username=?', array($_REQUEST['username']));
    $validator = new Validator();
    $validator->Register($_REQUEST['email'], V_EMAIL, 'The e-mail address is not properly formatted');
    if ($_REQUEST['password']) {
        $validator->Register($_REQUEST['password'], V_LENGTH, 'The password must contain at least 4 characters', array('min' => 4, 'max' => 999));
    }
    if (!$validator->Validate()) {
        $GLOBALS['errstr'] = join('<br />', $validator->GetErrors());
        lxShEditAdministrator();
        return;
    }
    if ($_REQUEST['password']) {
        // Password has changed, so invalidate any current session that may be active
        if ($_REQUEST['username'] != $_SERVER['REMOTE_USER']) {
            $DB->Update('UPDATE lx_administrators SET session=NULL,session_start=NULL WHERE username=?', array($_REQUEST['username']));
        }
        $_REQUEST['password'] = sha1($_REQUEST['password']);
    } else {
        $_REQUEST['password'] = $administrator['password'];
    }
    // Determine the privileges and notifications for this account
    $privileges = GenerateFlags($_REQUEST, '^p_');
    $notifications = GenerateFlags($_REQUEST, '^e_');
    // Update account information
    $DB->Update('UPDATE lx_administrators SET ' . 'password=?, ' . 'name=?, ' . 'email=?, ' . 'type=?, ' . 'categories=?, ' . 'notifications=?, ' . 'rights=? ' . 'WHERE username=?', array($_REQUEST['password'], $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['type'], $_REQUEST['categories'], $notifications, $privileges, $_REQUEST['username']));
    $GLOBALS['message'] = 'Administrator account successfully updated';
    $GLOBALS['added'] = true;
    lxShEditAdministrator();
}
Exemple #2
0
function txAdministratorEdit()
{
    global $DB, $C;
    VerifyAdministrator();
    $administrator = $DB->Row('SELECT * FROM `tx_administrators` WHERE `username`=?', array($_REQUEST['username']));
    $v = new Validator();
    $v->Register($_REQUEST['email'], V_EMAIL, 'The e-mail address is not properly formatted');
    if ($_REQUEST['password']) {
        $v->Register($_REQUEST['password'], V_LENGTH, 'The password must contain at least 4 characters', array('min' => 4, 'max' => 999));
    }
    if (isset($_REQUEST['e_cheat_report']) && !is_numeric($_REQUEST['reports_waiting'])) {
        $v->SetError('The number of reports waiting must be filled in and numeric');
    }
    if (isset($_REQUEST['e_partner_request']) && !is_numeric($_REQUEST['requests_waiting'])) {
        $v->SetError('The number of requests waiting must be filled in and numeric');
    }
    if (!$v->Validate()) {
        return $v->ValidationError('txShAdministratorEdit');
    }
    if ($_REQUEST['password']) {
        // Password has changed, so invalidate any current session that may be active
        if ($_REQUEST['username'] != $_SERVER['REMOTE_USER']) {
            $DB->Update('UPDATE `tx_administrators` SET `session`=NULL,`session_start`=NULL WHERE `username`=?', array($_REQUEST['username']));
        }
        $_REQUEST['password'] = sha1($_REQUEST['password']);
    } else {
        $_REQUEST['password'] = $administrator['password'];
    }
    // Determine the privileges and notifications for this account
    $privileges = GenerateFlags($_REQUEST, '^p_');
    $notifications = GenerateFlags($_REQUEST, '^e_');
    // Update account information
    $DB->Update('UPDATE `tx_administrators` SET ' . '`password`=?, ' . '`name`=?, ' . '`email`=?, ' . '`type`=?, ' . '`notifications`=?, ' . '`rights`=?, ' . '`reports_waiting`=?, ' . '`requests_waiting`=? ' . 'WHERE `username`=?', array($_REQUEST['password'], $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['type'], $notifications, $privileges, $_REQUEST['reports_waiting'], $_REQUEST['requests_waiting'], $_REQUEST['username']));
    $GLOBALS['message'] = 'Administrator account successfully updated';
    $GLOBALS['added'] = true;
    txShAdministratorEdit();
}