Re: [SMARTY] $trusted_dir and include_php script search path list
| From: | Monte Ohrt | Date: | Wed, 01 May 2002 15:41:20 +0000 |
| Subject: | Re: [SMARTY] $trusted_dir and include_php script search path list | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3953@lists.php.net to get a copy of this message | ||
This has been fixed, please try the CVS version.
Monte
g.p.ciceri wrote:
Hello all, I'm playing with include_php stuff in templates, and I think I have found a little bug with $trusted_dir path. I've set, in the driver php program --- define("SMARTY_REPOSITORY_DIR", "/usr/local/SmartyRepository/"); define("SMARTY_MDL_DIR", SMARTY_REPOSITORY_DIR."models"); $smarty = new Smarty; $smarty->trusted_dir = SMARTY_MDL_DIR; $smarty->display("mysql-stc.tpl"); --- and in the mysql-stc.tpl file I've put the statement --- {include_php file="temp/mysql-stc.php"} --- Running this, I take: Warning: Smarty error: 'file: /usr/local/SmartyRepository/models/temp/mysql-stc.php' is not readable in /usr/local/lib/php/Smarty-2.1.0/Smarty.class.php on line 546 I've looked a little in Smarty.class.php, and in the function _get_php_resource(...) I've found you search the script into $include_paths = preg_split('![:;]!', ini_get('include_path')); where ini_get('include_path') is the standard PHP include path. Now, since with $trusted_dir you prepend the trusted path to the script, you need to add the '/' directory to the path search list (it's infeasible to add it to incude_path), for example: array_push($include_paths, '/'); Doing this, all is o.k.. I've not tested for side effects, for the moment. HTH /gp p.s.: there is written in the documentation that $trusted_dir works only with secirity enabled. I've tested with security both enabled and disabled, with the same result.-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.