diff --git a/class2.php b/class2.php index 70da28b73d..7163f6a027 100755 --- a/class2.php +++ b/class2.php @@ -135,7 +135,7 @@ unset($retrieve_prefs); } -include(e_ROOT.'e107_config.php'); +$config = include(e_ROOT.'e107_config.php'); if(!defined('e_POWEREDBY_DISABLE')) { @@ -159,7 +159,7 @@ //define("MPREFIX", $mySQLprefix); moved to $e107->set_constants() -if(empty($mySQLdefaultdb) && !class_exists('e107_config')) +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'); @@ -184,7 +184,7 @@ e107_require_once($tmp.'/e107_class.php'); unset($tmp); -if(!class_exists('e107_config')) // old e107_config.php format. +if(empty($config['paths'])) // old e107_config.php format. { $dirNames = ['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']; @@ -211,9 +211,10 @@ } else // New e107_config.php format. v2.4+ { - $e107_paths = e107_config::paths(); - $sql_info = e107_config::database(); - $E107_CONFIG = e107_config::other() ?? []; + $e107_paths = $config['paths']; + $sql_info = $config['database']; + $E107_CONFIG = $config['other'] ?? []; + unset($config); } diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 644d3b9432..9268b321d4 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1228,7 +1228,9 @@ public function sc_admin_siteinfo($parm='') { return null; } - global $themename, $themeversion, $themeauthor, $themedate, $themeinfo, $mySQLdefaultdb; + global $themename, $themeversion, $themeauthor, $themedate, $themeinfo; + + $mySQLdefaultdb = e107::getMySQLConfig('defaultdb'); $pref = e107::getPref(); $ns = e107::getRender(); diff --git a/e107_handlers/e_thumbnail_class.php b/e107_handlers/e_thumbnail_class.php index c9b5a7eb31..23069e1ae0 100644 --- a/e107_handlers/e_thumbnail_class.php +++ b/e107_handlers/e_thumbnail_class.php @@ -608,9 +608,9 @@ private function placeholder($parm) return null; } - $getsize = isset($parm['size']) ? $parm['size'] : '100x100'; + $getsize = $parm['size'] ?? '100x100'; - header('location: https://via.placeholder.com/'.$getsize); + header('location: https://placehold.co/'.$getsize); header('Content-Length: 0'); exit(); } diff --git a/e107_tests/tests/_data/e107_config.php.sample b/e107_tests/tests/_data/e107_config.php.sample index 57cb68400e..bd177e5270 100644 --- a/e107_tests/tests/_data/e107_config.php.sample +++ b/e107_tests/tests/_data/e107_config.php.sample @@ -38,23 +38,16 @@ $E107_CONFIG = array('site_path' => '000000test'); */ const e_MOD_REWRITE = true; -class e107_config -{ - public static function database() - { - return [ +return [ + 'database' => [ 'server' => '{{ mySQLserver }}', 'user' => '{{ mySQLuser }}', 'password' => '{{ mySQLpassword }}', 'defaultdb'=> '{{ mySQLdefaultdb }}', 'prefix' => '{{ mySQLprefix }}', 'charset' => 'utf8', - ]; - } - - public static function paths() - { - return [ + ], + 'paths' => [ // leave empty to use default 'admin' => 'e107_admin/', 'files' => 'e107_files/', 'images' => 'e107_images/', @@ -65,14 +58,8 @@ class e107_config 'help' => 'e107_docs/help/', 'system' => 'e107_system/', 'media' => 'e107_media/', - ]; - } - - public static function other() - { - return [ + ], + 'other' => [ 'site_path' => '000000test' + ] ]; - } -} - diff --git a/install.php b/install.php index fedc65b4ca..1e5d0c01a8 100644 --- a/install.php +++ b/install.php @@ -1531,6 +1531,59 @@ private function stage_7() }*/ +// New format e107 v2.4+ + +$config_file = "previous_steps['admin']['email']}'; // email the admin (and share no details with the user) if a critical error occurs. +// const e_LOG_CRITICAL = true; // log critical errors but do not display them to user. (similar to above, but no email is sent - instead error goes into a log file) +// const e_DEBUG = true; // Enable debug mode to allow displaying of errors +// const e_HTTP_STATIC = 'https://static.mydomain.com/'; // Use a static subdomain for js/css/images etc. +// const e_MOD_REWRITE_STATIC = true; // Rewrite static image urls. +// const e_GIT = 'path-to-git'; // Path to GIT for developers +// const X_FRAME_SAMEORIGIN = false; // Option to override X-Frame-Options + + +return [ + 'database' => [ + 'server' => '{$this->previous_steps['mysql']['server']}', + 'user' => '{$this->previous_steps['mysql']['user']}', + 'password' => '{$this->previous_steps['mysql']['password']}', + 'defaultdb'=> '{$this->previous_steps['mysql']['db']}', + 'prefix' => '{$this->previous_steps['mysql']['prefix']}', + 'charset' => 'utf8mb4', + ], + 'paths' => [ + 'admin' => '{$this->e107->e107_dirs['ADMIN_DIRECTORY']}', + 'files' => '{$this->e107->e107_dirs['FILES_DIRECTORY']}', + 'images' => '{$this->e107->e107_dirs['IMAGES_DIRECTORY']}', + 'themes' => '{$this->e107->e107_dirs['THEMES_DIRECTORY']}', + 'plugins' => '{$this->e107->e107_dirs['PLUGINS_DIRECTORY']}', + 'handlers' => '{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}', + 'languages' => '{$this->e107->e107_dirs['LANGUAGES_DIRECTORY']}', + 'help' => '{$this->e107->e107_dirs['HELP_DIRECTORY']}', + 'media' => '{$this->e107->e107_dirs['MEDIA_DIRECTORY']}', + 'system' => '{$this->e107->e107_dirs['SYSTEM_DIRECTORY']}', + ], + 'site' => [ + 'site_path' => '{$this->previous_steps['paths']['hash']}', + ] +]; +"; + + $config_result = $this->write_config($config_file); if ($config_result) diff --git a/thumb.php b/thumb.php index 1c62a519eb..3e8070edb4 100755 --- a/thumb.php +++ b/thumb.php @@ -36,6 +36,7 @@ function thumbExceptionHandler(Throwable $e) $e->getLine(), $e->getTraceAsString() ); + var_dump($message); error_log($message); } @@ -97,7 +98,7 @@ function __construct() // Config - include($self.DIRECTORY_SEPARATOR.'e107_config.php'); + $config = include($self.DIRECTORY_SEPARATOR.'e107_config.php'); // support early include feature if(!empty($CLASS2_INCLUDE)) @@ -120,7 +121,7 @@ function __construct() //e107 class require($tmp.DIRECTORY_SEPARATOR.'e107_class.php'); - if(!class_exists('e107_config')) // old e107_config.php format. + if(empty($config['paths'])) // old e107_config.php format. { $dirNames = ['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']; @@ -142,9 +143,9 @@ function __construct() } else // New e107_config.php format. v2.4+ { - $e107_paths = e107_config::paths(); - $sql_info = e107_config::database(); - $E107_CONFIG = e107_config::other() ?? []; + $e107_paths = $config['paths']; + $sql_info = $config['database']; + $E107_CONFIG = $config['other'] ?? []; } $e107 = e107::getInstance()->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array()));