Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/error/ -> index.php (source)
<?php
> // This file is part of Moodle - http://moodle.org/ > // require('../config.php'); > // Moodle is free software: you can redistribute it and/or modify > // it under the terms of the GNU General Public License as published by // Form submitted, do not check referer (original page unknown). > // the Free Software Foundation, either version 3 of the License, or if ($form = data_submitted()) { > // (at your option) any later version. // Only deal with real users. > // if (!isloggedin()) { > // Moodle is distributed in the hope that it will be useful, redirect($CFG->wwwroot); > // but WITHOUT ANY WARRANTY; without even the implied warranty of } > // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > // GNU General Public License for more details. // Send the message and redirect. > // $eventdata = new \core\message\message(); > // You should have received a copy of the GNU General Public License $eventdata->courseid = SITEID; > // along with Moodle. If not, see <http://www.gnu.org/licenses/>. $eventdata->component = 'moodle'; > $eventdata->name = 'errors'; > /** $eventdata->userfrom = $USER; > * Moodle 404 Error page $eventdata->userto = core_user::get_support_user(); > * $eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested; > * This is for 404 error pages served by the webserver and then passed $eventdata->fullmessage = $form->text; > * to Moodle to be rendered using the site theme. $eventdata->fullmessageformat = FORMAT_PLAIN; > * $eventdata->fullmessagehtml = ''; > * ErrorDocument 404 /error/index.php $eventdata->smallmessage = ''; > * message_send($eventdata); > * @package core > * @copyright 2020 Brendan Heywood <brendan@catalyst-au.net> redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3); > * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later exit; > */
}
> // @codingStandardsIgnoreStart
> // @codingStandardsIgnoreEnd
< // Form submitted, do not check referer (original page unknown). < if ($form = data_submitted()) { < // Only deal with real users. < if (!isloggedin()) {
> $context = context_system::instance(); > $title = get_string('pagenotexisttitle', 'error'); > $PAGE->set_url('/error/index.php'); > $PAGE->set_context($context); > $PAGE->set_title($title); > $PAGE->set_heading($title); > $PAGE->navbar->add($title); > > $canmessage = has_capability('moodle/site:senderrormessage', $context); > > $supportuser = core_user::get_support_user(); > > // We can only message support if both the user has the capability > // and the support user is a real user. > if ($canmessage) { > $canmessage = core_user::is_real_user($supportuser->id); > } > > $mform = new \core\form\error_feedback($CFG->wwwroot . '/error/index.php'); > > if ($data = $mform->get_data()) { > > if (!$canmessage) {
< $eventdata = new \core\message\message(); < $eventdata->courseid = SITEID; < $eventdata->component = 'moodle'; < $eventdata->name = 'errors'; < $eventdata->userfrom = $USER; < $eventdata->userto = core_user::get_support_user(); < $eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested; < $eventdata->fullmessage = $form->text; < $eventdata->fullmessageformat = FORMAT_PLAIN; < $eventdata->fullmessagehtml = ''; < $eventdata->smallmessage = ''; < message_send($eventdata);
> $message = new \core\message\message(); > $message->courseid = SITEID; > $message->component = 'moodle'; > $message->name = 'errors'; > $message->userfrom = $USER; > $message->userto = core_user::get_support_user(); > $message->subject = 'Error: '. $data->referer .' -> '. $data->requested; > $message->fullmessage = $data->text; > $message->fullmessageformat = FORMAT_PLAIN; > $message->fullmessagehtml = ''; > $message->smallmessage = ''; > $message->contexturl = $data->requested; > message_send($message);
< redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
> redirect($CFG->wwwroot, get_string('sendmessagesent', 'error', $data->requested), 5);
< $site = get_site(); < $redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL']; < $httpreferer = get_local_referer(false); < $requesturi = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI']; < < header("HTTP/1.0 404 Not Found"); < header("Status: 404 Not Found"); < < $PAGE->set_url('/error/'); < $PAGE->set_context(context_system::instance()); < $PAGE->set_title($site->fullname .':Error'); < $PAGE->set_heading($site->fullname .': Error 404'); < $PAGE->navbar->add('Error 404 - File not Found');
< echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
> echo $OUTPUT->notification(get_string('pagenotexist', 'error', s($ME)), 'error');
< if (isloggedin()) { < ?> < <p><?php echo get_string('pleasereport', 'error'); ?> < <p><form action="<?php echo $CFG->wwwroot ?>/error/index.php" method="post"> < <textarea rows="3" cols="50" name="text" id="text" spellcheck="true"></textarea><br /> < <input type="hidden" name="referer" value="<?php p($httpreferer) ?>"> < <input type="hidden" name="requested" value="<?php p($requesturi) ?>"> < <input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?>"> < </form> < <?php
> if (!empty($CFG->supportpage)) { > echo \html_writer::tag('h4', get_string('supportpage', 'admin')); > $link = \html_writer::link($CFG->supportpage, $CFG->supportpage); > echo \html_writer::tag('p', $link); > } > if (!empty($CFG->supportemail)) { > echo \html_writer::tag('h4', get_string('supportemail', 'admin')); > $link = \html_writer::link('mailto:' . $CFG->supportemail, $CFG->supportemail); > echo \html_writer::tag('p', $link); > } > > if ($canmessage) { > echo \html_writer::tag('h4', get_string('sendmessage', 'error')); > $mform->display();
>
< ?>
>