Beispiel #1
0
 function KTCache()
 {
     require_once "Cache/Lite.php";
     require_once KT_LIB_DIR . '/config/config.inc.php';
     $aOptions = array();
     $oKTConfig = KTConfig::getSingleton();
     $this->bEnabled = $oKTConfig->get('cache/cacheEnabled', false);
     if (empty($this->bEnabled)) {
         return;
     }
     $aOptions['cacheDir'] = $oKTConfig->get('cache/cacheDirectory') . "/";
     $user = KTUtil::running_user();
     if ($user) {
         $aOptions['cacheDir'] .= $user . '/';
     }
     if (!file_exists($aOptions['cacheDir'])) {
         mkdir($aOptions['cacheDir']);
     }
     // See thirdparty/pear/Cache/Lite.php to customize cache
     $aOptions['lifeTime'] = 60;
     $aOptions['memoryCaching'] = true;
     $aOptions['automaticSerialization'] = true;
     /* Patched line */
     // Disable fileCaching (when cache > 5Mo)
     $aOptions['onlyMemoryCaching'] = true;
     $this->cacheDir = $aOptions['cacheDir'];
     $this->oLite = new Cache_Lite($aOptions);
 }
Beispiel #2
0
 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';
     // get the log level set in the configuration settings to override the level set in ktlog.ini
     // for the default / main logging. Additional logging can be configured through the ini file
     $logLevel = $oKTConfig->get('KnowledgeTree/logLevel');
     $properties['log4php.rootLogger'] = $logLevel . ', default';
     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');
 }
 function _deleteProxyFiles()
 {
     $oKTConfig =& KTConfig::getSingleton();
     // from ktentityutil::_proxyCreate
     $sDirectory = $oKTConfig->get('cache/proxyCacheDirectory');
     if (!file_exists($sDirectory)) {
         return;
     }
     $sRunningUser = KTUtil::running_user();
     if ($sRunningUser) {
         $sDirectory = sprintf("%s/%s", $sDirectory, $sRunningUser);
     }
     if (!file_exists($sDirectory)) {
         return;
     }
     $dh = @opendir($sDirectory);
     if (empty($dh)) {
         return;
     }
     $aFiles = array();
     while (false !== ($sFilename = readdir($dh))) {
         if (substr($sFilename, -8) == ".inc.php") {
             $aFiles[] = sprintf('%s/%s', $sDirectory, $sFilename);
         }
     }
     foreach ($aFiles as $sFile) {
         @unlink($sFile);
     }
 }