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') {
         $sUrl = KTInit::guessRootUrl();
         global $default;
         $sRootUrl = ($default->sslEnabled ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $sUrl;
         $sCustomErrorPage = $sRootUrl . '/' . $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;
     }
 }
Exemple #2
0
}
// }}}
$KTInit = new KTInit();
$KTInit->initConfig();
$KTInit->setupI18n();
//====================================
define('KTLOG_CACHE', false);
if (isset($GLOBALS['kt_test'])) {
    $KTInit->initTesting();
}
$oKTConfig = KTConfig::getSingleton();
if ($oKTConfig->get('CustomErrorMessages/customerrormessages') == 'on') {
    $KTInit->catchFatalErrors();
}
if (phpversion() < 5) {
    $rootUrl = $KTInit->guessRootUrl();
    $sErrorPage = 'http://' . $_SERVER['HTTP_HOST'] . $rootUrl . '/' . '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);
    exit(0);
}
$KTInit->setupServerVariables();
// instantiate log
$loggingSupport = $KTInit->setupLogging();
// Send all PHP errors to a file (and maybe a window)
set_error_handler(array('KTInit', 'handlePHPError'));
$KTInit->setupRandomSeed();
$GLOBALS['KTRootUrl'] = $oKTConfig->get('KnowledgeTree/rootUrl');
require_once KT_LIB_DIR . '/database/lookup.inc';
// table mapping entries