Skip to content

Instantly share code, notes, and snippets.

@fetus-hina
Created August 30, 2012 10:26
Show Gist options
  • Save fetus-hina/3525780 to your computer and use it in GitHub Desktop.
Save fetus-hina/3525780 to your computer and use it in GitHub Desktop.
Yii Framework と Smarty を使う時の CSRF トークン埋め込み用プラグイン(環境が限定的すぎる)
<?php
function smarty_function_csrf_token(array $params, Smarty_Internal_TemplateBase $smarty) {
$req = Yii::app()->getRequest();
return
$req->enableCsrfValidation
? CHtml::hiddenField($req->csrfTokenName, $req->getCsrfToken())
: '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment