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


PHP eZSession类代码示例

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


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

示例1: handleFileDownload

 function handleFileDownload($contentObject, $contentObjectAttribute, $type, $fileInfo)
 {
     $fileName = $fileInfo['filepath'];
     $file = eZClusterFileHandler::instance($fileName);
     if ($fileName != "" and $file->exists()) {
         $fileSize = $file->size();
         if (isset($_SERVER['HTTP_RANGE']) && preg_match("/^bytes=(\\d+)-(\\d+)?\$/", trim($_SERVER['HTTP_RANGE']), $matches)) {
             $fileOffset = $matches[1];
             $contentLength = isset($matches[2]) ? $matches[2] - $matches[1] + 1 : $fileSize - $matches[1];
         } else {
             $fileOffset = 0;
             $contentLength = $fileSize;
         }
         // Figure out the time of last modification of the file right way to get the file mtime ... the
         $fileModificationTime = $file->mtime();
         // stop output buffering, and stop the session so that browsing can be continued while downloading
         eZSession::stop();
         ob_end_clean();
         eZFile::downloadHeaders($fileName, self::dispositionType($fileInfo['mime_type']) === 'attachment', false, $fileOffset, $contentLength, $fileSize);
         try {
             $file->passthrough($fileOffset, $contentLength);
         } catch (eZClusterFileHandlerNotFoundException $e) {
             eZDebug::writeError($e->getMessage, __METHOD__);
             header($_SERVER["SERVER_PROTOCOL"] . ' 500 Internal Server Error');
         } catch (eZClusterFileHandlerGeneralException $e) {
             eZDebug::writeError($e->getMessage, __METHOD__);
             header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
         }
         eZExecution::cleanExit();
     }
     return eZBinaryFileHandler::RESULT_UNAVAILABLE;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:32,代码来源:ezfilepassthroughhandler.php

示例2: rate

 /**
  * Rate content object attribute id
  *
  * @param array $args ( 0 => contentobjectattribute_id,  1 => contentobject_version, 2 => rating )
  * @return array
  */
 public static function rate($args)
 {
     $ret = array('id' => 0, 'rated' => false, 'already_rated' => false, 'stats' => false);
     if (isset($args[0])) {
         $ret['id'] = $args[0];
     }
     if (!isset($args[2]) || !is_numeric($args[0]) || !is_numeric($args[1]) || !is_numeric($args[2]) || $args[2] > 5 || $args[2] < 1) {
         return $ret;
     }
     // Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
     // to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
     if (class_exists('eZSession') && eZSession::userHasSessionCookie() !== true) {
         return $ret;
     }
     // Return if parameters are not valid attribute id + version numbers
     $contentobjectAttribute = eZContentObjectAttribute::fetch($ret['id'], $args[1]);
     if (!$contentobjectAttribute instanceof eZContentObjectAttribute) {
         return $ret;
     }
     // Return if attribute is not a rating attribute
     if ($contentobjectAttribute->attribute('data_type_string') !== ezsrRatingType::DATA_TYPE_STRING) {
         return $ret;
     }
     // Return if rating has been disabled on current attribute
     if ($contentobjectAttribute->attribute('data_int')) {
         return $ret;
     }
     // Return if user does not have access to object
     $contentobject = $contentobjectAttribute->attribute('object');
     if (!$contentobject instanceof eZContentObject || !$contentobject->attribute('can_read')) {
         return $ret;
     }
     $rateDataObj = ezsrRatingDataObject::create(array('contentobject_id' => $contentobjectAttribute->attribute('contentobject_id'), 'contentobject_attribute_id' => $ret['id'], 'rating' => $args[2]));
     $proiorRating = $rateDataObj->userHasRated(true);
     if ($proiorRating === true) {
         $ret['already_rated'] = true;
     } else {
         if ($proiorRating instanceof ezsrRatingDataObject) {
             $rateDataObj = $proiorRating;
             $rateDataObj->setAttribute('rating', $args[2]);
             $ret['already_rated'] = true;
             $proiorRating = false;
             // just to reuse code bellow
         }
     }
     if (!$proiorRating) {
         $rateDataObj->store();
         $avgRateObj = $rateDataObj->getAverageRating();
         $avgRateObj->updateFromRatingData();
         $avgRateObj->store();
         eZContentCacheManager::clearContentCacheIfNeeded($rateDataObj->attribute('contentobject_id'));
         $ret['rated'] = true;
         $ret['stats'] = array('rating_count' => $avgRateObj->attribute('rating_count'), 'rating_average' => $avgRateObj->attribute('rating_average'), 'rounded_average' => $avgRateObj->attribute('rounded_average'));
     }
     return $ret;
 }
开发者ID:BGCX067,项目名称:ezpublish-thetechtalent-svn-to-git,代码行数:62,代码来源:ezsrserverfunctions.php

示例3: gc

 public function gc($maxLifeTime)
 {
     ezpEvent::getInstance()->notify('session/gc', array($maxLifeTime));
     $db = eZDB::instance();
     eZSession::triggerCallback('gc_pre', array($db, $maxLifeTime));
     $sfHandler = $this->storage->getSaveHandler();
     if (method_exists($sfHandler, 'gc')) {
         $sfHandler->gc($maxLifeTime);
     }
     eZSession::triggerCallback('gc_post', array($db, $maxLifeTime));
     return false;
 }
开发者ID:nlescure,项目名称:ezpublish,代码行数:12,代码来源:ezpsessionhandlersymfony.php

示例4: eZCheckUser

/**
 * Check if user login is required. If so, use login handler to redirect user.
 *
 * @deprecated As of 4.4, moved to {@link eZUserLoginHandler::preCheck()}
 * @param array $siteBasics
 * @param eZURI $uri
 * @return array|true|false|null An associative array on redirect with 'module' and 'function' keys, true on successful
 *                               and false/null on #fail.
 */
function eZCheckUser(array &$siteBasics, eZURI $uri)
{
    if (!$siteBasics['user-object-required']) {
        return null;
    }
    $ini = eZINI::instance();
    $requireUserLogin = $ini->variable('SiteAccessSettings', 'RequireUserLogin') == 'true';
    $forceLogin = false;
    if (eZSession::hasStarted()) {
        $http = eZHTTPTool::instance();
        $forceLogin = $http->hasSessionVariable(eZUserLoginHandler::FORCE_LOGIN);
    }
    if (!$requireUserLogin && !$forceLogin) {
        return null;
    }
    return eZUserLoginHandler::checkUser($siteBasics, $uri);
}
开发者ID:rmiguel,项目名称:ezpublish,代码行数:26,代码来源:pre_check.php

示例5: eZCheckUser

/**
 * Check if user login is required. If so, use login handler to redirect user.
 *
 * @deprecated As of 4.4, moved to {@link eZUserLoginHandler::preCheck()}
 * @param array $siteBasics
 * @param eZURI $uri
 * @return array|true|false|null An associative array on redirect with 'module' and 'function' keys, true on successful
 *                               and false/null on #fail.
 */
function eZCheckUser(array &$siteBasics, eZURI $uri)
{
    eZDebug::writeStrict('Function eZCheckUser() has been deprecated in 4.4 in favor of eZUserLoginHandler::preCheck()', 'Deprecation');
    if (!$siteBasics['user-object-required']) {
        return null;
    }
    $ini = eZINI::instance();
    $requireUserLogin = $ini->variable('SiteAccessSettings', 'RequireUserLogin') == 'true';
    $forceLogin = false;
    if (eZSession::hasStarted()) {
        $http = eZHTTPTool::instance();
        $forceLogin = $http->hasSessionVariable(eZUserLoginHandler::FORCE_LOGIN);
    }
    if (!$requireUserLogin && !$forceLogin) {
        return null;
    }
    return eZUserLoginHandler::checkUser($siteBasics, $uri);
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:27,代码来源:pre_check.php

示例6: rate

    /**
     * Rate content object attribute id
     *
     * @param array $args ( 0 => contentobjectattribute_id,  1 => contentobject_version, 2 => rating )
     * @return array
     */
    public static function rate( $args )
    {
        $ret = array( 'id' => 0, 'rated' => false, 'already_rated' => false, 'stats' => false );
        if ( !isset( $args[2] ) )
            throw new LengthException( 'Rating expects 3 arguments: attr_id, version, rating' );
        else if ( !is_numeric( $args[0] ) )
            throw new InvalidArgumentException( 'Rating argument[0] attr_id must be a number' );
        else if ( !is_numeric( $args[1] ) )
            throw new InvalidArgumentException( 'Rating argument[1] version must be a number' );
        else if ( !is_numeric( $args[2] ) )
            throw new InvalidArgumentException( 'Rating argument[2] rating must be a number' );
        else if ( $args[2] > 5 || $args[2] < 1 )
            throw new UnexpectedValueException( 'Rating argument[2] rating must be between 1 and 5' );

        $ret['id'] = (int) $args[0];

        // Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
        // to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
        if (
            eZSession::userHasSessionCookie() !== true
            && eZINI::instance()->variable( 'eZStarRating', 'AllowAnonymousRating' ) === 'disabled'
        )
            return $ret;

        // Return if parameters are not valid attribute id + version numbers
        $contentobjectAttribute = eZContentObjectAttribute::fetch( $ret['id'], $args[1] );
        if ( !$contentobjectAttribute instanceof eZContentObjectAttribute )
            return $ret;

        // Return if attribute is not a rating attribute
        if ( $contentobjectAttribute->attribute('data_type_string') !== ezsrRatingType::DATA_TYPE_STRING )
            return $ret;

        // Return if rating has been disabled on current attribute
        if ( $contentobjectAttribute->attribute('data_int') )
            return $ret;

        // Return if user does not have access to object
        $contentobject = $contentobjectAttribute->attribute('object');
        if ( !$contentobject instanceof eZContentObject || !$contentobject->attribute('can_read') )
            return $ret;

        $rateDataObj = ezsrRatingDataObject::create( array( 'contentobject_id' => $contentobjectAttribute->attribute('contentobject_id'),
                                                    'contentobject_attribute_id' =>  $ret['id'],
                                                    'rating' => $args[2]
        ));

        $proiorRating = $rateDataObj->userHasRated( true );

        if ( $proiorRating === true )
        {
            $ret['already_rated'] = true;
        }
        else if ( $proiorRating instanceof ezsrRatingDataObject )
        {
            $rateDataObj = $proiorRating;
            $rateDataObj->setAttribute( 'rating', $args[2] );
            $ret['already_rated'] = true;
            $proiorRating = false;// just to reuse code bellow
        }

        if ( !$proiorRating )
        {
            $rateDataObj->store();
            $avgRateObj = $rateDataObj->getAverageRating();
            $avgRateObj->updateFromRatingData();
            $avgRateObj->store();
            eZContentCacheManager::clearContentCacheIfNeeded( $rateDataObj->attribute('contentobject_id') );
            $ret['rated'] = true;
            $ret['stats'] = array(
               'rating_count' => $avgRateObj->attribute('rating_count'),
               'rating_average' => $avgRateObj->attribute('rating_average'),
               'rounded_average' => $avgRateObj->attribute('rounded_average'),
            );
        }
        return $ret;
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:83,代码来源:ezsrserverfunctions.php

示例7: htmlspecialchars

         }
         break;
     default:
         // give a warning
         $actionname = '[ERROR: unknown action] "' . $action . '"';
 }
 // Before calling execute, echo out brief description of action taken + date and time ???
 // this gives good user feedback for long-running methods...
 /// @todo use a template for html layout
 if ($action != 'inspect' || $debug) {
     echo '<h2>' . htmlspecialchars($actionname) . ' on server ' . htmlspecialchars($server) . " ...</h2>\n";
     flush();
 }
 // avoid locking in case we are using a session for executing the action which
 // is the sane session as used by the debugger and plain php session storage
 eZSession::stop();
 // execute method(s)
 $response = null;
 $responses = array();
 $time = microtime(true);
 foreach ($msg as $message) {
     $response = $client->send($message);
     $responses[] = $response;
     if (!is_object($response) || $response->isFault()) {
         break;
     }
 }
 $time = microtime(true) - $time;
 if ($debug) {
     /// @todo should echo the request+response of all requests, when sending more than 1
     echo '<div class="dbginfo"><h2>Debug info:</h2>';
开发者ID:gggeek,项目名称:ggwebservices,代码行数:31,代码来源:action.php

示例8: cleanup

 /**
  * Remove all session data (Truncate table)
  *
  * @return bool
  */
 public function cleanup()
 {
     $db = eZDB::instance();
     eZSession::triggerCallback('cleanup_pre', array($db));
     $db->query('TRUNCATE TABLE ezsession');
     eZSession::triggerCallback('cleanup_post', array($db));
     return true;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:13,代码来源:ezsessionhandlerdb.php

示例9: shouldProtectUser

 /**
  * Figures out if current user should be protected or not
  * based on if (s)he has a session and is logged in.
  *
  * @return bool
  */
 protected static function shouldProtectUser()
 {
     if (!eZSession::hasStarted()) {
         return false;
     }
     if (!eZUser::currentUser()->isLoggedIn()) {
         return false;
     }
     return true;
 }
开发者ID:nlescure,项目名称:ezpublish,代码行数:16,代码来源:ezxformtoken.php

示例10:

    $userID = 0;
    if ( $user instanceof eZUser )
        $userID = $user->id();
    if ( $userID > 0 )
    {
        if ( $http->hasPostVariable( 'Cookie' ) )
        {
            $ini = eZINI::instance();
            $rememberMeTimeout = $ini->hasVariable( 'Session', 'RememberMeTimeout' )
                                 ? $ini->variable( 'Session', 'RememberMeTimeout' )
                                 : false;
            if ( $rememberMeTimeout )
            {
                eZSession::stop();
                eZSession::start( $rememberMeTimeout );
            }

        }
        $http->removeSessionVariable( 'eZUserLoggedInID' );
        $http->setSessionVariable( 'eZUserLoggedInID', $userID );

        // Remove all temporary drafts
        eZContentObject::cleanupAllInternalDrafts( $userID );
        return $Module->redirectTo( $redirectionURI );
    }
}
else
{
    // called from outside of a template (?)
    $requestedURI = $GLOBALS['eZRequestedURI'];
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:30,代码来源:login.php

示例11: checkUser

 function checkUser(&$siteBasics, $uri)
 {
     $http = eZHTTPTool::instance();
     $check = array("module" => "user", "function" => "login");
     if (eZSession::issetkey('eZUserLoggedInID', false) && $http->sessionVariable("eZUserLoggedInID") != '' && $http->sessionVariable("eZUserLoggedInID") != self::anonymousId()) {
         $currentUser = eZUser::currentUser();
         if (!$currentUser->isEnabled()) {
             eZUser::logoutCurrent();
             $currentUser = eZUser::currentUser();
         } else {
             return null;
         }
     }
     $ini = eZINI::instance();
     $moduleName = $uri->element();
     $viewName = $uri->element(1);
     $anonymousAccessList = $ini->variable("SiteAccessSettings", "AnonymousAccessList");
     foreach ($anonymousAccessList as $anonymousAccess) {
         $elements = explode('/', $anonymousAccess);
         if (!isset($elements[1])) {
             if ($moduleName == $elements[0]) {
                 return null;
             }
         } else {
             if ($moduleName == $elements[0] and $viewName == $elements[1]) {
                 return null;
             }
         }
     }
     return $check;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:ezuser.php

示例12: shouldProtectUser

 /**
  * Figures out if current user should be protected or not
  * based on if (s)he has a session and is logged in.
  *
  * @return bool
  */
 protected static function shouldProtectUser()
 {
     if (!self::$isEnabled) {
         return false;
     }
     if (!eZSession::hasStarted()) {
         return false;
     }
     if (!eZUser::isCurrentUserRegistered()) {
         return false;
     }
     return true;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:19,代码来源:ezxformtoken.php

示例13: cleanup

 /**
  * reimp (not used in this handler)
  */
 public function cleanup()
 {
     $db = eZDB::instance();
     eZSession::triggerCallback('cleanup_pre', array($db));
     eZSession::triggerCallback('cleanup_post', array($db));
     return true;
 }
开发者ID:rmiguel,项目名称:ezpublish,代码行数:10,代码来源:ezpsessionhandlerphp.php

示例14: eZDisplayResult

        $tpl = eZTemplate::factory();
        if (empty($warningList)) {
            $warningList = false;
        }
        $tpl->setVariable('site', $site);
        $tpl->setVariable('warning_list', $warningList);
        $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
        $templateResult = $tpl->fetch('design:redirect.tpl');
        eZDebug::addTimingPoint("Script end");
        eZDisplayResult($templateResult);
    }
    eZExecution::cleanExit();
}
// Store the last URI for access history for login redirection
// Only if user has session and only if there was no error or no redirects happen
if (eZSession::hasStarted() && $module->exitStatus() == eZModule::STATUS_OK) {
    $currentURI = $completeRequestedURI;
    if (strlen($currentURI) > 0 and $currentURI[0] != '/') {
        $currentURI = '/' . $currentURI;
    }
    $lastAccessedURI = "";
    $lastAccessedViewURI = "";
    $http = eZHTTPTool::instance();
    // Fetched stored session variables
    if ($http->hasSessionVariable("LastAccessesURI")) {
        $lastAccessedViewURI = $http->sessionVariable("LastAccessesURI");
    }
    if ($http->hasSessionVariable("LastAccessedModifyingURI")) {
        $lastAccessedURI = $http->sessionVariable("LastAccessedModifyingURI");
    }
    // Update last accessed view page
开发者ID:legende91,项目名称:ez,代码行数:31,代码来源:index.php

示例15: eZDisplayResult

        $tpl = eZTemplate::factory();
        if (count($warningList) == 0) {
            $warningList = false;
        }
        $tpl->setVariable('site', $site);
        $tpl->setVariable('warning_list', $warningList);
        $tpl->setVariable('redirect_uri', eZURI::encodeURL($redirectURI));
        $templateResult = $tpl->fetch('design:redirect.tpl');
        eZDebug::addTimingPoint("End");
        eZDisplayResult($templateResult);
    }
    eZExecution::cleanExit();
}
// Store the last URI for access history for login redirection
// Only if database is connected, user has session and only if there was no error or no redirects happen
if (eZSession::hasStarted() && is_object($db) && $db->isConnected() && $module->exitStatus() == eZModule::STATUS_OK) {
    $currentURI = $completeRequestedURI;
    if (strlen($currentURI) > 0 and $currentURI[0] != '/') {
        $currentURI = '/' . $currentURI;
    }
    $lastAccessedURI = "";
    $lastAccessedViewURI = "";
    $http = eZHTTPTool::instance();
    // Fetched stored session variables
    if ($http->hasSessionVariable("LastAccessesURI")) {
        $lastAccessedViewURI = $http->sessionVariable("LastAccessesURI");
    }
    if ($http->hasSessionVariable("LastAccessedModifyingURI")) {
        $lastAccessedURI = $http->sessionVariable("LastAccessedModifyingURI");
    }
    // Update last accessed view page
开发者ID:runelangseid,项目名称:ezpublish,代码行数:31,代码来源:index.php


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