"docs/simplesamlphp-maintenance.md" did not exist on "e2ac43922fcb89932a3215254e17a9c54ba9f519"
Newer
Older
<?php
require_once('_include.php');
$config = \SimpleSAML\Configuration::getInstance();
Jaime Perez Crespo
committed
// this page will redirect to itself after processing a POST request and sending the email
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
// the message has been sent. Show error report page
$t = new \SimpleSAML\XHTML\Template($config, 'errorreport.twig');
Jaime Perez Crespo
committed
exit;
}
$reportId = $_REQUEST['reportId'];
$email = $_REQUEST['email'];
$text = $_REQUEST['text'];
if (!preg_match('/^[0-9a-f]{8}$/', $reportId)) {
throw new \SimpleSAML\Error\Exception('Invalid reportID');
}
Jaime Perez Crespo
committed
$data = null;
$session = \SimpleSAML\Session::getSessionFromRequest();
Jaime Perez Crespo
committed
$data = $session->getData('core:errorreport', $reportId);
} catch (\Exception $e) {
\SimpleSAML\Logger::error('Error loading error report data: ' . var_export($e->getMessage(), true));
Jaime Perez Crespo
committed
if ($data === null) {
Jaime Perez Crespo
committed
'exceptionMsg' => 'not set',
'exceptionTrace' => 'not set',
'trackId' => 'not set',
'url' => 'not set',
'referer' => 'not set',
Jaime Perez Crespo
committed
if (isset($session)) {
$data['trackId'] = $session->getTrackID();
}
$data['reportId'] = $reportId;
$data['version'] = $config->getVersion();
$data['hostname'] = php_uname('n');
$data['directory'] = dirname(dirname(__FILE__));
Olav Morken
committed
if ($config->getOptionalBoolean('errorreporting', true)) {
$mail = new SimpleSAML\Utils\EMail('SimpleSAMLphp error report from ' . $email);
if ($email) {
$mail->addReplyTo($email);
}
$mail->setText($text);
$mail->send();
SimpleSAML\Logger::error('Report with id ' . $reportId . ' sent');
}
Jaime Perez Crespo
committed
// redirect the user back to this page to clear the POST request
$httpUtils = new \SimpleSAML\Utils\HTTP();
$httpUtils->redirectTrustedURL($httpUtils->getSelfURLNoQuery());