public function register($arguments) { // Create if (Session::isLoggedIn()) { return Error::set('You can\'t register if you\'re logged in!'); } $this->view['valid'] = true; $this->view['publicKey'] = Config::get('recaptcha:publicKey'); if (!empty($arguments) && $arguments[0] == 'save') { if (empty($_POST['recaptcha_challenge_field']) || empty($_POST['recaptcha_response_field'])) { return Error::set('We could not find the captcha validation fields!'); } $recaptcha = Recaptcha::check($_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']); if (is_string($recaptcha)) { return Error::set(Recaptcha::$errors[$recaptcha]); } if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) { return Error::set('All forms are required.'); } $users = new users(ConnectionFactory::get('mongo')); $hideEmail = empty($_POST['hideEmail']) ? false : true; $created = $users->create($_POST['username'], $_POST['password'], $_POST['email'], $hideEmail, null, true); if (is_string($created)) { return Error::set($created); } $users->authenticate($_POST['username'], $_POST['password']); header('Location: ' . Url::format('/')); } }
/** * Import an account. * * @param string $username The username to use. * @param string $password The password to use. */ public function import($username, $password) { $data = $this->get($username); $this->db->remove(array('username' => $this->clean($username))); $users = new users(ConnectionFactory::get('mongo')); $id = $users->create($username, $password, $data['email'], $data['hideEmail'], $this->groups[$data['mgroup']], true); $newRef = MongoDBRef::create('users', $id); $oldRef = MongoDBRef::create('unimportedUsers', $data['_id']); $this->mongo->news->update(array('user' => $oldRef), array('$set' => array('user' => $newRef))); $this->mongo->articles->update(array('user' => $oldRef), array('$set' => array('user' => $newRef))); self::ApcPurge('get', $data['_id']); }
} $data['roles'] = users::getRoles($dbh); if (is_array($_SESSION['token'])) { $data = array_merge($data, $_SESSION['token']); } $app->render('adminUserShow.html', $data); }); $app->get('/admin/users/setStat/:userID/:status', $authenticateAdmin, function ($userID, $status) use($app) { $dbh = getConnection(); users::setStatus($dbh, $userID, $status); die; }); $app->post('/admin/users/New/', $authenticateAdmin, function () use($app) { $dbh = getConnection(); $userData = $app->request->post(); users::create($dbh, $userData); die; }); $app->post('/admin/users/:userID/', $authenticateAdmin, function ($userID) use($app) { $dbh = getConnection(); $userData = $app->request->post(); users::update($dbh, $userID, $userData); die; }); $app->get('/admin/users/setRole/:userID/:roleID/', $authenticateAdmin, function ($userID, $roleID) use($app) { $dbh = getConnection(); users::setRole($dbh, $userID, $roleID); die; }); $app->get('/admin/users/del/:userID/', $authenticateAdmin, function ($userID) use($app) { $dbh = getConnection();