function RightPanelTabs() { $page = CurrentPageName(); $tpl = new templates(); if ($_GET["panel-right"] == 0) { $rules = LoadRules(); if (!is_array($rules)) { return null; } reset($rules); $rules_z = array(); while (list($RuleID, $RuleName) = each($rules)) { if ($RuleID == null) { continue; } $rules_z[] = $ruleID; $_GET["panel-right"] = $RuleID; break; } } $array["whitelist"] = "{dansguardian_user_whitelists}"; $array["blacklist"] = "{dansguardian_user_blacklists}"; $array["files-blacklist"] = "{dansguardian_user_filesblacklists}"; while (list($num, $ligne) = each($array)) { $html[] = $tpl->_ENGINE_parse_body("<li><a href=\"{$page}?main-rules={$num}&RuleID={$_GET["panel-right"]}\"><span>{$ligne}</span></li>\n"); } echo "\n\t<div id=main_config_dansguardian_panel style='width:100%;height:550px;overflow:auto'>\n\t\t<ul>" . implode("\n", $html) . "</ul>\n\t</div>"; }
/** * List all rules, and allow adding/entering etc... */ function ManageRules() { global $txt, $context, $user_info, $scripturl, $smcFunc; // The link tree - gotta have this :o $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=manrules', 'name' => $txt['pm_manage_rules']); $context['page_title'] = $txt['pm_manage_rules']; $context['sub_template'] = 'rules'; // Load them... load them!! LoadRules(); // Likely to need all the groups! $request = $smcFunc['db_query']('', ' SELECT mg.id_group, mg.group_name, IFNULL(gm.id_member, 0) AS can_moderate, mg.hidden FROM {db_prefix}membergroups AS mg LEFT JOIN {db_prefix}group_moderators AS gm ON (gm.id_group = mg.id_group AND gm.id_member = {int:current_member}) WHERE mg.min_posts = {int:min_posts} AND mg.id_group != {int:moderator_group} AND mg.hidden = {int:not_hidden} ORDER BY mg.group_name', array('current_member' => $user_info['id'], 'min_posts' => -1, 'moderator_group' => 3, 'not_hidden' => 0)); $context['groups'] = array(); while ($row = $smcFunc['db_fetch_assoc']($request)) { // Hide hidden groups! if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { continue; } $context['groups'][$row['id_group']] = $row['group_name']; } $smcFunc['db_free_result']($request); // Applying all rules? if (isset($_GET['apply'])) { checkSession('get'); ApplyRules(true); redirectexit('action=pm;sa=manrules'); } // Editing a specific one? if (isset($_GET['add'])) { $context['rid'] = isset($_GET['rid']) && isset($context['rules'][$_GET['rid']]) ? (int) $_GET['rid'] : 0; $context['sub_template'] = 'add_rule'; // Current rule information... if ($context['rid']) { $context['rule'] = $context['rules'][$context['rid']]; $members = array(); // Need to get member names! foreach ($context['rule']['criteria'] as $k => $criteria) { if ($criteria['t'] == 'mid' && !empty($criteria['v'])) { $members[(int) $criteria['v']] = $k; } } if (!empty($members)) { $request = $smcFunc['db_query']('', ' SELECT id_member, member_name FROM {db_prefix}members WHERE id_member IN ({array_int:member_list})', array('member_list' => array_keys($members))); while ($row = $smcFunc['db_fetch_assoc']($request)) { $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; } $smcFunc['db_free_result']($request); } } else { $context['rule'] = array('id' => '', 'name' => '', 'criteria' => array(), 'actions' => array(), 'logic' => 'and'); } } elseif (isset($_GET['save'])) { checkSession('post'); $context['rid'] = isset($_GET['rid']) && isset($context['rules'][$_GET['rid']]) ? (int) $_GET['rid'] : 0; // Name is easy! $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); if (empty($ruleName)) { fatal_lang_error('pm_rule_no_name', false); } // Sanity check... if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { fatal_lang_error('pm_rule_no_criteria', false); } // Let's do the criteria first - it's also hardest! $criteria = array(); foreach ($_POST['ruletype'] as $ind => $type) { // Check everything is here... if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { continue; } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { continue; } // Members need to be found. if ($type == 'mid') { $name = trim($_POST['ruledef'][$ind]); $request = $smcFunc['db_query']('', ' SELECT id_member FROM {db_prefix}members WHERE real_name = {string:member_name} OR member_name = {string:member_name}', array('member_name' => $name)); if ($smcFunc['db_num_rows']($request) == 0) { continue; } list($memID) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); $criteria[] = array('t' => 'mid', 'v' => $memID); } elseif ($type == 'bud') { $criteria[] = array('t' => 'bud', 'v' => 1); } elseif ($type == 'gid') { $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); } } // Also do the actions! $actions = array(); $doDelete = 0; $isOr = $_POST['rule_logic'] == 'or' ? 1 : 0; foreach ($_POST['acttype'] as $ind => $type) { // Picking a valid label? if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind] - 1]))) { continue; } // Record what we're doing. if ($type == 'del') { $doDelete = 1; } elseif ($type == 'lab') { $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind] - 1); } } if (empty($criteria) || empty($actions) && !$doDelete) { fatal_lang_error('pm_rule_no_criteria', false); } // What are we storing? $criteria = serialize($criteria); $actions = serialize($actions); // Create the rule? if (empty($context['rid'])) { $smcFunc['db_insert']('', '{db_prefix}pm_rules', array('id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', 'delete_pm' => 'int', 'is_or' => 'int'), array($user_info['id'], $ruleName, $criteria, $actions, $doDelete, $isOr), array('id_rule')); } else { $smcFunc['db_query']('', ' UPDATE {db_prefix}pm_rules SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, delete_pm = {int:delete_pm}, is_or = {int:is_or} WHERE id_rule = {int:id_rule} AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'delete_pm' => $doDelete, 'is_or' => $isOr, 'id_rule' => $context['rid'], 'rule_name' => $ruleName, 'criteria' => $criteria, 'actions' => $actions)); } redirectexit('action=pm;sa=manrules'); } elseif (isset($_POST['delselected']) && !empty($_POST['delrule'])) { checkSession('post'); $toDelete = array(); foreach ($_POST['delrule'] as $k => $v) { $toDelete[] = (int) $k; } if (!empty($toDelete)) { $smcFunc['db_query']('', ' DELETE FROM {db_prefix}pm_rules WHERE id_rule IN ({array_int:delete_list}) AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'delete_list' => $toDelete)); } redirectexit('action=pm;sa=manrules'); } }
function CheckRules($ARRAY) { $IPSRC = $ARRAY["IPADDR"]; $DOMAIN = $ARRAY["DOMAIN"]; $fam = new squid_familysite(); $FAMILY = $fam->GetFamilySites($DOMAIN); if ($FAMILY == "articatech.net") { return false; } if ($FAMILY == "artica.fr") { return false; } if ($IPSRC == "127.0.0.1") { return false; } $MAIN = LoadRules(); if (isset($MAIN["IPSRC"])) { if (isset($MAIN["IPSRC"][$IPSRC])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[BLOCK]: {$IPSRC}"); } return true; } if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[SKIP]: IP:{$IPSRC}"); } } if (isset($MAIN["DOMS"])) { if (isset($MAIN["DOMS"][$DOMAIN])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[BLOCK]: {$DOMAIN}"); } return true; } if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[SKIP]: DOM:{$DOMAIN}"); } if (isset($MAIN["DOMS"][$FAMILY])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[BLOCK]: {$FAMILY}"); } return true; } if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[SKIP]: DOM:{$FAMILY}"); } } if (isset($MAIN["IPDOM"])) { if (!isset($MAIN["IPDOM"][$IPSRC])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[SKIP]: {$IPSRC} FOR {$IPSRC}/FAMILY"); } return false; } if (!isset($MAIN["IPDOM"][$IPSRC][$FAMILY])) { if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[SKIP]: {$IPSRC} FOR {$IPSRC}/{$FAMILY}"); } return false; } if ($GLOBALS["DEBUG_LEVEL"] > 1) { WLOG("CheckRules()::[BLOCK]: {$IPSRC}/{$FAMILY}"); } return true; } }
public function LoadMap() { $perfil = $this->perfil; if ($this->cfg['manutencao'] == true && true == LoadRules($perfil->ID_MEMBER, 'Administrator', $this)) { $_GET['q'] = "manutencao"; } if ($this->cfg['forcelogin'] == true && true == LoadRules($perfil->ID_MEMBER, 'ONLY_GUEST', $this)) { $_GET['q'] = "login"; } $this->map = ReadUrl(); }