Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

INCLUDE_PHP throwing "file not readable" error

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mhdn2
Smarty Rookie


Joined: 12 Aug 2015
Posts: 11

PostPosted: Mon Oct 19, 2015 1:18 am    Post subject: INCLUDE_PHP throwing "file not readable" error Reply with quote

I'm trying to use INCLUDE_PHP as a band-aid until I get all my pages converted to Smarty. However it keeps throwing this error.

Code:
Notice: Undefined property: SmartyBC::$trusted_dir in /home/clansta/public_html/iascripts/smarty/Smarty.class.php on line 1681

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "skins/nos1/claninfo.html" on line 7 "{INCLUDE_PHP file=$menu_path}" {include_php} file 'menu.php' is not readable <-- thrown in /home/clansta/public_html/iascripts/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 7


My viewer files are in the top level directory iascripts, and my Smarty HTML files are a couple of levels lower in iascripts/skins/nos1 (or in the future, whatever folder corresponds to the chosen skin)

Viewer File
/iascripts/claninfo.php

Code:
<?php

$skin_path = 'skins/nos1/';

include('./smarty/Smarty.class.php');
// temporarily using SmartyBC instead of Smarty to enable {INCLUDE_PHP}
$smarty = new SmartyBC();
$smarty->setTemplateDir($skin_path);
$smarty->setCompileDir('./smarty/templates_c');
$smarty->setCacheDir('./smarty/cache');
$smarty->setConfigDir('./smarty/configs');

$smarty->assign('menu_path', '../../claninfo/menu.php');
$smarty->assign('page_path', '../../claninfo/index.php');

$smarty->display('claninfo.html');

?>


Smarty Code
/iascripts/skins/nos1/claninfo.html

Code:
{INCLUDE_PHP file=$menu_path}

{INCLUDE_PHP file=$page_path}


Files we're trying to include:
/iascripts/claninfo/index.php
/iascripts/claninfo/menu.php

Clearly I am doing something wrong. Please take a look and see if you can steer me in the right direction. Thank you.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Oct 24, 2015 9:57 pm    Post subject: Reply with quote

Enable security and add the right folder as trusted_dir

See http://www.smarty.net/docs/en/variable.trusted.dir.tpl
http://www.smarty.net/docs/en/language.function.include.php.tpl


Or add in the Smarty BC class the trusted_dir property

public $trusted_dir = array(.....);
Back to top
View user's profile Send private message
mhdn2
Smarty Rookie


Joined: 12 Aug 2015
Posts: 11

PostPosted: Sat Oct 31, 2015 7:47 pm    Post subject: Reply with quote

I changed my Smarty code to this:

Code:
include('./smarty/SmartyBC.class.php');
$smarty = new SmartyBC();
$smarty->trusted_dir = array('/');
$smarty->enableSecurity();


I am still getting the error:

Code:
Notice: Undefined property: SmartyBC::$trusted_dir in /home/clansta/public_html/ics/smarty/Smarty.class.php on line 1702

Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "skins/nos1/claninfo.html" on line 7 "{INCLUDE_PHP file=$menu_path}" {include_php} file 'menu.php' is not readable <-- thrown in /home/clansta/public_html/ics/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 7


I also get the same error with this simpler code:

Code:
include('./smarty/SmartyBC.class.php');
$smarty = new SmartyBC();


Any suggestions?
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sat Oct 31, 2015 9:39 pm    Post subject: Reply with quote

Start using full paths.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat Oct 31, 2015 9:52 pm    Post subject: Reply with quote

mhdn2 wrote:
I changed my Smarty code to this:

Code:
include('./smarty/SmartyBC.class.php');
$smarty = new SmartyBC();
$smarty->trusted_dir = array('/');
$smarty->enableSecurity();



You can not add a property to the Smarty class like this
Code:
$smarty->trusted_dir = array('/');


You must add the property to SmartyBC.class.php
Code:
public $trusted_dir = array(.....);

as I told you before.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP