public function testAddNewRules() { $rules = rules(['number_five' => 5]); $this->assertInternalType('array', $rules); $this->assertArrayHasKey('number_five', $rules); $this->assertSame($rules, rules()); }
/** * Returns true if $value matches $pattern * * @param $value * @param string $pattern * * @return bool * * @see https://github.com/ptrofimov/matchmaker - ultra-fresh PHP matching functions * @author Petr Trofimov <*****@*****.**> */ function catcher($value, $pattern) { $args = []; if (($p = ltrim($pattern, ':')) != $pattern) { foreach (explode(' ', $p) as $name) { if (substr($name, -1) == ')') { list($name, $args) = explode('(', $name); $args = explode(',', rtrim($args, ')')); } if (is_callable(rules($name))) { if (!call_user_func_array(rules($name), array_merge([$value], $args))) { return false; } } elseif (rules($name) !== $value) { return false; } } } else { return $pattern === '' || $value === $pattern; } return true; }
if(isset($_GET["settings-popup"])){settings_popup();exit;} if(isset($_POST["EmptyCache"])){EmptyCache();exit;} if(isset($_GET["tabs"])){tabs();exit;} if(isset($_GET["help"])){help();exit;} if(isset($_GET["events"])){events();exit;} if(isset($_GET["events-search"])){events_search();exit;} if(isset($_GET["events-script"])){events_script_js();exit;} if(isset($_GET["events-script-popup"])){events_script_popup();exit;} if(isset($_GET["events-script-tester-js"])){events_script_tester_js();exit;} if(isset($_GET["events-script-tester-popup"])){events_script_tester_popup();exit;} if(isset($_POST["TESTER-URL"])){events_script_tester_perform();exit;} if(isset($_POST["rebuild-tables"])){rebuild_tables();exit;} if(isset($_GET["rules"])){rules();exit;} if(isset($_GET["rules-search"])){rules_search();exit;} if(isset($_GET["rule-js"])){rules_js();exit;} if(isset($_GET["rules-tabs"])){rules_tabs();exit;} if(isset($_POST["rule-enable"])){rules_enable();exit;} if(isset($_POST["rule-delete"])){rules_delete();exit;} if(isset($_GET["rules-sources"])){rules_sources();exit;} if(isset($_GET["rules-sources-search"])){rules_sources_search();exit;} if(isset($_GET["rules-options"])){rules_options();exit;} if(isset($_POST["isResolvable"])){rules_options_save();exit;} if(isset($_POST["rules-sources-link"])){rules_sources_link();exit;} if(isset($_POST["rules-sources-unlink"])){rules_sources_unlink();exit;} if(isset($_POST["rules-sources-negation"])){rules_sources_negation();exit;}
die; } if (isset($_GET["tabs"])) { echo tabs(); exit; } if (isset($_GET["status"])) { echo status(); exit; } if (isset($_GET["service-status"])) { echo status_service(); exit; } if (isset($_GET["rules"])) { echo rules(); exit; } if (isset($_GET["DeleteRuleMaster"])) { DeleteRuleMaster(); exit; } if (isset($_GET["rules-list"])) { echo rules_list(); exit; } if (isset($_GET["rule-form"])) { echo rule_form(); exit; } if (isset($_GET["EnablePOSTFWD2"])) {
include_once 'ressources/class.users.menus.inc'; include_once 'ressources/class.artica.inc'; include_once 'ressources/class.mysql.inc'; include_once 'ressources/class.ini.inc'; include_once 'ressources/class.system.network.inc'; include_once 'ressources/class.system.nics.inc'; include_once 'ressources/class.ndpi.services.inc'; $users = new usersMenus(); if (!$users->AsSystemAdministrator) { $tpl = new templates(); $error = $tpl->javascript_parse_text("{ERROR_NO_PRIVS}"); echo "alert('{$error}')"; die; } if (isset($_GET["rules"])) { rules(); exit; } if (isset($_GET["ruleid"])) { rule_js(); exit; } if (isset($_GET["rule-tabs"])) { rule_tab(); exit; } if (isset($_GET["rule-popup"])) { rule_popup(); exit; } if (isset($_POST["rule-new"])) {
<?php if (false === array_key_exists('FORWARD', $_SERVER) || 0 === sizeof($_SERVER['FORWARD'])) { error('Missing FORWARD environment', 1); } $file = end($_SERVER['argv']); if (file_exists($file) && !unlink($file)) { error("Can't replace configuration: {$file}", 4); } $links = links(); foreach (rules() as $port => $rule) { $service = $rule['service']; if (false === array_key_exists($service, $links)) { if ($service !== gethostbyname($service)) { rule($file, $port, $service, $rule['dst']); continue; } else { error("Missing host name: {$rule['service']}", 3); } error("Missing service name: {$rule['service']}", 2); } rule($file, $port, $links[$rule['service']][$rule['dst']]['addr'], $links[$rule['service']][$rule['dst']]['port']); } if (array_key_exists('LOGFILE', $_SERVER) && is_string($_SERVER['LOGFILE']) && strlen($_SERVER['LOGFILE']) > 0) { @file_put_contents('php://stdout', "Adding rule: [0;32mlogfile {$_SERVER['LOGFILE']}[0m\n"); @file_put_contents('php://stdout', "Adding rule: [0;32mlogcommon[0m\n"); file_put_contents($file, "logfile {$_SERVER['LOGFILE']}\nlogcommon\n", FILE_APPEND); } function rule($file, $port, $addr, $dst) { static $ip;
if(isset($_GET["main-rules-tabs"])){main_section_tabs();exit;} if(isset($_GET["options"])){options_section();exit;} if(isset($_GET["options-search"])){options_search();exit;} if(isset($_POST["options-enable"])){options_enable();exit;} if(isset($_GET["main-popup"])){main_popup();exit;} if(isset($_POST["main-ID"])){main_save();exit;} if(isset($_GET["parameters"])){global_parameters();exit;} if(isset($_POST["DisableAnyCache"])){global_parameters_save();exit;} if(isset($_GET["tabs"])){tabs();exit;} if(isset($_GET["main-subrules"])){rules();exit;} if(isset($_GET["rules-search"])){rules_search();exit;} if(isset($_GET["rule-js"])){rules_js();exit;} if(isset($_GET["subrules-tabs"])){subrules_tabs();exit;} if(isset($_POST["rule-enable"])){subrules_enable();exit;} if(isset($_POST["subrule-id"])){subrules_save();exit;} if(isset($_GET["rules-tabs"])){rules_tabs();exit;} if(isset($_GET["rules-popup"])){rules_popup();exit;} if(isset($_POST["rule-delete"])){members_delete();exit;} if(isset($_POST["serviceport"])){accounts_save();exit;} if(isset($_POST["username"])){members_save();exit;} if(isset($_GET["accounts-search"])){accounts_search();exit;}