本文整理汇总了PHP中Csrf::token方法的典型用法代码示例。如果您正苦于以下问题:PHP Csrf::token方法的具体用法?PHP Csrf::token怎么用?PHP Csrf::token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csrf
的用法示例。
在下文中一共展示了Csrf::token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __
?>
</h1>
<?php
echo Notifications::read();
?>
<section class="content">
<form method="post" action="<?php
echo Url::current();
?>
">
<input name="token" type="hidden" value="<?php
echo Csrf::token();
?>
">
<fieldset>
<p>
<label for="user"><?php
echo __('users.username', 'Username');
?>
:</label>
<input autocapitalize="off" name="user" id="user" value="<?php
echo filter_var(Input::post('user'), FILTER_SANITIZE_STRING);
?>
">
</p>
示例2: function
Notify::error($errors);
return Response::redirect('admin/users/edit/' . $id);
}
if ($password_reset) {
$input['password'] = Hash::make($input['password']);
}
User::update($id, $input);
Notify::success(__('users.updated'));
return Response::redirect('admin/users/edit/' . $id);
});
/*
Add user
*/
Route::get('admin/users/add', function () {
$vars['messages'] = Notify::read();
$vars['token'] = Csrf::token();
$vars['statuses'] = array('inactive' => __('global.inactive'), 'active' => __('global.active'));
$vars['roles'] = array('administrator' => __('global.administrator'), 'editor' => __('global.editor'), 'user' => __('global.user'));
return View::create('users/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
});
Route::post('admin/users/add', function () {
$input = Input::get(array('username', 'email', 'real_name', 'password', 'bio', 'status', 'role'));
$validator = new Validator($input);
$validator->check('username')->is_max(3, __('users.username_missing', 2));
$validator->check('email')->is_email(__('users.email_missing'));
$validator->check('password')->is_max(6, __('users.password_too_short', 6));
if ($errors = $validator->errors()) {
Input::flash();
Notify::error($errors);
return Response::redirect('admin/users/add');
}
示例3: array
return View::create('upgrade', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
});
/*
List extend
*/
Route::get('admin/extend', array('before' => 'auth', 'main' => function ($page = 1) {
$vars['messages'] = Notify::read();
$vars['token'] = Csrf::token();
return View::create('extend/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
}));
Route::post('admin/get_fields', array('before' => 'auth', 'main' => function () {
$input = Input::get(array('id', 'pagetype'));
// get the extended fields
$vars['fields'] = Extend::fields('page', -1, $input['pagetype']);
$html = View::create('pages/fields', $vars)->render();
$token = '<input name="token" type="hidden" value="' . Csrf::token() . '">';
return Response::json(array('token' => $token, 'html' => $html));
}));
/*
Upload an image
*/
Route::post('admin/upload', array('before' => 'auth', 'main' => function () {
$uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
$filepath = $uploader->upload($_FILES['file']);
$uri = Config::app('url', '/') . 'content/' . basename($filepath);
$output = array('uri' => $uri);
return Response::json($output);
}));
/*
404 error
*/