1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Issue #5120 - Work in progress. Subject to change.

This commit is contained in:
camer0n
2023-11-29 10:17:52 -08:00
parent 868895d29a
commit 2055720f6b
3 changed files with 82 additions and 22 deletions

View File

@@ -159,7 +159,7 @@ else
unset($retrieve_prefs);
}
@include(e_ROOT.'e107_config.php');
$config = include(e_ROOT.'e107_config.php');
if(!defined('e_POWEREDBY_DISABLE'))
{
@@ -183,7 +183,7 @@ if(empty($PLUGINS_DIRECTORY))
//define("MPREFIX", $mySQLprefix); moved to $e107->set_constants()
if(empty($mySQLdefaultdb))
if(empty($mySQLdefaultdb) && empty($config))
{
// e107_config.php is either empty, not valid or doesn't exist so redirect to installer..
header('Location: install.php');
@@ -201,8 +201,6 @@ unset($tmpPlugDir);
// clever stuff that figures out where the paths are on the fly.. no more need for hard-coded e_HTTP :)
//
$tmp = e_ROOT.$HANDLERS_DIRECTORY;
//Core functions - now API independent
@@ -210,24 +208,32 @@ $tmp = e_ROOT.$HANDLERS_DIRECTORY;
e107_require_once($tmp.'/e107_class.php');
unset($tmp);
/** @note compact() causes issues with PHP7.3 */
$dirPaths = array('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 = array();
foreach($dirPaths as $v)
if(empty($config['directories'])) // old e107_config.php format.
{
if(isset($$v))
$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');
if(isset($mySQLport))
{
$e107_paths[$v] = $$v;
$legacy_sql_info['mySQLport'] = $mySQLport;
}
$sql_info = array_combine(array_map(function($k) {
return str_replace('mySQL', '', $k);
}, array_keys($legacy_sql_info)),
$legacy_sql_info
);
}
else // New e107_config.php format. v2.4+
{
$e107_paths = $config['directories'];
$sql_info = $config['mySQL'];
$E107_CONFIG = $config['other'] ?? [];
unset($config);
}
// $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');
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
if(isset($mySQLport))
{
$sql_info['mySQLport'] = $mySQLport;
}
$e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array()));
e107::getSingleton('eIPHandler'); // This auto-handles bans etc
unset($dirPaths,$e107_paths);
@@ -304,7 +310,7 @@ $sql = e107::getDb(); //TODO - find & replace $sql, $e107->sql
$sql->db_SetErrorReporting(false);
$dbg->logTime('SQL Connect');
$merror=$sql->db_Connect($sql_info['mySQLserver'], $sql_info['mySQLuser'], $sql_info['mySQLpassword'], $mySQLdefaultdb);
$merror=$sql->db_Connect($sql_info['server'], $sql_info['user'], $sql_info['password'], $sql_info['defaultdb']);
unset($sql_info);
// create after the initial connection.
//DEPRECATED, BC, call the method only when needed

View File

@@ -530,8 +530,17 @@ class e107
* @param array $e107_config_override
* @return e107
*/
public function initCore($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override = array())
public function initCore($e107_paths, $e107_root_path, $e107_config_mysql_info=array(), $e107_config_override = array())
{
if(!empty($e107_paths['admin'])) //v2.4
{
foreach($e107_paths as $dir => $path)
{
$newKey = strtoupper($dir).'_DIRECTORY';
$e107_paths[$newKey] = $path;
unset($e107_paths[$dir]);
}
}
return $this->_init($e107_paths, $e107_root_path, $e107_config_mysql_info, $e107_config_override);
}
@@ -599,7 +608,7 @@ class e107
$this->prepare_request();
// mysql connection info
$this->e107_config_mysql_info = $e107_config_mysql_info;
$this->setMySQLConfig($e107_config_mysql_info);
// unique folder for e_MEDIA - support for multiple websites from single-install. Must be set before setDirs()
/* if (!empty($e107_config_override['site_path']))
@@ -836,7 +845,7 @@ class e107
public function initInstallSql($e107_config_mysql_info)
{
// mysql connection info
$this->e107_config_mysql_info = $e107_config_mysql_info;
$this->setMySQLConfig($e107_config_mysql_info);
// various constants - MAGIC_QUOTES_GPC, MPREFIX, ...
$this->set_constants();
@@ -6170,6 +6179,25 @@ class e107
}
/**
* @param array $sqlinfo
* @return void
*/
private function setMySQLConfig($sqlinfo): void
{
if(!empty($sqlinfo['server']))
{
foreach($sqlinfo as $key=>$val)
{
$newKey = 'mySQL'.$key;
$sqlinfo[$newKey] = $val;
unset($sqlinfo[$key]);
}
}
$this->e107_config_mysql_info = $sqlinfo;
}
}

View File

@@ -14,7 +14,7 @@
+----------------------------------------------------+
This file has been generated by the installation script.
*/
/*
$mySQLserver = '{{ mySQLserver }}';
$mySQLuser = '{{ mySQLuser }}';
$mySQLpassword = '{{ mySQLpassword }}';
@@ -35,5 +35,31 @@ $MEDIA_DIRECTORY = 'e107_media/';
$SYSTEM_DIRECTORY = 'e107_system/';
$E107_CONFIG = array('site_path' => '000000test');
*/
define('e_MOD_REWRITE',true);
return [
'mySQL' => [
'server' => '{{ mySQLserver }}',
'user' => '{{ mySQLuser }}',
'password' => '{{ mySQLpassword }}',
'defaultdb'=> '{{ mySQLdefaultdb }}',
'prefix' => '{{ mySQLprefix }}',
'charset' => 'utf8',
],
'directories' => [ // leave empty to use default
'admin' => 'e107_admin/',
'files' => 'e107_files/',
'images' => 'e107_images/',
'themes' => 'e107_themes/',
'plugins' => 'e107_plugins/',
'handlers' => 'e107_handlers/',
'languages' => 'e107_languages/',
'help' => 'e107_docs/help/',
'system' => 'e107_system/',
'media' => 'e107_media/',
],
'other' => [
'site_path' => '000000test'
]
];