dmsdefaults.php.tmp

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

TMP
626
字号
<?php/** * $Id$ * * Defines KnowledgeTree application defaults. * * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License * along with this program.  If not, see <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, 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): Guenter Roeck______________________________________ * */if (defined('DMS_DEFAULTS_INCLUDED')){	return;}define('DMS_DEFAULTS_INCLUDED',1);define('LATEST_WEBSERVICE_VERSION',2);if (function_exists('apd_set_pprof_trace')) {    apd_set_pprof_trace();}// Default settings differ, we need some of these, so force the matter.// Can be overridden here if actually necessary.error_reporting(E_ALL & ~E_NOTICE);ini_set('display_errors', '1');ini_set('display_startup_errors', '1');ini_set('magic_quotes_runtime', '0');ini_set('arg_separator.output', '&');$microtime_simple = explode(' ', microtime());$_KT_starttime = (float) $microtime_simple[1] + (float) $microtime_simple[0];unset($microtime_simple);// If not defined, set KT_DIR based on my usual location in the treeif (!defined('KT_DIR')) {    $rootLoc = realpath(dirname(__FILE__) . '/..');    if (substr(PHP_OS, 0, 3) == 'WIN') {            $rootLoc = str_replace('\\','/',$rootLoc);    }    define('KT_DIR', $rootLoc);}if (!defined('KT_LIB_DIR')) {    define('KT_LIB_DIR', KT_DIR . '/lib');}// If not defined, set KT_STACK_DIR based on my usual location in the tree// TODO: This needs to use a config.ini entry if availableif (!defined('KT_STACK_DIR')) {    $stackLoc = realpath(dirname(__FILE__) . '/../..');    if (substr(PHP_OS, 0, 3) == 'WIN') {            $stackLoc = str_replace('\\','/',$stackLoc);    }    define('KT_STACK_DIR', $stackLoc);}// PATH_SEPARATOR added in PHP 4.3.0if (!defined('PATH_SEPARATOR')) {    if (substr(PHP_OS, 0, 3) == 'WIN') {        define('PATH_SEPARATOR', ';');    } else {        define('PATH_SEPARATOR', ':');    }}require_once(KT_LIB_DIR . '/validation/customerror.php');// {{{ prependPath()function prependPath ($path) {    $include_path = ini_get('include_path');    ini_set('include_path', $path . PATH_SEPARATOR . $include_path);}// }}}prependPath(KT_DIR . '/thirdparty/ZendFramework/library');prependPath(KT_DIR . '/thirdparty/pear');prependPath(KT_DIR . '/thirdparty/Smarty');prependPath(KT_DIR . '/thirdparty/simpletest');prependPath(KT_DIR . '/thirdparty/xmlrpc-2.2/lib');prependPath(KT_DIR . '/ktapi');prependPath(KT_DIR . '/search2');require_once('PEAR.php');// Give everyone access to legacy PHP functionsrequire_once(KT_LIB_DIR . '/util/legacy.inc');// Give everyone access to KTUtil utility functionsrequire_once(KT_LIB_DIR . '/util/ktutil.inc');require_once(KT_LIB_DIR . '/ktentity.inc');require_once(KT_LIB_DIR . '/config/config.inc.php');require_once(KT_DIR . '/search2/indexing/indexerCore.inc.php');// {{{ KTInitclass KTInit {    // {{{ setupLogging()    function setupLogging () {        global $default;        $oKTConfig =& KTConfig::getSingleton();        if(!defined('APP_NAME')) {		    define('APP_NAME', $oKTConfig->get('ui/appName', 'KnowledgeTree'));		}        define('KT_LOG4PHP_DIR', KT_DIR . '/thirdparty/apache-log4php/src/main/php' . DIRECTORY_SEPARATOR);        define('LOG4PHP_CONFIGURATION', KT_DIR . '/config/ktlog.ini');        define('LOG4PHP_DEFAULT_INIT_OVERRIDE', true);        require_once(KT_LOG4PHP_DIR . 'LoggerManager.php');        require_once(KT_LOG4PHP_DIR . 'LoggerPropertyConfigurator.php');        $configurator = new LoggerPropertyConfigurator();        $repository = LoggerManager::getLoggerRepository();        $properties = @parse_ini_file(LOG4PHP_CONFIGURATION);        $properties['log4php.appender.default'] = 'LoggerAppenderDailyFile';        $properties['log4php.appender.default.layout'] = 'LoggerPatternLayout';        $properties['log4php.appender.default.layout.conversionPattern'] = '%d{Y-m-d | H:i:s} | %p | %t | %r | %X{userid} | %X{db} | %c | %M | %m%n';        $properties['log4php.appender.default.datePattern'] = 'Y-m-d';        $logDir = $oKTConfig->get('urls/logDirectory');        $properties['log4php.appender.default.file'] = $logDir . '/kt%s.' . KTUtil::running_user() .  '.log.txt';        session_start();        $configurator->doConfigureProperties($properties, $repository);        $userId = isset($_SESSION['userID'])?$_SESSION['userID']:'n/a';        LoggerMDC::put('userid', $userId);        LoggerMDC::put('db', $oKTConfig->get('db/dbName'));        $default->log = LoggerManager::getLogger('default');        $default->queryLog = LoggerManager::getLogger('sql');        $default->timerLog = LoggerManager::getLogger('timer');        $default->phpErrorLog = LoggerManager::getLogger('php');    }    // }}}    // {{{ setupI18n()    /**     * setupI18n     *     */    function setupI18n () {        require_once(KT_LIB_DIR . '/i18n/i18nutil.inc.php');        require_once('HTTP.php');        global $default;        $language = KTUtil::arrayGet($_COOKIE, 'kt_language');        if ($language) {            $default->defaultLanguage = $language;        }    }    // }}}    // {{{ cleanGlobals()    function cleanGlobals () {        /*         * Borrowed from TikiWiki         *         * Copyright (c) 2002-2004, Luis Argerich, Garland Foster,         * Eduardo Polidor, et. al.         */        if (ini_get('register_globals')) {            $aGlobals = array($_ENV, $_GET, $_POST, $_COOKIE, $_SERVER);            foreach ($aGlobals as $superglob) {                foreach ($superglob as $key => $val) {                    if (isset($GLOBALS[$key]) && $GLOBALS[$key] == $val) {                        unset($GLOBALS[$key]);                    }                }            }        }    }    // }}}    // {{{ cleanMagicQuotesItem()    function cleanMagicQuotesItem (&$var) {        if (is_array($var)) {            foreach ($var as $key => $val) {                $this->cleanMagicQuotesItem($var[$key]);            }        } else {            // XXX: Make it look pretty            $var = stripslashes($var);        }    }    // }}}    // {{{ cleanMagicQuotes()    function cleanMagicQuotes () {        if (get_magic_quotes_gpc()) {            $this->cleanMagicQuotesItem($_GET);            $this->cleanMagicQuotesItem($_POST);            $this->cleanMagicQuotesItem($_REQUEST);            $this->cleanMagicQuotesItem($_COOKIE);        }    }    // }}}    // {{{ setupServerVariables    function setupServerVariables() {        $oKTConfig =& KTConfig::getSingleton();        $bPathInfoSupport = $oKTConfig->get('KnowledgeTree/pathInfoSupport');        if ($bPathInfoSupport) {            // KTS-21: Some environments (FastCGI only?) don't set PATH_INFO            // correctly, but do set ORIG_PATH_INFO.            $path_info = KTUtil::arrayGet($_SERVER, 'PATH_INFO');            $orig_path_info = KTUtil::arrayGet($_SERVER, 'ORIG_PATH_INFO');            if (empty($path_info) && !empty($orig_path_info)) {                $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];                $_SERVER['PHP_SELF'] .= $_SERVER['PATH_INFO'];            }            $env_path_info = KTUtil::arrayGet($_SERVER, 'REDIRECT_kt_path_info');            if (empty($path_info) && !empty($env_path_info)) {                $_SERVER['PATH_INFO'] = $env_path_info;                $_SERVER['PHP_SELF'] .= $_SERVER['PATH_INFO'];            }            // KTS-50: IIS (and probably most non-Apache web servers) don't            // set REQUEST_URI.  Fake it.            $request_uri = KTUtil::arrayGet($_SERVER, 'REQUEST_URI');            if (empty($request_uri)) {                $_SERVER['REQUEST_URI'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']);            }        } else {            unset($_SERVER['PATH_INFO']);        }        $script_name = KTUtil::arrayGet($_SERVER, 'SCRIPT_NAME');        $php_self = KTUtil::arrayGet($_SERVER, 'PHP_SELF');        $kt_path_info = KTUtil::arrayGet($_REQUEST, 'kt_path_info');        if (!empty($kt_path_info)) {            $_SERVER['PHP_SELF'] .= '?kt_path_info=' . $kt_path_info;            $_SERVER['PATH_INFO'] = $kt_path_info;        }        $oConfig =& KTConfig::getSingleton();        $sServerName = $oConfig->get('KnowledgeTree/serverName');        $_SERVER['HTTP_HOST'] = $sServerName;    }    // }}}    // {{{ setupRandomSeed()    function setupRandomSeed () {        mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);    }    // }}}    // {{{ handleInitError()    function handleInitError($oError) {        global $checkup;        if ($checkup === true) {            echo $oError->toString();            exit(0);            //return;        }        if (KTUtil::arrayGet($_SERVER, 'REQUEST_METHOD')) {            require_once(KT_LIB_DIR . '/dispatcher.inc.php');            $oDispatcher =new KTErrorDispatcher($oError);            $oDispatcher->dispatch();        } else {            print $oError->toString() . "\n";        }        exit(0);    }    // }}}    static function detectMagicFile()    {    	$knownPaths = array(    			'/usr/share/file/magic', // the old default    			'/etc/httpd/conf/magic', // fedora's location    			'/etc/magic' // worst case scenario. Noticed this is sometimes empty and containing a reference to somewher else

⌨️ 快捷键说明

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