本文整理汇总了PHP中CSRF::getTokenId方法的典型用法代码示例。如果您正苦于以下问题:PHP CSRF::getTokenId方法的具体用法?PHP CSRF::getTokenId怎么用?PHP CSRF::getTokenId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSRF
的用法示例。
在下文中一共展示了CSRF::getTokenId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_POST
function edit_POST($w)
{
$p = $w->pathMatch("id");
$task = !empty($p["id"]) ? $w->Task->getTask($p["id"]) : new Task($w);
$taskdata = null;
if (!empty($p["id"])) {
$taskdata = $w->Task->getTaskData($p['id']);
}
$task->fill($_POST['edit']);
$task->assignee_id = intval($_POST['edit']['assignee_id']);
if (empty($task->dt_due)) {
$task->dt_due = $w->Task->getNextMonth();
}
$task->insertOrUpdate();
// Tell the template what the task id is (this post action is being called via ajax)
$w->setLayout(null);
$w->out($task->id);
// Get existing task_data objects for this task and update them
$existing_task_data = $w->Task->getTaskData($task->id);
if (!empty($existing_task_data)) {
foreach ($existing_task_data as $e_task_data) {
foreach ($_POST["extra"] as $key => $data) {
if ($key == \CSRF::getTokenId()) {
unset($_POST["extra"][\CSRF::getTokenID()]);
continue;
}
if ($e_task_data->data_key == $key) {
$e_task_data->value = $data;
$e_task_data->update();
unset($_POST["extra"][$key]);
continue;
}
// If we get here then remove the existing data?
// $e_task_data->delete();
}
}
}
// Insert data that didn't exist above as new task_data objects
if (!empty($_POST["extra"])) {
foreach ($_POST["extra"] as $key => $data) {
$tdata = new TaskData($w);
$tdata->task_id = $task->id;
$tdata->data_key = $key;
$tdata->value = $data;
$tdata->insert();
}
}
}
示例2: function
var edit_form = {};
var extras_form = {};
$.each($('#edit_form').serializeArray(), function(){
edit_form[this.name] = this.value;
});
$.each($('#form_fields_form').serializeArray(), function(){
extras_form[this.name] = this.value;
});
var action = $(this).attr('action');
$.ajax({
url : action,
type : 'POST',
data : {
'<?php
echo \CSRF::getTokenId();
?>
': '<?php
echo \CSRF::getTokenValue();
?>
',
'edit': edit_form,
'extra': extras_form
},
complete: function(response) {
if ($.isNumeric(response.responseText)) {
window.location.href = "/task/edit/" + response.responseText;
} else {
window.location.reload();
}
}