Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@EPinci
Copy link

EPinci commented Dec 25, 2013

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
Copy link
Member

mattab commented Dec 26, 2013

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
sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants