当前位置: 首页>>代码示例>>PHP>>正文


PHP UserAuth::getInstance方法代码示例

本文整理汇总了PHP中UserAuth::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAuth::getInstance方法的具体用法?PHP UserAuth::getInstance怎么用?PHP UserAuth::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserAuth的用法示例。


在下文中一共展示了UserAuth::getInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 /**
  * @see SessionFactory::create()
  */
 public function create()
 {
     // get spider information
     $spider = $this->isSpider(UserUtil::getUserAgent());
     if ($spider) {
         if (($session = $this->getExistingSpiderSession($spider['spiderID'])) !== null) {
             if (!$session->isCorrupt()) {
                 return $session;
             }
         }
     }
     // create new session hash
     $sessionID = StringUtil::getRandomID();
     // check cookies for userID & password
     require_once WCF_DIR . 'lib/system/auth/UserAuth.class.php';
     $user = UserAuth::getInstance()->loginAutomatically(true, $this->userClassName);
     if ($user === null) {
         // no valid user found
         // create guest user
         $user = new $this->guestClassName();
     }
     // update user session
     $user->update();
     if ($user->userID != 0) {
         // user is no guest
         // delete all other sessions of this user
         Session::deleteSessions($user->userID, true, false);
     }
     $requestMethod = !empty($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
     // insert session into database
     $sql = "INSERT INTO \twcf" . WCF_N . "_session\n\t\t\t\t\t(sessionID, packageID, userID, ipAddress, userAgent,\n\t\t\t\t\tlastActivityTime, requestURI, requestMethod,\n\t\t\t\t\tusername" . ($spider ? ", spiderID" : "") . ")\n\t\t\tVALUES\t\t('" . $sessionID . "',\n\t\t\t\t\t" . PACKAGE_ID . ",\n\t\t\t\t\t" . $user->userID . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getIpAddress()) . "',\n\t\t\t\t\t'" . escapeString(UserUtil::getUserAgent()) . "',\n\t\t\t\t\t" . TIME_NOW . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getRequestURI()) . "',\n\t\t\t\t\t'" . escapeString($requestMethod) . "',\n\t\t\t\t\t'" . ($spider ? escapeString($spider['spiderName']) : escapeString($user->username)) . "'\n\t\t\t\t\t" . ($spider ? ", " . $spider['spiderID'] : "") . ")";
     WCF::getDB()->sendQuery($sql);
     // save user data
     $serializedUserData = '';
     if (ENABLE_SESSION_DATA_CACHE && get_class(WCF::getCache()->getCacheSource()) == 'MemcacheCacheSource') {
         require_once WCF_DIR . 'lib/system/cache/source/MemcacheAdapter.class.php';
         MemcacheAdapter::getInstance()->getMemcache()->set('session_userdata_-' . $sessionID, $user);
     } else {
         $serializedUserData = serialize($user);
         try {
             $sql = "INSERT INTO \twcf" . WCF_N . "_session_data\n\t\t\t\t\t\t\t(sessionID, userData)\n\t\t\t\t\tVALUES \t\t('" . $sessionID . "',\n\t\t\t\t\t\t\t'" . escapeString($serializedUserData) . "')";
             WCF::getDB()->sendQuery($sql);
         } catch (DatabaseException $e) {
             // horizon update workaround
             $sql = "UPDATE \twcf" . WCF_N . "_session\n\t\t\t\t\tSET\tuserData = '" . escapeString($serializedUserData) . "'\n\t\t\t\t\tWHERE\tsessionID = '" . $sessionID . "'";
             WCF::getDB()->sendQuery($sql);
         }
     }
     // return new session object
     return new $this->sessionClassName(null, array('sessionID' => $sessionID, 'packageID' => PACKAGE_ID, 'userID' => $user->userID, 'ipAddress' => UserUtil::getIpAddress(), 'userAgent' => UserUtil::getUserAgent(), 'lastActivityTime' => TIME_NOW, 'requestURI' => UserUtil::getRequestURI(), 'requestMethod' => $requestMethod, 'userData' => $serializedUserData, 'sessionVariables' => '', 'username' => $spider ? $spider['spiderName'] : $user->username, 'spiderID' => $spider ? $spider['spiderID'] : 0, 'isNew' => true));
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:54,代码来源:CookieSessionFactory.class.php

示例2: define

define('INSIDE', true);
define('LOGIN', true);
$ugamela_root_path = './';
include $ugamela_root_path . 'extension.inc';
include $ugamela_root_path . 'common.' . $phpEx;
require_once WCF_DIR . 'lib/acp/form/LoginForm.class.php';
includeLang('login');
if ($_POST || isset($_GET['username']) && isset($_GET['password'])) {
    $login = WCF::getDB()->getFirstRow("SELECT * FROM ugml_users WHERE username = '" . escapeString($_REQUEST['username']) . "'");
    if ($login) {
        /**
         * WCF Hack
         */
        try {
            $wcfUser = UserAuth::getInstance()->loginManually($_REQUEST['username'], $_REQUEST['password']);
            UserAuth::getInstance()->storeAccessData($wcfUser, $_REQUEST['username'], $_REQUEST['password']);
            WCF::getSession()->changeUser($wcfUser);
        } catch (Exception $e) {
            message($lang['Login_FailPassword'], $lang['Login_Error']);
            exit;
        }
        $sql = "UPDATE ugml_users\r\n\t\t\t\tSET lastLoginTime = " . TIME_NOW . ",\r\n\t\t\t\t\tcurrent_planet = id_planet,\r\n\t\t\t\t\tplanetClassName = 'UserPlanet'\r\n\t\t\t\tWHERE id = " . $login['id'];
        WCF::getDB()->sendQuery($sql);
        // ugamela
        $expiretime = 0;
        $rememberme = 0;
        @(include 'config.php');
        $cookie = $wcfUser->userID . ' ' . md5($_REQUEST['password'] . '--' . $dbsettings['secretword']) . " " . $rememberme;
        setcookie('LWGAME_REF_N', 1, time() + 24 * 60 * 60 * 365 * 10);
        setcookie($game_config['COOKIE_NAME'], $cookie, $expiretime);
        // dili link
开发者ID:sonicmaster,项目名称:RPG,代码行数:31,代码来源:login.php

示例3: save

 /**
  * @see Form::save()
  */
 public function save()
 {
     AbstractForm::save();
     // save language id
     $this->additionalFields['languageID'] = $this->languageID;
     // save registration ip address
     $this->additionalFields['registrationIpAddress'] = WCF::getSession()->ipAddress;
     // generate activation code
     $addDefaultGroups = true;
     if (REGISTER_ACTIVATION_METHOD == 1 || REGISTER_ACTIVATION_METHOD == 2) {
         $activationCode = UserRegistrationUtil::getActivationCode();
         $this->additionalFields['activationCode'] = $activationCode;
         $addDefaultGroups = false;
         $this->groupIDs = Group::getGroupIdsByType(array(Group::EVERYONE, Group::GUESTS));
     }
     // create
     $this->user = UserEditor::create($this->username, $this->email, $this->password, $this->groupIDs, $this->activeOptions, $this->additionalFields, $this->visibleLanguages, $addDefaultGroups);
     // update session
     WCF::getSession()->changeUser($this->user);
     // activation management
     if (REGISTER_ACTIVATION_METHOD == 0) {
         $this->message = 'wcf.user.register.success';
     }
     if (REGISTER_ACTIVATION_METHOD == 1) {
         $mail = new Mail(array($this->username => $this->email), WCF::getLanguage()->get('wcf.user.register.needActivation.mail.subject', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE))), WCF::getLanguage()->get('wcf.user.register.needActivation.mail', array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => $this->username, '$userID' => $this->user->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS)));
         $mail->send();
         $this->message = 'wcf.user.register.needActivation';
     }
     if (REGISTER_ACTIVATION_METHOD == 2) {
         $this->message = 'wcf.user.register.awaitActivation';
     }
     // notify admin
     if (REGISTER_ADMIN_NOTIFICATION) {
         // get default language
         $language = WCF::getLanguage()->getLanguageID() != Language::getDefaultLanguageID() ? new Language(Language::getDefaultLanguageID()) : WCF::getLanguage();
         $language->setLocale();
         // send mail
         $mail = new Mail(MAIL_ADMIN_ADDRESS, $language->get('wcf.user.register.notification.mail.subject', array('PAGE_TITLE' => $language->get(PAGE_TITLE))), $language->get('wcf.user.register.notification.mail', array('PAGE_TITLE' => $language->get(PAGE_TITLE), '$username' => $this->username)));
         $mail->send();
         WCF::getLanguage()->setLocale();
     }
     // delete captcha
     if (REGISTER_USE_CAPTCHA && !WCF::getSession()->getVar('captchaDone')) {
         $this->captcha->delete();
     }
     WCF::getSession()->unregister('captchaDone');
     // login user
     UserAuth::getInstance()->storeAccessData($this->user, $this->username, $this->password);
     $this->saved();
     // forward to index page
     WCF::getTPL()->assign(array('url' => 'index.php' . SID_ARG_1ST, 'message' => WCF::getLanguage()->get($this->message, array('$username' => $this->username, '$email' => $this->email))));
     WCF::getTPL()->display('redirect');
     exit;
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:57,代码来源:RegisterForm.class.php

示例4: assignVariables

 /**
  * @see Page::assignVariables()
  */
 public function assignVariables()
 {
     parent::assignVariables();
     WCF::getTPL()->assign(array('useCookies' => $this->useCookies, 'captchaID' => $this->captchaID, 'supportsPersistentLogins' => UserAuth::getInstance()->supportsPersistentLogins()));
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:8,代码来源:UserLoginForm.class.php

示例5: create

 /**
  * Creates a new session.
  * 
  * Generates a new session hash, inserts the new session into database
  * and returns the object of the created session. 
  * 
  * @return 	 Session 	$session
  */
 public function create()
 {
     // create new session hash
     $sessionID = StringUtil::getRandomID();
     // get user automatically
     if (!defined('NO_IMPORTS')) {
         require_once WCF_DIR . 'lib/system/auth/UserAuth.class.php';
     }
     $user = UserAuth::getInstance()->loginAutomatically();
     // create user
     if ($user === null) {
         // no valid user found
         // create guest user
         $user = new $this->userClassName();
     }
     // update user session
     $user->update();
     // insert session into database
     $requestMethod = !empty($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
     $sql = "INSERT INTO \twcf" . WCF_N . "_acp_session\n\t\t\t\t\t(sessionID, packageID, userID, ipAddress, userAgent, lastActivityTime, requestURI, requestMethod)\n\t\t\tVALUES \t\t('" . $sessionID . "',\n\t\t\t\t\t" . PACKAGE_ID . ",\n\t\t\t\t\t" . $user->userID . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getIpAddress()) . "',\n\t\t\t\t\t'" . escapeString(UserUtil::getUserAgent()) . "',\n\t\t\t\t\t" . TIME_NOW . ",\n\t\t\t\t\t'" . escapeString(UserUtil::getRequestURI()) . "',\n\t\t\t\t\t'" . escapeString($requestMethod) . "')";
     WCF::getDB()->sendQuery($sql);
     // save user data
     $serializedUserData = '';
     if (ENABLE_SESSION_DATA_CACHE && get_class(WCF::getCache()->getCacheSource()) == 'MemcacheCacheSource') {
         require_once WCF_DIR . 'lib/system/cache/source/MemcacheAdapter.class.php';
         MemcacheAdapter::getInstance()->getMemcache()->set('acp_session_userdata_' . $sessionID, $user);
     } else {
         $serializedUserData = serialize($user);
         try {
             $sql = "INSERT INTO \twcf" . WCF_N . "_acp_session_data\n\t\t\t\t\t\t\t(sessionID, userData)\n\t\t\t\t\tVALUES \t\t('" . $sessionID . "',\n\t\t\t\t\t\t\t'" . escapeString($serializedUserData) . "')";
             WCF::getDB()->sendQuery($sql);
         } catch (DatabaseException $e) {
             // horizon update workaround
             $sql = "UPDATE \twcf" . WCF_N . "_acp_session\n\t\t\t\t\tSET\tuserData = '" . escapeString($serializedUserData) . "'\n\t\t\t\t\tWHERE\tsessionID = '" . $sessionID . "'";
             WCF::getDB()->sendQuery($sql);
         }
     }
     // return new session object
     return new $this->sessionClassName(null, array('sessionID' => $sessionID, 'packageID' => PACKAGE_ID, 'ipAddress' => UserUtil::getIpAddress(), 'userAgent' => UserUtil::getUserAgent(), 'lastActivityTime' => TIME_NOW, 'requestURI' => UserUtil::getRequestURI(), 'requestMethod' => $requestMethod, 'userData' => $serializedUserData, 'sessionVariables' => '', 'userID' => $user->userID, 'isNew' => true));
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:48,代码来源:SessionFactory.class.php

示例6: validateUser

 /**
  * Validates the user access data.
  */
 protected function validateUser()
 {
     $this->user = UserAuth::getInstance()->loginManually($this->username, $this->password);
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:7,代码来源:LoginForm.class.php


注:本文中的UserAuth::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。