Skip to content

Commit

Permalink
Bring settings.php in line with Config.php
Browse files Browse the repository at this point in the history
Signed by Shawn Bulen, [email protected]
  • Loading branch information
sbulen committed Oct 7, 2024
1 parent 187837d commit 7ba18f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
8 changes: 8 additions & 0 deletions Sources/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,14 @@ public static function updateSettingsFile(array $config_vars, ?bool $keep_quotes

if (!empty($setting_def['raw_default']) && $setting_def['default'] !== '') {
$var_pattern[] = preg_replace('/\s+/', '\s+', preg_quote($setting_def['default'], '~'));

if (str_contains($setting_def['default'], 'dirname(__FILE__)')) {
$var_pattern[] = preg_replace('/\s+/', '\s+', preg_quote(str_replace('dirname(__FILE__)', '__DIR__', $setting_def['default']), '~'));
}

if (str_contains($setting_def['default'], '__DIR__')) {
$var_pattern[] = preg_replace('/\s+/', '\s+', preg_quote(str_replace('__DIR__', 'dirname(__FILE__)', $setting_def['default']), '~'));
}
}

$var_pattern = array_unique($var_pattern);
Expand Down
12 changes: 6 additions & 6 deletions other/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
*
* Path to the cache directory for the file-based cache system.
*/
$cachedir = dirname(__FILE__) . '/cache';
$cachedir = __DIR__ . '/cache';

########## Image Proxy ##########
/**
Expand Down Expand Up @@ -202,25 +202,25 @@
*
* The absolute path to the forum's folder. (not just '.'!)
*/
$boarddir = dirname(__FILE__);
$boarddir = __DIR__;
/**
* @var string
*
* Path to the Sources directory.
*/
$sourcedir = dirname(__FILE__) . '/Sources';
$sourcedir = __DIR__ . '/Sources';
/**
* @var string
*
* Path to the Packages directory.
*/
$packagesdir = dirname(__FILE__) . '/Packages';
$packagesdir = __DIR__ . '/Packages';
/**
* @var string
*
* Path to the language directory.
*/
$languagesdir = dirname(__FILE__) . '/Languages';
$languagesdir = __DIR__ . '/Languages';

######### Modification Support #########
/**
Expand All @@ -242,7 +242,7 @@
*/
$db_character_set = 'utf8';

if (file_exists(dirname(__FILE__) . '/install.php'))
if (file_exists(__DIR__ . '/install.php'))
{
$secure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
Expand Down
12 changes: 6 additions & 6 deletions other/Settings_bak.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
*
* Path to the cache directory for the file-based cache system.
*/
$cachedir = dirname(__FILE__) . '/cache';
$cachedir = __DIR__ . '/cache';

########## Image Proxy ##########
/**
Expand Down Expand Up @@ -202,25 +202,25 @@
*
* The absolute path to the forum's folder. (not just '.'!)
*/
$boarddir = dirname(__FILE__);
$boarddir = __DIR__;
/**
* @var string
*
* Path to the Sources directory.
*/
$sourcedir = dirname(__FILE__) . '/Sources';
$sourcedir = __DIR__ . '/Sources';
/**
* @var string
*
* Path to the Packages directory.
*/
$packagesdir = dirname(__FILE__) . '/Packages';
$packagesdir = __DIR__ . '/Packages';
/**
* @var string
*
* Path to the language directory.
*/
$languagesdir = dirname(__FILE__) . '/Languages';
$languagesdir = __DIR__ . '/Languages';

######### Modification Support #########
/**
Expand All @@ -242,7 +242,7 @@
*/
$db_character_set = 'utf8';

if (file_exists(dirname(__FILE__) . '/install.php'))
if (file_exists(__DIR__ . '/install.php'))
{
$secure = false;
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
Expand Down

0 comments on commit 7ba18f9

Please sign in to comment.