aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/elgglib.php59
-rw-r--r--engine/lib/input.php16
-rw-r--r--engine/start.php25
-rw-r--r--views/default/messages/errors/exception.php27
4 files changed, 84 insertions, 43 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index d8065a84a..63baf16d5 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -123,7 +123,7 @@
*/
function get_library_files($directory, $file_exceptions = array(), $file_list = array()) {
- if (is_file($directory)) {
+ if (is_file($directory) && !in_array($directory,$file_exceptions)) {
$file_list[] = $directory;
} else if ($handle = opendir($directory)) {
while ($file = readdir($handle)) {
@@ -346,19 +346,23 @@
}
return false;
}
+
+ /**
+ * Error handling
+ */
- /**
- * PHP Error handler function.
- * This function acts as a wrapper to catch and report PHP error messages.
- *
- * @see http://uk3.php.net/set-error-handler
- * @param unknown_type $errno
- * @param unknown_type $errmsg
- * @param unknown_type $filename
- * @param unknown_type $linenum
- * @param unknown_type $vars
- */
- function __php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
+ /**
+ * PHP Error handler function.
+ * This function acts as a wrapper to catch and report PHP error messages.
+ *
+ * @see http://www.php.net/set-error-handler
+ * @param int $errno The level of the error raised
+ * @param string $errmsg The error message
+ * @param string $filename The filename the error was raised in
+ * @param int $linenum The line number the error was raised at
+ * @param array $vars An array that points to the active symbol table at the point that the error occurred
+ */
+ function __elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
{
$error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file " . $filename . " (line " . $linenum . ")";
@@ -374,17 +378,30 @@
case E_WARNING :
case E_USER_WARNING :
error_log("WARNING: " . $error);
- register_error("WARNING: " . $error);
+ // register_error("WARNING: " . $error);
break;
default:
error_log("DEBUG: " . $error);
- register_error("DEBUG: " . $error);
- }
+ // register_error("DEBUG: " . $error);
+ }
+
+ return true;
+ }
+
+ /**
+ * Custom exception handler.
+ * This function catches any thrown exceptions and handles them appropriately.
+ *
+ * @see http://www.php.net/set-exception-handler
+ * @param Exception $exception The exception being handled
+ */
+
+ function __elgg_php_exception_handler($exception) {
+
+ $body = elgg_view("messages/errors/exception",array('object' => $exception));
+ echo elgg_view("pageshell", array("title" => "Exception", "body" => $body));
+
}
-
-
- // Register the error handler
- error_reporting(E_ALL);
- set_error_handler('__php_error_handler');
+
?> \ No newline at end of file
diff --git a/engine/lib/input.php b/engine/lib/input.php
index c62539f49..c1b575e64 100644
--- a/engine/lib/input.php
+++ b/engine/lib/input.php
@@ -12,20 +12,20 @@
*/
/**
- * Get some input from passed variables.
+ * Get some input from variables passed on the GET or POST line.
*
* @param $variable string The variable we want to return.
* @param $default mixed A default value for the variable if it is not found.
*/
function get_input($variable, $default = "")
{
-
-
- // TODO: Some nice filtering here
- if (isset($_REQUEST[$variable]))
- return trim($_REQUEST[$variable]);
-
- return $default;
+ if (isset($_REQUEST[$variable])) {
+ $value = $_REQUEST[$variable];
+ return trim($_REQUEST[$variable]);
+ }
+
+ return $default;
+
}
?> \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index 412081a93..03274ae4b 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -24,7 +24,15 @@
if (!@include_once(dirname(__FILE__) . "/lib/elgglib.php")) { // Main Elgg library
throw new InstallationException("Could not load the main Elgg library.");
}
-
+
+ /**
+ * Establish handlers
+ */
+
+ // Register the error handler
+ set_error_handler('__elgg_php_error_handler');
+ set_exception_handler('__elgg_php_exception_handler');
+
/**
* Load the system settings
*/
@@ -58,7 +66,7 @@
$file_exceptions = array(
'.','..',
'.svn',
- 'CVS',
+ 'CVS','cvs',
'settings.php','settings.example.php','elgglib.php','database.php'
);
@@ -82,16 +90,5 @@
// Trigger events
trigger_event('init', 'system');
-
-
-// TODO: Have the View catch and render any exceptions
- // If we have load errors, display them
-/* if ($count = count_messages("errors")) {
- echo elgg_view('pageshell', array(
- 'title' => "Elgg isn't ready to run just yet.",
- 'body' => elgg_view('messages/errors/list',array('object' => system_messages(null, "errors")))
- ));
- exit;
- }
-*/
+
?> \ No newline at end of file
diff --git a/views/default/messages/errors/exception.php b/views/default/messages/errors/exception.php
new file mode 100644
index 000000000..8973db714
--- /dev/null
+++ b/views/default/messages/errors/exception.php
@@ -0,0 +1,27 @@
+<?php
+
+ /**
+ * Elgg exception
+ * Displays a single exception
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ *
+ * @uses $vars['object'] An exception
+ */
+
+?>
+
+ <p class="messages-exception">
+ <span title="<?php echo get_class($vars['object']); ?>">
+ <?php
+
+ echo nl2br($vars['object']->getMessage());
+
+ ?>
+ </span>
+ </p> \ No newline at end of file