示例#1
0
文件: Welcome.php 项目: sinfocol/gwf3
 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
文件: Form.php 项目: sinfocol/gwf3
 private function onLoggedIn(GWF_User $user, $isAjax)
 {
     $last_url = GWF_Session::getLastURL();
     if (false === GWF_Session::onLogin($user, isset($_POST['bind_ip']))) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/Login/GWF_LoginHistory.php';
     GWF_LoginHistory::insertEvent($user->getID());
     # save last login time
     $user->saveVar('user_lastlogin', time());
     if ($this->module->cfgCleanupAlways()) {
         GWF_LoginFailure::cleanupUser($user->getID());
     }
     if ($isAjax) {
         return sprintf('1:%s', GWF_Session::getSessID());
     } else {
         GWF_Session::set('GWF_LOGIN_BACK', $last_url);
         if (false !== ($lang = $user->getLanguage())) {
             GWF_Language::setCurrentLanguage($lang);
         }
         if (0 < ($fails = GWF_LoginFailure::getFailCount($user, $this->module->cfgTryExceed()))) {
             GWF_Session::set('GWF_LOGIN_FAILS', $fails);
         }
         GWF_Website::redirect(GWF_WEB_ROOT . 'welcome');
     }
 }