In Theme.php, file_exists() triggers open_basedir restrictions in Windows PHP if contaning querystring #4438

Closed
EPinci opened this Issue Dec 25, 2013 · 1 comment

2 participants

@EPinci

Looks like, in Windows PHP 5.5.7,
if the filename passed to file_exists() contains a querystring
the open_basedir restrictions bogusly triggered.
Dunno if relevant, i have two paths in my open_basedir directive.

I fixed the Core\Theme.php file as follows:

        // replace all plugin assets to the theme, if the theme overrides this asset
        // when there are name conflicts (two plugins define the same asset name in same folder),
        // we shall rename so there is no more conflict.
        $defaultThemePath = "plugins/" . $pathPluginName;
        $newThemePath = "plugins/" . $this->themeName;
        $overridingAsset = str_replace($defaultThemePath, $newThemePath, $pathAsset);

    // Strip trailing querystring, if any
    $fileToCheck = $overridingAsset;
    $posQMInFileToCheck = strpos($fileToCheck, '?');
        if( $posQMInFileToCheck !== 0) {
            $fileToCheck = substr($fileToCheck, 0, $posQMInFileToCheck);
        }

        if(file_exists($fileToCheck)) {
            return str_replace($pathAsset, $overridingAsset, $source);
        }
        return $source;

Thank you.

@mattab
Piwik Open Source Analytics member

In 1782c1e: Remove query string before checking if file exists, for windows + open_basedir. fixes #4438

@EPinci EPinci added this to the 2.0.3 - Piwik 2.0.3 milestone Jul 8, 2014
@mattab mattab was assigned by EPinci Jul 8, 2014
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Remove query string before checking if file exists, for windows + ope…
…n_basedir. fixes #4438
1782c1e
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment