|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
c960657 Smarty Regular
Joined: 07 May 2003 Posts: 75 Location: Copenhagen, Denmark
|
Posted: Tue Sep 07, 2004 3:19 pm Post subject: {include_php} and $smarty->default_resource_type |
|
|
There appears to be problems using {include_php} when $smarty->default_resource_type is different from 'file'.
According to the documentation, the file attribute is an absolute file path or a file path relative to $smarty->trusted_dir. However, when $smarty->default_resource_type is different from 'file', I get the following error:
Quote: | Warning: Smarty error: myresourcetype:foo.php is not readable |
when I write {include_php file="foo.php"}.
If I prepend 'file:' to the file attribute, i.e. {include_php file="file:foo.php"}, it works as expected. But this is not a file name as described in the documentation.
If I change core.smarty_include_php.php from
[php:1:2b357e6887]$_params = array('resource_name' => $params['smarty_file']);[/php:1:2b357e6887]
to
[php:1:2b357e6887]$_params = array('resource_name' => 'file:' . $params['smarty_file']);[/php:1:2b357e6887]
it works. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Tue Sep 07, 2004 3:50 pm Post subject: |
|
|
It is not documented but it seems that you can actually retrieve PHP from a resource. In that case, it is up to the resource to deal with the appropriate path searches.
One odd thing is that you have to strip the <?php and ?> from the included file since it appears to be run through $smarty->_eval().
At anyrate, this could be considered a feature rather than a bug. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Sep 07, 2004 6:00 pm Post subject: |
|
|
though doubtly usefuly, smarty fully support resources with include_php.
the is_trusted()-function of a resource gives you control which php-files can be included in a secured environment, for example.
so it's quite reasonable for include_php to follow the default_resource_type. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|