mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-01 05:55:02 +03:00
122 lines
4.1 KiB
PHP
122 lines
4.1 KiB
PHP
<?php
|
||
/*-------------------------------------------------------
|
||
*
|
||
* 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
|
||
*
|
||
---------------------------------------------------------
|
||
*/
|
||
/**
|
||
* Operations with Config object
|
||
*/
|
||
require_once(dirname(__FILE__)."/../engine/lib/internal/ConfigSimple/Config.class.php");
|
||
Config::LoadFromFile(dirname(__FILE__).'/config.php');
|
||
Config::DefineConstant();
|
||
|
||
/**
|
||
* Загружает конфиги модулей вида /config/modules/[module_name]/config.php
|
||
*/
|
||
$sDirConfig=Config::get('path.root.server').'/config/modules/';
|
||
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)) {
|
||
$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)
|
||
);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
closedir($hDirConfig);
|
||
}
|
||
|
||
|
||
/**
|
||
* Инклудим все *.php файлы из каталога {DIR_SERVER_ENGINE}/include/ - это файлы ядра
|
||
*/
|
||
$sDirInclude=Config::get('path.root.engine').'/include/';
|
||
$sDirInclude=DIR_SERVER_ENGINE.'/include/';
|
||
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);
|
||
}
|
||
|
||
/**
|
||
* Инклудим все *.php файлы из каталога {DIR_SERVER_ROOT}/include/ - пользовательские файлы
|
||
*/
|
||
$sDirInclude=Config::get('path.root.server').'/include/';
|
||
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);
|
||
}
|
||
|
||
/**
|
||
* Ищет routes-конфиги модулей и объединяет их с текущим
|
||
* @see Router.class.php
|
||
*/
|
||
$sDirConfig=Config::get('path.root.server').'/config/modules/';
|
||
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);
|
||
}
|
||
|
||
Config::DefineConstant();
|
||
?>
|