Advertisement:

Author Topic: How to Enable / Disable eval()  (Read 45501 times)

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
How to Enable / Disable eval()
« on: February 03, 2009, 07:38:28 AM »
You might want to see: Why does SMF use eval()?

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?), select your forum database and run this query:

Code: (Disable) [Select]
REPLACE INTO smf_settings VALUES ('disableTemplateEval', 1);
Empty the Forum Error Log 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.



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

-[n3rve]
« Last Edit: May 03, 2009, 02:28:36 PM by Fustrate »
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline shadow82x

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 11,278
  • Gender: Male
    • cmblaber on LinkedIn
Re: How to Enable / Disable eval()
« Reply #1 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
Colin B
Former Spammer, Customize, & Support Team Member

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
Re: How to Enable / Disable eval()
« Reply #2 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]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline aw06

  • SMF Hero
  • ******
  • Posts: 2,763
  • Gender: Male
  • Make The Link
    • shopinja.classifieds on Facebook
    • @shopinja on Twitter
    • ShopinJA.com
Re: How to Enable / Disable eval()
« Reply #3 on: February 12, 2009, 03:49:55 PM »
What happens if i leave eval disabled ??
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
Re: How to Enable / Disable eval()
« Reply #4 on: March 06, 2009, 12:32:24 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]
« Last Edit: March 06, 2009, 01:26:23 PM by [n3rve] »
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline C4G-TK

  • Sr. Member
  • ****
  • Posts: 961
  • SHOW others respect & you GET respect in return.
Re: How to Enable / Disable eval()
« Reply #5 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
-img removed-

Offline C4G-TK

  • Sr. Member
  • ****
  • Posts: 961
  • SHOW others respect & you GET respect in return.
Re: How to Enable / Disable eval()
« Reply #6 on: April 18, 2009, 02:19:30 AM »
Empty the Forum Error Log 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!   ??? ???
« Last Edit: April 18, 2009, 02:23:50 AM by C4G-TK »
-img removed-

Offline Fustrate

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,474
  • Gender: Male
  • Controller of the rum budget
    • Fustrate on GitHub
    • @Fustrate on Twitter
    • Fustrate
Re: How to Enable / Disable eval()
« Reply #7 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.

;)
« Last Edit: May 03, 2009, 02:29:18 PM by Fustrate »
Steven Hoffman
Former Team Member, 2009-2012

Offline heavyccasey

  • Jr. Member
  • **
  • Posts: 212
Re: How to Enable / Disable eval()
« Reply #8 on: April 18, 2009, 02:46:09 AM »
Thank you, this sped up my forum by a noticeable amount (I use an accelerator).

Offline Sarge

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,209
  • Gender: Male
    • Zëri YT!
Re: How to Enable / Disable eval()
« Reply #9 on: May 15, 2009, 03:43:06 PM »
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?
    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Offline Fustrate

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,474
  • Gender: Male
  • Controller of the rum budget
    • Fustrate on GitHub
    • @Fustrate on Twitter
    • Fustrate
Re: How to Enable / Disable eval()
« Reply #10 on: May 15, 2009, 03:45:09 PM »
Probably disabled, since it's enabled by default.
Steven Hoffman
Former Team Member, 2009-2012

Offline Neighbours-Unite

  • Semi-Newbie
  • *
  • Posts: 11
Re: How to Enable / Disable eval()
« Reply #11 on: August 06, 2009, 03:58:23 PM »
Quote from: [n3rve
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).

-[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.

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
Re: How to Enable / Disable eval()
« Reply #12 on: August 06, 2009, 04:27:05 PM »
Just run: REPLACE INTO settings VALUES ('disableTemplateEval', 1);

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline abidejaz4u

  • Jr. Member
  • **
  • Posts: 387
Re: How to Enable / Disable eval()
« Reply #13 on: August 09, 2009, 06:02:18 AM »
in there show like this



full image
click here

where i can put that Query

Offline N3RVE

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,907
  • Gender: Male
    • N3RVE.COM
Re: How to Enable / Disable eval()
« Reply #14 on: August 09, 2009, 06:04:15 AM »
SQL, see the screenshot above.

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote
“Somewhere, something incredible is waiting to be known.” - Carl Sagan

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,392
    • StoryBB/StoryBB on GitHub
Re: How to Enable / Disable eval()
« Reply #15 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Marthless

  • Semi-Newbie
  • *
  • Posts: 10
Re: How to Enable / Disable eval()
« Reply #16 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. :)

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,919
  • Gender: Male
Re: How to Enable / Disable eval()
« Reply #17 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_.

MrPhil

  • Guest
Re: How to Enable / Disable eval()
« Reply #18 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.

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,919
  • Gender: Male
Re: How to Enable / Disable eval()
« Reply #19 on: January 10, 2011, 05:49:21 AM »
By the way, there is a mod (2054) that gives you an admin switch to do this more easily.


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.