ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
errorreport.php
Go to the documentation of this file.
1<?php
2
3require_once('_include.php');
4
6
7// this page will redirect to itself after processing a POST request and sending the email
8if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
9 // the message has been sent. Show error report page
10
11 $t = new SimpleSAML_XHTML_Template($config, 'errorreport.php', 'errors');
12 $t->show();
13 exit;
14}
15
16$reportId = (string) $_REQUEST['reportId'];
17$email = (string) $_REQUEST['email'];
18$text = htmlspecialchars((string) $_REQUEST['text']);
19
20$data = null;
21try {
23 $data = $session->getData('core:errorreport', $reportId);
24} catch (Exception $e) {
25 SimpleSAML\Logger::error('Error loading error report data: '.var_export($e->getMessage(), true));
26}
27
28if ($data === null) {
29 $data = array(
30 'exceptionMsg' => 'not set',
31 'exceptionTrace' => 'not set',
32 'reportId' => $reportId,
33 'trackId' => 'not set',
34 'url' => 'not set',
35 'version' => $config->getVersion(),
36 'referer' => 'not set',
37 );
38
39 if (isset($session)) {
40 $data['trackId'] = $session->getTrackID();
41 }
42}
43
44foreach ($data as $k => $v) {
45 $data[$k] = htmlspecialchars($v);
46}
47
48// build the email message
49$message = <<<MESSAGE
50<h1>SimpleSAMLphp Error Report</h1>
51
52<p>Message from user:</p>
53<div class="box" style="background: yellow; color: #888; border: 1px solid #999900; padding: .4em; margin: .5em">
54 %s
55</div>
56
57<p>Exception: <strong>%s</strong></p>
58<pre>%s</pre>
59
60<p>URL:</p>
61<pre><a href="%s">%s</a></pre>
62
63<p>Host:</p>
64<pre>%s</pre>
65
66<p>Directory:</p>
67<pre>%s</pre>
68
69<p>Track ID:</p>
70<pre>%s</pre>
71
72<p>Version: <tt>%s</tt></p>
73
74<p>Report ID: <tt>%s</tt></p>
75
76<p>Referer: <tt>%s</tt></p>
77
78<hr />
79<div class="footer">
80 This message was sent using SimpleSAMLphp. Visit the <a href="http://simplesamlphp.org/">SimpleSAMLphp homepage</a>.
81</div>
82MESSAGE;
85 htmlspecialchars($text),
86 $data['exceptionMsg'],
87 $data['exceptionTrace'],
88 $data['url'],
89 $data['url'],
90 htmlspecialchars(php_uname('n')),
91 dirname(dirname(__FILE__)),
92 $data['trackId'],
93 $data['version'],
94 $data['reportId'],
95 $data['referer']
96);
97
98// add the email address of the submitter as the Reply-To address
99$email = trim($email);
100
101// check that it looks like a valid email address
102if (!preg_match('/\s/', $email) && strpos($email, '@') !== false) {
103 $replyto = $email;
104 $from = $email;
105} else {
106 $replyto = null;
107 $from = 'no-reply@simplesamlphp.org';
108}
109
110// send the email
111$toAddress = $config->getString('technicalcontact_email', 'na@example.org');
112if ($config->getBoolean('errorreporting', true) && $toAddress !== 'na@example.org') {
113 $email = new SimpleSAML_XHTML_EMail($toAddress, 'SimpleSAMLphp error report', $from);
114 $email->setBody($message);
115 $email->send();
116 SimpleSAML\Logger::error('Report with id '.$reportId.' sent to <'.$toAddress.'>.');
117}
118
119// redirect the user back to this page to clear the POST request
120\SimpleSAML\Utils\HTTP::redirectTrustedURL(\SimpleSAML\Utils\HTTP::getSelfURLNoQuery());
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
static error($string)
Definition: Logger.php:168
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
Definition: HTTP.php:962
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
static getSessionFromRequest()
Retrieves the current session.
Definition: Session.php:243
Attribute-related utility methods.
Temporary autoloader to ensure compatibility with old, non-PSR-2 compliant classes.
$session
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$from
if($_SERVER['REQUEST_METHOD'] !=='POST') $reportId
Definition: errorreport.php:16
$config
Definition: errorreport.php:5
$data
Definition: errorreport.php:20
catch(Exception $e) if( $data===null) foreach($data as $k=> $v) $message
Definition: errorreport.php:49
$email
Definition: errorreport.php:17
$text
Definition: errorreport.php:18
$toAddress