Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 01-19-2010, 01:45 AM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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));
        } 
Reply With Quote
  #2  
Old 01-19-2010, 03:53 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 01-19-2010, 03:57 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 01-19-2010, 04:06 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 01-19-2010, 04:17 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok tried the litteral approach but honestly I have no idea how to mess with javascript outside of templates. Any suggestions?
Reply With Quote
  #6  
Old 01-19-2010, 04:31 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #7  
Old 01-19-2010, 04:31 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 01-19-2010, 04:37 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by derfelix View Post
ooooooops didnt see lynn posting while i was posting... sorry
hehe. Happens all the time.
Reply With Quote
  #9  
Old 01-19-2010, 05:05 PM
Mythotical Mythotical is offline
 
Join Date: Jun 2004
Location: Booneville, AR, USA
Posts: 1,428
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Got it though, now to fix the stupid layout.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:11 PM.


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.06761 seconds
  • Memory Usage 2,331KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_html
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete