PDA

View Full Version : Syntax Error


Mythotical
01-19-2010, 01:45 AM
Trying to put things together but it is killing me trying to understand why I get this error.

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

Line 50:
function CybChFRAll(obj) {


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

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']!=0 AND !in_array($foruminfo['cyb_frules'], array($cybfr_checkaccepted)))
{
$cybfr_havenotaccepted = true;
}
if (!$vbulletin->userinfo['userid'] AND $foruminfo['cyb_frules']!=0 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($vbulletin, fetch_tag_list());
$forum_rules_description = $cafr_parser->do_parse($cybfr_rules['rules'],1, 1, 1, 1, 1);
}
else
{
$forum_rules_description = $cybfr_rules['rules'];
}
$templater->register('forum_rules_description', $forum_rules_description);
$db->show_errors();
}

vB_Template::preRegister('FORUMDISPLAY',array('cyb fr_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_l ocs' => $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('cybf r_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:
{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:
<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:
<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:
{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:
<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
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.