SimplePortal

Development => Bugs => Fixed or Bogus Bugs => Topic started by: steiger on April 03, 2009, 05:19:59 AM

Title: PHP block and backslashes added with 2.2
Post by: steiger on April 03, 2009, 05:19:59 AM
Hi,
I have a board with SMF 1.1.8 and just upgraded to SP 2.2

Some of my PHP blocks have the following code:

global $boarddir;
require_once ($boarddir . '/run/personal_info.php');
dispPersonalBest();


Everything works fine!

If I edit this code under SP 2.2 the every quote gets a backslash as in
global $boarddir;
require_once ($boarddir . \'/run/personal_info.php\');
dispPersonalBest();


And this does not work!

Any ideas how to solve this or what was changed in SP 2.2?
Title: Re: PHP block and backslashes added with 2.2
Post by: [SiNaN] on April 03, 2009, 07:50:31 AM
Each time you edit a PHP block, backslashes are added to single quotes?
Title: Re: PHP block and backslashes added with 2.2
Post by: steiger on April 03, 2009, 08:01:41 AM
Each time you edit a PHP block, backslashes are added to single quotes?
Yes.
Regardless if new or edit, every single or double quote gets a backslash.

But I just found out that this only happens in Preview. If I enter the code and click "Edit Block" everything is fine.

Another example while adding a new block:

Code I entered:
Code: [Select]
echo "<iframe src='run/results_main.php' />";
Code after "Preview":
Code: [Select]
echo \"<iframe src=\'run/results_main.php\' />\";
Seems to be a bug in Preview
Title: Re: PHP block and backslashes added with 2.2
Post by: [SiNaN] on April 03, 2009, 08:06:50 AM
Thanks for detailed testing, that helps a lot. Here is a quick fix:

SPortalAdmin1-1.php

Find:

Code: [Select]
$context['SPortal']['block'] = array(
'id' => $_POST['block_id'],

Replace:

Code: [Select]
if (!empty($_POST['parameters']))
foreach ($_POST['parameters'] as $variable => $value)
$_POST['parameters'][$variable] = stripslashes($value);

$context['SPortal']['block'] = array(
'id' => $_POST['block_id'],

This most probably does not affect SMF 2.0 version, but I'll have a look at that too. Thanks again.

Edit:

Yeah, it does not affect SMF 2.0 version. Moved to the Bugs (http://simpleportal.net/index.php?board=3.0) board.
Title: Re: PHP block and backslashes added with 2.2
Post by: steiger on April 03, 2009, 08:12:14 AM
Thanks for the quick fix.

Just for clarification:

I should add:
Code: [Select]
      if (!empty($_POST['parameters']))
         foreach ($_POST['parameters'] as $variable => $value)
            $_POST['parameters'][$variable] = stripslashes($value);
before
Code: [Select]
      $context['SPortal']['block'] = array(
         'id' => $_POST['block_id'],

Because in your code the line
Code: [Select]
    'id' => $_POST['block_id'],would be removed
Title: Re: PHP block and backslashes added with 2.2
Post by: [SiNaN] on April 03, 2009, 08:15:23 AM
Oops, thanks for correction. ;) Let us know if that works for you.
Title: Re: PHP block and backslashes added with 2.2
Post by: steiger on April 03, 2009, 08:20:03 AM
Fix solves the problem.

Thanks again for your fast work.
Title: Re: PHP block and backslashes added with 2.2
Post by: [SiNaN] on April 03, 2009, 08:26:42 AM
Wouldn't be this fast if you haven't said that it is just when you use the "Preview" button. Thanks again!
Title: Re: PHP block and backslashes added with 2.2
Post by: steiger on April 03, 2009, 08:28:14 AM
Wouldn't be this fast if you haven't said that it is just when you use the "Preview" button. Thanks again!
As a long time SW developer I can imagine what you need to know ;D

Title: Re: PHP block and backslashes added with 2.2
Post by: [SiNaN] on April 09, 2009, 03:11:04 AM
Reported:

http://simpleportal.net/index.php?issue=174.0
SimplePortal 2.3.8 © 2008-2024, SimplePortal