Merge branch 'MDL-47755_master' of https://github.com/totara/openbadges
[moodle.git] / error / index.php
blob54f0b53e22b6224b18e3e9ca264de1cdbaefa7ca
1 <?php
3 require('../config.php');
4 require_once($CFG->libdir.'/eventslib.php');
6 // Form submitted, do not check referer (original page unknown).
7 if ($form = data_submitted()) {
8 // Only deal with real users.
9 if (!isloggedin()) {
10 redirect($CFG->wwwroot);
13 // Send the message and redirect.
14 $eventdata = new stdClass();
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 = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
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();