$trusted_dir and include_php script search path list

From: Date: Wed, 01 May 2002 10:52:30 +0000
Subject: $trusted_dir and include_php script search path list
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3966@lists.php.net to get a copy of this message
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.: in the documentation there is written that $trusted_dir works only with secirity enabled. I've tested with security both enabled and disabled, with the same result. -- Discussion: How do you feel about Open Source firms making millions through public offerings? "I wish these companies were making the same millions without distributing any non-free, user-subjugating software." -- Richard Stallman "We're so forward that sometimes we reach ourself." -- g.p. "It is amazing how much you can achieve when you don't have to do the real work yourself." -- Joe Celko Gian Paolo Ciceri Via B.Diotti 45 - 20153 Milano MI ITALY I2BITM @ Cofiri mobile : ++39 347 4106213 : ++39 329 8103661 eMail : gp.ciceri@acm.org, gp.ciceri@computer.org : gp.ciceri@cofiri.it webSite: http://www.cofiri.it (forecoming) ICQ # : 94620118

« previous php.smarty.general (#3966) next »