<?php
namespace wcf\system\exception;
use wcf\system\WCF;
+use wcf\util\StringUtil;
/**
* A logged exceptions prevents information disclosures and provides an easy
* way to log errors.
*
- * @author Alexander Ebert
- * @copyright 2001-2011 WoltLab GmbH
+ * @author Tim Düsterhus, Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.exception
}
$e = ($this->getPrevious() ?: $this);
- // build message
- $message = date('r', TIME_NOW) . "\n" . $e->getMessage() . "\n\n" . $e->getTraceAsString() . "\n\n\n";
+
+ $message = date('r', TIME_NOW)."\n".
+ 'Message: '.$e->getMessage()."\n".
+ 'File: '.$e->getFile().' ('.$e->getLine().")\n".
+ 'PHP version: '.phpversion()."\n".
+ 'WCF version: '.WCF_VERSION."\n".
+ 'Request URI: '.(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '')."\n".
+ 'Referrer: '.(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')."\n".
+ "Stacktrace: \n ".implode("\n ", explode("\n", $e->getTraceAsString()))."\n";
+
+ // calculate Exception-ID
+ $id = StringUtil::getHash($message);
+ $message = "<<<<<<<<".$id."<<<<\n".$message."<<<<\n\n";
// append
@file_put_contents($logFile, $message, FILE_APPEND);
+
+ return $id;
}
}
*/
public function show() {
// log error
- $this->logError();
+ $exceptionID = $this->logError();
// send status code
@header('HTTP/1.1 503 Service Unavailable');
<?php if (WCF::debugModeIsEnabled()) { ?>
<div>
<p><?php echo $this->getDescription(); ?></p>
-
+
<h2>Information:</h2>
<p>
+ <b>id:</b> <code><?php echo $exceptionID; ?></code><br>
<b>error message:</b> <?php echo StringUtil::encodeHTML($this->_getMessage()); ?><br>
<b>error code:</b> <?php echo intval($e->getCode()); ?><br>
<?php echo $this->information; ?>
<b>request:</b> <?php if (isset($_SERVER['REQUEST_URI'])) echo StringUtil::encodeHTML($_SERVER['REQUEST_URI']); ?><br>
<b>referer:</b> <?php if (isset($_SERVER['HTTP_REFERER'])) echo StringUtil::encodeHTML($_SERVER['HTTP_REFERER']); ?><br>
</p>
-
+
<h2>Stacktrace:</h2>
<pre><?php echo StringUtil::encodeHTML($this->__getTraceAsString()); ?></pre>
</div>
+ <?php } else { ?>
+ <div>
+ <h2>Information:</h2>
+ <p>
+ <b>id:</b> <code><?php echo $exceptionID; ?></code><br>
+ Send this ID to the administrator of this website to report this issue.
+ </p>
+ </div>
<?php } ?>
-
+
<?php echo $this->functions; ?>
</div>
</body>