News:

Welcome to the Unofficial Help Forum



Author Topic: Disabling template eval FAQ  (Read 13723 times)

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Disabling template eval FAQ
« on: April 23, 2012, 03:39:21 PM »
I see all the complex piece of code in http://smfhelp.org/index.php?topic=5.0

Why so complicated? If you're loading Settings.php, might as well load SSI.php and simplify the entire thing down to:

Code: [Select]
<?php
require_once('SSI.php');
updateSettings(array('disableTemplateEval' => 1));
?>

Let SMF do the work ;)

Offline Ermintrude

  • Jr. Member
  • *
  • Posts: 80
    • View Profile
Re: Disabling template eval FAQ
« Reply #1 on: April 23, 2012, 03:46:19 PM »
I dunno, me. Coding's all Irish-Swahili, to me.

Dunno why that smiley has a box around it, eeva.

Offline Sully

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling template eval FAQ
« Reply #2 on: April 23, 2012, 03:53:16 PM »
Yeahh...after I coded the disable template eval script I realized I could have just used updateSettings and SSI :P

Offline Illori

  • Administrator
  • *
  • Posts: 322
    • View Profile
Re: Disabling template eval FAQ
« Reply #3 on: April 23, 2012, 03:53:43 PM »
because of the mods we have installed here ;)

and that code is a bit complicated as it works on both 1.1.1* and 2.0.*.

Offline Sully

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling template eval FAQ
« Reply #4 on: April 23, 2012, 03:54:48 PM »
@Illori
Code: [Select]
<?php
require_once('SSI.php');
updateSettings(array('disableTemplateEval' => 1));
Will indeed work on both 1.1.x and 2.0.x environments.

Offline Illori

  • Administrator
  • *
  • Posts: 322
    • View Profile
Re: Disabling template eval FAQ
« Reply #5 on: April 23, 2012, 03:56:17 PM »
then you could edit that post and the attachment to that instead.

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: Disabling template eval FAQ
« Reply #6 on: April 23, 2012, 03:57:23 PM »
Yup, it will certainly work that way, just as the *original* version of mod 2054 did, it would disable it, not put a UI item in as was requested by the Customization Team at the time. (Back then, there wasn't a UI item in 2.0 either, as it happened.)

Offline Sully

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling template eval FAQ
« Reply #7 on: April 23, 2012, 03:57:50 PM »
You'd probably want it to be slightly more robust than the two lines provided, although in reality that's all that's necessary to accomplish the task.

Offline Illori

  • Administrator
  • *
  • Posts: 322
    • View Profile
Re: Disabling template eval FAQ
« Reply #8 on: April 23, 2012, 03:59:27 PM »
as long as the task can be done. i had asked the team to add it to repair_settings.php and months on it has not been done. it is not so easy to explain to a user how to do it in phpmyadmin if they cant access their forum to install the mod.

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: Disabling template eval FAQ
« Reply #9 on: April 23, 2012, 04:01:29 PM »
Well, all you'd need to be more robust is detect SSI.php's presence and be nicer about it if it's in the wrong place. It just struck me as odd that a whole amount of work, and a class, was needed to perform what really takes two lines of code, is all.

@Illori, that's exactly why the mod got written in the first place ;)

Though, interestingly, I had a discussion with Karl B at the time about it and he noted that you generally didn't need the actual line number, just to know the URL and it was about as easy to back-trace it from there, though I didn't agree at the time!

Offline Illori

  • Administrator
  • *
  • Posts: 322
    • View Profile
Re: Disabling template eval FAQ
« Reply #10 on: April 23, 2012, 04:03:07 PM »
yes but if you cant access your forum [which i have seen a few times] using the mod does not work as you cant even login, all you see is the error message at the top of the screen

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: Disabling template eval FAQ
« Reply #11 on: April 23, 2012, 04:10:11 PM »
If you can't even access the forum, the mod won't make a lot of difference either way because it just changes how you'll see the error message, rather than preventing them or anything.

Offline Illori

  • Administrator
  • *
  • Posts: 322
    • View Profile
Re: Disabling template eval FAQ
« Reply #12 on: April 23, 2012, 04:17:45 PM »
yep, but getting the error message without eval can help greatly to resolve the issue ;)

and odd enough some users in the past have said just installing the mod have made their errors disappear totally :P

Offline Arantor

  • Team Member
  • *
  • Posts: 82
    • View Profile
Re: Disabling template eval FAQ
« Reply #13 on: April 23, 2012, 04:23:39 PM »
I know people have said that, and I never understood why since there's actually no good reason for it o.O

I have to admit in the couple of years since then, I've found that actually it isn't the big help that I thought it used to be, usually the line number is right but the filename is wrong, and usually the filename can be figured out by looking at the code (or knowing) where a given action loads a given template.

But it's just one of those quirky things.

Offline Sully

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling template eval FAQ
« Reply #14 on: April 23, 2012, 04:36:37 PM »
For someone experienced with SMF and or programming in general, disabling template eval isn't that much of an assistance. However for someone who doesn't, it could be fairly useful, for sure.