Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: N3RVE on February 03, 2009, 07:38:28 AM

Title: How to Enable / Disable eval()
Post by: N3RVE on February 03, 2009, 07:38:28 AM
You might want to see: Why does SMF use eval()? (http://www.simplemachines.org/community/index.php?topic=50227.0)


Let me guess, you are reading this topic because you've been asked to enable / disable eval()?
When eval() is used, errors reported in templates and other files might not actually be happening there. So you might need to disable eval() temporarily to get accurate errors.

To do that, open phpMyAdmin (What is phpMyAdmin? (http://www.simplemachines.org/community/index.php?topic=21919.0)), select your forum database and run this query:

Code (Disable) Select
REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);

Empty the Forum Error Log (http://docs.simplemachines.org/index.php?topic=150) from Admin Control Panel > "Forum Error Log" and wait for new errors. The newly generated errors should be different and should point out where exactly the errors are happening. Copy those errors and post them where you've been asked to and run the following query to enable eval()

Code (Enable) Select
REPLACE INTO smf_settings VALUES ('disableTemplateEval', 0);

The SQL queries above work if the database tables prefix for your forum is smf_ (which is the default). The actual prefix for your forum can be found in the Admin CP -> Server Settings -> "Database Tables Prefix" or as the value for $db_prefix in Settings.php (which is located in your forum directory).


To run each of the queries, click on the SQL link at the top of the right pane (see the image below), enter the query in the box and click the Go button.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimg177.imageshack.us%2Fimg177%2F9899%2Fsqlhm7.png&hash=a354b647bba8aa2a8908611993c6c9d031066cf9)

Do *not* post support request here, please, start a new topic with your query :)

-[n3rve]
Title: Re: How to Enable / Disable eval()
Post by: shadow82x on February 03, 2009, 06:05:52 PM
Nice tutorial [n3rve]. This will help the many support topics that ask for assistance on this. :P
Title: Re: How to Enable / Disable eval()
Post by: N3RVE on February 04, 2009, 12:18:20 PM
Thanks Shadow82x, I've had to reply with these instructions to quite a lot of support topics recently and thought it'll help to have it posted ;)

-[n3rve]
Title: Re: How to Enable / Disable eval()
Post by: aw06 on February 12, 2009, 03:49:55 PM
What happens if i leave eval disabled ??
Title: Re: How to Enable / Disable eval()
Post by: N3RVE on March 06, 2009, 12:32:24 PM
Quote from: aw06 on February 12, 2009, 03:49:55 PM
What happens if i leave eval disabled ??

eval() simply executes the specified string as PHP code. Since file_get_contents() returns the contents of a file as a string, this allows SMF to track down the specific code that's causing a parse error, and consequently output a pretty color-coded error message showing you the code that's causing the problem.

The downside to using eval() is that PHP doesn't really know where an "undefined" error occurred. By switching eval() off, SMF uses require() (or, more often, require_once()) to get the template file. This in turn lets PHP report the exact location of the error.

Hope that clears things up for you :)

-[n3rve]
Title: Re: How to Enable / Disable eval()
Post by: C4G-TK on April 18, 2009, 02:15:12 AM
OK, I got it disabled correctly, but now I can't get it to enable again!!  LOL

I ran the query, but I get this message:

SQL query:

INSERT INTO channel4gaming_com_c4g_settings
VALUES (
'disableTemplateEval', 0
)

MySQL said: Documentation
#1062 - Duplicate entry 'disableTemplateEval' for key 1
Title: Re: How to Enable / Disable eval()
Post by: C4G-TK on April 18, 2009, 02:19:30 AM
Quote from: [n3rve] on February 03, 2009, 07:38:28 AM
Empty the Forum Error Log (http://docs.simplemachines.org/index.php?topic=150) from Admin Control Panel > "Forum Error Log" and wait for new errors. The newly generated errors should be different and should point out where exactly the errors are happening. Copy those errors and post them where you've been asked to and run the following query to enable eval()

Code (Enable) Select
INSERT INTO smf_settings VALUES ('disableTemplateEval', 0);


Ummm, shouldn't the 2nd query be  enableTemplateEval instead of disable?  Because otherwise, I keep getting an error and it won't correctly do the query.

ok maybe not... help!   ??? ???
Title: Re: How to Enable / Disable eval()
Post by: Fustrate on April 18, 2009, 02:41:00 AM
I edited it to use REPLACE INTO instead of INSERT INTO, so that this can be done more than once.

;)
Title: Re: How to Enable / Disable eval()
Post by: heavyccasey on April 18, 2009, 02:46:09 AM
Thank you, this sped up my forum by a noticeable amount (I use an accelerator).
Title: Re: How to Enable / Disable eval()
Post by: Sarge on May 15, 2009, 03:43:06 PM
Quote from: heavyccasey on April 18, 2009, 02:46:09 AM
Thank you, this sped up my forum by a noticeable amount (I use an accelerator).

I'm curious... what sped up your forum, enabling or disabling eval?
Title: Re: How to Enable / Disable eval()
Post by: Fustrate on May 15, 2009, 03:45:09 PM
Probably disabled, since it's enabled by default.
Title: Re: How to Enable / Disable eval()
Post by: Neighbours-Unite on August 06, 2009, 03:58:23 PM
Quote from: [n3rveThe SQL queries above work if the database tables prefix for your forum is smf_ (which is the default). The actual prefix for your forum can be found in the Admin CP -> Server Settings -> "Database Tables Prefix" or as the value for $db_prefix in Settings.php (which is located in your forum directory).

-[n3rve]

But what if the tables prefix isn't smf_?
What if that is left blank like this  $db_prefix = '';
MIght that start causing problems in the future?
I tried to change it so it said smf_ but everything whent down then so had to change it back.
Title: Re: How to Enable / Disable eval()
Post by: N3RVE on August 06, 2009, 04:27:05 PM
Just run: REPLACE INTO settings VALUES ('disableTemplateEval', 1);

-[n3rve]
Title: Re: How to Enable / Disable eval()
Post by: abidejaz4u on August 09, 2009, 06:02:18 AM
in there show like this

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi30.tinypic.com%2F2z57wjp.jpg&hash=59c144f2f8745307238840c8ed1462d3512dce4d)

full image
click here (http://i30.tinypic.com/2z57wjp.jpg)

where i can put that Query
Title: Re: How to Enable / Disable eval()
Post by: N3RVE on August 09, 2009, 06:04:15 AM
SQL, see the screenshot above.

-[n3rve]
Title: Re: How to Enable / Disable eval()
Post by: Arantor on August 09, 2009, 01:47:03 PM
You can also use this mod: http://custom.simplemachines.org/mods/index.php?mod=2054 to add a UI item to both 1.1 and 2.0.
Title: Re: How to Enable / Disable eval()
Post by: Marthless on December 13, 2010, 12:37:14 PM
Hello, whether somebody can say where I will find with the one options REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);. ?

I will add that in smf_settings I don't have it.
I ask you for the help in solving this problem. Because no longer I know what is not this way.

I will be very grateful for it. :)
Title: Re: How to Enable / Disable eval()
Post by: Masterd on January 09, 2011, 12:31:08 PM
This is a query. You need to run it in the phpMyAdmin query section. Maybe your database prefix is not smf_.
Title: Re: How to Enable / Disable eval()
Post by: MrPhil on January 09, 2011, 10:24:15 PM
I think the statement was that "disableTemplateEval" isn't found in his smf_settings. That's OK. It is suggested to do a REPLACE instead of an INSERT in case that entry has already been added -- you don't want two copies of it. If it doesn't already exist, REPLACE will act like INSERT.

By the way, there is a mod (2054) that gives you an admin switch to do this more easily.
Title: Re: How to Enable / Disable eval()
Post by: Masterd on January 10, 2011, 05:49:21 AM
Quote from: MrPhil on January 09, 2011, 10:24:15 PM
By the way, there is a mod (2054) that gives you an admin switch to do this more easily.

Quote from: IncognitoMuse on August 09, 2009, 01:47:03 PM
You can also use this mod: http://custom.simplemachines.org/mods/index.php?mod=2054 to add a UI item to both 1.1 and 2.0.