menatwork / syncCto

Contao Extension :: Synchronize multiple contao installations with each other
https://packagist.org/packages/menatwork/synccto
25 stars 14 forks source link

Wrong base tag when no pathconfig.php present #278

Open discordier opened 7 years ago

discordier commented 7 years ago

If the system/config/pathconfig.php is missing, synCto popups screw up big time, as they then add their whole path as base tag.

Solution is to run the following code right before the require($dir . '/system/initialize.php');:

if (!is_file($dir . '/system/config/pathconfig.php')) {
    \File::putContent(
        $dir . '/system/config/pathconfig.php',
        '<?php' . "\n\n// Relative path to the installation\nreturn " . var_export(preg_replace('/\/system\/modules\/syncCto\/SyncCtoPopup[a-z]+\.php$/i', '', (PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi' || PHP_SAPI == 'fpm-fcgi') && ($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) ? ($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) : ($_SERVER['ORIG_SCRIPT_NAME'] ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']))), true) . ";\n"
    );
}
discordier commented 7 years ago

@stefanheimes BUMP!