function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    if (!$q->TABLE_EXISTS("firehol_services_routers")) {
        $fire = new firehol();
        $fire->checkTables();
    }
    $sock = new sockets();
    $t = $_GET["t"];
    $search = '%';
    $table = "firehol_services_routers";
    $page = 1;
    $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();
    $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE routerid={$_GET["routerid"]} {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, "artica_backup"));
    $total = $ligne["TCOUNT"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM `{$table}` WHERE routerid={$_GET["routerid"]} {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $all = $tpl->javascript_parse_text("{all}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}");
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("!!! no data");
    }
    $tpl = new templates();
    $all = $tpl->javascript_parse_text("{all}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $ID = $ligne["ID"];
        $service = $ligne["service"];
        $delete = imgsimple("delete-48.png", null, "Loadjs('{$MyPage}?delete-pattern-js={$ID}&routerid={$_GET["routerid"]}',true)");
        $pic = "cloud-deny-48.png";
        if ($ligne["allow"] == 1) {
            $pic = "cloud-goto-48.png";
        }
        $allow = imgtootltip($pic, "{allow}/{deny}", "Loadjs('{$MyPage}?switch-pattern-js=yes&ID={$ID}&routerid={$_GET["routerid"]}')");
        $excludes = imgtootltip("folder-script-48.png", "", "Loadjs('{$MyPage}?excludes-js=yes&service={$service}&routerid={$_GET["routerid"]}')");
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNt(ID) as tcount FROM firehol_routers_exclude\n\t\t\tWHERE service='{$service}' AND routerid='{$_GET["routerid"]}' AND destination=1", "artica_backup"));
        $whitelisted_destination_networks = $tpl->javascript_parse_text("{whitelisted_destination_networks}: {$ligne2["tcount"]}");
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNt(ID) as tcount FROM firehol_routers_exclude\n\t\t\tWHERE service='{$service}' AND routerid='{$_GET["routerid"]}' AND destination=0", "artica_backup"));
        $whitelisted_src_networks = $tpl->javascript_parse_text("{whitelisted_src_networks}: {$ligne2["tcount"]}");
        $data['rows'][] = array('id' => $ID, 'cell' => array("<center style='margin-top:3px;font-size:16px;font-weight:normal;color:{$color}'>{$allow}</center>", "<span style='font-size:36px;font-weight:normal;color:{$color}'>{$service}</span>\n\t\t\t\t\t<br> <span style='font-size:18px'>{$whitelisted_destination_networks}<br>{$whitelisted_src_networks}</span>\t\t\n\t\t\t\t\t", "<center style='margin-top:3px;font-size:16px;font-weight:normal;color:{$color}'>{$excludes}</center>", "<center style='margin-top:3px;font-size:16px;font-weight:normal;color:{$color}'>{$delete}</center>"));
    }
    echo json_encode($data);
}
Ejemplo n.º 2
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $database = "artica_backup";
    $search = '%';
    $table = "nics";
    $page = 1;
    $ORDER = null;
    $allow = null;
    $total = 0;
    if ($q->COUNT_ROWS($table, $database) == 0) {
        json_error_show("no data");
    }
    $searchstring = string_to_flexquery();
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $table = "(SELECT * FROM nics WHERE isFW=1) as t";
    $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$searchstring}";
    $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
    $total = $ligne["TCOUNT"];
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT * FROM {$table} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        json_error_show($q->mysql_error_html(), 1);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data {$sql}");
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error);
    }
    $fontsize = 18;
    $firehole = new firehol();
    while ($ligne = mysql_fetch_assoc($results)) {
        $mouse = "OnMouseOver=\"this.style.cursor='pointer'\" OnMouseOut=\"this.style.cursor='default'\"";
        $linkstyle = "style='text-decoration:underline'";
        $Interface = $ligne["Interface"];
        $NICNAME = $ligne["NICNAME"];
        $netzone = $ligne["netzone"];
        $CountDelocal = $firehole->interface_count_local_services($Interface);
        $CountServices = $firehole->interface_count_allowed_services($Interface);
        $js = "Loadjs('system.nic.edit.php?nic={$Interface}')";
        $link = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-size:{$fontsize}px;text-decoration:underline'>";
        $data['rows'][] = array('id' => $ligne["Interface"], 'cell' => array("<img src='img/folder-network-32.png' valign='middle'>", "<span style='font-size:18px'>{$link}{$Interface}</a></span>", "<span style='font-size:18px'>{$link}{$NICNAME}</a></span>", "<span style='font-size:18px'>{$netzone}</span>", "<span style='font-size:18px'>{$CountDelocal}</span>", "<span style='font-size:18px'>{$CountServices}</span>"));
    }
    echo json_encode($data);
}
Ejemplo n.º 3
0
function stepfinal()
{
    $sock = new sockets();
    $sock->GET_INFO("FireHolConfigured", 1);
    $sock->SET_INFO("FireHolEnable", 1);
    $sock->SET_INFO("FireHolRouter", 0);
    $FireHolConf = unserialize(base64_decode($sock->GET_INFO("FireHolConf")));
    $eth = new system_nic($FireHolConf["IF_LAN"]);
    $eth->firewall_policy = $FireHolConf["IF_LAN_BEHAVIOR"];
    $eth->isFW = 1;
    $eth->SaveNic();
    $servs[] = "artica";
    $servs[] = "http";
    $servs[] = "https";
    $servs[] = "dns";
    $servs[] = "ping";
    $servs[] = "ssh";
    $servs[] = "squid";
    $servs[] = "snmp";
    $servs[] = "snmptrap";
    $servs[] = "icmp";
    $servs[] = "dhcp";
    $f = new firehol();
    if ($FireHolConf["IF_LAN_BEHAVIOR"] == "reject") {
        if (!$f->checkTables()) {
            echo "FAILED";
            return false;
        }
        while (list($a, $service) = each($servs)) {
            if (!$f->edit_service($FireHolConf["IF_LAN"], $service, 1, 1)) {
                echo "edit_service({$service}) FAILED";
                return;
            }
        }
    }
    $servs = array();
    $servs1[] = "http";
    $servs1[] = "https";
    $servs1[] = "ftp";
    $servs1[] = "dns";
    $servs1[] = "ping";
    $servs1[] = "icmp";
    if (!$f->checkTables()) {
        echo "FAILED";
        return false;
    }
    while (list($a, $service) = each($servs1)) {
        if (!$f->edit_client_service($FireHolConf["IF_LAN"], $service, 1, 1)) {
            echo "edit_client_service({$service}) FAILED";
            return;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "edit_client_service({$service}) TRUE<br>\n";
        }
    }
    $sock->SET_INFO("FireHolConfigured", 1);
    echo "<script>Loadjs('firehol.progress.php');</script>";
}
Ejemplo n.º 4
0
function reconfigure_progress()
{
    $sock = new sockets();
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    if (!$sock->isFirehol()) {
        build_progress("{building_init_script}", 80);
        build_init();
        build_progress("{building_rules}", 80);
        system("{$php} /usr/share/artica-postfix/exec.squid.transparent.php");
        build_progress("FireWall service:{disabled}", 100);
        return;
    }
    build_progress("{building_rules}", 10);
    $fire = new firehol();
    $fire->build();
    build_progress("{stopping_firewall}", 50);
    shell_exec("/usr/local/sbin/firehol stop");
    build_progress("{starting_firewall}", 70);
    shell_exec("/usr/local/sbin/firehol start");
    build_progress("{building_init_script}", 80);
    build_init();
    build_progress("{done}", 100);
}
function table()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $tt = time();
    $t = $_GET["t"];
    $type = $tpl->javascript_parse_text("{type}");
    $networks = $tpl->_ENGINE_parse_body("{networks}");
    $new_rule = $tpl->_ENGINE_parse_body("{new_network}");
    $port = $tpl->javascript_parse_text("{listen_port}");
    $address = $tpl->javascript_parse_text("{listen_address}");
    $delete = $tpl->javascript_parse_text("{delete} {rule} ?");
    $enabled = $tpl->javascript_parse_text("{enabled}");
    $apply = $tpl->javascript_parse_text("{apply}");
    $q = new mysql();
    if (!$q->TABLE_EXISTS("firehol_routers_exclude", "artica_backup")) {
        $fire = new firehol();
        $fire->checkTables();
    }
    $ex[1] = '{whitelisted_destination_networks}';
    $ex[0] = "{whitelisted_src_networks}";
    $title = "<strong style=font-size:30px>" . $tpl->javascript_parse_text("{$ex[$_GET["destination"]]}") . "</strong>";
    $buttons = "\n\tbuttons : [\n\t{name: '<strong style=font-size:18px>{$new_rule}</strong>', bclass: 'add', onpress : NewRule{$tt}},\n\t{name: '<strong style=font-size:18px>{$apply}</strong>', bclass: 'Reconf', onpress : Apply{$tt}},\n\t],";
    $html = "\n<table class='TABLE_ROUTERS_SERVICE_EX{$_GET["destination"]}' style='display: none' id='TABLE_ROUTERS_SERVICE_EX{$_GET["destination"]}' style='width:100%'></table>\n<script>\nfunction Start{$tt}(){\n\t\$('#TABLE_ROUTERS_SERVICE_EX{$_GET["destination"]}').flexigrid({\n\t\turl: '{$page}?search=yes&service={$_GET["service"]}&routerid={$_GET["routerid"]}&destination={$_GET["destination"]}',\n\t\tdataType: 'json',\n\t\tcolModel : [\n\t\t\n\t\t\t{display: '<strong style=font-size:18px>{$networks}</strong>', name : 'networks', width :433, sortable : true, align: 'left'},\n\t\t\t{display: '&nbsp;', name : 'delete', width : 70, sortable : false, align: 'center'},\n\t\t\t],\n\t\t\t{$buttons}\n\t\t\tsearchitems : [\n\t\t\t\t{display: '{$networks}', name : 'networks'},\n\t\t\t],\n\t\t\tsortname: 'ID',\n\t\t\tsortorder: 'desc',\n\t\t\tusepager: true,\n\t\t\ttitle: '{$title}',\n\t\t\tuseRp: true,\n\t\t\trp: 50,\n\t\t\tshowTableToggleBtn: false,\n\t\t\twidth: '99%',\n\t\t\theight: 350,\n\t\t\tsingleSelect: true,\n\t\t\trpOptions: [10, 20, 30, 50,100,200]\n\t\n\t});\n}\n\t\nvar xNewRule{$tt}= function (obj) {\n\tvar res=obj.responseText;\n\tif (res.length>3){alert(res);return;}\n\t\$('#flexRT{$t}').flexReload();\n\t\$('#flexRT{$tt}').flexReload();\n}\n\t\nfunction Apply{$tt}(){\n\tLoadjs('firehol.progress.php');\n}\n\t\n\t\nfunction NewRule{$tt}(){\n\tLoadjs('{$page}?pattern-js=yes&service={$_GET["service"]}&routerid={$_GET["routerid"]}&destination={$_GET["destination"]}');\n}\nfunction RuleDestinationDelete{$tt}(zmd5){\n\tif(!confirm('{$delete}')){return;}\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('rules-destination-delete', zmd5);\n\tXHR.sendAndLoad('{$page}', 'POST',xNewRule{$tt});\n}\nvar xRuleEnable{$t}= function (obj) {\n\tvar res=obj.responseText;\n\tif (res.length>3){alert(res);return;}\n\t\$('#flexRT{$t}').flexReload();\n\t\$('#flexRT{$tt}').flexReload();\n}\n\t\n\t\nfunction RuleEnable{$tt}(ID,md5){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('rule-enable', ID);\n\tif(document.getElementById(md5).checked){XHR.appendData('enable', 1);}else{XHR.appendData('enable', 0);}\n\tXHR.sendAndLoad('{$page}', 'POST',xRuleEnable{$tt});\n}\n\t\nStart{$tt}();\n</script>\n";
    echo $html;
}