當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SecurityUtil::validateCsrfToken方法代碼示例

本文整理匯總了PHP中SecurityUtil::validateCsrfToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP SecurityUtil::validateCsrfToken方法的具體用法?PHP SecurityUtil::validateCsrfToken怎麽用?PHP SecurityUtil::validateCsrfToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SecurityUtil的用法示例。


在下文中一共展示了SecurityUtil::validateCsrfToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Main event loop handler.
  *
  * This is the function to call instead of the normal $view->fetch(...).
  *
  * @param boolean                     $template     Name of template file.
  * @param Zikula_Form_AbstractHandler $eventHandler Instance of object that inherits from Zikula_Form_AbstractHandler.
  *
  * @return mixed False on errors, true on redirects, and otherwise it returns the HTML output for the page.
  */
 public function execute($template, Zikula_Form_AbstractHandler $eventHandler)
 {
     if (!$eventHandler instanceof Zikula_Form_AbstractHandler) {
         throw new Zikula_Exception_Fatal('Form handlers must inherit from Zikula_Form_AbstractHandler.');
     }
     // Save handler for later use
     $this->eventHandler = $eventHandler;
     $this->eventHandler->setView($this);
     $this->eventHandler->setEntityManager($this->entityManager);
     $this->eventHandler->setRequest($this->request);
     $this->eventHandler->setDomain($this->domain);
     $this->eventHandler->setName($this->getModuleName());
     $this->eventHandler->setup();
     $this->eventHandler->preInitialize();
     if ($this->isPostBack()) {
         if (!SecurityUtil::validateCsrfToken($this->request->request->filter('csrftoken', '', FILTER_SANITIZE_STRING), $this->serviceManager)) {
             return LogUtil::registerAuthidError();
         }
         // retrieve form id
         $formId = $this->request->request->filter("__formid", '', FILTER_SANITIZE_STRING);
         $this->setFormId($formId);
         $this->decodeIncludes();
         $this->decodeStateData();
         $this->decodeState();
         if ($this->eventHandler->initialize($this) === false) {
             return $this->getErrorMsg();
         }
         // if we get this far, the form processed correctly and we can GC the session
         unset($_SESSION['__formid'][$this->formId]);
         $this->eventHandler->postInitialize();
         // (no create event)
         $this->initializePlugins();
         // initialize event
         $this->decodePlugins();
         // decode event
         $this->decodePostBackEvent();
         // Execute optional postback after plugins have read their values
     } else {
         $this->setFormId(uniqid('f'));
         if ($this->eventHandler->initialize($this) === false) {
             return $this->getErrorMsg();
         }
         $this->eventHandler->postInitialize();
     }
     // render event (calls registerPlugin)
     $this->assign('__formid', $this->formId);
     $output = $this->fetch($template);
     if ($this->hasError()) {
         return $this->getErrorMsg();
     }
     // Check redirection at this point, ignore any generated HTML if redirected is required.
     // We cannot skip HTML generation entirely in case of System::redirect since there might be
     // some relevant code to execute in the plugins.
     if ($this->redirected) {
         // only reach this point if redirectTarget is a Zikula\Core\ModUrl
         return new RedirectResponse(System::normalizeUrl($this->redirectTarget->getUrl()));
     }
     return $output;
 }
開發者ID:Silwereth,項目名稱:core,代碼行數:69,代碼來源:View.php

示例2: isCsrfTokenValid

 /**
  * {@inheritdoc}
  */
 public function isCsrfTokenValid($intention, $token)
 {
     return \SecurityUtil::validateCsrfToken($token);
 }
開發者ID:rmaiwald,項目名稱:core,代碼行數:7,代碼來源:ZikulaCsrfProvider.php


注:本文中的SecurityUtil::validateCsrfToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。