IMO CMSimple uses way too many global variables, but especially irritating is the fact that all GET parameters without a value are promoted to globals. This happens in cmsimple/cms.php line 562 (XH 1.6.1):
Code: Select all
foreach ($rq as $i) {
if (!strpos($i, '=')) {
$GLOBALS[$i] = 'true';
}
}
The biggest problem (if not the only one) seem to be requests to the administration of a plugin. The customary idiom to handle the adminstration of a plugin (for instance, the "example" plugin) is to conditionally execute the required code (in the plugin's admin.php):
Code: Select all
if ($example) {...}
Code: Select all
if (isset($example) && $example == 'true') {...}
Code: Select all
if (XH_wantsPluginAdminstration('example')) {...}
Code: Select all
function XH_wantsPluginAdministration($pluginName)
{
return $GLOBALS[$pluginName] == 'true';
}
Code: Select all
if (function_exists('XH_wantsPluginAdministration')
&& XH_wantsPluginAdministration('example')
|| $example
) {...}
[1] I wonder why the value of these globals is set to 'true' (string) instead of true (boolean). Is that a relict of PHP 3, where there might have been no boolean variables available?
Christoph