2009-05-10 10:50:39 +03:00
|
|
|
|
<?php
|
2009-04-10 15:34:20 +03:00
|
|
|
|
/*-------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* LiveStreet Engine Social Networking
|
|
|
|
|
* Copyright © 2008 Mzhelskiy Maxim
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* Official site: www.livestreet.ru
|
|
|
|
|
* Contact e-mail: rus.engine@gmail.com
|
|
|
|
|
*
|
|
|
|
|
* GNU General Public License, version 2:
|
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
|
*
|
|
|
|
|
---------------------------------------------------------
|
|
|
|
|
*/
|
2009-08-19 12:17:38 +03:00
|
|
|
|
/**
|
|
|
|
|
* Operations with Config object
|
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
require_once(dirname(dirname(__FILE__))."/engine/lib/internal/ConfigSimple/Config.class.php");
|
|
|
|
|
Config::LoadFromFile(dirname(__FILE__).'/config.php');
|
2009-04-10 15:34:20 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Загружает конфиги модулей вида /config/modules/[module_name]/config.php
|
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
$sDirConfig=Config::get('path.root.server').'/config/modules/';
|
2009-04-10 15:34:20 +03:00
|
|
|
|
if ($hDirConfig = opendir($sDirConfig)) {
|
|
|
|
|
while (false !== ($sDirModule = readdir($hDirConfig))) {
|
|
|
|
|
if ($sDirModule !='.' and $sDirModule !='..' and is_dir($sDirConfig.$sDirModule)) {
|
|
|
|
|
$sFileConfig=$sDirConfig.$sDirModule.'/config.php';
|
|
|
|
|
if (file_exists($sFileConfig)) {
|
2009-08-19 12:17:38 +03:00
|
|
|
|
$aConfig = include($sFileConfig);
|
|
|
|
|
if(!empty($aConfig) && is_array($aConfig)) {
|
|
|
|
|
// Если конфиг этого модуля пуст, то загружаем массив целиком
|
|
|
|
|
$sKey = "module.$sDirModule";
|
|
|
|
|
if(!Config::isExist($sKey)) {
|
|
|
|
|
Config::Set($sKey,$aConfig);
|
|
|
|
|
} else {
|
|
|
|
|
// Если уже существую привязанные к модулю ключи,
|
|
|
|
|
// то сливаем старые и новое значения ассоциативно
|
|
|
|
|
Config::Set(
|
|
|
|
|
$sKey,
|
|
|
|
|
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-10 15:34:20 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($hDirConfig);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 12:10:14 +03:00
|
|
|
|
|
|
|
|
|
/**
|
2009-08-19 13:47:19 +03:00
|
|
|
|
* Инклудим все *.php файлы из каталога {path.root.engine}/include/ - это файлы ядра
|
2009-08-18 12:10:14 +03:00
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
$sDirInclude=Config::get('path.root.engine').'/include/';
|
2009-08-18 12:10:14 +03:00
|
|
|
|
if ($hDirInclude = opendir($sDirInclude)) {
|
|
|
|
|
while (false !== ($sFileInclude = readdir($hDirInclude))) {
|
|
|
|
|
$sFileIncludePathFull=$sDirInclude.$sFileInclude;
|
|
|
|
|
if ($sFileInclude !='.' and $sFileInclude !='..' and is_file($sFileIncludePathFull)) {
|
|
|
|
|
$aPathInfo=pathinfo($sFileIncludePathFull);
|
|
|
|
|
if (strtolower($aPathInfo['extension'])=='php') {
|
|
|
|
|
require_once($sDirInclude.$sFileInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($hDirInclude);
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-12 17:22:57 +03:00
|
|
|
|
/**
|
2009-08-19 13:47:19 +03:00
|
|
|
|
* Инклудим все *.php файлы из каталога {path.root.server}/include/ - пользовательские файлы
|
2009-04-12 17:22:57 +03:00
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
$sDirInclude=Config::get('path.root.server').'/include/';
|
2009-04-12 17:22:57 +03:00
|
|
|
|
if ($hDirInclude = opendir($sDirInclude)) {
|
|
|
|
|
while (false !== ($sFileInclude = readdir($hDirInclude))) {
|
|
|
|
|
$sFileIncludePathFull=$sDirInclude.$sFileInclude;
|
|
|
|
|
if ($sFileInclude !='.' and $sFileInclude !='..' and is_file($sFileIncludePathFull)) {
|
|
|
|
|
$aPathInfo=pathinfo($sFileIncludePathFull);
|
|
|
|
|
if (strtolower($aPathInfo['extension'])=='php') {
|
|
|
|
|
require_once($sDirInclude.$sFileInclude);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($hDirInclude);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-19 12:17:38 +03:00
|
|
|
|
/**
|
|
|
|
|
* Ищет routes-конфиги модулей и объединяет их с текущим
|
|
|
|
|
* @see Router.class.php
|
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
$sDirConfig=Config::get('path.root.server').'/config/modules/';
|
2009-08-19 12:17:38 +03:00
|
|
|
|
if ($hDirConfig = opendir($sDirConfig)) {
|
|
|
|
|
while (false !== ($sDirModule = readdir($hDirConfig))) {
|
|
|
|
|
if ($sDirModule !='.' and $sDirModule !='..' and is_dir($sDirConfig.$sDirModule)) {
|
|
|
|
|
$sFileConfig=$sDirConfig.$sDirModule.'/config.route.php';
|
|
|
|
|
if (file_exists($sFileConfig)) {
|
|
|
|
|
$aConfig = include($sFileConfig);
|
|
|
|
|
if(!empty($aConfig) && is_array($aConfig)) {
|
|
|
|
|
// Если конфиг этого модуля пуст, то загружаем массив целиком
|
|
|
|
|
$sKey = "router";
|
|
|
|
|
if(!Config::isExist($sKey)) {
|
|
|
|
|
Config::Set($sKey,$aConfig);
|
|
|
|
|
} else {
|
|
|
|
|
// Если уже существую привязанные к модулю ключи,
|
|
|
|
|
// то сливаем старые и новое значения ассоциативно
|
|
|
|
|
Config::Set(
|
|
|
|
|
$sKey,
|
|
|
|
|
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($hDirConfig);
|
|
|
|
|
}
|
2009-10-09 23:16:53 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Подгружаем файлы локального и продакшн-конфига
|
|
|
|
|
*/
|
|
|
|
|
if(file_exists(Config::Get('path.root.server').'/config/config.local.php')) {
|
|
|
|
|
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.local.php',false);
|
|
|
|
|
}
|
|
|
|
|
if(file_exists(Config::Get('path.root.server').'/config/config.stable.php')) {
|
|
|
|
|
Config::LoadFromFile(Config::Get('path.root.server').'/config/config.stable.php',false);
|
|
|
|
|
}
|
2009-12-24 22:18:13 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2010-01-08 22:01:40 +02:00
|
|
|
|
* Загружает конфиги плагинов вида /plugins/[plugin_name]/config/*.php
|
|
|
|
|
* и include-файлы /plugins/[plugin_name]/include/*.php
|
2009-12-24 22:18:13 +02:00
|
|
|
|
*/
|
2010-01-30 19:12:40 +02:00
|
|
|
|
$sPluginsDir = Config::Get('path.root.server').'/plugins';
|
2009-12-24 22:18:13 +02:00
|
|
|
|
$sPluginsListFile = $sPluginsDir.'/plugins.dat';
|
|
|
|
|
if($aPluginsList=@file($sPluginsListFile)) {
|
2010-01-27 17:14:00 +02:00
|
|
|
|
$aPluginsList=array_map('trim',$aPluginsList);
|
2009-12-24 22:18:13 +02:00
|
|
|
|
foreach ($aPluginsList as $sPlugin) {
|
|
|
|
|
$aConfigFiles = glob($sPluginsDir.'/'.$sPlugin.'/config/*.php');
|
2010-04-17 18:12:10 +03:00
|
|
|
|
if($aConfigFiles and count($aConfigFiles)>0) {
|
2009-12-24 22:18:13 +02:00
|
|
|
|
$aConfig=array();
|
|
|
|
|
foreach ($aConfigFiles as $sPath) {
|
|
|
|
|
$aConfig = include($sPath);
|
|
|
|
|
if(!empty($aConfig) && is_array($aConfig)) {
|
|
|
|
|
// Если конфиг этого плагина пуст, то загружаем массив целиком
|
|
|
|
|
$sKey = "plugin.$sPlugin";
|
|
|
|
|
if(!Config::isExist($sKey)) {
|
|
|
|
|
Config::Set($sKey,$aConfig);
|
|
|
|
|
} else {
|
|
|
|
|
// Если уже существую привязанные к плагину ключи,
|
|
|
|
|
// то сливаем старые и новое значения ассоциативно
|
|
|
|
|
Config::Set(
|
|
|
|
|
$sKey,
|
|
|
|
|
func_array_merge_assoc(Config::Get($sKey), $aConfig)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Подключаем include-файлы
|
|
|
|
|
*/
|
|
|
|
|
$aIncludeFiles = glob($sPluginsDir.'/'.$sPlugin.'/include/*.php');
|
|
|
|
|
if($aIncludeFiles and count($aIncludeFiles)) {
|
|
|
|
|
foreach ($aIncludeFiles as $sPath) {
|
|
|
|
|
require_once($sPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-04-10 15:34:20 +03:00
|
|
|
|
?>
|