Forums / Bug Reports / Error coming from additional_images.php -- problems using + and [ and ] in image name

Error coming from additional_images.php -- problems using + and [ and ] in image name

Locked

Views: 6,427

Results 21 to 23 of 23
This thread is locked. New replies are disabled.
11 Nov 2009, 1:55 AM
#21
skinnyg avatar

skinnyg

New Zenner

Join Date:
Nov 2009
Location:
California
Posts:
2
Plugin Contributions:
0

Error coming from additional_images.php -- problems using + and [ and ] in image name

TheOracle:

Excellent. Glad to know this problem was about a typo query. :smile:
I'm hoping TheOracle can help with a similar problem as above. I did the exact same fixes you prescribed but now I get a third additional error message: [09-Nov-2009 21:33:25] PHP Parse error: syntax error, unexpected ')' in /home/anima/public_html/includes/modules/additional_images.php on line 189

We are using Zen Cart 1.3.7 Patch: 1:: Database Patch Level: 1.3.7 PHP Version 5.2.6 with Server OS: Linux 2.6.18-53.1.14.el5.

11 Nov 2009, 3:27 AM
#22
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Error coming from additional_images.php -- problems using + and [ and ] in image name

TheOracle has not been active for a couple of years.
The "fix" in post #4 may have stopped some error from occurring, but it can cause an error at least in some circumstances.
The only change was to move a ) from near the end of the statement to near the beginning (red = removed, green = inserted):```
$noscript_link = '<noscript>' . ($flag_display_large[B])[/B] ? '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large) . '" target="_blank">' . $thumb_regular . '<br /><span class="imgLinkAdditional">' . TEXT_CLICK_TO_ENLARGE . '</span></a>' : $thumb_regular [B])[/B] . '</noscript>';

This takes the form
x ? a : b
where if x (any expression that can be evaluated) is true, then a is performed, and if it is false, b is performed. 
Without the last ) to define where the effect of the ternary operator stops, the . '</noscript>' is part of the alternate output and will not occur if $flag_display_large is true. 
This is a problem, because we then have an unclosed <noscript> tag in the output.
I had observed numerous times when TheOracle gave incorrect advice while seeming extremely knowledgeable.
11 Nov 2009, 3:48 AM
#23
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Error coming from additional_images.php -- problems using + and [ and ] in image name

Actually, it is possible that there is another error introduced by the change, which would partially counteract or at least overlap with the previously described error.

The beginning of the ternary operator is originally defined by the ( to evaluate only the $flag_display_large after outputting the <noscript> tag.

The change may well allow the entire first part of the statement to be evaluated instead of part of it being output. It would probably work thus:
'<noscript>' . ($flag_display_large)
evaluates to a string like
'<noscript>1'
'<noscript>TRUE'
or
'<noscript>0'
'<noscript>FALSE'
none of which will be read as equalling false, so the first ("a") output will be processed and the second ("b") output will be ignored. There will be neither opening nor closing <noscript> tags, eliminating a syntax error but leaving output in the form of the standard link to a larger image whether or not that setting was active.
For a user with javascript enabled, there would possibly be two larger image links, one to a popup and one to a new window. Users with js disabled would see only the normal version of the link which <noscript> is supposed to display.