Merge branch 'install_master' of https://git.in.moodle.com/amosbot/moodle-install
[moodle.git] / error / index.php
blobdbb69cd3c0ecb6c4203e62a0f874b61ca82be32b
1 <?php
3 require('../config.php');
5 // Form submitted, do not check referer (original page unknown).
6 if ($form = data_submitted()) {
7 // Only deal with real users.
8 if (!isloggedin()) {
9 redirect($CFG->wwwroot);
12 // Send the message and redirect.
13 $eventdata = new \core\message\message();
14 $eventdata->courseid = SITEID;
15 $eventdata->component = 'moodle';
16 $eventdata->name = 'errors';
17 $eventdata->userfrom = $USER;
18 $eventdata->userto = core_user::get_support_user();
19 $eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested;
20 $eventdata->fullmessage = $form->text;
21 $eventdata->fullmessageformat = FORMAT_PLAIN;
22 $eventdata->fullmessagehtml = '';
23 $eventdata->smallmessage = '';
24 message_send($eventdata);
26 redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
27 exit;
30 $site = get_site();
31 $redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL'];
32 $httpreferer = get_local_referer(false);
33 $requesturi = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI'];
35 header("HTTP/1.0 404 Not Found");
36 header("Status: 404 Not Found");
38 $PAGE->set_url('/error/');
39 $PAGE->set_context(context_system::instance());
40 $PAGE->set_title($site->fullname .':Error');
41 $PAGE->set_heading($site->fullname .': Error 404');
42 $PAGE->navbar->add('Error 404 - File not Found');
43 echo $OUTPUT->header();
44 echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
46 if (isloggedin()) {
48 <p><?php echo get_string('pleasereport', 'error'); ?>
49 <p><form action="<?php echo $CFG->wwwroot ?>/error/index.php" method="post">
50 <textarea rows="3" cols="50" name="text" id="text" spellcheck="true"></textarea><br />
51 <input type="hidden" name="referer" value="<?php p($httpreferer) ?>">
52 <input type="hidden" name="requested" value="<?php p($requesturi) ?>">
53 <input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?>">
54 </form>
55 <?php
56 } else {
57 echo $OUTPUT->continue_button($CFG->wwwroot);
59 echo $OUTPUT->footer();