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


PHP CSmartyDP::csrf_values方法代碼示例

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


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

示例1: array

 /**
  * mb_form
  */
 function mb_form($params, $content, &$smarty, &$repeat)
 {
     $fields = array("m" => CMbArray::extract($params, "m", null, true), "dosql" => CMbArray::extract($params, "dosql"), "tab" => CMbArray::extract($params, "tab"), "a" => CMbArray::extract($params, "a"));
     $attributes = array("name" => CMbArray::extract($params, "name", null, true), "method" => CMbArray::extract($params, "method", "get"), "action" => CMbArray::extract($params, "action", "?"), "class" => CMbArray::extract($params, "className", ""));
     // If protection enabled
     if (CAppUI::conf("csrf_protection")) {
         // During opening tag, we generate the token
         if ($repeat) {
             // Form is open
             self::$is_open = true;
         } else {
             if (strtoupper($attributes["method"]) == "POST") {
                 $lifetime = CMbArray::extract($params, "lifetime", CAppUI::conf("csrf_token_lifetime"));
                 $lifetime = abs(round($lifetime));
                 $token = CCSRF::generateToken();
                 if ($token) {
                     // Key is token, value is expiration date and fields to check
                     $_SESSION["tokens"][$token] = array("lifetime" => time() + $lifetime, "fields" => self::$csrf_values);
                     // In order to add the hidden input
                     $fields["csrf"] = $token;
                     self::$csrf_values = array();
                 }
             }
             // Form is closing
             self::$is_open = false;
         }
     }
     $attributes += $params;
     $fields = array_filter($fields);
     $_content = "";
     foreach ($fields as $name => $value) {
         $_content .= "\n" . CHTMLResourceLoader::getTag("input", array("type" => "hidden", "name" => $name, "value" => $value));
     }
     $_content .= $content;
     return CHTMLResourceLoader::getTag("form", $attributes, $_content);
 }
開發者ID:OpenXtrem,項目名稱:mediboard-test,代碼行數:39,代碼來源:CSmartyDP.class.php


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