本文整理汇总了PHP中confirm_sesskey函数的典型用法代码示例。如果您正苦于以下问题:PHP confirm_sesskey函数的具体用法?PHP confirm_sesskey怎么用?PHP confirm_sesskey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了confirm_sesskey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_access
/**
* This is function verifies that the user has basic access to this page. More detailed checks
* may be performed later depending on the action.
*
* @param int $requesttype The type of the ajax request.
*
*/
public function verify_access($requesttype)
{
// Whether or not to output JSON depends on the type of request (view mail just outputs directly).
$outputjson = $requesttype == 'view' ? false : true;
$this->courseid = required_param('courseid', PARAM_INT);
// Require users to be logged in, but do not redirect to login page -> we'll tell the user manually.
try {
require_login($this->courseid, false, null, false, true);
} catch (Exception $e) {
if ($outputjson === true) {
echo json_encode(array('result' => 'false', 'text' => get_string('mailnologin', BLOCK_CM_LANG_TABLE)));
} else {
echo '<p>' . get_string('mailnologin', BLOCK_CM_LANG_TABLE) . '</p>';
}
return false;
}
if (!confirm_sesskey(required_param("sesskey", PARAM_TEXT))) {
if ($outputjson === true) {
echo json_encode(array('result' => 'false', 'text' => get_string('mailbadsesskey', BLOCK_CM_LANG_TABLE)));
} else {
echo '<p>' . get_string('mailbadsesskey', BLOCK_CM_LANG_TABLE) . '</p>';
}
return false;
}
return true;
}
示例2: blocks_skills_group_verify_access
/**
* This function checks for a user's access to a particular form/page. The main check
* is requiring a user to be logged into a particular course. Optionally, it will check
* for a capability and check the user's sesskey.
*
* @param string $capability Verify the user has this capability.
* @param bool $checksesskey T/F indicating whether sesskey should be checked.
* @return bool T/F indicating if access is permitted.
*
*/
function blocks_skills_group_verify_access($capability = null, $checksesskey = false)
{
$courseid = required_param('courseid', PARAM_INT);
try {
require_login($courseid, false);
} catch (Exception $e) {
echo get_string('nologin', BLOCK_SG_LANG_TABLE);
return false;
}
if ($capability != null) {
if (!has_capability($capability, context_course::instance($courseid))) {
echo get_string('noaccess', BLOCK_SG_LANG_TABLE);
return false;
}
}
try {
if ($checksesskey != false) {
if (!confirm_sesskey()) {
echo get_string('badsesskey', BLOCK_SG_LANG_TABLE);
return false;
}
}
} catch (Exception $e) {
echo get_string('badsesskey', BLOCK_SG_LANG_TABLE);
return false;
}
return true;
}
示例3: process_feedback
function process_feedback($formdata = null)
{
if (!($feedback = data_submitted()) or !confirm_sesskey()) {
// No incoming data?
return false;
}
$userid = required_param('userid', PARAM_INT);
$offset = required_param('offset', PARAM_INT);
$mform = $this->display_submission($offset, $userid, false);
parent::process_feedback($mform);
}
示例4: verify_access
/**
* This is function verifies that the user has basic access to this page. More detailed checks
* may be performed later depending on the action.
*
* @param int $requesttype The type of the ajax request.
*
*/
public function verify_access($requesttype)
{
$this->courseid = required_param('courseid', PARAM_INT);
// Require users to be logged in, but do not redirect to login page -> we'll tell the user manually.
try {
require_login($this->courseid, false, null, false, true);
} catch (Exception $e) {
echo json_encode(array('result' => 'false', 'text' => get_string('nologin', BLOCK_SG_LANG_TABLE)));
return false;
}
if (!confirm_sesskey(required_param("sesskey", PARAM_TEXT))) {
echo json_encode(array('result' => 'false', 'text' => get_string('badsesskey', BLOCK_SG_LANG_TABLE)));
return false;
}
return true;
}
示例5: process_data
/**
* process any view specific actions.
*
* @return void
*/
public function process_data()
{
global $CFG;
// Proces csv export request.
$exportcsv = optional_param('exportcsv', '', PARAM_ALPHA);
if ($exportcsv and $this->param4 and confirm_sesskey()) {
$this->process_export($exportcsv);
return;
}
// Proces csv import request.
$importcsv = optional_param('importcsv', 0, PARAM_INT);
if ($importcsv and $this->param5 and confirm_sesskey()) {
$this->process_import();
return;
}
parent::process_data();
}
示例6: moodle_url
echo '<div align="center">';
echo $OUTPUT->box($message);
echo '<br/>';
echo $OUTPUT->continue_button($returnurl);
echo '</div>';
} else {
$yesurl = new moodle_url('/local/scheduleexam/edit.php', array('id' => $id, 'delete' => 1, 'confirm' => 1, 'sesskey' => sesskey()));
$message = get_string('delconfirm', 'local_scheduleexam');
echo $OUTPUT->confirm($message, $yesurl, $returnurl);
}
echo $OUTPUT->footer();
die;
}
//to hide or unhide
if ($visible != -1 and $id and confirm_sesskey()) {
$result = $DB->set_field('local_scheduledexams', 'visible', $visible, array('id' => $id));
$data->visible = $DB->get_field('local_scheduledexams', 'visible', array('id' => $id));
if ($data->visible == 1) {
$data->visible = 'Activated';
} else {
$data->visible = 'Inactivated';
}
if ($result) {
$message = get_string('success', 'local_scheduleexam', $data);
$style = array('style' => 'notifysuccess');
} else {
$message = get_string('failure', 'local_scheduleexam', $data);
$style = array('style' => 'notifyproblem');
}
$hierarchy->set_confirmation($message, $returnurl, $style);
示例7: array
//update the registration
$function = 'hub_update_site_info';
$siteinfo = $registrationmanager->get_site_info($huburl);
$params = array('siteinfo' => $siteinfo);
$serverurl = $huburl . "/local/hub/webservice/webservices.php";
require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token);
try {
$result = $xmlrpcclient->call($function, $params);
} catch (Exception $e) {
$error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage()));
}
}
/////// FORM REGISTRATION ACTION //////
if (!empty($fromform) and empty($update) and confirm_sesskey()) {
if (!empty($fromform) and confirm_sesskey()) {
// if the register button has been clicked
$params = (array) $fromform;
//we are using the form input as the redirection parameters (token, url and name)
$unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl);
if (empty($unconfirmedhub)) {
//we save the token into the communication table in order to have a reference
$unconfirmedhub = new stdClass();
$unconfirmedhub->token = $registrationmanager->get_site_secret_for_hub($huburl);
$unconfirmedhub->secret = $unconfirmedhub->token;
$unconfirmedhub->huburl = $huburl;
$unconfirmedhub->hubname = $hubname;
$unconfirmedhub->confirmed = 0;
$unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub);
}
$params['token'] = $unconfirmedhub->token;
示例8: groups_get_activity_group
}
$PAGE->set_title($data->name);
$PAGE->set_heading($course->fullname);
/// Check to see if groups are being used here
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);
if ($currentgroup) {
$groupselect = " AND groupid = '{$currentgroup}'";
$groupparam = "&groupid={$currentgroup}";
} else {
$groupselect = "";
$groupparam = "";
$currentgroup = 0;
}
/// Process incoming data for adding/updating records
if ($datarecord = data_submitted() and confirm_sesskey()) {
$ignorenames = array('MAX_FILE_SIZE', 'sesskey', 'd', 'rid', 'saveandview', 'cancel');
// strings to be ignored in input data
if ($rid) {
/// Update some records
/// All student edits are marked unapproved by default
$record = $DB->get_record('data_records', array('id' => $rid));
/// reset approved flag after student edit
if (!has_capability('mod/data:approve', $context)) {
$record->approved = 0;
}
$record->groupid = $currentgroup;
$record->timemodified = time();
$DB->update_record('data_records', $record);
/// Update all content
$field = NULL;
示例9: get_field
break;
}
if ($extendperiod > 0) {
$timeend = $timestart + $extendperiod;
} else {
$timeend = 0;
}
if (!role_assign($roleid, $adduser, 0, $context->id, $timestart, $timeend, $hidden)) {
$errors[] = "Could not add user with id {$adduser} to this role!";
}
}
}
$rolename = get_field('role', 'name', 'id', $roleid);
add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid=' . $context->id . '&roleid=' . $roleid, $rolename, '', $USER->id);
} else {
if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
$sitecontext = get_context_instance(CONTEXT_SYSTEM);
$topleveladmin = false;
// we only worry about this if the role has doanything capability at site level
if ($context->id == $sitecontext->id && ($adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext))) {
foreach ($adminroles as $adminrole) {
if ($adminrole->id == $roleid) {
$topleveladmin = true;
}
}
}
foreach ($frm->removeselect as $removeuser) {
$removeuser = clean_param($removeuser, PARAM_INT);
if ($topleveladmin && $removeuser == $USER->id) {
// Prevent unassigning oneself from being admin
continue;
示例10: print_error
exit;
}
if ($id) {
if (!($view = get_record('block_exabeporview', 'id', $id, 'userid', $USER->id))) {
print_error("wrongviewid", "block_exabis_eportfolio");
}
} else {
$view = null;
}
$returnurl = $CFG->wwwroot . '/blocks/exabis_eportfolio/views_list.php?courseid=' . $courseid;
// delete item
if ($action == 'delete') {
if (!$view) {
print_error("bookmarknotfound", "block_exabis_eportfolio");
}
if (data_submitted() && $confirm && confirm_sesskey()) {
delete_records('block_exabeporviewblock', 'viewid', $view->id);
$status = delete_records('block_exabeporview', 'id', $view->id);
add_to_log(SITEID, 'blog', 'delete', 'views_mod.php?courseid=' . $courseid . '&id=' . $view->id . '&action=delete&confirm=1', $view->name);
if (!$status) {
print_error('deleteposterror', 'block_exabis_eportfolio', $returnurl);
}
redirect($returnurl);
} else {
$optionsyes = array('id' => $id, 'action' => 'delete', 'confirm' => 1, 'sesskey' => sesskey(), 'courseid' => $courseid);
$optionsno = array('courseid' => $courseid);
block_exabis_eportfolio_print_header('views');
echo '<br />';
notice_yesno(get_string("deleteconfirm", "block_exabis_eportfolio"), 'views_mod.php', 'views_list.php', $optionsyes, $optionsno, 'post', 'get');
print_footer();
die;
示例11: course_category_hide
if ($tempcat->visible == 1) {
course_category_hide($tempcat);
}
}
} else {
if ($show and confirm_sesskey()) {
if ($tempcat = $DB->get_record('course_categories', array('id' => $show))) {
require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent));
if ($tempcat->visible == 0) {
course_category_show($tempcat);
}
}
}
}
/// Move a category up or down
if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) {
fix_course_sortorder();
$swapcategory = NULL;
if (!empty($moveup)) {
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveup));
if ($movecategory = $DB->get_record('course_categories', array('id' => $moveup))) {
if ($swapcategory = $DB->get_records_select('course_categories', "sortorder<? AND parent=?", array($movecategory->sortorder, $movecategory->parent), 'sortorder DESC', '*', 0, 1)) {
$swapcategory = reset($swapcategory);
}
}
} else {
require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $movedown));
if ($movecategory = $DB->get_record('course_categories', array('id' => $movedown))) {
if ($swapcategory = $DB->get_records_select('course_categories', "sortorder>? AND parent=?", array($movecategory->sortorder, $movecategory->parent), 'sortorder ASC', '*', 0, 1)) {
$swapcategory = reset($swapcategory);
}
示例12: required_param
$id = required_param('id', PARAM_INT);
// Course Module ID
$mode = optional_param('mode', '', PARAM_ALPHA);
$link = optional_param('link', 0, PARAM_INT);
list($cm, $course, $lesson) = lesson_get_basics($id);
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
switch ($mode) {
case 'add':
// Ensure that we came from view.php
if (!confirm_sesskey() or !data_submitted()) {
print_error('invalidformdata');
}
break;
case 'save':
if (confirm_sesskey() and $form = data_submitted($CFG->wwwroot . '/mod/lesson/view.php')) {
$name = trim(optional_param('name', '', PARAM_CLEAN));
// Make sure it is not empty
if (empty($name)) {
lesson_set_message(get_string('missingname', 'lesson'));
$mode = 'add';
break;
}
// Check for censored words
$filterwords = explode(',', get_string('censorbadwords'));
foreach ($filterwords as $filterword) {
if (strstr($name, $filterword)) {
lesson_set_message(get_string('namereject', 'lesson'));
$mode = 'add';
break;
}
示例13: choice_user_submit_response
if ($answer) {
choice_user_submit_response($answer, $choice, $USER->id, $course, $cm);
redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'choicesaved', 'sesskey' => sesskey())));
} else {
if (empty($answer) and $action === 'makechoice') {
// We cannot use the 'makechoice' alone because there might be some legacy renderers without it,
// outdated renderers will not get the 'mustchoose' message - bad luck.
redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'mustchooseone', 'sesskey' => sesskey())));
}
}
}
// Completion and trigger events.
choice_view($choice, $course, $cm, $context);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($choice->name), 2, null);
if ($notify and confirm_sesskey()) {
if ($notify === 'choicesaved') {
echo $OUTPUT->notification(get_string('choicesaved', 'choice'), 'notifysuccess');
} else {
if ($notify === 'mustchooseone') {
echo $OUTPUT->notification(get_string('mustchooseone', 'choice'), 'notifyproblem');
}
}
}
/// Display the choice and possibly results
$eventdata = array();
$eventdata['objectid'] = $choice->id;
$eventdata['context'] = $context;
/// Check to see if groups are being used in this choice
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) {
示例14: require_capability
$context = context_module::instance($cm->id);
require_capability('mod/choice:readresponses', $context);
if (!($choice = choice_get_choice($cm->instance))) {
print_error('invalidcoursemodule');
}
$strchoice = get_string("modulename", "choice");
$strchoices = get_string("modulenameplural", "choice");
$strresponses = get_string("responses", "choice");
$eventdata = array();
$eventdata['objectid'] = $choice->id;
$eventdata['context'] = $context;
$eventdata['courseid'] = $course->id;
$eventdata['other']['content'] = 'choicereportcontentviewed';
$event = \mod_choice\event\report_viewed::create($eventdata);
$event->trigger();
if (data_submitted() && $action == 'delete' && has_capability('mod/choice:deleteresponses', $context) && confirm_sesskey()) {
choice_delete_responses($attemptids, $choice, $cm, $course);
//delete responses.
redirect("report.php?id={$cm->id}");
}
if (!$download) {
$PAGE->navbar->add($strresponses);
$PAGE->set_title(format_string($choice->name) . ": {$strresponses}");
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($choice->name, 2, null);
/// Check to see if groups are being used in this choice
$groupmode = groups_get_activity_groupmode($cm);
if ($groupmode) {
groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choice/report.php?id=' . $id);
示例15: require_capability
require_capability('moodle/role:assign', $context, NULL, false);
$roles = get_user_roles($context, $userid, false);
// verify user may unassign all roles at course context
foreach ($roles as $role) {
if (!user_can_assign($context, $role->roleid)) {
print_error('cannotunassignrolefrom', '', '', $role->roleid);
}
}
} else {
// Unenrol yourself
require_capability('moodle/role:unassignself', $context, NULL, false);
}
if (!empty($USER->access['rsw'][$context->path])) {
print_error('cantunenrollinthisrole', '', $CFG->wwwroot . '/course/view.php?id=' . $course->id);
}
if ($confirm and confirm_sesskey()) {
if ($userid) {
if (!role_unassign(0, $userid, 0, $context->id)) {
print_error("unenrolerror");
}
add_to_log($course->id, 'course', 'unenrol', "view.php?id={$course->id}", $course->id);
redirect($CFG->wwwroot . '/user/index.php?id=' . $course->id);
} else {
if (!role_unassign(0, $USER->id, 0, $context->id)) {
print_error("unenrolerror");
}
// force a refresh of mycourses
unset($USER->mycourses);
add_to_log($course->id, 'course', 'unenrol', "view.php?id={$course->id}", $course->id);
redirect($CFG->wwwroot);
}