public function __construct() { if (!template_session::is_admin() and !template_session::is_editor()) { if (get('ajax')) { exit(RUDE_AJAX_ACCESS_VIOLATION); } return false; } switch (get('task')) { case 'remove': $status = users::remove(get('id')); break; case 'edit': $status = users::edit(get('id'), get('name'), get('role_id')); break; default: $status = false; break; } if (get('ajax')) { if ($status) { exit(RUDE_AJAX_OK); } else { exit(RUDE_AJAX_ERROR); } } return true; }
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Email author@demila.org // +---------------------------------------------------------------------- _setView(__FILE__); _setTitle($langArray['edit']); if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { refresh('?m=' . $_GET['m'] . '&c=list', 'INVALID ID', 'error'); } $cms = new users(); if (isset($_POST['edit'])) { $adminEdit = true; if (isset($personalEdit)) { $adminEdit = false; } $status = $cms->edit($_GET['id'], $adminEdit); if ($status !== true) { abr('error', $status); } else { if (isset($personalEdit)) { refresh("?m=" . $_GET['m'] . "&c=edit&id=" . $_GET['id'], $langArray['edit_complete']); } else { refresh("?m=" . $_GET['m'] . "&c=list", $langArray['edit_complete']); } } } else { //独家设置 if (isset($_POST['exclusive_false'])) { $usersClass = new users(); $usersClass->editExclusiveAuthor('false', $_GET['id']); } elseif (isset($_POST['exclusive_true'])) {
public function settings($arguments) { // Update if (!Session::isLoggedIn()) { return Error::set('You are not logged in!'); } $user = new users(ConnectionFactory::get('mongo')); $this->view['valid'] = true; $this->view['user'] = $user->get(Session::getVar('username')); $this->view['secure'] = !empty($_SERVER['SSL_CLIENT_RAW_CERT']) ? true : false; if ($this->view['secure']) { $this->view['clientSSLKey'] = certs::getKey($_SERVER['SSL_CLIENT_RAW_CERT']); } if (!empty($arguments[0]) && $arguments[0] == 'save') { if (!empty($_POST['oldpassword']) && !empty($_POST['password'])) { $old = $user->hash($_POST['oldpassword'], $this->view['user']['username']); if ($old != $this->view['user']['password']) { return Error::set('Previous password is invalid.'); } } $username = !empty($_POST['username']) ? $_POST['username'] : null; $password = !empty($_POST['password']) ? $_POST['password'] : null; $email = !empty($_POST['email']) ? $_POST['email'] : null; $hideEmail = !empty($_POST['hideEmail']) ? true : false; $lockToIp = !empty($_POST['lockToIp']) ? true : false; $error = $user->edit(Session::getVar('_id'), $username, $password, $email, $hideEmail, null, $lockToIp); if (is_string($error)) { return Error::set($error); } $this->view['user'] = $user->get(Session::getVar('username')); Session::setBatchVars($this->view['user']); Error::set('User profile saved.', true); } if (!empty($arguments[0]) && $arguments[0] == 'saveAuth') { $password = !empty($_POST['passwordAuth']) ? true : false; $certificate = !empty($_POST['certificateAuth']) ? true : false; $certAndPass = !empty($_POST['certAndPassAuth']) ? true : false; $autoauth = !empty($_POST['autoAuth']) ? true : false; $return = $user->changeAuth(Session::getVar('_id'), $password, $certificate, $certAndPass, $autoauth); if (is_string($return)) { return Error::set($return); } $this->view['user'] = $user->get(Session::getVar('username')); } Layout::set('title', 'Settings'); }