vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Syntax Error (https://vborg.vbsupport.ru/showthread.php?t=233482)

Mythotical 01-19-2010 01:45 AM

Syntax Error
 
Trying to put things together but it is killing me trying to understand why I get this error.

Quote:

Parse error: syntax error, unexpected '[' in /home/project9/public_html/vb40/includes/class_core.php(4029) : eval()'d code on line 50
Line 50:
PHP Code:

            function CybChFRAll(obj) { 

The entire plugin just in case anyone wants to go over it and point out any mistakes I may have made.

PHP Code:

if ($vbulletin->options['cybfrules_enable_global'])
        {
            
$cybfr_locs = array("forumdisplay""showthread""newthread""newreply""sendmessage");
            if (
in_array(THIS_SCRIPT$cybfr_locs))
            {
                
$vbulletin->input->clean_gpc('c'COOKIE_PREFIX 'cfrrs'TYPE_STR);
                eval(
'$cybfr_checkaccepted = in_array($foruminfo[cyb_frules], array(' $vbulletin->userinfo['cybfrules_sets'] . '));');
                eval(
'$cybfr_checkaccepted_g = in_array($foruminfo[cyb_frules], array(' $vbulletin->GPC[COOKIE_PREFIX 'cfrrs'] . '));');
                
                
$cybfr_havenotaccepted false;
                if (
$vbulletin->userinfo['userid'] AND $foruminfo['cyb_frules']!=AND !in_array($foruminfo['cyb_frules'], array($cybfr_checkaccepted)))
                {
                    
$cybfr_havenotaccepted true;
                }
                if (!
$vbulletin->userinfo['userid'] AND $foruminfo['cyb_frules']!=AND !in_array($foruminfo['cyb_frules'], array($cybfr_checkaccepted_g)))
                {
                    
$cybfr_havenotaccepted true;
                }
            
                
$cfrules_forumruleslink $foruminfo['cyb_frules'];
                if (
$cfrules_forumruleslink<1)
                {
                    
$cfrules_forumruleslink 1;
                }
                
$vbulletin->templatecache['forumrules'] = str_replace('showrules','cfrules&cfrset='.$cfrules_forumruleslink,$vbulletin->templatecache['forumrules']);
            }
    
            if ((
$vbulletin->options['cybfrules_reg_rules']=='1') AND (THIS_SCRIPT=='register'))
            {
                
$db->hide_errors();
                
$cybfr_rules $vbulletin->db->query_first("
                    SELECT id, name, rules
                    FROM " 
TABLE_PREFIX "cyb_frules AS cyb_frules
                    WHERE id = 1
                "
);
                if (
$vbulletin->options['cybfrules_bb'])
                {
                    require_once(
DIR '/includes/class_bbcode.php');
                    
$cafr_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
                    
$forum_rules_description $cafr_parser->do_parse($cybfr_rules['rules'],11111);
                }
                else
                {
                    
$forum_rules_description $cybfr_rules['rules'];
                }
                
$templater->register('forum_rules_description'$forum_rules_description);
                
$db->show_errors();
            }

                
vB_Template::preRegister('FORUMDISPLAY',array('cybfr_locs' => $cybfr_locs'cybfr_havenotaccepted' => $cybfr_havenotaccepted'cybfr_checkaccepted' => $cybfr_checkaccepted'cybfr_checkaccepted_g' => $cybfr_checkaccepted_g'cfrules_forumruleslink' => $cfrules_forumruleslink));
                
vB_Template::preRegister('SHOWTHREAD',array('cybfr_locs' => $cybfr_locs'cybfr_havenotaccepted' => $cybfr_havenotaccepted'cybfr_checkaccepted' => $cybfr_checkaccepted'cybfr_checkaccepted_g' => $cybfr_checkaccepted_g'cfrules_forumruleslink' => $cfrules_forumruleslink));
                
vB_Template::preRegister('newthread',array('cybfr_locs' => $cybfr_locs'cybfr_havenotaccepted' => $cybfr_havenotaccepted'cybfr_checkaccepted' => $cybfr_checkaccepted'cybfr_checkaccepted_g' => $cybfr_checkaccepted_g'cfrules_forumruleslink' => $cfrules_forumruleslink));
                
vB_Template::preRegister('newreply',array('cybfr_locs' => $cybfr_locs'cybfr_havenotaccepted' => $cybfr_havenotaccepted'cybfr_checkaccepted' => $cybfr_checkaccepted'cybfr_checkaccepted_g' => $cybfr_checkaccepted_g'cfrules_forumruleslink' => $cfrules_forumruleslink));
                
vB_Template::preRegister('sendmessage',array('cybfr_locs' => $cybfr_locs'cybfr_havenotaccepted' => $cybfr_havenotaccepted'cybfr_checkaccepted' => $cybfr_checkaccepted'cybfr_checkaccepted_g' => $cybfr_checkaccepted_g'cfrules_forumruleslink' => $cfrules_forumruleslink));
        } 


derfelix 01-19-2010 03:53 PM

Just go over the code and rem out one line at the time..
or remove, little blocks.. or if(){} rules...

After one of them.. you will NOT get the error anymore..
Put the others back in.. and inspect the line you removed to make it working..

F.

Mythotical 01-19-2010 03:57 PM

Forgot to put the template up:
HTML Code:

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
   
    {vb:raw header}
   
    {vb:raw navbar}
       
                <div id="cfrules_mngrules" style="display:{vb:raw cybfr_display_rules};">
                        <table class="tborder" cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%" align="center">
                                <tr>
                                        <td class="tcat" align="{vb:stylevar left}" colspan="4"><a style="float:{vb:stylevar right}" href="misc.php?do=cfrules_addedit">{vb:rawphrase cybfrules_add}</a><a class="smallfont" style="font-weight:bold;text-decoration:underline;" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('rules');">{vb:rawphrase cybfrules_manage}</a> | <a class="smallfont" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('forums');">{vb:rawphrase cybfrules_manage_forums}</a></td>
                                </tr>
                                <tbody id="collapseobj_cybfr_manage" style="{vb:raw vbcollapse.collapseobj_cybfr_manage}">
                                        <tr>
                                                <td class="thead" align="center" width="1%">#</td>
                                                <td class="thead" align="{vb:stylevar left}">{vb:rawphrase title}</td>
                                                <td class="thead" align="{vb:stylevar left}">{vb:rawphrase cybfrules_rules}</td>
                                                <td class="thead" align="center" width="1%">{vb:rawphrase edit}/{vb:rawphrase delete}</td>
                                        </tr>
                                        {vb:raw cyb_frules_manage}
                                </tbody>
                        </table>
                </div>
       
                <div id="cfrules_mngforums" style="display:{vb:raw cybfr_display_forums};">
                        <form id="cfrules_setforum" name="cfrules_setforum" action="misc.php?do=cfrules_dosetforum" method="post">
                        <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
                        <table class="tborder" cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%" align="center">
                                <tr>
                                        <td class="tcat" align="{vb:stylevar left}" colspan="3"><span class="smallfont" style="float:{vb:stylevar right}">{vb:rawphrase cybfrules_setforum} <select id="rules_id" name="rules_id">{vb:raw cybfrules_list}</select> <input class="button" type="submit" name="cfrules_sendf" value="{vb:rawphrase submit}" /></span><a class="smallfont" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('rules');">{vb:rawphrase cybfrules_manage}</a> | <a class="smallfont" style="font-weight:bold;text-decoration:underline;" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('forums');">{vb:rawphrase cybfrules_manage_forums}</a></td>
                                </tr>
                                <tbody id="collapseobj_cybfr_managef" style="{vb:raw vbcollapse.collapseobj_cybfr_managef}">
                                        <tr>
                                                <td class="thead" align="{vb:stylevar left}" width="50%">{vb:rawphrase forum} <span class="smallfont">({vb:rawphrase threads}/{vb:rawphrase posts})</span></td>
                                                <td class="thead" align="{vb:stylevar left}" width="50%">{vb:rawphrase cybfrules_rules}</td>
                                                <td class="thead" align="center"><input type="checkbox" name="cybfr_check_all" id="cybfr_check_all" value="" onclick="CybChFRAll(this);" /></td>
                                        </tr>
                                        {vb:raw cyb_frules_forums}
                                </tbody>
                        </table>
                        </form>
                </div>
       
                <script language="Javascript" type="text/javascript">
                        function CybChFRAll(obj) {
                                var arrInput = document.getElementsByTagName("input");
                                for (i=0; i<arrInput.length; i++) {
                                        if (arrInput[i].type == 'checkbox') {
                                                arrInput[i].checked = obj.checked;
                                        }
                                }
                        }
                        function Cyb_SwitchCFRMNG(target)
                        {
                                if (target=="rules")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "block";
                                        document.getElementById("cfrules_mngforums").style.display = "none";
                                }
                                if (target=="forums")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "none";
                                        document.getElementById("cfrules_mngforums").style.display = "block";
                                }
                        }
                </script>

                <br />
                {vb:raw footer}
                </body>
                </html>

Area of concern:
HTML Code:

                <script language="Javascript" type="text/javascript">
                        function CybChFRAll(obj) {
                                var arrInput = document.getElementsByTagName("input");
                                for (i=0; i<arrInput.length; i++) {
                                        if (arrInput[i].type == 'checkbox') {
                                                arrInput[i].checked = obj.checked;
                                        }
                                }
                        }
                        function Cyb_SwitchCFRMNG(target)
                        {
                                if (target=="rules")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "block";
                                        document.getElementById("cfrules_mngforums").style.display = "none";
                                }
                                if (target=="forums")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "none";
                                        document.getElementById("cfrules_mngforums").style.display = "block";
                                }
                        }
                </script>

I did what you suggested above last night but in the template as it seems to pertain to the template.

derfelix 01-19-2010 04:06 PM

it seems to be related to the javascript bug... in vbulletin..
template parser doesnt like the word var inside curly brackets..

var arrInput

inside a curly bracket doesnt work..
2 solutions:

either put the javascript inbetween <vb:litteral> tags
or declare the var outside the curly brackets...

PS its maybe not that bug.. because usually then you cannot save the template...
but its worth a try

Mythotical 01-19-2010 04:17 PM

Ok tried the litteral approach but honestly I have no idea how to mess with javascript outside of templates. Any suggestions?

Lynne 01-19-2010 04:31 PM

As suggested, just put <vb:literal> tags around your javascript:
HTML Code:

<vb:literal>
        <script language="Javascript" type="text/javascript">
            function CybChFRAll(obj) {
                var arrInput = document.getElementsByTagName("input");
                for (i=0; i<arrInput.length; i++) {
                    if (arrInput[i].type == 'checkbox') {
                        arrInput[i].checked = obj.checked;
                    }
                }
            }
            function Cyb_SwitchCFRMNG(target)
            {
                if (target=="rules")
                {
                    document.getElementById("cfrules_mngrules").style.display = "block";
                    document.getElementById("cfrules_mngforums").style.display = "none";
                }
                if (target=="forums")
                {
                    document.getElementById("cfrules_mngrules").style.display = "none";
                    document.getElementById("cfrules_mngforums").style.display = "block";
                }
            }
        </script>

</vb:literal>


derfelix 01-19-2010 04:31 PM

I would do it that way...
either:
HTML Code:

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
   
    {vb:raw header}
   
    {vb:raw navbar}
       
                <div id="cfrules_mngrules" style="display:{vb:raw cybfr_display_rules};">
                        <table class="tborder" cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%" align="center">
                                <tr>
                                        <td class="tcat" align="{vb:stylevar left}" colspan="4"><a style="float:{vb:stylevar right}" href="misc.php?do=cfrules_addedit">{vb:rawphrase cybfrules_add}</a><a class="smallfont" style="font-weight:bold;text-decoration:underline;" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('rules');">{vb:rawphrase cybfrules_manage}</a> | <a class="smallfont" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('forums');">{vb:rawphrase cybfrules_manage_forums}</a></td>
                                </tr>
                                <tbody id="collapseobj_cybfr_manage" style="{vb:raw vbcollapse.collapseobj_cybfr_manage}">
                                        <tr>
                                                <td class="thead" align="center" width="1%">#</td>
                                                <td class="thead" align="{vb:stylevar left}">{vb:rawphrase title}</td>
                                                <td class="thead" align="{vb:stylevar left}">{vb:rawphrase cybfrules_rules}</td>
                                                <td class="thead" align="center" width="1%">{vb:rawphrase edit}/{vb:rawphrase delete}</td>
                                        </tr>
                                        {vb:raw cyb_frules_manage}
                                </tbody>
                        </table>
                </div>
       
                <div id="cfrules_mngforums" style="display:{vb:raw cybfr_display_forums};">
                        <form id="cfrules_setforum" name="cfrules_setforum" action="misc.php?do=cfrules_dosetforum" method="post">
                        <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
                        <table class="tborder" cellpadding="{vb:stylevar cellpadding}" cellspacing="{vb:stylevar cellspacing}" border="0" width="100%" align="center">
                                <tr>
                                        <td class="tcat" align="{vb:stylevar left}" colspan="3"><span class="smallfont" style="float:{vb:stylevar right}">{vb:rawphrase cybfrules_setforum} <select id="rules_id" name="rules_id">{vb:raw cybfrules_list}</select> <input class="button" type="submit" name="cfrules_sendf" value="{vb:rawphrase submit}" /></span><a class="smallfont" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('rules');">{vb:rawphrase cybfrules_manage}</a> | <a class="smallfont" style="font-weight:bold;text-decoration:underline;" href="javascript:void(0);" onclick="return Cyb_SwitchCFRMNG('forums');">{vb:rawphrase cybfrules_manage_forums}</a></td>
                                </tr>
                                <tbody id="collapseobj_cybfr_managef" style="{vb:raw vbcollapse.collapseobj_cybfr_managef}">
                                        <tr>
                                                <td class="thead" align="{vb:stylevar left}" width="50%">{vb:rawphrase forum} <span class="smallfont">({vb:rawphrase threads}/{vb:rawphrase posts})</span></td>
                                                <td class="thead" align="{vb:stylevar left}" width="50%">{vb:rawphrase cybfrules_rules}</td>
                                                <td class="thead" align="center"><input type="checkbox" name="cybfr_check_all" id="cybfr_check_all" value="" onclick="CybChFRAll(this);" /></td>
                                        </tr>
                                        {vb:raw cyb_frules_forums}
                                </tbody>
                        </table>
                        </form>
                </div>
       
                <script language="Javascript" type="text/javascript">
<vb:literal>
                        function CybChFRAll(obj) {
                                var arrInput = document.getElementsByTagName("input");
                                for (i=0; i<arrInput.length; i++) {
                                        if (arrInput[i].type == 'checkbox') {
                                                arrInput[i].checked = obj.checked;
                                        }
                                }
                        }
                        function Cyb_SwitchCFRMNG(target)
                        {
                                if (target=="rules")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "block";
                                        document.getElementById("cfrules_mngforums").style.display = "none";
                                }
                                if (target=="forums")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "none";
                                        document.getElementById("cfrules_mngforums").style.display = "block";
                                }
                        }
</vb:literal>

                </script>
                <br />
                {vb:raw footer}
                </body>
                </html>

Or you could:
HTML Code:

                <script language="Javascript" type="text/javascript">
                        var arrInput;
                        function CybChFRAll(obj) {
                                arrInput = document.getElementsByTagName("input");
                                for (i=0; i<arrInput.length; i++) {
                                        if (arrInput[i].type == 'checkbox') {
                                                arrInput[i].checked = obj.checked;
                                        }
                                }
                        }
                        function Cyb_SwitchCFRMNG(target)
                        {
                                if (target=="rules")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "block";
                                        document.getElementById("cfrules_mngforums").style.display = "none";
                                }
                                if (target=="forums")
                                {
                                        document.getElementById("cfrules_mngrules").style.display = "none";
                                        document.getElementById("cfrules_mngforums").style.display = "block";
                                }
                        }
                </script>

test the vb:literal first...
if it works.. then you can remove the vb:literal and play around with the var
dunno if you put var arrInput; or var arrInput = new array(); or or...Important is outside the curly brackets...

ooooooops didnt see lynn posting while i was posting... sorry

Lynne 01-19-2010 04:37 PM

Quote:

Originally Posted by derfelix (Post 1960350)
ooooooops didnt see lynn posting while i was posting... sorry

hehe. Happens all the time. :)

Mythotical 01-19-2010 05:05 PM

LOL I spelled it wrong, I am having spelling issues today.

Got it though, now to fix the stupid layout.


All times are GMT. The time now is 09:14 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01499 seconds
  • Memory Usage 1,900KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_html_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete