Пример #1
0
 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);
 }
Пример #2
0
 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');
     }
 }
Пример #3
0
 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');
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
 public function onStartup()
 {
     self::$instance = $this;
     // Register login hook
     GWF_Hook::add(GWF_HOOK::LOGIN_PRE, array(__CLASS__, 'hookLoginPre'));
     GWF_Hook::add(GWF_HOOK::LOGIN_AFTER, array(__CLASS__, 'hookLoginAfter'));
     GWF_Hook::add(GWF_HOOK::VOTED_SCORE, array(__CLASS__, 'hookVoteScore'));
     GWF_Hook::add(GWF_HOOK::ACTIVATE, array(__CLASS__, 'hookRegister'));
     GWF_Hook::add(GWF_HOOK::CHANGE_PASSWD, array(__CLASS__, 'hookChangePass'));
     GWF_Hook::add(GWF_HOOK::DELETE_USER, array(__CLASS__, 'hookDeleteUser'));
     GWF_Hook::add(GWF_HOOK::CHANGE_UNAME, array(__CLASS__, 'hookDeleteUser'));
     $this->onLoadLanguage();
     if (Common::getGet('mo') !== 'WeChall') {
         $this->onInclude();
     }
     GWF_Website::addJavascriptOnload('wcjsInit();');
     GWF_Website::setPageTitlePre('[WeChall] ');
     GWF_Website::setMetaTags(WC_HTML::lang('mt_wechall'));
     GWF_Website::setMetaDescr(WC_HTML::lang('md_wechall'));
     GWF_Website::addJavascript('/js/module/WeChall/wc.js?v=5.1');
 }
Пример #7
0
 public static function installHTHooks(array $modules)
 {
     foreach ($modules as $module) {
         $module instanceof GWF_Module;
         if ($module->isEnabled()) {
             $module->onAddHooks();
         }
     }
     return GWF_Hook::writeHooks();
 }
Пример #8
0
 public function onAddHooks()
 {
     # Add Hooks
     GWF_Hook::add(GWF_Hook::ACTIVATE, array(__CLASS__, 'hookActivate'));
     GWF_Hook::add(GWF_Hook::DELETE_USER, array(__CLASS__, 'hookDeleteUser'));
 }
Пример #9
0
 public static function executeGWFHook($hook, $args)
 {
     if ($gwf_user = self::getGWFUser()) {
         return GWF_Hook::call($hook, $gwf_user, $args);
     }
 }
Пример #10
0
 private static function initHooks()
 {
     if (self::$HOOKS === true) {
         if (false !== ($hooks = GWF_Settings::getSetting('gwf3_hooks', false))) {
             self::$HOOKS = unserialize($hooks);
         } else {
             self::$HOOKS = array();
         }
     }
 }
Пример #11
0
 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)));
 }
Пример #12
0
 public function onAddHooks()
 {
     GWF_Hook::add(GWF_Hook::CHANGE_UNAME, array(__CLASS__, 'hookRenameUser'));
     GWF_Hook::add(GWF_Hook::DELETE_USER, array(__CLASS__, 'hookDeleteUser'));
     GWF_Hook::add(GWF_Hook::ADD_TO_GROUP, array(__CLASS__, 'hookAddToGroup'));
 }
Пример #13
0
 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;
 }
Пример #14
0
 public function onAddHooks()
 {
     GWF_Hook::add(GWF_Hook::DOWNLOAD, array(__CLASS__, 'hookDownload'));
 }
Пример #15
0
 public function onAddHooks()
 {
     GWF_Hook::add(GWF_Hook::VOTED_SCORE, array(__CLASS__, 'hookVoted'));
     GWF_Hook::add(GWF_Hook::DELETE_USER, array(__CLASS__, 'hookDeleteUser'));
 }
Пример #16
0
 public function onAddHooks()
 {
     GWF_Hook::add(GWF_Hook::DELETE_USER, array(__CLASS__, 'hookDeleteUser'));
 }
Пример #17
0
 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))));
 }
Пример #18
0
 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');
 }
Пример #19
0
 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()));
 }
Пример #20
0
 public function onAddHooks()
 {
     GWF_Hook::add(GWF_Hook::INSTALL_MODULE, array(__CLASS__, 'onHookInstallModule'));
     GWF_Hook::add(GWF_Hook::CHANGE_MAIL, array(__CLASS__, 'onHookChangeMail'));
 }