FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Syntax error in code generated after adding {IF} to template
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Syntax error in code generated after adding {IF} to template [message #167801] Mon, 01 October 2012 23:20 Go to next message
DPhan is currently offline  DPhan   United States
Messages: 9
Registered: September 2012
Location: San Jose, Calif
Karma: 0
Junior Member
In the default index.tmpl file, I made the following change:

before:
{TEMPLATE: show_links}

after:
{IF: _uid} {TEMPLATE: show_links} {ENDIF}

The generated code BEFORE the change is as follows:

"index.php?t=selmsg&amp;date=today&amp;<?php echo _rsid; ?>&amp;frm_id=<?php echo (isset($frm->forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'&amp;th='.$th.'" title="Show all messages that were posted today" rel="nofollow">Today's Messages</a>
'.(_uid ? '<b>::</b> <a href=" index.php?t=selmsg&amp;unread=1&amp;'._rsid.'&amp;frm_id='.(iss et($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all unread messages" rel="nofollow">Unread Messages</a>&nbsp;' : ''); ?>
<?php echo (!$th ? '<b>::</b> <a href=" index.php?t=selmsg&amp;reply_count=0&amp;'._rsid.'&amp;frm_id=' .(isset($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all messages, which have no replies" rel="nofollow">Unanswered Messages</a>&nbsp;' : ''); ?>
<b>::</b> <a href="index.php?t=mnav&amp;<?php echo _rsid; ?>" rel="nofollow">Message Navigator</a><?php echo $admin_cp; ?>
<?php echo $cat_path; ?>

The generated code AFTER the change contains syntax error and is as follows:

<?php echo (_uid ? ' <span class="GenText fb">Show:</span>
<a href=" index.php?t=selmsg&amp;date=today&amp;'._rsid.'&amp;frm_id='.(i sset($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'&amp;th='.$th.'" title="Show all messages that were posted today" rel="nofollow">Today's Messages</a>
'.(_uid ? '<b>::</b> <a href=" index.php?t=selmsg&amp;unread=1&amp;'._rsid.'&amp;frm_id='.(iss et($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all unread messages" rel="nofollow">Unread Messages</a>&nbsp;' : ''); ?>
<?php echo (!$th ? '<b>::</b> <a href=" index.php?t=selmsg&amp;reply_count=0&amp;'._rsid.'&amp;frm_id=' .(isset($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all messages, which have no replies" rel="nofollow">Unanswered Messages</a>&nbsp;' : ''); ?>
<b>::</b> <a href="index.php?t=mnav&amp;<?php echo _rsid; ?>" rel="nofollow">Message Navigator</a> ' : ''); ?>
<?php echo $admin_cp; ?>
<?php echo $cat_path; ?>

Correct the syntax error by removing the trailing ; ?> near "Unanswered Messages" and replace with a dot, and add a
single quote on the next line.

Corrected version:

<?php echo (_uid ? ' <span class="GenText fb">Show:</span>
<a href=" index.php?t=selmsg&amp;date=today&amp;'._rsid.'&amp;frm_id='.(i sset($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'&amp;th='.$th.'" title="Show all messages that were posted today" rel="nofollow">Today's Messages</a>
'.(_uid ? '<b>::</b> <a href=" index.php?t=selmsg&amp;unread=1&amp;'._rsid.'&amp;frm_id='.(iss et($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all unread messages" rel="nofollow">Unread Messages</a>&nbsp;' : ''); ?>
<?php echo (!$th ? '<b>::</b> <a href=" index.php?t=selmsg&amp;reply_count=0&amp;'._rsid.'&amp;frm_id=' .(isset($frm- >forum_id) ? $frm->forum_id.'' : $frm->id.'' ) .'" title="Show all messages, which have no replies" rel="nofollow">Unanswered Messages</a>&nbsp;' : '') .
'<b>::</b> <a href="index.php?t=mnav&amp;<?php echo _rsid; ?>" rel="nofollow">Message Navigator</a> ' : ''); ?>
<?php echo $admin_cp; ?>
<?php echo $cat_path; ?>

I started to look at the code generation routine compiler.inc for a permanent fix but I thought I should ask if there is someone who is more familiar with this code generation routine.

Dan
Re: Syntax error in code generated after adding {IF} to template [message #167803 is a reply to message #167801] Wed, 03 October 2012 21:43 Go to previous messageGo to next message
DPhan is currently offline  DPhan   United States
Messages: 9
Registered: September 2012
Location: San Jose, Calif
Karma: 0
Junior Member
Still no reply from anyone....just wondering if my posting wasn't clear enough.

Has anyone had experience modifying the template code? The findings I posted suggest that (randomly) adding {IF} is not to be taken lightly. I can suggest a code fix to the code generation routine but due to its potentially extensive impact, lots of testing will be required.

Is there a test suite for the code generator?

Dan
Re: Syntax error in code generated after adding {IF} to template [message #167806 is a reply to message #167803] Thu, 04 October 2012 10:30 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
See http://fudforum.org/forum/index.php?t=msg&th=9288

"Normally you can end the expression using {end}, but if you don't have an else you need to use {endif}. The {endI} and {endifI} are special terminators you need to use in the place of {end} and {endif} when your conditional expression is within another conditional expression."

I normally play with the various forms of {IF: } until I get one that works:
{IF: ...}...{ELSE}...{END}
{IF: ...}...{ENDIF}

Within another {IF: }
{IF: ...}...{ELSE}...{ENDI}
{IF: ...}...{ENDIFI}
Re: Syntax error in code generated after adding {IF} to template [message #167807 is a reply to message #167806] Thu, 04 October 2012 22:36 Go to previous message
DPhan is currently offline  DPhan   United States
Messages: 9
Registered: September 2012
Location: San Jose, Calif
Karma: 0
Junior Member
Hi Naudefj,

Thanks for the reply.

I took your advice and tried all the combinations you suggested, but alas the syntax error problem persists. In fact in looking at the code generation routine in compile.inc, aside from a simple white space in the generated code, I really don't see the difference between ENDIF and ENDIFI, nor the difference between END and ENDI.

Straight from .../FUDforum/include/compiler.inc, starting from line 302:

           case 'END':
                $ret .= "' ) .'";
                break;

            case 'ENDI':
                $ret .= "' )  .'";
                break;

            case 'ENDIF':
                $ret .= "' : '' ) .'";
                break;

            case 'ENDIFI':
                $ret .= "' : '' )  .'";
                break;


Any other ideas how to resolve this issue?

Thanks

Dan
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Cross-site scripting attacks
Next Topic: Fatal error if moderator uses the "move selected" button
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Mar 28 16:23:34 GMT 2024

Total time taken to generate the page: 0.02720 seconds