function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } $alertunit = $DB->get_record('block_timetracker_alertunits', array('id' => $this->alertid)); $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $alertunit->userid)); $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $alertunit->courseid, 'userid' => $alertunit->userid)); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } if (!$canmanage && $USER->id != $userinfo->mdluserid) { redirect($nextpage, 'You do not have permission to change this alert.', 1); } else { $mform->addElement('hidden', 'userid', $alertunit->userid); $mform->addElement('hidden', 'courseid', $alertunit->courseid); $mform->addElement('hidden', 'payrate', $alertunit->payrate); $mform->addElement('hidden', 'lasteditedby', $USER->id); $mform->addElement('hidden', 'alertid', $alertunit->id); $mform->addElement('hidden', 'action', $alertunit->id); $mform->addElement('header', 'general', get_string('changealert', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('html', get_string('emessage2', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage3', 'block_timetracker', userdate($alertunit->origtimein))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage4', 'block_timetracker', userdate($alertunit->origtimeout))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->origtimeout - $alertunit->origtimein, $alertunit->courseid))); $mform->addElement('html', get_string('br2', 'block_timetracker')); $mform->addElement('html', get_string('emessage5', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage3', 'block_timetracker', userdate($alertunit->timein))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage4', 'block_timetracker', userdate($alertunit->timeout))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessageduration', 'block_timetracker', format_elapsed_time($alertunit->timeout - $alertunit->timein, $alertunit->courseid))); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('html', get_string('emessage6', 'block_timetracker', $alertunit->message)); $mform->addElement('html', get_string('br2', 'block_timetracker')); $mform->addElement('html', get_string('changeto', 'block_timetracker')); $mform->addElement('html', get_string('br1', 'block_timetracker')); $mform->addElement('date_time_selector', 'timein', get_string('timeinerror', 'block_timetracker'), array('optional' => false, 'step' => 1)); $mform->setDefault('timein', $alertunit->timein); $mform->addHelpButton('timein', 'timein', 'block_timetracker'); $mform->addElement('date_time_selector', 'timeout', get_string('timeouterror', 'block_timetracker'), array('optional' => false, 'step' => 1)); $mform->setDefault('timeout', $alertunit->timeout); $mform->addHelpButton('timeout', 'timeout', 'block_timetracker'); $mform->addElement('checkbox', 'deleteunit', get_string('deleteunit', 'block_timetracker')); $mform->addHelpButton('deleteunit', 'deleteunit', 'block_timetracker'); $this->add_action_buttons(true, get_string('savebutton', 'block_timetracker')); } }
/** * Redirect to referer * * @access public * @param string $alternative Alternative URL is used if referer is not valid URL * @return null */ function redirect_to_referer($alternative = null) { $referer = get_referer(); if ($referer) { redirect_to($referer); } else { redirect_to($alternative); } // if }
function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! //check to make sure that if $this->userid != $USER->id that they have //the correct capability TODO $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $this->userid)); if (!$userinfo) { print_error('Worker info does not exist for workerinfo id of ' . $this->userid); return; } $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $this->courseid, 'userid' => $this->userid)); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } if (!$canmanage && $USER->id != $userinfo->mdluserid) { redirect($nextpage, 'No permission to add hours', 1); } $mform->addElement('header', 'general', get_string('hourlogtitle', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('hidden', 'userid', $this->userid); $mform->addElement('hidden', 'id', $this->courseid); $mform->addElement('hidden', 'editedby', $USER->id); $workunit = $DB->get_record('block_timetracker_workunit', array('id' => $this->userid, 'courseid' => $this->courseid)); $mform->addElement('date_time_selector', 'timein', 'Time In: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timein', 'timein', 'block_timetracker'); $mform->addElement('date_time_selector', 'timeout', 'Time Out: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timeout', 'timeout', 'block_timetracker'); $this->add_action_buttons(true, get_string('savebutton', 'block_timetracker')); }
/** * Reopen completed project task * * @access public * @param void * @return null */ function open_task() { $task = ProjectTasks::findById(get_id()); if (!$task instanceof ProjectTask) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if $task_list = $task->getTaskList(); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if if (!$task->canChangeStatus(logged_user())) { flash_error(lang('no access permissions')); $this->redirectTo('task'); } // if $redirect_to = array_var($_GET, 'redirect_to'); if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) { $redirect_to = get_referer($task_list->getViewUrl()); } // if try { DB::beginWork(); $task->openTask(); ApplicationLogs::createLog($task, active_project(), ApplicationLogs::ACTION_OPEN); DB::commit(); flash_success(lang('success open task')); } catch (Exception $e) { flash_error(lang('error open task')); DB::rollback(); } // try $this->redirectToUrl($redirect_to); }
function definition() { global $CFG, $USER, $DB, $COURSE; $mform =& $this->_form; // Don't forget the underscore! //check to make sure that if $this->userid != $USER->id that they have //the correct capability TODO $canmanage = false; if (has_capability('block/timetracker:manageworkers', $this->context)) { $canmanage = true; } if ($this->ispending) { //Get from pending table $unit = $DB->get_record('block_timetracker_pending', array('id' => $this->unitid)); } else { //Get from workunit $unit = $DB->get_record('block_timetracker_workunit', array('id' => $this->unitid)); } if (!$unit) { print_error('Unit does not exist for unit id of ' . $this->unitid); return; } $userinfo = $DB->get_record('block_timetracker_workerinfo', array('id' => $this->userid)); if (!$userinfo) { print_error('Worker info does not exist for workerinfo id of ' . $this->userid); return; } $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', array('id' => $this->courseid, 'userid' => $this->userid)); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } if (!$canmanage && $USER->id != $userinfo->mdluserid) { redirect($nextpage, 'No permission to add hours', 1); } $mform->addElement('header', 'general', get_string('errortitle', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('hidden', 'userid', $this->userid); $mform->addElement('hidden', 'id', $this->courseid); $mform->addElement('hidden', 'unitid', $this->unitid); $mform->addElement('hidden', 'ispending', $this->ispending); if ($canmanage) { } else { $mform->addElement('hidden', 'editedby', $this->userid); $mform->addElement('html', '<b>'); $mform->addElement('html', get_string('to', 'block_timetracker')); $mform->addElement('html', '</b>'); $teachers = get_users_by_capability($this->context, 'block/timetracker:manageworkers'); if (!$teachers) { print_error('No supervisor is enrolled in this course. Please alert your Administrator.'); } foreach ($teachers as $teacher) { if (is_enrolled($this->context, $teacher->id)) { //!has_capability('moodle/category:manage',$this->context,$teacher) && //is_enrolled($this->context, $teacher->id)){ $mform->addElement('advcheckbox', 'teacherid[' . $teacher->id . ']', $teacher->firstname . ' ' . $teacher->lastname, null, array('group' => 1)); } } $this->add_checkbox_controller(1, null, null, 1); $mform->addElement('html', '<b>'); $mform->addElement('html', get_string('subject', 'block_timetracker')); $mform->addElement('html', '</b>'); $mform->addElement('html', get_string('subjecttext', 'block_timetracker', $userinfo->firstname . ' ' . $userinfo->lastname)); $mform->addElement('html', '<br /><br />'); $mform->addElement('html', get_string('existingunit', 'block_timetracker')); $mform->addElement('html', '<blockquote>'); $mform->addElement('html', get_string('existingtimein', 'block_timetracker', userdate($unit->timein, get_string('datetimeformat', 'block_timetracker')))); if (!$this->ispending) { //Time out and elapsed time $mform->addElement('html', '<br />'); $mform->addElement('html', get_string('existingtimeout', 'block_timetracker', userdate($unit->timeout, get_string('datetimeformat', 'block_timetracker')))); $mform->addElement('html', '<br />'); $mform->addElement('html', get_string('existingduration', 'block_timetracker', format_elapsed_time($unit->timeout - $unit->timein, $unit->courseid))); } $mform->addElement('html', '</blockquote><b>'); $mform->addElement('html', get_string('data', 'block_timetracker')); $mform->addElement('date_time_selector', 'timeinerror', 'Time In: ', array('optional' => false, 'step' => 1)); $mform->setDefault('timeinerror', $unit->timein); $mform->addHelpButton('timeinerror', 'timein', 'block_timetracker'); $mform->addElement('date_time_selector', 'timeouterror', 'Time Out: ', array('optional' => false, 'step' => 1)); $mform->addHelpButton('timeouterror', 'timeout', 'block_timetracker'); $mform->addElement('hidden', 'origtimein', $unit->timein); if (!$this->ispending) { $mform->setDefault('timeouterror', $unit->timeout); $mform->addElement('hidden', 'origtimeout', $unit->timeout); } else { $mform->setDefault('timeouterror', $unit->timein + 60 * 60 * 2); } if (!$this->ispending) { $mform->addElement('checkbox', 'deleteunit', get_string('deleteunit', 'block_timetracker')); $mform->addHelpButton('deleteunit', 'deleteunit', 'block_timetracker'); } $mform->addElement('textarea', 'message', get_string('messageforerror', 'block_timetracker'), 'wrap="virtual" rows="6" cols="75"'); $mform->addHelpButton('message', 'messageforerror', 'block_timetracker'); $mform->addRule('message', null, 'required', null, 'client', 'false'); $mform->addElement('html', '</b>'); $this->add_action_buttons(true, get_string('sendbutton', 'block_timetracker')); } }
$collect_url = trim($_POST['collect_url']); $collect_title = trim($_POST['collect_title']); $collect_content = empty($_POST['content']) ? '' : filters_content($_POST['content']); $sortname = $_POST['sortname']; $ctype = $_POST['ctype']; $public = $_POST['public']; $dblink->query("INSERT INTO {$dbprefix}collect SET uid={$cyask_uid},username='******',sortname='{$sortname}',ctype='{$ctype}',title='{$collect_title}',content='{$collect_content}',url='{$collect_url}',public='{$public}',collecttime='{$timestamp}'"); $url = $_POST['url']; show_message('collect_succeed', $url); exit; } else { show_message('url_error', './'); exit; } } else { $url = get_referer(); $neturl = empty($_POST['neturl']) ? trim($_GET['neturl']) : trim($_POST['neturl']); $collect_url = empty($neturl) ? $url : $neturl; $contents = ''; if ($fid = @fopen($collect_url, "r")) { do { $data = fread($fid, 4096); if (strlen($data) == 0) { break; } $contents .= $data; } while (true); fclose($fid); } else { show_message('collect_url_error', ''); exit;
$baseurl->params(array('id' => $courseid, 'userid' => $userid)); $nextpage = $baseurl; if ($astart != 0) { $nextpage->params(array('start' => $astart)); } if ($aend != 0) { $nextpage->params(array('end' => $aend)); } if ($camefrom == 'editunit') { if ($prevunitid != -1) { $nextpage->params(array('unitid' => $prevunitid)); } } } else { if (get_referer(false)) { $nextpage = new moodle_url(get_referer(false)); } else { $nextpage = $index; } //if we posted to ourself from ourself if (strpos($nextpage, qualified_me()) !== false) { $nextpage = new moodle_url($SESSION->lastpage); } else { $SESSION->lastpage = $nextpage; } if (isset($SESSION->fromurl) && !empty($SESSION->fromurl)) { $nextpage = new moodle_url($SESSION->fromurl); unset($SESSION->fromurl); } } //error_log("In editunit and next is: $nextpage");
} echo $OUTPUT->box_start('quizinfo'); $accessmanager->print_messages($messages); echo $OUTPUT->box_end(); /// Show number of attempts summary to those who can view reports. if (has_capability('mod/quiz:viewreports', $context)) { if ($strattemptnum = quiz_attempt_summary_link_to_reports($quiz, $cm, $context)) { echo '<div class="quizattemptcounts">' . $strattemptnum . "</div>\n"; } } /// Guests can't do a quiz, so offer them a choice of logging in or going back. if (isguestuser()) { echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false)); echo $OUTPUT->footer(); exit; } /// If they are not enrolled in this course in a good enough role, tell them to enrol. if (!($canattempt || $canpreview || $canreviewmine)) { echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" . $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) . "</p>\n", 'generalbox', 'notice'); echo $OUTPUT->footer(); exit; } /// Update the quiz with overrides for the current user $quiz = quiz_update_effective_access($quiz, $USER->id);
$months = date("n"); $years = date("Y"); $days = mktime(0, 0, 0, $months, $days, $years); if (empty($_POST['content'])) { show_message('response_null', ''); exit; } if ($cyask_user) { $query = $dblink->query("SELECT count(*) FROM {$dbprefix}res WHERE aid={$aid} AND uid={$cyask_uid} AND days={$days}"); } else { $query = $dblink->query("SELECT count(*) FROM {$dbprefix}res WHERE aid={$aid} AND uip='{$onlineip}' AND days={$days}"); } if ($dblink->result($query, 0) > 3) { show_message('response_more', ''); exit; } else { $content = filters_content($_POST['content']); $dblink->query("INSERT INTO {$dbprefix}res set aid={$aid},uid={$cyask_uid},username='******',uip='{$onlineip}',content='{$content}',time={$timestamp},days={$days}"); $dblink->query("UPDATE {$dbprefix}answer SET response=response+1 WHERE aid={$aid}"); $referer = get_referer($default = './') . '#response'; header("location:signal.php?resultno=111&url={$referer}"); exit; } } else { show_message('url_error', './'); exit; } } else { show_message('action_error', './'); exit; }
$returnurl = "{$CFG->wwwroot}/mod/facetoface/view.php?f={$backtoallsessions}"; } $pagetitle = format_string($facetoface->name); $PAGE->set_cm($cm); $PAGE->set_url('/mod/facetoface/signup.php', array('s' => $s, 'backtoallsessions' => $backtoallsessions)); $PAGE->set_title($pagetitle); $PAGE->set_heading($course->fullname); // Guests can't signup for a session, so offer them a choice of logging in or going back. if (isguestuser()) { $loginurl = $CFG->wwwroot . '/login/index.php'; if (!empty($CFG->loginhttps)) { $loginurl = str_replace('http:', 'https:', $loginurl); } echo $OUTPUT->header(); $out = html_writer::tag('p', get_string('guestsno', 'facetoface')) . html_writer::empty_tag('br') . html_writer::tag('p', get_string('continuetologin', 'facetoface')); echo $OUTPUT->confirm($out, $loginurl, get_referer(false)); echo $OUTPUT->footer(); exit; } $manageremail = false; if (get_config(null, 'facetoface_addchangemanageremail')) { $manageremail = facetoface_get_manageremail($USER->id); } $showdiscountcode = $session->discountcost > 0; $mform = new mod_facetoface_signup_form(null, compact('s', 'backtoallsessions', 'manageremail', 'showdiscountcode')); if ($mform->is_cancelled()) { redirect($returnurl); } if ($fromform = $mform->get_data()) { // Form submitted. if (empty($fromform->submitbutton)) {
function view() { global $OUTPUT; if (!$this->items && $this->canedit()) { redirect(new moodle_url('/mod/checklist/edit.php', array('id' => $this->cm->id))); } if ($this->canupdateown()) { $currenttab = 'view'; } else { if ($this->canpreview()) { $currenttab = 'preview'; } else { if ($this->canviewreports()) { // No editing, but can view reports redirect(new moodle_url('/mod/checklist/report.php', array('id' => $this->cm->id))); } else { $this->view_header(); echo $OUTPUT->heading(format_string($this->checklist->name)); echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'checklist') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false)); echo $OUTPUT->footer(); die; } $currenttab = ''; } } $this->view_header(); echo $OUTPUT->heading(format_string($this->checklist->name)); $this->view_tabs($currenttab); add_to_log($this->course->id, 'checklist', 'view', "view.php?id={$this->cm->id}", $this->checklist->name, $this->cm->id); if ($this->canupdateown()) { $this->process_view_actions(); } $this->view_items(); $this->view_footer(); }
public function view() { global $OUTPUT, $CFG; if (!$this->items && $this->canedit()) { redirect(new moodle_url('/mod/checklist/edit.php', array('id' => $this->cm->id))); } if ($this->canupdateown()) { $currenttab = 'view'; } else { if ($this->canpreview()) { $currenttab = 'preview'; } else { if ($this->canviewreports()) { // No editing, but can view reports. redirect(new moodle_url('/mod/checklist/report.php', array('id' => $this->cm->id))); } else { $this->view_header(); if ($CFG->branch >= 30) { $ref = get_local_referer(false); } else { $ref = get_referer(false); } echo $OUTPUT->heading(format_string($this->checklist->name)); echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'checklist') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), $ref); echo $OUTPUT->footer(); die; } $currenttab = ''; } } $this->view_header(); echo $OUTPUT->heading(format_string($this->checklist->name)); $this->view_tabs($currenttab); if ($CFG->version > 2014051200) { // Moodle 2.7+. $params = array('contextid' => $this->context->id, 'objectid' => $this->checklist->id); $event = \mod_checklist\event\course_module_viewed::create($params); $event->trigger(); } else { // Before Moodle 2.7. add_to_log($this->course->id, 'checklist', 'view', "view.php?id={$this->cm->id}", $this->checklist->id, $this->cm->id); } if ($this->canupdateown()) { $this->process_view_actions(); } $this->view_items(); $this->view_footer(); }
$PAGE->set_url($hotpot->view_url()); $PAGE->set_title($hotpot->name); $PAGE->set_heading($course->fullname); $output = $PAGE->get_renderer('mod_hotpot'); //////////////////////////////////////////////////////////////////////////////// // Output starts here // //////////////////////////////////////////////////////////////////////////////// echo $output->header(); // Guests can't do a HotPot, so offer them a choice of logging in or going back. if (isguestuser()) { if (function_exists('get_local_referer')) { // Moodle >= 2.8 $referer = get_local_referer(false); } else { // Moodle <= 2.7 $referer = get_referer(false); } $message = html_writer::tag('p', get_string('guestsno', 'quiz')); $message .= html_writer::tag('p', get_string('liketologin')); echo $output->confirm($message, get_login_url(), $referer); echo $output->footer(); exit; } // If user is not enrolled in this course in a good enough role, show a link to course enrolment page. if (!($hotpot->can_attempt() || $hotpot->can_preview())) { $message = html_writer::tag('p', get_string('youneedtoenrol', 'quiz')); $message .= html_writer::tag('p', $output->continue_button($hotpot->course_url())); echo $output->box($message, 'generalbox', 'notice'); echo $output->footer(); exit; }
/** * Determine if there is data waiting to be processed from a form * * Used on most forms in Moodle to check for data * Returns the data as an object, if it's found. * This object can be used in foreach loops without * casting because it's cast to (array) automatically * * Checks that submitted POST data exists, and also * checks the referer against the given url (it uses * the current page if none was specified. * * @uses $CFG * @param string $url the url to compare to referer for secure forms * @return boolean */ function data_submitted($url = '') { global $CFG; if (empty($_POST)) { return false; } else { if (match_referer($url)) { return (object) $_POST; } else { if ($CFG->debug > 10) { notice('The form did not come from this page! (referer = ' . get_referer() . ')'); } return false; } } }
/** * Outputs an error message for any guests accessing the quiz * * @param int $course The course ID * @param array $quiz Array contingin quiz data * @param int $cm Course Module ID * @param int $context The page contect ID * @param array $messages Array containing any messages */ public function view_page_guest($course, $quiz, $cm, $context, $messages) { $output = ''; $output .= $this->view_information($quiz, $cm, $context, $messages); $guestno = html_writer::tag('p', get_string('guestsno', 'quiz')); $liketologin = html_writer::tag('p', get_string('liketologin')); $output .= $this->confirm($guestno."\n\n".$liketologin."\n", get_login_url(), get_referer(false)); return $output; }
// / ___/__ ___ / /________ / / / _ \___ ____ ___ / / // / /__/ _ \/ _ \/ __/ __/ _ \/ / / ___/ _ `/ _ \/ -_) / // \___/\___/_//_/\__/_/ \___/_/ /_/ \_,_/_//_/\__/_/ // ========================================================================= // Copyright (c) Stargames Control Panel - Licensed under GNU GPL. // See LICENSE File // ========================================================================= // Project Lead by: Mysterious // ========================================================================= --> <?php require_once "memory.php"; if (empty($POST_ch_lang) && !$CONFIG_language_select_mode) { exit; } $HTTP_REFERER = get_referer(); if ($POST_ch_lang != '') { $dir = "lang/" . $POST_ch_lang . ".php"; if (is_file($dir)) { $ch_lang = $POST_ch_lang; } else { $ch_lang = $CONFIG_language; } if ($CONFIG_save_type == 1) { $_SESSION["userlang"] = $ch_lang; } else { CP_setCookie("userlang", $ch_lang); //setcookie("userlang","$ch_lang",$CP[time]+60*60*24*30); } } header("location:{$HTTP_REFERER}");
$PAGE->set_course($course); $context = $PAGE->context; $canmanage = false; if (has_capability('block/timetracker:manageworkers', $context)) { //supervisor $canmanage = true; } $canview = false; if (has_capability('block/timetracker:viewonly', $context)) { $canview = true; } $urlparams['id'] = $courseid; $urlparams['userid'] = $userid; $index = new moodle_url($CFG->wwwroot . '/blocks/timetracker/index.php', $urlparams); if (get_referer(false)) { $nextpage = get_referer(false); } else { $nextpage = $index; } //if we posted to ourself from ourself if (strpos($nextpage, qualified_me()) !== false) { $nextpage = $SESSION->lastpage; } else { $SESSION->lastpage = $nextpage; } //$nextpage = $index; $worker = $DB->get_record('block_timetracker_workerinfo', array('id' => $userid)); if ($worker) { $userid = $worker->id; $index->params(array('userid' => $userid)); $ttuserid = $worker->id;
} if (!($course = $DB->get_record('course', array('id' => $forum->course)))) { print_error('invalidcourseid'); } if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) { // For the logs print_error('invalidcoursemodule'); } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } $PAGE->set_cm($cm, $course, $forum); $PAGE->set_context($modcontext); $PAGE->set_title($course->shortname); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->confirm(get_string('noguestpost', 'forum') . '<br /><br />' . get_string('liketologin'), get_login_url(), get_referer(false)); echo $OUTPUT->footer(); exit; } require_login(0, false); // Script is useless unless they're logged in if (!empty($forum)) { // User is starting a new discussion in a forum if (!($forum = $DB->get_record("forum", array("id" => $forum)))) { print_error('invalidforumid', 'forum'); } if (!($course = $DB->get_record("course", array("id" => $forum->course)))) { print_error('invalidcourseid'); } if (!($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id))) { print_error("invalidcoursemodule");
} if (check_submit($_POST['dosubmit'], $_POST['formhash'])) { $days = strtotime(date("Y-m-d")); if (empty($_POST['content'])) { show_message('response_null', ''); exit; } if ($cyask_user) { $query = $dblink->query("SELECT count(*) FROM {$tablepre}res WHERE aid={$aid} AND uid={$cyask_uid} AND days={$days}"); } else { $query = $dblink->query("SELECT count(*) FROM {$tablepre}res WHERE aid={$aid} AND uip='{$onlineip}' AND days={$days}"); } if ($dblink->result($query, 0) > 3) { show_message('response_more', ''); exit; } else { $content = filters_content($_POST['content']); $dblink->query("INSERT INTO {$tablepre}res set aid={$aid},uid={$cyask_uid},username='******',uip='{$onlineip}',content='{$content}',time={$timestamp},days={$days}"); $dblink->query("UPDATE {$tablepre}answer SET response=response+1 WHERE aid={$aid}"); $referer = get_referer('./') . '#response'; header("location:signal.php?resultno=111&url={$referer}"); exit; } } else { show_message('url_error', './'); exit; } } else { show_message('action_error', './'); exit; }
// For the logs error('Could not get the course module for the forum instance.'); } else { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); } $strforums = get_string('modulenameplural', 'forum'); if (!get_referer()) { // No referer - probably coming in via email See MDL-9052 require_login(); } if ($course->id != SITEID) { print_header($course->shortname, $course->fullname, "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->\n <a href=\"../forum/index.php?id={$course->id}\">{$strforums}</a> ->\n <a href=\"view.php?f={$forum->id}\">" . format_string($forum->name, true) . "</a>", '', '', true, "", navmenu($course, $cm)); } else { print_header($course->shortname, $course->fullname, "<a href=\"../forum/index.php?id={$course->id}\">{$strforums}</a> ->\n <a href=\"view.php?f={$forum->id}\">" . format_string($forum->name) . "</a>", '', '', true, "", navmenu($course, $cm)); } notice_yesno(get_string('noguestpost', 'forum') . '<br /><br />' . get_string('liketologin'), $wwwroot, get_referer(false)); print_footer($course); exit; } require_login(0, false); // Script is useless unless they're logged in if (!empty($forum)) { // User is starting a new discussion in a forum if (!($forum = get_record("forum", "id", $forum))) { error("The forum number was incorrect ({$forum})"); } if (!($course = get_record("course", "id", $forum->course))) { error("The course number was incorrect ({$forum->course})"); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); if (!forum_user_can_post_discussion($forum)) {
} } if (!($course = $DB->get_record('course', array('id' => $forum->course)))) { print_error('invalidcourseid'); } if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) { // For the logs print_error('invalidcoursemodule'); } else { $modcontext = context_module::instance($cm->id); } $PAGE->set_cm($cm, $course, $forum); $PAGE->set_context($modcontext); $PAGE->set_title($course->shortname); $PAGE->set_heading($course->fullname); $referer = clean_param(get_referer(false), PARAM_LOCALURL); echo $OUTPUT->header(); echo $OUTPUT->confirm(get_string('noguestpost', 'forum') . '<br /><br />' . get_string('liketologin'), get_login_url(), $referer); echo $OUTPUT->footer(); exit; } require_login(0, false); // Script is useless unless they're logged in if (!empty($forum)) { // User is starting a new discussion in a forum if (!($forum = $DB->get_record("forum", array("id" => $forum)))) { print_error('invalidforumid', 'forum'); } if (!($course = $DB->get_record("course", array("id" => $forum->course)))) { print_error('invalidcourseid'); }
$messages = $accessmanager->describe_rules(); if ($quiz->attempts != 1) { $messages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod)); } echo $OUTPUT->box_start('quizinfo'); $accessmanager->print_messages($messages); echo $OUTPUT->box_end(); /// Show number of attempts summary to those who can view reports. if (has_capability('mod/quiz:viewreports', $context)) { if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm)) { echo '<div class="quizattemptcounts"><a href="report.php?mode=overview&id=' . $cm->id . '">' . $strattemptnum . "</a></div>\n"; } } /// Guests can't do a quiz, so offer them a choice of logging in or going back. if (isguestuser()) { echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false)); echo $OUTPUT->footer(); exit; } /// If they are not enrolled in this course in a good enough role, tell them to enrol. if (!($canattempt || $canpreview || $canreviewmine)) { echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" . $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) . "</p>\n", 'generalbox', 'notice'); echo $OUTPUT->footer(); exit; } /// Get this user's attempts. $attempts = quiz_get_user_attempts($quiz->id, $USER->id); $lastfinishedattempt = end($attempts); $unfinished = false; if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) { $attempts[] = $unfinishedattempt;
define('CURSCRIPT', 'vote'); require_once './include/common.inc.php'; //update_session(); $aid = empty($_GET['aid']) ? $_POST['aid'] : $_GET['aid']; $aid = intval($aid); $query = $dblink->query("SELECT aid,qid FROM {$dbprefix}answer WHERE aid={$aid}"); if (!$dblink->num_rows($query)) { show_message('action_error', './'); exit; } $answer = $dblink->fetch_array($query); if ($cyask_uid) { $query = $dblink->query("SELECT count(*) FROM {$dbprefix}vote WHERE qid={$answer['qid']} AND uid={$cyask_uid}"); } else { $query = $dblink->query("SELECT count(*) FROM {$dbprefix}vote WHERE qid={$answer['qid']} AND uip='{$onlineip}'"); } if ($dblink->result($query, 0)) { $referer = get_referer(); show_message('vote_more', $referer); exit; } if (check_submit($_POST['votesubmit'], $_POST['formhash'])) { $dblink->query("INSERT INTO {$dbprefix}vote SET qid={$answer['qid']},aid={$aid},uid={$cyask_uid},uip='{$onlineip}'"); $dblink->query("UPDATE {$dbprefix}answer SET votevalue=votevalue+1 where aid={$aid}"); $referer = get_referer(); header("location:signal.php?resultno=112&url={$referer}"); exit; } else { show_message('url_error', './'); exit; }
/** * Will get called before the login page is shownr. Ff NTLM SSO * is enabled, and the user is in the right network, we'll redirect * to the magic NTLM page for SSO... * */ function loginpage_hook() { global $CFG, $SESSION; // HTTPS is potentially required //httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php if (($_SERVER['REQUEST_METHOD'] === 'GET' // Only on initial GET of loginpage || ($_SERVER['REQUEST_METHOD'] === 'POST' && (get_referer() != strip_querystring(qualified_me())))) // Or when POSTed from another place // See MDL-14071 && !empty($this->config->ntlmsso_enabled) // SSO enabled && !empty($this->config->ntlmsso_subnet) // have a subnet to test for && empty($_GET['authldap_skipntlmsso']) // haven't failed it yet && (isguestuser() || !isloggedin()) // guestuser or not-logged-in users && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) { // First, let's remember where we were trying to get to before we got here if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = (array_key_exists('HTTP_REFERER', $_SERVER) && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot.'/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot.'/login/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot.'/login/index.php') ? $_SERVER['HTTP_REFERER'] : NULL; } // Now start the whole NTLM machinery. if(!empty($this->config->ntlmsso_ie_fastpath)) { // Shortcut for IE browsers: skip the attempt page if(check_browser_version('MSIE')) { $sesskey = sesskey(); redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_magic.php?sesskey='.$sesskey); } else { redirect($CFG->httpswwwroot.'/login/index.php?authldap_skipntlmsso=1'); } } else { redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php'); } } // No NTLM SSO, Use the normal login page instead. // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login // page insists on redirecting us to that page after user validation. If // we clicked on the redirect link at the ntlmsso_finish.php page (instead // of waiting for the redirection to happen) then we have a 'Referer:' header // we don't want to use at all. As we can't get rid of it, just point // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there). if (empty($SESSION->wantsurl) && (get_referer() == $CFG->httpswwwroot.'/auth/ldap/ntlmsso_finish.php')) { $SESSION->wantsurl = $CFG->wwwroot; } }
/** * Redirect to referer * * @access public * @param string $alternative Alternative URL is used if referer is not valid URL * @return null */ function redirect_to_referer($alternative = nulls) { $referer = get_referer(); if (true || !is_valid_url($referer)) { if (is_ajax_request()) { $alternative = make_ajax_url($alternative); } redirect_to($alternative); } else { if (is_ajax_request()) { $referer = make_ajax_url($referer); } redirect_to($referer); } // if }
echo html_writer::tag('div', get_string('downloadingsize', 'block_community', $sizeinfo), array('class' => 'textinfo')); flush(); $filenames = $communitymanager->block_community_download_course_backup($course); echo html_writer::tag('div', get_string('downloaded', 'block_community'), array('class' => 'textinfo')); echo $OUTPUT->notification(get_string('downloadconfirmed', 'block_community', '/downloaded_backup/' . $filenames['privatefile']), 'notifysuccess'); echo $renderer->restore_confirmation_box($filenames['tmpfile'], $context); echo $OUTPUT->footer(); die; } /// Remove community $remove = optional_param('remove', '', PARAM_INTEGER); $communityid = optional_param('communityid', '', PARAM_INTEGER); if ($remove != -1 and !empty($communityid) and confirm_sesskey()) { $communitymanager->block_community_remove_course($communityid, $USER->id); echo $OUTPUT->header(); echo $renderer->remove_success(new moodle_url(get_referer(false))); echo $OUTPUT->footer(); die; } //Get form default/current values $fromformdata['coverage'] = optional_param('coverage', 'all', PARAM_TEXT); $fromformdata['licence'] = optional_param('licence', 'all', PARAM_ALPHANUMEXT); $fromformdata['subject'] = optional_param('subject', 'all', PARAM_ALPHANUMEXT); $fromformdata['audience'] = optional_param('audience', 'all', PARAM_ALPHANUMEXT); $fromformdata['language'] = optional_param('language', current_language(), PARAM_ALPHANUMEXT); $fromformdata['educationallevel'] = optional_param('educationallevel', 'all', PARAM_ALPHANUMEXT); $fromformdata['downloadable'] = optional_param('downloadable', 0, PARAM_ALPHANUM); $fromformdata['orderby'] = optional_param('orderby', 'newest', PARAM_ALPHA); $fromformdata['huburl'] = optional_param('huburl', HUB_MOODLEORGHUBURL, PARAM_URL); $fromformdata['search'] = $search; $fromformdata['courseid'] = $courseid;
} } } if ($questionnaire->is_active() && !$questionnaire->questions) { echo '<p>' . get_string('noneinuse', 'questionnaire') . '</p>'; } if ($questionnaire->is_active() && $questionnaire->capabilities->editquestions && !$questionnaire->questions) { // Sanity check. echo '<a href="' . $CFG->wwwroot . htmlspecialchars('/mod/questionnaire/questions.php?' . 'id=' . $questionnaire->cm->id) . '">' . '<strong>' . get_string('addquestions', 'questionnaire') . '</strong></a>'; } echo $OUTPUT->box_end(); if (isguestuser()) { $output = ''; $guestno = html_writer::tag('p', get_string('noteligible', 'questionnaire')); $liketologin = html_writer::tag('p', get_string('liketologin')); $output .= $OUTPUT->confirm($guestno . "\n\n" . $liketologin . "\n", get_login_url(), get_referer(false)); echo $output; } // Log this course module view. // Needed for the event logging. $context = context_module::instance($questionnaire->cm->id); $anonymous = $questionnaire->respondenttype == 'anonymous'; $event = \mod_questionnaire\event\course_module_viewed::create(array('objectid' => $questionnaire->id, 'anonymous' => $anonymous, 'context' => $context)); $event->trigger(); $usernumresp = $questionnaire->count_submissions($USER->id); if ($questionnaire->capabilities->readownresponses && $usernumresp > 0) { echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); $argstr = 'instance=' . $questionnaire->id . '&user='******'viewyourresponses', 'questionnaire', $usernumresp); } else {
/** * Will get called before the login page is shownr. Ff NTLM SSO * is enabled, and the user is in the right network, we'll redirect * to the magic NTLM page for SSO... * */ function loginpage_hook() { global $CFG, $SESSION; // HTTPS is potentially required //httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php if (($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST' && get_referer() != strip_querystring(qualified_me())) && !empty($this->config->ntlmsso_enabled) && !empty($this->config->ntlmsso_subnet) && empty($_GET['authldap_skipntlmsso']) && (isguestuser() || !isloggedin()) && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) { // First, let's remember where we were trying to get to before we got here if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = array_key_exists('HTTP_REFERER', $_SERVER) && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot && $_SERVER['HTTP_REFERER'] != $CFG->wwwroot . '/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot . '/login/' && $_SERVER['HTTP_REFERER'] != $CFG->httpswwwroot . '/login/index.php' ? $_SERVER['HTTP_REFERER'] : NULL; } // Now start the whole NTLM machinery. if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESATTEMPT || $this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { if (core_useragent::is_ie()) { $sesskey = sesskey(); redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey=' . $sesskey); } else { if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1'); } } } redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_attempt.php'); } // No NTLM SSO, Use the normal login page instead. // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login // page insists on redirecting us to that page after user validation. If // we clicked on the redirect link at the ntlmsso_finish.php page (instead // of waiting for the redirection to happen) then we have a 'Referer:' header // we don't want to use at all. As we can't get rid of it, just point // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there). if (empty($SESSION->wantsurl) && get_referer() == $CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php') { $SESSION->wantsurl = $CFG->wwwroot; } }
} else { $available = false; } // Show number of attempts summary to those who can view reports. if (has_capability('mod/quiz:viewreports', $context)) { if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm)) { echo '<div class="quizattemptcounts"><a href="report.php?mode=overview&id=' . $cm->id . '">' . $strattemptnum . '</a></div>'; } } // Guests can't do a quiz, so offer them a choice of logging in or going back. if (isguestuser()) { $loginurl = $CFG->wwwroot . '/login/index.php'; if (!empty($CFG->loginhttps)) { $loginurl = str_replace('http:', 'https:', $loginurl); } notice_yesno('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n</p>" . get_string('liketologin') . '</p>', $loginurl, get_referer(false)); finish_page($course); } if (!has_any_capability(array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt', 'mod/quiz:preview'), $context)) { print_box('<p>' . get_string('youneedtoenrol', 'quiz') . '</p><p>' . print_continue($CFG->wwwroot . '/course/view.php?id=' . $course->id, true) . '</p>', 'generalbox', 'notice'); finish_page($course); } // Get this user's attempts. $attempts = quiz_get_user_attempts($quiz->id, $USER->id); $unfinished = false; if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) { $attempts[] = $unfinishedattempt; $unfinished = true; } $numattempts = count($attempts); // Work out the final grade, checking whether it was overridden in the gradebook.
function kento_pvc_display($cont) { $kento_pvc_posttype = get_option('kento_pvc_posttype'); if ($kento_pvc_posttype == NULL) { $type = "none"; } else { $type = ""; foreach ($kento_pvc_posttype as $post_type => $post_type_value) { $type .= $post_type . ","; } } if (is_singular(explode(',', $type))) { $post_id = get_the_id(); $cookie_nam = "kentopvc_" . $post_id; if (isset($_COOKIE[$cookie_nam])) { $visited = "yes"; $kento_pvc_uniq = get_option('kento_pvc_uniq'); if (empty($kento_pvc_uniq)) { $visited = "no"; } } else { ?> <script> document.cookie="<?php echo $cookie_nam; ?> =yes"; </script> <?php $visited = "no"; } if ($visited == "yes") { } elseif ($visited == "no") { global $wpdb; $table = $wpdb->prefix . "kento_pvc"; $result = $wpdb->get_results("SELECT count FROM {$table} WHERE postid = {$post_id}", ARRAY_A); if (empty($result[0]['count'])) { $view_count = 0; } else { $view_count = $result[0]['count']; } $already_insert = $wpdb->num_rows; if ($already_insert > 0) { $wpdb->query("UPDATE {$table} SET count = count+1 WHERE postid = '{$post_id}'"); } else { $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t\t\t( id, postid, count )\r\n\t\t\t\t\t\t\t\tVALUES\t( %d, %d, %d )", array('', $post_id, 1))); } $date = date('Y-m-d', strtotime('+' . get_option('gmt_offset') . ' hour')); global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $result = $wpdb->get_results("SELECT * FROM {$table} WHERE date = '{$date}' AND postid = {$post_id}", ARRAY_A); $already_insert = $wpdb->num_rows; if ($already_insert > 0) { global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $wpdb->query("UPDATE {$table} SET count = count+1 WHERE (date = '{$date}') AND (postid = {$post_id})"); } else { global $wpdb; $table = $wpdb->prefix . "kento_pvc_info"; $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t\t\t( id, postid, count, date )\r\n\t\t\t\t\t\t\t\tVALUES\t( %d, %d, %d, %s)", array('', $post_id, 1, $date))); } $ip = $_SERVER['REMOTE_ADDR']; /* $content = file_get_contents("http://www.geoplugin.net/xml.gp?ip=".$ip); preg_match('/<geoplugin_city>(.*)/i', $content, $matches); $city = !empty($matches[1]) ? $matches[1] : 0; $city = substr($city,0,-17); if($city == "") { $city = "none"; } else { $city = $city; } preg_match('/<geoplugin_countryName>(.*)/i', $content, $matches); $country= !empty($matches[1]) ? $matches[1] : 0; $country = substr($country,0,-24); if($country == ""){ $country = "none";} else { $country = $country; } */ $geoplugin = new geoPlugin(); $geoplugin->locate(); $city = $geoplugin->city; $country = $geoplugin->countryName; if ($country == "") { $country = "none"; } else { $country = $country; } if ($city == "") { $city = "none"; } else { $city = $city; } global $wpdb; $table = $wpdb->prefix . "kento_pvc_city"; $post_id = get_the_id(); $datetime = date('Y-m-d H:i:s', strtotime('+' . get_option('gmt_offset') . ' hour')); $referer = get_referer($_SERVER["HTTP_REFERER"]); $wpdb->query($wpdb->prepare("INSERT INTO {$table} \r\n\t\t\t\t\t\t\t\t( id, postid, ip, city, country, datetime, referer )\r\n\t\t\t\t\t\tVALUES\t( %d, %d, %s, %s, %s, %s, %s)", array('', $post_id, $ip, $city, $country, $datetime, $referer))); } // end of $visited if global $wpdb; $table = $wpdb->prefix . "kento_pvc"; $result = $wpdb->get_results("SELECT count FROM {$table} WHERE postid = {$post_id}", ARRAY_A); if (empty($result[0]['count'])) { $view_count = 0; } else { $view_count = $result[0]['count']; } $kento_pvc_today_text = get_option('kento_pvc_today_text'); $kento_pvc_total_text = get_option('kento_pvc_total_text'); if (!empty($kento_pvc_today_text)) { $kento_pvc_today_text = $kento_pvc_today_text; } else { $kento_pvc_today_text = "Views Today "; } if (!empty($kento_pvc_total_text)) { $kento_pvc_total_text = $kento_pvc_total_text; } else { $kento_pvc_total_text = "Total Views "; } $cont .= "<div id='kento-pvc'><span class='kento-pvc-total'> " . kento_pvc_convert_lang($view_count) . " " . $kento_pvc_total_text . "</span> <span class='kento-pvc-today'>" . kento_pvc_convert_lang(kento_pvc_today_total()) . " " . $kento_pvc_today_text . "</span>"; $cont .= "</div>"; return $cont; } else { return $cont; } }