diff --git a/config/config.ini b/config/config.ini index 604cb72..e150a1d 100644 --- a/config/config.ini +++ b/config/config.ini @@ -398,9 +398,12 @@ warningThreshold=10 urgentThreshold=5 [CustomErrorMessages] -;Turn custom error messages on or off here // account wide -customerrormessages=on -;name or url of custom error page +;Turn custom error messages on or off here. +customerrormessages=off +;name or url of custom error page. customerrorpagepath=customerrorpage.php -;Turn custom error handler on or off +;Turn custom error handler on or off. +;The custom error handler will log any non php errors caught +;by the custom error handler if it is turned on. +;Php errors are always logged by php itself. customerrorhandler=on diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index 3e0c17c..228e3d0 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -97,6 +97,7 @@ if (!defined('PATH_SEPARATOR')) { } require_once(KT_LIB_DIR . '/Log.inc'); +require_once(KT_LIB_DIR . '/validation/customerror.php'); // {{{ KTInit class KTInit { @@ -388,18 +389,27 @@ class KTInit { // }}} -function catchFatalErrors($p_OnOff='On'){ - ini_set('display_errors','On'); - $phperror='>>
- '; - ini_set('error_append_string',$phperror); +function catchFatalErrors() +{ + + $CustomErrorPage = KTCustomErrorViewer::getCustomErrorRedirectPage(); + if($CustomErrorPage != '0') + { + ini_set('display_errors','On'); + $phperror='>>
+ '; + ini_set('error_append_string',$phperror); + } + } @@ -704,21 +714,6 @@ require_once(KT_LIB_DIR . '/util/ktutil.inc'); require_once(KT_LIB_DIR . '/ktentity.inc'); -//$KTInit->catchFatalErrors(); - -if (phpversion()<5){ - - $sErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.'customerrorpage.php'; - - session_start(); - - $_SESSION['sErrorMessage'] = 'KnowledgeTree now requires that PHP version 5 is installed. PHP version 4 is no longer supported.'; - - - header('location:'. $sErrorPage ) ; - -} - require_once(KT_LIB_DIR . '/config/config.inc.php'); require_once(KT_DIR . '/search2/indexing/indexerCore.inc.php'); @@ -732,6 +727,24 @@ if (isset($GLOBALS['kt_test'])) { } $oKTConfig =& KTConfig::getSingleton(); + +if($oKTConfig->get('CustomErrorMessages/customerrormessages') == 'on') +{ + $KTInit->catchFatalErrors(); +} + +if (phpversion()<5){ + + $sErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.'customerrorpage.php'; + + session_start(); + + $_SESSION['sErrorMessage'] = 'KnowledgeTree now requires that PHP version 5 is installed. PHP version 4 is no longer supported.'; + + + header('location:'. $sErrorPage ) ; + +} $KTInit->setupServerVariables(); // instantiate log diff --git a/customerrorpage.php b/customerrorpage.php index 2f4cdc4..e2f7397 100644 --- a/customerrorpage.php +++ b/customerrorpage.php @@ -13,32 +13,39 @@ if (array_key_exists('Error_MessageOne', $_POST) && array_key_exists('Error_Mess } session_start(); -require_once("config/dmsDefaults.php"); + if (array_key_exists('sErrorMessage', $_SESSION)) { -$phperror = $_SESSION['sErrorMessage']; + $phperror = $_SESSION['sErrorMessage']; } -global $default; - -$sUrl = $default->rootUrl; +//Finding root Url +$sHost = $_SERVER['HTTP_HOST']; +$sScriptName = dirname($_SERVER['SCRIPT_NAME']); +$sRoot = $sHost.$sScriptName; +$bSSLEnabled = false; +if ($_SERVER['HTTPS'] === 'on') +{ + $bSSLEnabled = true; +} +$sRootUrl = ($bSSLEnabled ? 'https://' : 'http://').$sRoot; ?> Knowledgetree - Desklet - + @@ -53,7 +60,7 @@ border.style.height = '250px';

Error!! - You have encountered a problem starting your document management system.

Please contact your systems administrator

-

For more details, click here

+

For more details, click here

diff --git a/lib/dispatcher.inc.php b/lib/dispatcher.inc.php index 3bf4474..bf631f1 100644 --- a/lib/dispatcher.inc.php +++ b/lib/dispatcher.inc.php @@ -537,38 +537,17 @@ 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); - } + + require_once(KT_LIB_DIR . '/validation/customerror.php'); + + $bCustomCheck = KTCustomErrorCheck::customErrorInit($this->oError); + + if($bCustomCheck) + { + 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(); diff --git a/lib/validation/customerror.php b/lib/validation/customerror.php new file mode 100644 index 0000000..07d3094 --- /dev/null +++ b/lib/validation/customerror.php @@ -0,0 +1,84 @@ +. + * + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + */ + +require_once(KT_LIB_DIR . '/validation/errorviewer.inc.php'); +require_once(KT_LIB_DIR . '/validation/customerrorviewer.inc.php'); + +class KTCustomErrorCheck +{ + function customErrorInit($error) + { + $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(); + + + if ($sErrorHandler == 'on') + { + $oErrorHandler = KTCustomErrorHandler::initCustomErrorHandler(); + $oErrorHandler->logError($error); + } + + //redirect + $oCustomViewer->doCustomErrorPageRedirect($CustomErrorPage, $error); + + + //exit without errors + return true; + } + else + { + return false; + } + } + else + { + return false; + } + } +} +?> \ No newline at end of file diff --git a/lib/validation/customerrorhandler.php b/lib/validation/customerrorhandler.php index 2847a00..7c74abe 100644 --- a/lib/validation/customerrorhandler.php +++ b/lib/validation/customerrorhandler.php @@ -33,7 +33,7 @@ * copyright notice. * Contributor( s): ______________________________________ */ - require_once('config/dmsDefaults.php'); + //require_once(KT_DIR.'config/dmsDefaults.php'); require_once(KT_LIB_DIR.'/Log.inc'); class KTCustomErrorHandler diff --git a/lib/validation/customerrorviewer.inc.php b/lib/validation/customerrorviewer.inc.php index 3dc822b..0af1d6a 100644 --- a/lib/validation/customerrorviewer.inc.php +++ b/lib/validation/customerrorviewer.inc.php @@ -72,7 +72,11 @@ if (substr($sCustomErrorPage, 0, 4) != 'http') { - $sCustomErrorPage = 'http://'.$_SERVER['HTTP_HOST'].'/'.$sCustomErrorPage; + $sUrl = KTInit::guessRootUrl(); + global $default; + $sRootUrl = ($default->sslEnabled ? 'https' : 'http') .'://'.$_SERVER['HTTP_HOST'].$sUrl; + $sCustomErrorPage = $sRootUrl.'/'.$sCustomErrorPage; + } @@ -106,7 +110,6 @@ // {{{ customErrorPageRedirect() function doCustomErrorPageRedirect($CustomErrorPage, $oError = null) { - $sErrorMessage = ''; if($oError != null) { //call error handler @@ -114,22 +117,19 @@ $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_SSL_VERIFYPEER, false); curl_setopt($ErrorPageCurlSession, CURLOPT_POST, true); curl_setopt($ErrorPageCurlSession, CURLOPT_POSTFIELDS, $aErrorMessage); $ErrorPageSent = curl_exec($ErrorPageCurlSession); - curl_close($ErrorPageCurlSession); - + curl_close($ErrorPageCurlSession); + } // }}} + } ?>