private function welcome($first_time) { if (false === ($user = GWF_Session::getUser())) { return GWF_HTML::err('ERR_LOGIN_REQUIRED'); } require_once GWF_CORE_PATH . 'module/Login/GWF_LoginHistory.php'; GWF_Hook::call(GWF_Hook::LOGIN_AFTER, $user, array(GWF_Session::getOrDefault('GWF_LOGIN_BACK', GWF_WEB_ROOT))); $fails = GWF_Session::getOrDefault('GWF_LOGIN_FAILS', 0); GWF_Session::remove('GWF_LOGIN_FAILS'); if ($fails > 0) { $fails = $this->module->lang('err_failures', array($fails)); } else { $fails = ''; } $href_hist = $this->module->getMethodURL('History'); $username = $user->display('user_name'); if (false !== ($ll = GWF_LoginHistory::getLastLogin($user->getID()))) { $last_login = $this->module->lang('msg_last_login', array($ll->displayDate(), $ll->displayIP(), $ll->displayHostname(), $href_hist)); $welcome = $this->module->lang('welcome_back', array($username, $ll->displayDate(), $ll->displayIP())); } else { $last_login = ''; $welcome = $this->module->lang('welcome', array($username)); } $tVars = array('welcome' => $welcome, 'fails' => $fails, 'last_login' => $last_login, 'href_history' => $href_hist); return $this->module->template('welcome.tpl', $tVars); }
private static function onActivated(Module_Register $module, GWF_User $user) { if (false === GWF_Hook::call(GWF_Hook::ACTIVATE, $user, array(true))) { return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } if ($module->wantAutoLogin()) { if (false === GWF_Session::onLogin($user)) { return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } GWF_Website::redirect(GWF_WEB_ROOT . 'welcome'); } else { return $module->message('msg_activated'); } }
private function onChangePass(GWF_AccountChange $ac) { $form = $this->getForm(); if (false !== ($errors = $form->validate($this->module))) { return $errors . $this->templateChange($ac); } $user = $ac->getUser(); $password = $form->getVar('password'); GWF_Hook::call(GWF_Hook::CHANGE_PASSWD, $user, array($password, '')); $ac->delete(); if (false === $user->saveVar('user_password', GWF_Password::hashPasswordS($password))) { return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } return $this->module->message('msg_pass_changed'); }
public function templateOnDownload(GWF_Download $dl, $token = false) { # submit this file pls $path = $dl->getDownloadPath(); if (!is_file($path) || !is_readable($path)) { return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($path)); } $user = GWF_User::getStaticOrGuest(); if ($dl->isPaidContent()) { if (false === GWF_DownloadToken::checkUser($this->module, $dl, $user) && false === GWF_DownloadToken::checkToken($this->module, $dl, $user, $token)) { return GWF_HTML::err('ERR_NO_PERMISSION'); } } GWF_Hook::call(GWF_Hook::DOWNLOAD, $user, array($dl)); # Downloaded one more time $dl->increase('dl_count', 1); $this->sendTheFile($dl); }
public function onLogin($doValidate = true) { require_once GWF_CORE_PATH . 'module/Login/GWF_LoginFailure.php'; $isAjax = isset($_GET['ajax']); $form = $this->getForm(); if ($doValidate) { if (false !== ($errors = $form->validate($this->module, $isAjax))) { if ($isAjax) { return $errors; } else { return $errors . $this->form(); } } } $username = Common::getPostString('username'); $password = Common::getPostString('password'); $users = GDO::table('GWF_User'); if (false === ($user = $users->selectFirstObject('*', sprintf('user_name=\'%s\' AND user_options&%d=0', $users->escape($username), GWF_User::DELETED)))) { if ($isAjax) { return $this->module->error('err_login'); } else { return $this->module->error('err_login') . $this->form(); } } elseif (true !== ($error = $this->checkBruteforce($user, $isAjax))) { if ($isAjax) { return $error; } else { return $error . $this->form(); } } elseif (false === GWF_Hook::call(GWF_HOOK::LOGIN_PRE, $user, array($password, ''))) { return ''; #GWF_HTML::err('ERR_GENERAL', array( __FILE__, __LINE__)); } elseif (false === GWF_Password::checkPasswordS($password, $user->getVar('user_password'))) { if ($isAjax) { return $this->onLoginFailed($user, $isAjax); } else { return $this->onLoginFailed($user, $isAjax) . $this->form(); } } GWF_Password::clearMemory('password'); return $this->onLoggedIn($user, $isAjax); }
private function onEditPassword($newpass) { $user = $this->user; if ($newpass === '') { return array(); } unset($_POST['password']); if (false === $user->saveVar('user_password', GWF_Password::hashPasswordS($newpass))) { GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__), true, true); return array(); } GWF_Hook::call(GWF_Hook::CHANGE_PASSWD, $user, array($newpass, '')); return array($this->module->lang('msg_userpass_changed', array($user->displayUsername(), GWF_HTML::display($newpass)))); }
private function onVoted($user) { GWF_Hook::call(GWF_Hook::VOTED_SCORE, $user, array($this->votescore->getID(), $this->score)); return isset($_GET['ajax']) ? $this->module->message('msg_voted_ajax') : $this->module->message('msg_voted', array(GWF_Session::getLastURL())); }
private function onDelete() { $t = $this->thread; $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateEditThread(); } if (false === $t->deleteThread()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateEditThread(); } GWF_Hook::call('deleteforumthread', GWF_User::getStaticOrGuest(), array($t->getID())); $this->module->cachePostcount(); return $this->module->message('msg_thread_deleted'); }
private function onChangeB($token) { $userid = (int) Common::getGet('userid'); if (false === ($ac = GWF_AccountChange::checkToken($userid, $token, 'email2'))) { return $this->module->error('err_token'); } if (false === ($user = $ac->getUser())) { return GWF_HTML::err('ERR_UNKNOWN_USER'); } if (false === $ac->delete()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $oldmail = $user->getValidMail(); $newmail = $ac->getVar('data'); if (false === GWF_Hook::call(GWF_Hook::CHANGE_MAIL, $user, array($oldmail, $newmail))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $user->saveVar('user_email', $newmail)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $user->saveOption(GWF_User::MAIL_APPROVED, true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_mail_changed', array(htmlspecialchars($newmail))); }
public static function onLogout() { if (self::$USER === false) { return true; } GWF_Hook::call(GWF_HOOK::LOGOUT, self::$USER); if (self::$USER->isWebspider()) { self::$USER = false; return self::createSession(); } # Mark the session to be recreated as human // if (self::$USER->isWebspider()) // { // self::create(); // self::setCookies($id, $uid, $sessid)$webspider_killer = true; // } self::$USER = false; if (false === self::$SESSION->saveVars(array('sess_user' => 0, 'sess_ip' => null))) { return false; } self::$SESSION->setVar('sess_user', GWF_Guest::getGuest()); return true; }
public static function executeGWFHook($hook, $args) { if ($gwf_user = self::getGWFUser()) { return GWF_Hook::call($hook, $gwf_user, $args); } }