Smarty & open_basedir

From: Date: Mon, 14 Oct 2002 16:20:31 +0000
Subject: Smarty & open_basedir
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-295@lists.php.net to get a copy of this message
There is a problem with Smarty when the directive open_basedir is used. A message like this is showed by PHP: Warning: open_basedir restriction in effect. File is in wrong directory The problem is in the method _create_dir_structure() in Smarty class that use file_exists() and mkdir() trying to access directories restricted by PHP. I have this patch that solve this problem without setting $use_sub_dirs=true. --- Smarty.class.php.orig Mon Oct 14 17:55:16 2002 +++ Smarty.class.php Mon Oct 14 17:48:13 2002 @@ -1599,13 +1601,15 @@ if (!@file_exists($dir)) { $dir_parts = preg_split('!\\'.DIR_SEP.'+!', $dir, -1, PREG_SPLIT_NO_EMPTY); $new_dir = ($dir{0} == DIR_SEP) ? DIR_SEP : ''; - foreach ($dir_parts as $dir_part) { - $new_dir .= $dir_part; + for ($i = 0; $i < sizeof($dir_parts); $i++, $new_dir .= DIR_SEP) { + $new_dir .= $dir_parts[$i]; + if (substr($new_dir, 0, strlen($this->compile_dir)) != $this->compile_dir) { + continue; + } if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) { $this->trigger_error("problem creating directory \"$dir\""); return false; } - $new_dir .= DIR_SEP; } } } -- Alessandro 'Asterix' Astarita <aleast@capri.it> CapriOnLine S.r.l. http://www.caprionline.com/

« previous php.smarty.dev (#295) next »