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


PHP WebRequest::setSessionData方法代码示例

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


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

示例1: getEditTokenAtTimestamp

 /**
  * Internal implementation for self::getEditToken() and
  * self::matchEditToken().
  *
  * @param string|array $salt
  * @param WebRequest $request
  * @param string|int $timestamp
  * @return string
  */
 private function getEditTokenAtTimestamp($salt, $request, $timestamp)
 {
     if ($this->isAnon()) {
         return self::EDIT_TOKEN_SUFFIX;
     } else {
         $token = $request->getSessionData('wsEditToken');
         if ($token === null) {
             $token = MWCryptRand::generateHex(32);
             $request->setSessionData('wsEditToken', $token);
         }
         if (is_array($salt)) {
             $salt = implode('|', $salt);
         }
         return hash_hmac('md5', $timestamp . $salt, $token, false) . dechex($timestamp) . self::EDIT_TOKEN_SUFFIX;
     }
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:25,代码来源:User.php

示例2: evaluateForm

 private function evaluateForm(WebRequest &$request)
 {
     global $wgOut, $wgUser, $spsgIterators;
     $requestValues = $_POST;
     if (array_key_exists('iteratordata', $requestValues)) {
         $iteratorData = FormatJson::decode($requestValues['iteratordata'], true);
         unset($requestValues['iteratordata']);
     } else {
         throw new SPSException(SPSUtils::buildMessage('spserror-noiteratordata'));
     }
     $iteratorName = null;
     $targetFormName = null;
     $targetFieldName = null;
     $originPageId = null;
     foreach ($iteratorData as $param => $value) {
         switch ($param) {
             case 'iterator':
                 // iteratorName
                 $iteratorName = $value;
                 break;
             case 'target_form':
                 $targetFormName = $value;
                 break;
             case 'target_field':
                 $targetFieldName = $value;
                 break;
             case 'origin':
                 $originPageId = $value;
                 break;
             default:
                 $iteratorParams[$param] = $this->getAndRemoveFromArray($requestValues, $value);
         }
     }
     if (is_null($iteratorName) || $iteratorName === '') {
         throw new SPSException(SPSUtils::buildMessage('spserror-noiteratorname'));
     }
     if (!array_key_exists($iteratorName, $spsgIterators)) {
         throw new SPSException(SPSUtils::buildMessage('spserror-iteratorunknown', $iteratorName));
     }
     // iterator
     $iterator = new $spsgIterators[$iteratorName]();
     $iteratorValues = $iterator->getValues($iteratorParams);
     $iteratorValuesCount = count($iteratorValues);
     $userlimit = $this->getPageGenerationLimit();
     // check userlimit
     if ($iteratorValuesCount > $userlimit) {
         throw new SPSException(SPSUtils::buildMessage('spserror-pagegenerationlimitexeeded', $iteratorValuesCount, $userlimit));
     }
     $targetFormTitle = Title::makeTitleSafe(SF_NS_FORM, $targetFormName);
     $targetFormPageId = $targetFormTitle->getArticleID();
     $requestValues['user'] = $wgUser->getId();
     foreach ($iteratorValues as $value) {
         SFAutoeditAPI::addToArray($requestValues, $targetFieldName, $value, true);
         wfDebugLog('sps', 'Insert SPSPageCreationJob');
         $job = new SPSPageCreationJob($targetFormTitle, $requestValues);
         $job->insert();
     }
     // if given origin page does not exist use Main page
     if (Title::newFromID($originPageId) === null) {
         $originPageId = Title::newMainPage()->getArticleID();
     }
     if (isset($_SESSION)) {
         // cookies enabled
         $request->setSessionData('spsResult', $iteratorValuesCount);
         $request->setSessionData('spsForm', $targetFormPageId);
         $request->setSessionData('spsOrigin', $originPageId);
         header('Location: ' . $this->getTitle()->getFullURL());
     } else {
         // cookies disabled, write result data to URL
         header('Location: ' . $this->getTitle()->getFullURL() . "?{$targetFormPageId};{$iteratorValuesCount};{$originPageId}");
     }
     return null;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:73,代码来源:SPSSpecialSeriesEdit.php


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