forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
73 lines (62 loc) · 2.98 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require('../config.php');
require_once($CFG->libdir.'/eventslib.php');
if ($form = data_submitted()) { // form submitted, do not check referer (original page unknown)!
/// Only deal with real users
if (!isloggedin()) {
redirect($CFG->wwwroot);
}
/// Work out who to send the message to
if (!$admin = get_admin() ) {
print_error('cannotfindadmin', 'debug');
}
$supportuser = new stdClass();
$supportuser->email = $CFG->supportemail ? $CFG->supportemail : $admin->email;
$supportuser->firstname = $CFG->supportname ? $CFG->supportname : $admin->firstname;
$supportuser->lastname = $CFG->supportname ? '' : $admin->lastname;
// emailstop could be hard coded "false" to ensure error reports are sent
// but then admin's would have to alter their messaging preferences to temporarily stop them
$supportuser->emailstop = $admin->emailstop;
$supportuser->maildisplay = true;
/// Send the message and redirect
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = $USER;
$eventdata->userto = $supportuser;
$eventdata->subject = 'Error: '. $form->referer .' -> '. $form->requested;
$eventdata->fullmessage = $form->text;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
exit;
}
$site = get_site();
$redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL'];
$httpreferer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
$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_title($site->fullname .':Error');
$PAGE->set_heading($site->fullname .': Error 404');
$PAGE->set_context(get_system_context());
$PAGE->navbar->add('Error 404 - File not Found');
echo $OUTPUT->header();
echo $OUTPUT->box(get_string('pagenotexist', 'error'). '<br />'.s($requesturi), 'generalbox boxaligncenter');
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
} else {
echo $OUTPUT->continue_button($CFG->wwwroot);
}
echo $OUTPUT->footer();
?>