[BUG] relative cache file path causes Open Basedir error

GK User
Thu May 18, 2017 5:39 pm
Hi! Today I reviewed an issue with JotCache component that caused the JotCache to not cache anything. After some deugging I found that if enabled JS or JSS compression the function store_file from helper.cache.php caused an Open Basedir error and the cached file won't be created.

To solve this I've added the full path to the compressed CSS/JS file on store_file function like this
Code: Select all
if(!function_exists('store_file')){
  function store_file($data, $filename, $overwrite = false) {
        $path = JPATH_ROOT . DS . 'cache' . DS . 'gk';
        jimport('joomla.filesystem.folder');
        if (!is_dir($path)) JFolder::create($path);
        $path = $path . DS . $filename;
        $url = JURI::base(true) .DS. 'cache'. DS .'gk' . DS. $filename;
        if (is_file($path) && !$overwrite) return $url;
        JFile::write($path, $data);
        return is_file($path) ? $url : false;
    }
}


Added JPATH_ROOT . DS . to the first $path assignment.
User avatar
Expert Boarder

teitbite
Mon May 22, 2017 9:37 am
Hi

Ok. Thanks for shearing that. Will show this to programmers.
User avatar
Moderator


cron