diff --git a/config/config.ini b/config/config.ini
index 7d83893..533fffb 100644
--- a/config/config.ini
+++ b/config/config.ini
@@ -362,3 +362,10 @@ warningThreshold=10
; the disk usage dashlet will will highlight the mount in RED
urgentThreshold=5
+[CustomErrorMessages]
+;Turn custom error messages on or off here // account wide
+customerrormessages=on
+;name or url of custom error page
+customerrorpagepath=customerrorpage.php
+;Turn custom error handler on or off
+customerrorhandler=on
\ No newline at end of file
diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php
index 5779baa..e23a361 100644
--- a/config/dmsDefaults.php
+++ b/config/dmsDefaults.php
@@ -353,8 +353,20 @@ class KTInit {
}
return false;
}
+
// }}}
+function catchFatalErrors($p_OnOff='On'){
+ ini_set('display_errors','On');
+ $phperror='>
';
+ ini_set('error_prepend_string',$phperror);
+
+ $phperror='
>
+ ';
+ ini_set('error_append_string',$phperror);
+}
+
+
// {{{ guessRootUrl()
function guessRootUrl() {
@@ -595,6 +607,9 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc');
require_once(KT_LIB_DIR . '/ktentity.inc');
+$KTInit->catchFatalErrors();
+
+
require_once(KT_LIB_DIR . '/config/config.inc.php');
require_once(KT_DIR . '/search2/indexing/indexerCore.inc.php');
diff --git a/customerrorpage.php b/customerrorpage.php
new file mode 100644
index 0000000..e28a938
--- /dev/null
+++ b/customerrorpage.php
@@ -0,0 +1,48 @@
+
+
+
+
+ Knowledgetree - Desklet
+
+
+
+
+
+
+
+
+
+
+
+
+
Error!! - You have encountered a problem starting your document management system.
+
Please contact your systems administrator
+
For more details, click here
+
+
+
+
+
+
\ No newline at end of file
diff --git a/error_01.gif b/error_01.gif
new file mode 100644
index 0000000..3f7dfbf
--- /dev/null
+++ b/error_01.gif
diff --git a/errors.css b/errors.css
new file mode 100644
index 0000000..f5da2d6
--- /dev/null
+++ b/errors.css
@@ -0,0 +1,43 @@
+div#error-container {
+ width: 500px;
+ color: #555;
+ font-size: 11px;
+ font-family: Verdana, Arial, sans-serif;
+}
+div#error-container div {
+ height: 140px;
+}
+div#error-container h1 {
+ font-weight: lighter;
+ font-size: 22px;
+ margin-left: 100px;
+}
+div#error-container p {
+ margin-left: 100px;
+}
+
+ div#acc-error {
+ background: transparent url(error_01.gif) no-repeat top left;
+ }
+ div#acc-suspend {
+ background: transparent url(error_02.gif) no-repeat top left;
+ }
+ div#acc-maint {
+ background: transparent url(error_03.gif) no-repeat top left;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php
index 0c7f34e..dd8aa19 100644
--- a/lib/dispatcher.inc.php
+++ b/lib/dispatcher.inc.php
@@ -538,6 +538,39 @@ class KTErrorDispatcher extends KTStandardDispatcher {
function dispatch() {
require_once(KT_LIB_DIR . '/validation/errorviewer.inc.php');
+ require_once(KT_LIB_DIR . '/validation/customerrorviewer.inc.php');
+
+ $oCustomViewer =& KTCustomErrorViewer::initCustomErrorViewer();
+
+ //if the custom error messages are set to 'on' in the config file
+ //we check if the error page exists and redirect to it if it does.
+ //if either the page doesn't exit or the custom error option is off in the config file
+ //we carry out default error reporting
+ if ($oCustomViewer->getCustomErrorConfigSetting() == 'on'){
+ $CustomErrorPage = $oCustomViewer->getCustomErrorRedirectPage();
+ if ( $CustomErrorPage != '0') //if an error is not returned from getCustomErrorRedirectPage();
+ {
+ $sErrorHandler = $oCustomViewer->getCustomErrorHandlerSetting();
+
+ //redirect
+ if ($sErrorHandler == 'on')
+ {
+ //if custom error handler is set to on inside config.ini then send error object with error page
+ $oCustomViewer->doCustomErrorPageRedirect($CustomErrorPage, $this->oError);
+ }
+ else if ($sErrorHandler != 'on')
+ {
+ //if custom error handler is set to off inside config.ini then just send error page
+ $oCustomViewer->doCustomErrorPageRedirect($CustomErrorPage);
+ }
+
+ //exit without errors
+ exit(0);
+ }
+ }
+
+ //if either customer error messages is off or the custom error page doesn't exist the function will run
+ //the default error handling here
$oRegistry =& KTErrorViewerRegistry::getSingleton();
$oViewer =& $oRegistry->getViewer($this->oError);
$this->oPage->setTitle($oViewer->view());
diff --git a/lib/validation/customerrorhandler.php b/lib/validation/customerrorhandler.php
new file mode 100644
index 0000000..aaa5cbf
--- /dev/null
+++ b/lib/validation/customerrorhandler.php
@@ -0,0 +1,63 @@
+toString(),1,2) == 'db')
+ {
+ $sErrorType = 'database_error';
+ }
+ else
+ {
+ $sErrorType = 'unknown_error';
+ }
+
+
+ $default->log->error($oError->toString());
+
+ }
+ }
+ ?>
\ No newline at end of file
diff --git a/lib/validation/customerrorviewer.inc.php b/lib/validation/customerrorviewer.inc.php
new file mode 100644
index 0000000..1cb6478
--- /dev/null
+++ b/lib/validation/customerrorviewer.inc.php
@@ -0,0 +1,129 @@
+get('CustomErrorMessages/customerrormessages');
+ return $sCustomErrorCheck;
+ }
+ //}}}
+
+ //{{{ getCustomErrorHandlerSetting()
+ function getCustomErrorHandlerSetting()
+ {
+ $oKTConfig =& KTConfig::getSingleton();
+ $sCustomErrorCheck = $oKTConfig->get('CustomErrorMessages/customerrorhandler');
+ return $sCustomErrorCheck;
+ }
+ //}}}
+
+ // {{{ getCustomErrorRedirectPage()
+ function getCustomErrorRedirectPage ()
+ {
+ $oKTErrorConfig =& KTConfig::getSingleton();
+ $sCustomErrorPage = $oKTErrorConfig->get('CustomErrorMessages/customerrorpagepath');
+
+ //if a filname is specified in the config.ini file make it into a url
+ if (substr($sCustomErrorPage, 0, 4) != 'http')
+ {
+
+ $sCustomErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.$sCustomErrorPage;
+
+ }
+
+ //checking if file exists
+ //curl options will return the page header, we can then check for an http error
+ $CurlSession = curl_init();
+ curl_setopt($CurlSession, CURLOPT_URL, $sCustomErrorPage);
+ curl_setopt($CurlSession, CURLOPT_HEADER, true);
+ curl_setopt($CurlSession, CURLOPT_NOBODY, true);
+ curl_setopt($CurlSession, CURLOPT_RETURNTRANSFER, true);
+ $data = curl_exec($CurlSession);
+ curl_close($CurlSession);
+ preg_match("/HTTP\/1\.[1|0]\s(\d{3})/",$data,$matches);
+
+ //checking for http error - if the retunr code isn't 200 then we have an error
+ //on an error we return 0
+ if ($matches[1] != '200')
+ {
+ //if file does not exist return error code of 0
+ return '0';
+ }
+ else
+ {
+ //if file exists return error page address
+ return $sCustomErrorPage;
+
+ }
+ }
+ // }}}
+
+ // {{{ customErrorPageRedirect()
+ function doCustomErrorPageRedirect($CustomErrorPage, $oError = null)
+ {
+ $sErrorMessage = '';
+ if($oError != null)
+ {
+ //call error handler
+
+ $aErrorMessage = array ();
+ $aErrorMessage['Error_MessageOne'] = $oError->getMessage();
+ $aErrorMessage['Error_MessageTwo'] = $oError->getUserInfo();
+ //echo '';
+ //print_r($aErrorMessage);
+ //echo ' ';
+ //exit;
+ $customErrorHandler = KTCustomErrorHandler::initCustomErrorHandler();
+ $customErrorHandler->logError($oError);
+ }
+
+ $ErrorPageCurlSession = curl_init($CustomErrorPage);
+ //curl_setopt($ErrorPageCurlSession, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ErrorPageCurlSession, CURLOPT_POST, true);
+ curl_setopt($ErrorPageCurlSession, CURLOPT_POSTFIELDS, $aErrorMessage);
+ $ErrorPageSent = curl_exec($ErrorPageCurlSession);
+ curl_close($ErrorPageCurlSession);
+
+ }
+ // }}}
+ }
+ ?>