/**
  * Initializes the front-end login user.
  *
  * @return void
  */
 public function initFEuser()
 {
     $this->fe_user = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
     $this->fe_user->lockIP = $this->TYPO3_CONF_VARS['FE']['lockIP'];
     $this->fe_user->checkPid = $this->TYPO3_CONF_VARS['FE']['checkFeUserPid'];
     $this->fe_user->lifetime = (int) $this->TYPO3_CONF_VARS['FE']['lifetime'];
     // List of pid's acceptable
     $pid = GeneralUtility::_GP('pid');
     $this->fe_user->checkPid_value = $pid ? $GLOBALS['TYPO3_DB']->cleanIntList($pid) : 0;
     // Check if a session is transferred:
     if (GeneralUtility::_GP('FE_SESSION_KEY')) {
         $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
         // If the session key hash check is OK:
         if (md5($fe_sParts[0] . '/' . $this->TYPO3_CONF_VARS['SYS']['encryptionKey']) === (string) $fe_sParts[1]) {
             $cookieName = \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication::getCookieName();
             $_COOKIE[$cookieName] = $fe_sParts[0];
             if (isset($_SERVER['HTTP_COOKIE'])) {
                 // See http://forge.typo3.org/issues/27740
                 $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
             }
             $this->fe_user->forceSetCookie = 1;
             unset($cookieName);
         }
     }
     $this->fe_user->start();
     $this->fe_user->unpack_uc('');
     // Gets session data
     $this->fe_user->fetchSessionData();
     $recs = GeneralUtility::_GP('recs');
     // If any record registration is submitted, register the record.
     if (is_array($recs)) {
         $this->fe_user->record_registration($recs, $this->TYPO3_CONF_VARS['FE']['maxSessionDataSize']);
     }
     // Call hook for possible manipulation of frontend user object
     if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
         $_params = array('pObj' => &$this);
         foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
             GeneralUtility::callUserFunction($_funcRef, $_params, $this);
         }
     }
     // For every 60 seconds the is_online timestamp is updated.
     if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online'] < $GLOBALS['EXEC_TIME'] - 60) {
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid=' . (int) $this->fe_user->user['uid'], array('is_online' => $GLOBALS['EXEC_TIME']));
     }
 }
예제 #2
0
 /**
  * Initializes the front-end login user.
  *
  * @return void
  */
 public function initFEuser()
 {
     $this->fe_user = GeneralUtility::makeInstance(FrontendUserAuthentication::class);
     // List of pid's acceptable
     $pid = GeneralUtility::_GP('pid');
     $this->fe_user->checkPid_value = $pid ? implode(',', GeneralUtility::intExplode(',', $pid)) : 0;
     // Check if a session is transferred:
     if (GeneralUtility::_GP('FE_SESSION_KEY')) {
         $fe_sParts = explode('-', GeneralUtility::_GP('FE_SESSION_KEY'));
         // If the session key hash check is OK:
         if (md5($fe_sParts[0] . '/' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) === (string) $fe_sParts[1]) {
             $cookieName = FrontendUserAuthentication::getCookieName();
             $_COOKIE[$cookieName] = $fe_sParts[0];
             if (isset($_SERVER['HTTP_COOKIE'])) {
                 // See http://forge.typo3.org/issues/27740
                 $_SERVER['HTTP_COOKIE'] .= ';' . $cookieName . '=' . $fe_sParts[0];
             }
             $this->fe_user->forceSetCookie = 1;
             $this->fe_user->dontSetCookie = false;
             unset($cookieName);
         }
     }
     $this->fe_user->start();
     $this->fe_user->unpack_uc();
     // Gets session data
     $this->fe_user->fetchSessionData();
     $recs = GeneralUtility::_GP('recs');
     // If any record registration is submitted, register the record.
     if (is_array($recs)) {
         $this->fe_user->record_registration($recs, $GLOBALS['TYPO3_CONF_VARS']['FE']['maxSessionDataSize']);
     }
     // Call hook for possible manipulation of frontend user object
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'])) {
         $_params = ['pObj' => &$this];
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'] as $_funcRef) {
             GeneralUtility::callUserFunction($_funcRef, $_params, $this);
         }
     }
     // For every 60 seconds the is_online timestamp is updated.
     if (is_array($this->fe_user->user) && $this->fe_user->user['uid'] && $this->fe_user->user['is_online'] < $GLOBALS['EXEC_TIME'] - 60) {
         $dbConnection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('fe_users');
         $dbConnection->update('fe_users', ['is_online' => $GLOBALS['EXEC_TIME']], ['uid' => (int) $this->fe_user->user['uid']]);
     }
 }