本文整理汇总了PHP中KTUtil::running_user方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::running_user方法的具体用法?PHP KTUtil::running_user怎么用?PHP KTUtil::running_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::running_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: KTCache
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);
}
示例2: 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';
// 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');
}
示例3: _deleteProxyFiles
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);
}
}