From 7eac1fc242ef95f06c2ba75c16a49191af9e0d38 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 30 Apr 2011 18:52:04 +1000 Subject: [PATCH] added an error handling thing and started on custom fields --- inc/functions.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 3830e90a..c23168d9 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -94,6 +94,31 @@ if($config['memcached']['enabled']) memcached_open(); + + // Test custom fields and stuff + if(isset($config['fields'])) { + $error_func = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; + + foreach($config['fields'] as $index => $field) { + if(!is_array($field)) + $error_func(sprintf("Error parsing custom fields. Field at index %d is not an array!", $index)); + if(!isset($field['name'])) + $error_func(sprintf("Error parsing custom fields. Field at index %d doesn't have a name!", $index)); + } + } + } + + function basic_error_function_because_the_other_isnt_loaded_yet($message) { + if(function_exists('sql_close')) sql_close(); + // Yes, this is horrible. + die('Error' . + '' . + '

Error

' . $message . '
' . + '

This alternative error page is being displayed because the other couldn\'t be found or hasn\'t loaded yet.

'); } function fatal_error_handler() {