1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Issue #5120 - Reworked as object for increased flexibility. Some tweaking still to be done.

This commit is contained in:
camer0n
2023-11-29 16:07:39 -08:00
parent 93132395b8
commit dbcc26544a
2 changed files with 47 additions and 33 deletions

View File

@@ -143,7 +143,7 @@ $error_handler = new error_handler();
// //
// E: Setup other essential PHP parameters // E: Setup other essential PHP parameters
// //
define('e107_INIT', true); const e107_INIT = true;
// DEPRECATED, use e107::getConfig() and e107::getPlugConfig() // DEPRECATED, use e107::getConfig() and e107::getPlugConfig()
@@ -208,7 +208,7 @@ $tmp = e_ROOT.$HANDLERS_DIRECTORY;
e107_require_once($tmp.'/e107_class.php'); e107_require_once($tmp.'/e107_class.php');
unset($tmp); unset($tmp);
if(empty($config['directories'])) // old e107_config.php format. if(!class_exists('e107_config')) // old e107_config.php format.
{ {
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY'); $e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY');
$legacy_sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix'); $legacy_sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
@@ -225,10 +225,10 @@ if(empty($config['directories'])) // old e107_config.php format.
} }
else // New e107_config.php format. v2.4+ else // New e107_config.php format. v2.4+
{ {
$e107_paths = $config['directories']; $e107_paths = $config->paths();
$sql_info = $config['mySQL']; $sql_info = $config->database();
$E107_CONFIG = $config['other'] ?? []; $E107_CONFIG = $config->other() ?? [];
unset($config); //unset($config);
} }
@@ -1369,7 +1369,7 @@ function getperms($arg, $ap = null, $path = null)
return true; return true;
} }
if ($arg === 'P' && preg_match('#(.*?)/' .e107::getInstance()->getFolder('plugins'). '(.*?)/(.*?)#', $path, $matches)) if ($arg === 'P' && preg_match('#(.*?)/' .e107::getFolder('plugins'). '(.*?)/(.*?)#', $path, $matches))
{ {
$sql = e107::getDb('psql'); $sql = e107::getDb('psql');

View File

@@ -36,30 +36,44 @@ $SYSTEM_DIRECTORY = 'e107_system/';
$E107_CONFIG = array('site_path' => '000000test'); $E107_CONFIG = array('site_path' => '000000test');
*/ */
define('e_MOD_REWRITE',true); const e_MOD_REWRITE = true;
return [ class e107_config
'mySQL' => [ {
'server' => '{{ mySQLserver }}', public function database()
'user' => '{{ mySQLuser }}', {
'password' => '{{ mySQLpassword }}', return [
'defaultdb'=> '{{ mySQLdefaultdb }}', 'server' => '{{ mySQLserver }}',
'prefix' => '{{ mySQLprefix }}', 'user' => '{{ mySQLuser }}',
'charset' => 'utf8', 'password' => '{{ mySQLpassword }}',
], 'defaultdb'=> '{{ mySQLdefaultdb }}',
'directories' => [ // leave empty to use default 'prefix' => '{{ mySQLprefix }}',
'admin' => 'e107_admin/', 'charset' => 'utf8',
'files' => 'e107_files/', ];
'images' => 'e107_images/', }
'themes' => 'e107_themes/',
'plugins' => 'e107_plugins/', public function paths()
'handlers' => 'e107_handlers/', {
'languages' => 'e107_languages/', return [
'help' => 'e107_docs/help/', 'admin' => 'e107_admin/',
'system' => 'e107_system/', 'files' => 'e107_files/',
'media' => 'e107_media/', 'images' => 'e107_images/',
], 'themes' => 'e107_themes/',
'other' => [ 'plugins' => 'e107_plugins/',
'site_path' => '000000test' 'handlers' => 'e107_handlers/',
] 'languages' => 'e107_languages/',
]; 'help' => 'e107_docs/help/',
'system' => 'e107_system/',
'media' => 'e107_media/',
];
}
public function other()
{
return [
'site_path' => '000000test'
];
}
}
return new e107_config;