本文整理匯總了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);
}