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

smarty with php

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
Meganathan
Smarty n00b


Joined: 18 May 2012
Posts: 1

PostPosted: Fri May 18, 2012 9:15 am    Post subject: smarty with php Reply with quote

Hi,
I've a problem when use following code in smarty file(.tpl):
{php}
echo "hi";
{/php}

please reply what is problem here
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri May 18, 2012 10:13 am    Post subject: Reply with quote

The {php} tag is in Smarty 3 deprecated for security reasions.

If you really need it use the SmartyBC class.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Oct 10, 2012 5:00 pm    Post subject: Reply with quote

Include SamrtyBC.class.php instead of Smarty.class.php and create the Smarty instance with $smarty = new SmartyBC;
Back to top
View user's profile Send private message
Izabella
Smarty n00b


Joined: 03 Apr 2013
Posts: 1

PostPosted: Wed Apr 03, 2013 1:48 am    Post subject: Reply with quote

I also have a similar issue.

My problem is that I need to insert a php file into header.tpl with {include_php} but I receive the error code:
Fatal error: Uncaught exception 'SmartyException' with message '{include_php} is deprecated, use SmartyBC class to enable

I know that I should use SmartyBC, but the problem is that the software is fully encoded, so I am not able to change anything. Only 1 .php file "config.php" is not encoded, which includes the database login details. The software using Smarty v. 3.1.12.

My question would be is there any alternate way to fix the issue?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Apr 03, 2013 2:18 am    Post subject: Reply with quote

Izabella wrote:
I also have a similar issue.

My problem is that I need to insert a php file into header.tpl with {include_php} but I receive the error code:
Fatal error: Uncaught exception 'SmartyException' with message '{include_php} is deprecated, use SmartyBC class to enable

I know that I should use SmartyBC, but the problem is that the software is fully encoded, so I am not able to change anything. Only 1 .php file "config.php" is not encoded, which includes the database login details. The software using Smarty v. 3.1.12.

My question would be is there any alternate way to fix the issue?


If you are using software that is encoding the Smarty libraries, they are using it against the LGPL license. You might inform them they need to leave the Smarty libs unencoded.

To answer your question, don't try to embed PHP in templates. Use template functions to fulfill your task. There is a reason Smarty 3 deprecated php in templates, it is always a bad idea and there is always a better way. Also, find another software vendor that doesn't encode source.

I hate encoded software, it solves a problem in completely the wrong way. It makes the software completely unmaintainable and a PITA. They will eventually learn that it works best to protect software with licenses, not with encoding. That is, if their software doesn't completely fail to succeed first because of it. Maybe they'll realize no one wants to copy their software anyways. /end rant
Back to top
View user's profile Send private message Visit poster's website
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 -> Smarty Development 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