Commit 9bd697b5 authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie

Cleaned up and fixed some bugs in the error reporting. Now critical

errors that happen during ensure_sanity are output to the screen and
look a lot better
parent ae20ffa0
......@@ -42,7 +42,8 @@ $string['magicquotessybase'] = 'You have dangerous PHP settings, magic_quotes_sy
$string['safemodeon'] = '<p>Your server appears to be running safe mode. Mahara does not support running in safe mode. You must turn this off in either the php.ini file, or in your apache config for the site.</p><p>If you are on shared hosting, it is likely that there is little you can do to get safe_mode turned off, other than ask your hosting provider. Perhaps you could consider moving to a different host.</p>';
$string['datarootinsidedocroot'] = 'You have set up your data root to be inside your document root. This is a large security problem, as then anyone can directly request session data (in order to hijack other peoples\' sessions), or files that they are not allowed to access that other people have uploaded. Please configure the data root to be outside of the document root.';
$string['datarootnotwritable'] = 'Your defined data root directory, %s, is not writable. This means that neither session data, user files nor anything else that needs to be uploaded can be saved on your server. Please make the directory if it does not exist, or give ownership of the directory to the web server user if it does';
$string['datarootnotwritable'] = 'Your defined data root directory, <tt>%s</tt>, is not writable. This means that neither session data, user files nor anything else that needs to be uploaded can be saved on your server. Please make the directory if it does not exist, or give ownership of the directory to the web server user if it does.';
$string['couldnotmakedatadirectories'] = 'For some reason some of the core data directories could not be created. This should not happen, as Mahara previously detected that the dataroot directory was writable. Please check the permissions on the dataroot directory.';
$string['dbconnfailed'] = 'Failed to connect to database, error message was %s';
......
......@@ -378,7 +378,6 @@ function error ($code, $message, $file, $line, $vars) {
function exception (Exception $e) {
global $USER;
if ($USER) {
$logged = false;
if (!($e instanceof MaharaException) || get_class($e) == 'MaharaException') {
log_warn("An exception was thrown of class " . get_class($e) . ". \nTHIS IS BAD "
. "and should be changed to something extending MaharaException,\n"
......@@ -388,12 +387,8 @@ function exception (Exception $e) {
$e = new SystemException($e->getMessage());
$e->set_log_off();
}
$e->handle_exception($logged);
}
else {
log_message($e->getMessage(), LOG_LEVEL_WARN, true, true, $e->getFile(), $e->getLine(), $e->getTrace());
}
$e->handle_exception();
}
......@@ -461,7 +456,7 @@ class MaharaException extends Exception {
public function handle_exception() {
if (!empty($this->log)) {
log_message($message, LOG_LEVEL_WARN, true, true, $this->getFile(), $this->getLine(), $this->getTrace());
log_message($this->getMessage(), LOG_LEVEL_WARN, true, true, $this->getFile(), $this->getLine(), $this->getTrace());
}
if (defined('JSON')) { // behave differently
......@@ -488,6 +483,31 @@ class MaharaException extends Exception {
<head>
<title>$outputtitle</title>
<style type="text/css">
html {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}
body {
width: 600px;
margin: 100px auto;
font-size: 12px;
}
h1 {
color: #547c22;
font-size: 20px;
font-weight: normal;
margin: 0 0 5px 0;
padding: 0;
text-transform: capitalize;
border-bottom: 1px solid #819f18;
text-align: center;
}
#message {
width: 90%;
margin: 0 auto;
text-align: justify;
}
#reason {
margin: 0 3em;
}
......@@ -500,8 +520,7 @@ EOF;
}
echo <<<EOF
<h1>$outputtitle</h1>
$outputmessage
<hr>
<div id="message">$outputmessage</div>
</body>
</html>
EOF;
......
......@@ -120,11 +120,12 @@ function ensure_sanity() {
throw new ConfigSanityException(get_string('datarootnotwritable', 'error', get_config('dataroot')));
}
// @todo the results of these should be checked
check_dir_exists(get_config('dataroot') . 'smarty/compile');
check_dir_exists(get_config('dataroot') . 'smarty/cache');
check_dir_exists(get_config('dataroot') . 'templates');
if (
!check_dir_exists(get_config('dataroot') . 'smarty/compile') ||
!check_dir_exists(get_config('dataroot') . 'smarty/cache') ||
!check_dir_exists(get_config('dataroot') . 'templates')) {
throw new ConfigSanityException(get_string('couldnotmakedatadirectories', 'error'));
}
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment