Code:
if ($vbulletin->options['vsafrules_enable_global'])
{
require_once(DIR . '/includes/class_bbcode.php');
if ($_REQUEST['do'] == 'vsarules')
{
if ($_REQUEST['doredir'] != '1')
{
vbsetcookie('vsafr_redtopage', $_SERVER['HTTP_REFERER']);
}
$vsafr_requestedset = $vbulletin->input->clean_gpc('r', 'cfrset', TYPE_UINT);
if (!$vsafr_requestedset)
{
$vsafr_requestedset = 1;
}
$vsarulesforumperms = array();
if ($vbulletin->options['apboupc_global_enable'])
{
$vsarules_vsaapbopc_exclgroups = explode(",",$vbulletin->options['apboupc_forum_excludedgroups']);
}
foreach($vbulletin->forumcache AS $vsafrforum)
{
$vsarulesforumperms[$vsafrforum["forumid"]] = fetch_permissions($vsafrforum['forumid']);
if ((!($vsarulesforumperms[$vsafrforum["forumid"]] & $vbulletin->bf_ugp_forumpermissions['canview'])) OR (!($vsafrforum['options'] & $vbulletin->bf_misc_forumoptions['active']) AND !$vbulletin->options['showprivateforums'] AND !is_member_of($vbulletin->userinfo, 5,6,7)) OR ($vbulletin->options['apboupc_global_enable'] AND ($vsafrforum['accessf_nb']>$vbulletin->userinfo['posts']) AND !is_member_of($vbulletin->userinfo, $vsarules_vsaapbopc_exclgroups)))
{
$vsafrexclfids .= ','.$vsafrforum['forumid'];
}
}
$vsafrexclfids = substr($vsafrexclfids, 1);
if ($vsafrexclfids!='')
{
$vsafrexclfids = "WHERE forum.forumid NOT IN($vsafrexclfids) OR ISNULL(forum.forumid)";
}
$vbulletin->db->hide_errors();
$vsafr_getallrules = $vbulletin->db->query_read("
SELECT vsa_frules.id, vsa_frules.name, vsa_frules.rules, forum.forumid
FROM " . TABLE_PREFIX . "vsa_frules AS vsa_frules
LEFT JOIN " . TABLE_PREFIX . "forum AS forum ON (forum.vsa_frules = vsa_frules.id)
$vsafrexclfids
GROUP BY vsa_frules.id
ORDER BY vsa_frules.id ASC
");
$vsafrules_fsetnr = $vbulletin->db->num_rows($vsafr_getallrules);
while ($vsafr_ruleset = $vbulletin->db->fetch_array($vsafr_getallrules))
{
if ($vsafr_ruleset['id']==1)
{
$vsafrules_general_id = $vsafr_ruleset['id'];
$vsafrules_general_name = $vsafr_ruleset['name'];
$vsafrules_general_rules = $vsafr_ruleset['rules'];
}
if (($vsafr_ruleset['id']==$vsafr_requestedset) AND ($vsafr_requestedset!=1))
{
$vsafrules_target_id = $vsafr_ruleset['id'];
$vsafrules_target_name = $vsafr_ruleset['name'];
$vsafrules_target_rules = $vsafr_ruleset['rules'];
}
eval('$vsafrules_setselector .= " <option value=\"'.$vsafr_ruleset['id'].'\" " . iif($vsafr_requestedset==$vsafr_ruleset[id]," selected=\"selected\"","").">'.htmlspecialchars($vsafr_ruleset['name']).'</option> ";');
}
$vbulletin->db->show_errors();
if ($vbulletin->options['vsafrules_bb'])
{
$cafr_parse_rules = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$vsafrules_general_rules = $cafr_parse_rules->do_parse($vsafrules_general_rules,1, 1, 1, 1, 1);
$vsafrules_target_rules = $cafr_parse_rules->do_parse($vsafrules_target_rules,1, 1, 1, 1, 1);
}
$vsafrules_showgeneral = true;
$vsafrules_acceptgeneral = true;
if (($vbulletin->options['vsafrules_gen_rules']==3) AND ($vsafrules_target_id!=''))
{
$vsafrules_showgeneral = false;
}
$vsafrules_style_general = '$vbcollapse[collapseobj_cybfrules_rsetg]';
if (($vbulletin->options['vsafrules_gen_rules']==2) AND ($vsafrules_target_id!=''))
{
$vsafrules_style_general = 'display:none';
$vsafrules_acceptgeneral = false;
}
if ($vsafrules_showgeneral AND $vsafrules_acceptgeneral)
{
$vsafr_rulestoaccept .= ",1";
}
if ($vsafrules_target_id)
{
$vsafr_rulestoaccept .= ",".$vsafrules_target_id;
}
$vsafr_rulestoaccept = substr($vsafr_rulestoaccept, 1);
$vsafr_checkaccepted_form = in_array($vsafr_requestedset, explode(',',$vbulletin->userinfo['vsafrules_sets']));
$vsafr_showaccform = false;
if (!$vsafr_checkaccepted_form AND !is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['vsafrules_excluded_groups'])) AND (strstr($vbulletin->options['vsafrules_enable_items'], 'viewforums') OR strstr($vbulletin->options['vsafrules_enable_items'], 'postthreads') OR strstr($vbulletin->options['vsafrules_enable_items'], 'postreplies') OR strstr($vbulletin->options['vsafrules_enable_items'], 'sendpms')))
{
$vsafr_showaccform = true;
}
$navbits = construct_navbits(array('' => $vbphrase['vsafrules_rules']));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::Create('vsa_frules');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('vsafrules_fsetnr', $vsafrules_fsetnr);
$templater->register('vsafrules_setselector', $vsafrules_setselector);
$templater->register('vsafr_showaccform', $vsafr_showaccform);
$templater->register('vsafr_rulestoaccept', $vsafr_rulestoaccept);
$templater->register('vsafrules_showgeneral', $vsafrules_showgeneral);
$templater->register('vsafrules_general_name', $vsafrules_general_name);
$templater->register('vsafrules_general_rules', $vsafrules_general_rules);
$templater->register('vsafrules_style_general', $vsafrules_style_general);
$templater->register('vsafrules_target_id', $vsafrules_target_id);
$templater->register('vsafrules_target_name', $vsafrules_target_name);
$templater->register('vsafrules_target_rules', $vsafrules_target_rules);
$templater->register('vsacb_cantpost', $vsacb_cantpost);
print_output($templater->render());
}
if (($_REQUEST['do'] == 'vsaafr_mng') AND $vbulletin->userinfo['userid'] AND is_member_of($vbulletin->userinfo,6))
{
$vbulletin->db->hide_errors();
$vsafr_getrules = $vbulletin->db->query_read("
SELECT id, name, rules
FROM " . TABLE_PREFIX . "vsa_frules AS vsa_frules
ORDER BY id ASC
");
while ($vsafr_rules = $vbulletin->db->fetch_array($vsafr_getrules))
{
$vsafrules_rowid += 1;
$vsafrules_list .= '<option value="'.$vsafr_rules['id'].'">'.$vsafr_rules['name'].'</option>';
if ($vbulletin->options['vsafrules_bb'])
{
$cafr_parse_mng = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$vsafr_rules['rules'] = $cafr_parse_mng->do_parse($vsafr_rules['rules'],1, 1, 1, 1, 1);
}
$templater = vB_Template::Create('vsa_frules_mng_bit');
$templater->register('vsafrules_rowid', $vsafrules_rowid);
$templater->register('vsafr_rules', $vsafr_rules);
$vsa_frules_manage .= $templater->render();
}
$vsafrules_list .= '<option value="0">'.$vbphrase['none'].'</option>';
$vsafr_getforums = $vbulletin->db->query_read("
SELECT forum.forumid, forum.title_clean, forum.parentid, forum.displayorder, forum.vsa_frules, forum.threadcount, forum.replycount, vsa_frules.name
FROM " . TABLE_PREFIX . "forum AS forum
LEFT JOIN " . TABLE_PREFIX . "vsa_frules AS vsa_frules ON (vsa_frules.id = forum.vsa_frules)
ORDER BY parentid, displayorder, title_clean ASC
");
while ($vsafr_forum = $vbulletin->db->fetch_array($vsafr_getforums))
{
if ($vsafr_forum['parentid']=='-1')
{
$vsafrules_iscat = $vsafr_forum['forumid'];
}
if ($vsafr_forum['parentid']==$vsafrules_iscat)
{
$vsafr_forum['title_clean'] = '-- <a href="forumdisplay.php?f='.$vsafr_forum['forumid'].'">'.$vsafr_forum['title_clean'].'</a>';
}
else if ($vsafr_forum['parentid']!='-1')
{
$vsafr_forum['title_clean'] = '---- <a href="forumdisplay.php?f='.$vsafr_forum['forumid'].'">'.$vsafr_forum['title_clean'].'</a>';
}
else
{
$vsafr_forum['title_clean'] = '<a href="forumdisplay.php?f='.$vsafr_forum['forumid'].'">'.$vsafr_forum['title_clean'].'</a>';
}
$vsafr_id = $vsafr_forum['forumid'];
if (!$vsafr_forum['name'])
{
$vsafr_forum['name'] = $vbphrase['none'];
}
$templater = vB_Template::Create('vsa_frules_frms_bit');
$templater->register('vsafr_id', $vsafr_id);
$templater->register('vsafr_forum', $vsafr_forum);
$vsa_frules_forums .= $templater->render();
}
$vbulletin->db->show_errors();
$vsafr_display_rules = "none";
$vsafr_display_forums = "none";
switch ($_REQUEST['at'])
{
case rs: $vsafr_display_rules = "block"; ; break;
case fs: $vsafr_display_forums = "block"; ; break;
default: $vsafr_display_rules = "block"; ; break;
}
$navbits = construct_navbits(array('' => $vbphrase['vsafrules_rules']));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::Create('vsa_frules_mng');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('vsafr_display_rules', $vsafr_display_rules);
$templater->register('vsa_frules_manage', $vsa_frules_manage);
$templater->register('vsafr_display_forums', $vsafr_display_forums);
$templater->register('vsafrules_list', $vsafrules_list);
$templater->register('vsa_frules_forums', $vsa_frules_forums);
print_output($templater->render());
}
if (($_REQUEST['do'] == 'vsaafr_addedit') AND $vbulletin->userinfo['userid'] AND is_member_of($vbulletin->userinfo,6))
{
$vsafr_getrule_set = $vbulletin->input->clean_gpc('r', 'cfrset', TYPE_UINT);
if ($vsafr_getrule_set>0)
{
$vbulletin->db->hide_errors();
$vsafr_getrule = $vbulletin->db->query_first("
SELECT id, name, rules
FROM " . TABLE_PREFIX . "vsa_frules AS vsa_frules
WHERE id = '" . $vbulletin->db->escape_string($vsafr_getrule_set) . "'
");
$vsafr_getrule['name'] = htmlspecialchars($vsafr_getrule['name'],ENT_COMPAT | ENT_HTML401,"ISO-8859-1");
$vsafr_getrule['rules'] = htmlspecialchars($vsafr_getrule['rules'],ENT_COMPAT | ENT_HTML401,"ISO-8859-1");
$vbulletin->db->show_errors();
}
$navbits = construct_navbits(array('' => $vbphrase['vsafrules_rules']));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::Create('vsa_frules_addedit');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('vsafr_getrule_set', $vsafr_getrule_set);
$templater->register('vsafr_getrule', $vsafr_getrule);
print_output($templater->render());
}
if (($_REQUEST['do'] == 'vsaafr_doaddedit') AND $vbulletin->userinfo['userid'] AND is_member_of($vbulletin->userinfo,6))
{
$vbulletin->db->hide_errors();
$vbulletin->input->clean_array_gpc('p', array(
'set_id' => TYPE_UINT,
'set_name' => TYPE_STR,
'set_rules' => TYPE_STR,
'set_del' => TYPE_UINT)
);
if ($vbulletin->GPC['set_id'])
{
if ($vbulletin->GPC['set_del']=='1')
{
$vbulletin->db->query_write(" DELETE FROM " . TABLE_PREFIX . "vsa_frules WHERE id = '" . $vbulletin->db->escape_string($vbulletin->GPC['set_id']) . "' ");
}
else
{
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "vsa_frules SET name = '" . $vbulletin->db->escape_string($vbulletin->GPC['set_name']) . "', rules = '" . $vbulletin->db->escape_string($vbulletin->GPC['set_rules']) . "' WHERE id = '" . $vbulletin->db->escape_string($vbulletin->GPC['set_id']) . "' ");
}
}
else
{
$vbulletin->db->query_write("
INSERT INTO `". TABLE_PREFIX ."vsa_frules`
(name, rules)
VALUES ('" . $vbulletin->db->escape_string($vbulletin->GPC['set_name']) . "', '" . $vbulletin->db->escape_string($vbulletin->GPC['set_rules']) . "')
");
}
$vbulletin->db->show_errors();
$vbulletin->url = 'misc.php?do=vsaafr_mng&at=rs';
exec_header_redirect($vbulletin->url);
}
if (($_REQUEST['do'] == 'vsaafr_dosetforum') AND $vbulletin->userinfo['userid'] AND is_member_of($vbulletin->userinfo,6))
{
$vbulletin->db->hide_errors();
$vbulletin->input->clean_array_gpc('p', array(
'forum_id' => TYPE_ARRAY,
'rules_id' => TYPE_INT)
);
$vsaafr_forums = implode(',', $vbulletin->GPC['forum_id']);
if ($vsaafr_forums)
{
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "forum SET vsa_frules = '" . $vbulletin->db->escape_string($vbulletin->GPC['rules_id']) . "' WHERE forumid IN ($vsaafr_forums) ");
}
$vbulletin->db->show_errors();
require_once(DIR . '/includes/adminfunctions.php');
build_forum_permissions();
$vbulletin->url = 'misc.php?do=vsaafr_mng&at=fs';
exec_header_redirect($vbulletin->url);
}
if ($_REQUEST['do'] == 'vsaafragree')
{
$vbulletin->db->hide_errors();
$vsafr_rulesaccept = $vbulletin->input->clean_gpc('p', 'cfrset', TYPE_NOHTML);
if ($vbulletin->userinfo['userid'])
{
$vsafr_rulesaccepted = $vbulletin->userinfo['vsafrules_sets'].",".$vsafr_rulesaccept;
}
else
{
$vsafr_rulesaccepted = $_COOKIE[COOKIE_PREFIX . 'cfrrs'].",".$vsafr_rulesaccept;
}
$vsafr_rulesaccepted = explode(",",trim($vsafr_rulesaccepted, ','));
$vsafr_rulesaccepted = implode(",",array_unique($vsafr_rulesaccepted));
if (!$vsafr_rulesaccepted)
{
$vsafr_rulesaccepted = '0';
}
if ($vbulletin->userinfo['userid'])
{
$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "user SET vsafrules_sets = '" . $vbulletin->db->escape_string($vsafr_rulesaccepted) . "', vsafrules_date = '".TIMENOW."' WHERE userid = " . $vbulletin->userinfo['userid'] . " ");
}
else
{
vbsetcookie('cfrrs', $vsafr_rulesaccepted);
}
$vbulletin->input->clean_gpc('c', COOKIE_PREFIX . 'vsafr_redtopage', TYPE_NOHTML);
if ($vbulletin->GPC[COOKIE_PREFIX . 'vsafr_redtopage']!='')
{
$vbulletin->url = $vbulletin->GPC[COOKIE_PREFIX . 'vsafr_redtopage'];
}
else
{
$vbulletin->url = $vbulletin->options['homeurl'];
}
$vbulletin->db->show_errors();
exec_header_redirect($vbulletin->url);
}
if (($_REQUEST['do']=='cfrresetuser') OR ($_REQUEST['do']=='cfrresetall'))
{
if ($_REQUEST['do']=='cfrresetuser')
{
$afrresettype='user';
}
if ($_REQUEST['do']=='cfrresetall')
{
$afrresettype='all';
$vsafr_getrulesets = $vbulletin->db->query_read("
SELECT id, name
FROM " . TABLE_PREFIX . "vsa_frules AS vsa_frules
ORDER BY id ASC
");
while ($vsafr_ruleset = $vbulletin->db->fetch_array($vsafr_getrulesets))
{
$vsa_frules_rulesetid = $vsafr_ruleset['id'];
$vsa_frules_rulesets .= "<br /><input type=\"checkbox\" name=\"cfrdel[$vsa_frules_rulesetid]\" value=\"$vsa_frules_rulesetid\" /> ".$vsafr_ruleset['name'];
}
}
$vbulletin->input->clean_array_gpc('r', array(
'tu' => TYPE_UINT,
'tun' => TYPE_NOHTML,
'cfrset' => TYPE_UINT,
'cfrsetn' => TYPE_NOHTML)
);
$cfr_tu = $vbulletin->GPC['tu'];
$cfr_tun = $vbulletin->GPC['tun'];
$cfr_tset = $vbulletin->GPC['cfrset'];
$cfr_tsetn = $vbulletin->GPC['cfrsetn'];
if ($cfr_tun=='')
{
$cfr_tu = '';
}
$vsafr_resetuserall_phrase = construct_phrase($vbphrase['vsafrules_resetuser_confirmall'], $cfr_tun.' (ID:'.$cfr_tu.')', 'member.php?u='.$cfr_tu, $cfr_tsetn);
$vsafr_resetusersel_phrase = construct_phrase($vbphrase['vsafrules_resetuser_confirm'], $cfr_tun.' (ID:'.$cfr_tu.')', 'member.php?u='.$cfr_tu, $cfr_tsetn);
$navbits = construct_navbits(array('' => $vbphrase['vbulletin_message']));
$navbar = render_navbar_template($navbits);
$templater = vB_Template::Create('vsa_frules_reset');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('cfr_tset', $cfr_tset);
$templater->register('afrresettype', $afrresettype);
$templater->register('vsa_frules_rulesets', $vsa_frules_rulesets);
$templater->register('cfr_tu', $cfr_tu);
$templater->register('vsafr_resetuserall_phrase', $vsafr_resetuserall_phrase);
$templater->register('vsafr_resetusersel_phrase', $vsafr_resetusersel_phrase);
print_output($templater->render());
}
if ($_REQUEST['do']=='cfrreset')
{
$vbulletin->input->clean_array_gpc('p', array(
'resettype' => TYPE_NOHTML,
'cfrtu' => TYPE_UINT,
'cfrtset' => TYPE_UINT)
);
if (($vbulletin->GPC['resettype']=='cfruser') AND ($vbulletin->GPC['cfrtu']!='') AND can_moderate())
{
$vbulletin->db->hide_errors();
if ($vbulletin->GPC['cfrtset']==0)
{
$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "user SET vsafrules_sets = '0', vsafrules_date = '0' WHERE userid = '" . $vbulletin->GPC['cfrtu'] . "' ");
}
else
{
$vsafr_tgtuser = $vbulletin->db->query_first("
SELECT userid, vsafrules_sets
FROM " . TABLE_PREFIX . "user AS user
WHERE userid = '".$vbulletin->GPC['cfrtu']."'
");
$vsafr_rulesaccepted = str_replace($vbulletin->GPC['cfrtset'],"",$vsafr_tgtuser['vsafrules_sets']);
$vsafr_rulesaccepted = str_replace(",,",",",$vsafr_rulesaccepted);
$vsafr_rulesaccepted = trim($vsafr_rulesaccepted, ',');
if (!$vsafr_rulesaccepted)
{
$vsafr_rulesaccepted = '0';
}
$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "user SET vsafrules_sets = '" . $vbulletin->db->escape_string($vsafr_rulesaccepted) . "' WHERE userid = " . $vbulletin->GPC['cfrtu'] . " ");
}
$vbulletin->db->show_errors();
$vbulletin->url = 'member.php?u='.$vbulletin->GPC['cfrtu'];
eval(print_standard_redirect('redirect_vsafrules_resetdone_user',1,1));
}
if (($vbulletin->GPC['resettype']=='cfrall') AND is_member_of($vbulletin->userinfo,6))
{
$vbulletin->db->hide_errors();
$vbulletin->input->clean_gpc('r', 'cfrdel', TYPE_ARRAY);
if ($vbulletin->GPC['cfrdel']!='')
{
foreach ($vbulletin->GPC['cfrdel'] AS $vsafr_rsetid)
{
$vbulletin->db->query_write(" UPDATE " . TABLE_PREFIX . "user SET vsafrules_sets = REPLACE(vsafrules_sets, $vsafr_rsetid, '0') ");
}
}
$vbulletin->db->show_errors();
$vbulletin->url = $vbulletin->config['Misc']['admincpdir'].'/options.php?do=options&dogroup=vsafrules';
eval(print_standard_redirect('redirect_vsafrules_resetdone_all',1,1));
}
if ($vbulletin->GPC['resettype']=='')
{
exec_header_redirect($vbulletin->options['homeurl']);
}
}
}
I know the answer is in the above posts, but I made it easier for people to copy/paste the solution rather than searching for the proper plugin/line(s) to alter.