Exemplo n.º 1
0
function rules_search()
{
    //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $servicename = trim($_GET["servicename"]);
    $table_type = $_GET["table"];
    $sock = new sockets();
    $EnableL7Filter = intval($sock->GET_INFO("EnableL7Filter"));
    $EnableQOS = intval($sock->GET_INFO("EnableQOS"));
    $t = $_GET["t"];
    $FORCE_FILTER = null;
    $search = '%';
    $table = "haproxy_acls_rules";
    $table = "(SELECT * FROM haproxy_acls_rules WHERE servicename='{$servicename}' ORDER BY zorder ) as t";
    $page = 1;
    if ($q->COUNT_ROWS("haproxy_acls_rules", "artica_backup") == 0) {
        json_error_show("No datas - COUNT_ROWS", 1);
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        json_error_show($q->mysql_error . "\n{$sql}", 1);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        json_error_show($q->mysql_error, 1);
    }
    $rules = $tpl->_ENGINE_parse_body("{rules}");
    $log_all_events = $tpl->_ENGINE_parse_body("{log_all_events}");
    $c = 0;
    while ($ligne = mysql_fetch_assoc($results)) {
        $val = 0;
        $color = "black";
        $time = null;
        $mkey = md5(serialize($ligne));
        $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?rule-delete-js=yes&ID={$ligne["ID"]}')");
        $up = imgsimple("arrow-up-32.png", "", "RuleHaproxyAclsGroupUpDown('{$ligne["ID"]}',0)");
        $down = imgsimple("arrow-down-32.png", "", "RuleHaproxyAclsGroupUpDown('{$ligne["ID"]}',1)");
        $rulename = trim($ligne["rulename"]);
        $EXPLAIN = EXPLAIN_THIS_RULE($ligne["ID"]);
        if ($rulename == null) {
            $rulename = $tpl->_ENGINE_parse_body("{rule} {$ligne["ID"]}");
        }
        if ($ligne["rule_action"] == 0) {
            $color = "#8a8a8a";
        }
        $js = "Loadjs('{$MyPage}?rule-js=yes&ruleid={$ligne["ID"]}',true);";
        $JSRULE = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\"\n\t\t\tstyle='font-size:22px;font-weight:bold;text-decoration:underline;color:{$color}'>";
        if ($c == 0) {
            $up = null;
        }
        $data['rows'][] = array('id' => "{$mkey}", 'cell' => array("{$JSRULE}{$rulename}</a><br><span style='font-size:16px;color:{$color}'>{$EXPLAIN}</span>", "<center style=\"margin-top:5px\">{$up}</center>", "<center style=\"margin-top:5px\">{$down}</center>", "<center style=\"margin-top:4px\">{$delete}</center>"));
        $c++;
    }
    echo json_encode($data);
}
Exemplo n.º 2
0
function rules()
{
    //ini_set('html_errors',0);ini_set('display_errors', 1);ini_set('error_reporting', E_ALL);ini_set('error_prepend_string','');ini_set('error_append_string','');
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $eth = trim($_GET["eth"]);
    $table_type = $_GET["table"];
    $sock = new sockets();
    $EnableL7Filter = intval($sock->GET_INFO("EnableL7Filter"));
    $EnableQOS = intval($sock->GET_INFO("EnableQOS"));
    $t = $_GET["t"];
    $FORCE_FILTER = null;
    $search = '%';
    $table = "iptables_main";
    if ($eth != null) {
        $table = "(SELECT iptables_main.* FROM iptables_main WHERE iptables_main.eth='{$eth}' AND iptables_main.MOD='{$table_type}'\n\t\tORDER BY zOrder ) as t";
    }
    $page = 1;
    if ($q->COUNT_ROWS("iptables_main", "artica_backup") == 0) {
        json_error_show("No datas - COUNT_ROWS", 1);
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        json_error_show($q->mysql_error . "\n{$sql}", 1);
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (mysql_num_rows($results) == 0) {
        json_error_show($q->mysql_error, 1);
    }
    $rules = $tpl->_ENGINE_parse_body("{rules}");
    $log_all_events = $tpl->_ENGINE_parse_body("{log_all_events}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $val = 0;
        $color = "black";
        $time = null;
        $mkey = md5(serialize($ligne));
        $delete = imgsimple("delete-32.png", null, "DeleteRule{$t}('{$ligne["ID"]}')");
        $enabled = Field_checkbox("enabled-{$ligne["ID"]}", 1, $ligne["enabled"], "ChangEnabled{$_GET["t"]}('{$ligne["ID"]}')");
        $up = imgsimple("arrow-up-32.png", "", "RuleGroupUpDown{$_GET["t"]}('{$ligne["ID"]}',0)");
        $down = imgsimple("arrow-down-32.png", "", "RuleGroupUpDown{$_GET["t"]}('{$ligne["ID"]}',1)");
        $L7Mark = $ligne["L7Mark"];
        $FORWARD_TEXT = null;
        if ($EnableL7Filter == 0) {
            $L7Mark = 0;
        }
        $rulename = trim(utf8_encode($ligne["rulename"]));
        $eth_text = $ligne["eth"];
        if (!preg_match("#(.+?)2(.+?)#", $eth_text)) {
            $eth_text = "<a href=\"javascript:blud();\" OnClick=\"javascript:GoToNicFirewallConfiguration('{$eth_text}');\"\n\t\t\tstyle='text-decoration:underline;font-weight:bold'>{$eth_text}</a>";
        }
        $EXPLAIN = EXPLAIN_THIS_RULE($ligne);
        if ($ligne["jlog"] == 1) {
            $explain = $explain . "<br><span style='font-size:12px'>{$log_all_events}</span>";
        }
        if ($rulename == null) {
            $rulename = $tpl->_ENGINE_parse_body("{rule} {$ligne["ID"]}");
        }
        if ($ligne["enabled"] == 0) {
            $color = "#8a8a8a";
        }
        $js = "Loadjs('{$MyPage}?ruleid={$ligne["ID"]}&eth={$eth}&t={$_GET["t"]}&table={$table_type}',true);";
        $ACTION = "cloud-goto-32.png";
        if ($ligne["enabled"] == 0) {
            $ACTION = "cloud-goto-32-grey.png";
        }
        if ($ligne["accepttype"] == "DROP") {
            $ACTION = "cloud-deny-32.png";
            if ($ligne["enabled"] == 0) {
                $ACTION = "cloud-deny-32-grey.png";
            }
        }
        if ($ligne["accepttype"] == "RETURN") {
            $ACTION = "arrow-right-32.png";
        }
        if ($ligne["accepttype"] == "LOG") {
            $ACTION = "log-32.png";
        }
        $JSRULE = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\"\n\t\tstyle='font-size:22px;font-weight:bold;text-decoration:underline;color:{$color}'>";
        if ($ligne["zOrder"] == 1) {
            $up = null;
        }
        if ($ligne["zOrder"] == 0) {
            $up = null;
        }
        $data['rows'][] = array('id' => "{$mkey}", 'cell' => array("<span style='font-size:18px;font-weight:bold;color:{$color}'>{$ligne["zOrder"]}</span>", "{$JSRULE}{$rulename}</a>&nbsp;{$EXPLAIN}{$FORWARD_TEXT}{$time}", "<center style='font-size:18px;font-weight:bold;color:{$color}'>{$eth_text}</center>", "<div style=\"margin-top:5px\">{$enabled}</div>", "<center style='font-size:14px;font-weight:bold;color:{$color}'><img src='img/{$ACTION}'></span>", "<center style=\"margin-top:5px\">{$up}</center>", "<center style=\"margin-top:5px\">{$down}</center>", "<center style=\"margin-top:4px\">{$delete}</center>"));
    }
    echo json_encode($data);
}
Exemplo n.º 3
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $database = "artica_backup";
    $t = $_GET["t"];
    $search = '%';
    $table = "routing_rules";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $searchstring = string_to_flexquery();
    if ($searchstring != null) {
        $search = $_POST["query"];
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (!is_numeric($rp)) {
        $rp = 50;
    }
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, $database);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    if (mysql_num_rows($results) == 0) {
        $array = routes_default();
        echo json_encode($array[1]);
        return;
    }
    $fontsize = 22;
    $types[1] = $tpl->_ENGINE_parse_body("{network_nic}");
    $types[2] = $tpl->_ENGINE_parse_body("{host}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $RouteName = $ligne["RouteName"];
        if ($ligne["enabled"] == 0) {
            $color = "#8a8a8a";
        }
        $style = "style='font-size:{$fontsize}px;color:{$color};'";
        $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?route-delete-js=yes&ID={$ligne["ID"]}&t={$t}');");
        $js = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?route-js=yes&ID={$ligne["ID"]}&t={$t}');\"\n\t\tstyle='font-size:{$fontsize}px;color:{$color};text-decoration:underline'>";
        $down = imgsimple("arrow-down-32.png", null, "Loadjs('{$MyPage}?route-move-js=yes&ID={$ligne["ID"]}&t={$t}&dir=down');");
        $up = imgsimple("arrow-up-32.png", null, "Loadjs('{$MyPage}?route-move-js=yes&ID={$ligne["ID"]}&t={$t}&dir=up');");
        if ($ligne["gateway"] == null) {
            $ligne["gateway"] = $ligne["nic"];
        }
        $EXPLAIN_THIS_RULE = EXPLAIN_THIS_RULE($ligne["ID"], $ligne["nic"]);
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span {$style}>{$js}{$ligne["nic"]}</a></span>", "<span {$style}>{$js}{$RouteName}</a></span>", "<span style='font-size:16px;color:{$color};'>{$EXPLAIN_THIS_RULE}</span>", "<center {$style}>{$delete}</center>"));
    }
    echo json_encode($data);
}