inspired by a German support thread I had a closer look at the current definition of CMSIMPLE_ROOT (in cmsimple/cms.php):
Code: Select all
/**
* The absolute path of the root folder.
*/
define(
'CMSIMPLE_ROOT',
str_replace('index.php', '', str_replace('/' . $sl . '/', "/", $sn))
);
Furthermore there are some (rather theoretical) issues, because the current solution does not regard the position of the replacements (the search strings do not necessarily have to be at the end of $sn).
So, a solution would be to "shuffle" some of the definitions in cms.php and to use preg_replace() instead of str_replace():
Code: Select all
Index: cms.php
===================================================================
--- cms.php (revision 3)
+++ cms.php (working copy)
@@ -261,21 +261,52 @@
}
/**
+ * Whether the webserver is IIS.
+ *
+ * @global bool $iis
+ */
+$iis = strpos(sv('SERVER_SOFTWARE'), "IIS");
+
+/**
+ * Whether PHP is executed as (F)CGI.
+ *
+ * @global bool $cgi
+ */
+$cgi = (php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi');
+
+/**
+ * The relative path of the root folder, i.e. the script name.
+ *
+ * @global string $sn
+ */
+$sn = preg_replace(
+ '/([^\?]*)\?.*/', '$1',
+ sv(($iis ? 'SCRIPT_NAME' : 'REQUEST_URI'))
+);
+
+/**
* The current language.
*
* @global string $sl
*/
-if (preg_match('/\/([A-z]{2})\/index.php$/', sv('SCRIPT_NAME'), $temp)
+if (preg_match('/\/([A-z]{2})\/index\.php$/', sv('SCRIPT_NAME'), $temp)
&& XH_isLanguageFolder($temp = strtolower($temp[1]))
) {
$sl = $temp;
$pth['folder']['content']
= $pth['folder']['base'] . $cf['folders']['content'] . $sl . '/';
+ $temp = preg_replace('/[A-z]{2}\/(index\.php)?$/', '', $sn);
} else {
$sl = $cf['language']['default'];
$pth['folder']['content'] = $pth['folder']['base'] . $cf['folders']['content'];
+ $temp = preg_replace('/index\.php$/', '', $sn);
}
+/**
+ * The absolute path of the root folder.
+ */
+define('CMSIMPLE_ROOT', $temp);
+
$pth['file']['content'] = $pth['folder']['content'] . 'content.htm';
$pth['file']['pagedata'] = $pth['folder']['content'] . 'pagedata.php';
$pth['file']['language'] = $pth['folder']['language'] . basename($sl) . '.php';
@@ -332,30 +363,6 @@
);
/**
- * Whether the webserver is IIS.
- *
- * @global bool $iis
- */
-$iis = strpos(sv('SERVER_SOFTWARE'), "IIS");
-
-/**
- * Whether PHP is executed as (F)CGI.
- *
- * @global bool $cgi
- */
-$cgi = (php_sapi_name() == 'cgi' || php_sapi_name() == 'cgi-fcgi');
-
-/**
- * The relative path of the root folder, i.e. the script name.
- *
- * @global string $sn
- */
-$sn = preg_replace(
- '/([^\?]*)\?.*/', '$1',
- sv(($iis ? 'SCRIPT_NAME' : 'REQUEST_URI'))
-);
-
-/**
* The requested action.
*
* @global string $action
@@ -520,14 +527,6 @@
}
/**
- * The absolute path of the root folder.
- */
-define(
- 'CMSIMPLE_ROOT',
- str_replace('index.php', '', str_replace('/' . $sl . '/', "/", $sn))
-);
-
-/**
* The relative path of the root folder.
*/
define('CMSIMPLE_BASE', $pth['folder']['base']);
Christoph