dmsdefaults.php.tmp

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· TMP 代码 · 共 626 行 · 第 1/2 页

TMP
626
字号
    		);		foreach($knownPaths as $path)		{			if (file_exists($path))			{				return $path;			}		}		return KT_DIR . '/config/magic';    }    static protected $handlerMapping = array(    		E_WARNING=>'warn',    		E_USER_WARNING=>'warn',        	E_NOTICE=>'info',        	E_USER_NOTICE=>'info',			E_ERROR=>'error',			E_USER_ERROR=>'error'    );    // {{{ handlePHPError()    static function handlePHPError($code, $message, $file, $line) {        global $default;        $priority = 'info';        if (array_key_exists($code, KTInit::$handlerMapping))        {			$priority = KTInit::$handlerMapping[$code];        }        if (empty($priority))        {            $priority = 'info';        }        $msg = $message . ' in ' . $file . ' at line ' . $line;        if (isset($default->phpErrorLog))        {            $default->phpErrorLog->$priority($msg);        }    }    // }}}	function catchFatalErrors()	{		ini_set('display_errors','On');	    $phperror='><div id="phperror" style="display:none">';		ini_set('error_prepend_string',$phperror);		$CustomErrorPage = KTUtil::kt_url().'/customerrorpage.php';		$phperror='</div>><form name="catcher" action="'.$CustomErrorPage.'" method="post" ><input type="hidden" name="fatal" value=""></form>		<script> document.catcher.fatal.value = document.getElementById("phperror").innerHTML; document.catcher.submit();</script>';		ini_set('error_append_string',$phperror);	}    // {{{ guessRootUrl()    function guessRootUrl() {        $urlpath = $_SERVER['SCRIPT_NAME'];        $bFound = false;        $rootUrl = '';        while ($urlpath) {            if (file_exists(KT_DIR . '/' . $urlpath)) {                $bFound = true;                break;            }            $i = strpos($urlpath, '/');            if ($i === false) {                break;            }            if ($rootUrl)            {            	$rootUrl .= '/';            }            $rootUrl .= substr($urlpath, 0, $i);            $urlpath = substr($urlpath, $i + 1);        }        if ($bFound) {            if ($rootUrl) {                $rootUrl = '/' . $rootUrl;            }            return $rootUrl;        }        return '';    }    // }}}	// {{{ getDynamicConfigSettings	//This function gets the intial config settings which can only be resolved by using php	function getDynamicConfigSettings()	{		$oKTConfig =& KTConfig::getSingleton();        $oKTConfig->setdefaultns('KnowledgeTree', 'fileSystemRoot', KT_DIR);        $oKTConfig->setdefaultns('KnowledgeTree', 'serverName', KTUtil::arrayGet($_SERVER, 'HTTP_HOST', 'localhost'));        $oKTConfig->setdefaultns('KnowledgeTree', 'sslEnabled', 0);        if (array_key_exists('HTTPS', $_SERVER)) {            if (strtolower($_SERVER['HTTPS']) === 'on') {                $oKTConfig->setdefaultns('KnowledgeTree', 'sslEnabled', 1);            }        }        $oKTConfig->setdefaultns('KnowledgeTree', 'rootUrl', $this->guessRootUrl());        $oKTConfig->setdefaultns('KnowledgeTree', 'execSearchPath', $_SERVER['PATH']);        $oKTConfig->setdefaultns('KnowledgeTree', 'magicDatabase', KTInit::detectMagicFile());	}	// }}}    // {{{ initConfig    function initConfig() {        global $default;        $oKTConfig = KTConfig::getSingleton();        // TODO: refactor when all the config settings are stored in the database        // Check for the config cache        $use_cache = false;        $store_cache = true;        $cachePath = $oKTConfig->getCacheFilename();        if (file_exists($cachePath)) {            $configPath = $oKTConfig->getConfigFilename();            // This check can be removed once all config settings are in the database            // Check if the config file has been updated since the last time the cache file was generated.            $cachestat = stat($cachePath);            $configstat = stat($configPath);            $tval = 9;            if ($cachestat[$tval] > $configstat[$tval]) {                $use_cache = true;                $store_cache = false;            }            if ($use_cache) {                $use_cache = $oKTConfig->loadCache($cachePath);            }        }else{            if(!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])){                // If the http_host server variable is not set then the serverName gets set to localhost                // We don't want to store this setting so we set store_cache to false                $store_cache = false;                /*                // Check if serverName.txt is set and use that                $pathFile = KT_DIR .  '/config/cache-path';                $cachePath = trim(file_get_contents($pathFile));                $serverNamePath = $cachePath . '/' . KTUtil::SERVER_NAME_FILE;                if(file_exists($serverNamePath)){                    $serverName = @file_get_contents($serverNamePath);                    $_SERVER['HTTP_HOST'] = $serverName;                }                */            }        }        if(!$use_cache) {            // Get default server url settings            $this->getDynamicConfigSettings();            //Read in DB settings and config settings            $oKTConfig->readDBConfig();        }        $dbSetup = $oKTConfig->setupDB();        if(PEAR::isError($dbSetup))        {        	/* We need to setup the language handler to display this error correctly */        	$this->setupI18n();        	$this->handleInitError($dbSetup);        }        // Read in the config settings from the database        // Create the global $default array        if(!$use_cache) $res = $oKTConfig->readConfig();        if($store_cache && isset($cachePath)){            @touch($cachePath);            if (is_writable($cachePath)) {                $oKTConfig->createCache($cachePath);            }        }    }    // }}}    // {{{ initTesting    function initTesting() {        $oKTConfig =& KTConfig::getSingleton();        $sConfigFile = trim(@file_get_contents(KT_DIR .  '/config/test-config-path'));        if (empty($sConfigFile)) {            $sConfigFile = 'config/test.ini';        }        if (!KTUtil::isAbsolutePath($sConfigFile)) {            $sConfigFile = sprintf('%s/%s', KT_DIR, $sConfigFile);        }        if (!file_exists($sConfigFile)) {            $this->handleInitError(PEAR::raiseError('Test infrastructure not configured'));            exit(0);        }        $res = $oKTConfig->loadFile($sConfigFile);        if (PEAR::isError($res)) {            return $res;        }        $_SESSION['userID'] = 1;    }    // }}}}// }}}$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){	$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$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 entriesinclude('tableMappings.inc');$default->systemVersion = trim(file_get_contents(KT_DIR . '/docs/VERSION.txt'));$default->versionName = trim(file_get_contents(KT_DIR . '/docs/VERSION-NAME.txt'));$KTInit->cleanGlobals();$KTInit->cleanMagicQuotes();// site map definitionrequire_once(KT_DIR . '/config/siteMap.inc');require_once(KT_LIB_DIR . '/session/Session.inc');require_once(KT_LIB_DIR . '/session/control.inc');require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php');if ($checkup !== true) {    // Replace function later    /* ** Get the page being loaded and load the plugins specific to the page ** */    $sScriptName = $GLOBALS['_SERVER']['SCRIPT_NAME'];    $sScript = basename($sScriptName);    $pos = strpos($sScript, '.');    $sType = substr($sScript, 0, $pos);    KTPluginUtil::loadPlugins($sType);}if ($checkup !== true) {    if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {        require_once(KT_DIR .  '/plugins/wintools/baobabkeyutil.inc.php');        $name = BaobabKeyUtil::getName();        if ($name) {            $default->versionName = sprintf('%s %s', $default->versionName, $name);        }    }else{        $default->versionName = $default->versionName.' '._kt('(Community Edition)');    }}if (!extension_loaded('mbstring')){	require_once(KT_LIB_DIR . '/mbstring.inc.php');}require_once(KT_LIB_DIR . '/templating/kt3template.inc.php');$GLOBALS['main'] =new KTPage();?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?