Skip to content

Commit

Permalink
Issue #5120 Return to multi-dimensional format for multisite plugin c…
Browse files Browse the repository at this point in the history
…ompatibility.
  • Loading branch information
CaMer0n committed Apr 8, 2024
1 parent 145d1de commit 8711f50
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 34 deletions.
13 changes: 7 additions & 6 deletions class2.php
Expand Up @@ -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'))
{
Expand All @@ -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');
Expand All @@ -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'];

Expand All @@ -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);
}


Expand Down
4 changes: 3 additions & 1 deletion e107_core/shortcodes/batch/admin_shortcodes.php
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions e107_handlers/e_thumbnail_class.php
Expand Up @@ -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();
}
Expand Down
27 changes: 7 additions & 20 deletions e107_tests/tests/_data/e107_config.php.sample
Expand Up @@ -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/',
Expand All @@ -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'
]
];
}
}

53 changes: 53 additions & 0 deletions install.php
Expand Up @@ -1531,6 +1531,59 @@ private function stage_7()
}*/


// New format e107 v2.4+

$config_file = "<?php
/*
* e107 website system
*
* Copyright (C) 2008-".date('Y')." e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* e107 configuration file
*
* This file has been generated by the installation script on ".date('r').".
*/
// -- Optional --
// const e_EMAIL_CRITICAL = '{$this->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)
Expand Down
11 changes: 6 additions & 5 deletions thumb.php
Expand Up @@ -36,6 +36,7 @@ function thumbExceptionHandler(Throwable $e)
$e->getLine(),
$e->getTraceAsString()
);
var_dump($message);
error_log($message);
}

Expand Down Expand Up @@ -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))
Expand All @@ -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'];

Expand All @@ -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()));
Expand Down

0 comments on commit 8711f50

Please sign in to comment.