Exemplo n.º 1
0
function page()
{
    $sock = new sockets();
    $nic = new system_nic($_GET["eth"]);
    $DATAS = $nic->ShoreWallServices;
    $q = new mysql_shorewall();
    $sql = "SELECT zone  FROM `fw_zones` ORDER BY zone";
    $results = $q->QUERY_SQL($sql);
    $t = time();
    $page = CurrentPageName();
    $tpl = new templates();
    $ZONES["all+"] = "{all}";
    $ZONES["NONE"] = "{deny}";
    while ($ligne = mysql_fetch_assoc($results)) {
        if ($ligne["zone"] == "fw") {
            continue;
        }
        $ZONES[$ligne["zone"]] = $ligne["zone"];
    }
    $ACCEPT_PING = $DATAS["ACCEPT_PING"];
    $ACCEPT_SMTP = $DATAS["ACCEPT_SMTP"];
    $ACCEPT_ARTICA = $DATAS["ACCEPT_ARTICA"];
    $ACCEPT_WWWW = $DATAS["ACCEPT_WWWW"];
    $ACCEPT_LDAP = $DATAS["ACCEPT_LDAP"];
    $ACCEPT_MYSQL = $DATAS["ACCEPT_MYSQL"];
    $ACCEPT_PROXY = $DATAS["ACCEPT_PROXY"];
    $ACCEPT_IMAP = $DATAS["ACCEPT_IMAP"];
    $ACCEPT_DNS = $DATAS["ACCEPT_DNS"];
    $ACCEPT_SSH = $DATAS["ACCEPT_SSH"];
    if ($ACCEPT_SSH == null) {
        $ACCEPT_SSH = "all+";
    }
    if ($ACCEPT_PING == null) {
        $ACCEPT_PING = "all+";
    }
    if ($ACCEPT_SMTP == null) {
        $ACCEPT_SMTP = "all+";
    }
    if ($ACCEPT_ARTICA == null) {
        $ACCEPT_ARTICA = "all+";
    }
    if ($ACCEPT_WWWW == null) {
        $ACCEPT_WWWW = "all+";
    }
    if ($ACCEPT_LDAP == null) {
        $ACCEPT_LDAP = "all+";
    }
    if ($ACCEPT_MYSQL == null) {
        $ACCEPT_MYSQL = "all+";
    }
    if ($ACCEPT_IMAP == null) {
        $ACCEPT_IMAP = "all+";
    }
    if ($ACCEPT_DNS == null) {
        $ACCEPT_DNS = "all+";
    }
    $html = "<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_ping}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_PING-{$t}", $ACCEPT_PING, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_ssh}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_SSH-{$t}", $ACCEPT_SSH, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_smtp}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_SMTP-{$t}", $ACCEPT_SMTP, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_imap}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_IMAP-{$t}", $ACCEPT_IMAP, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\t\t\t\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_artica_webconsole}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_ARTICA-{$t}", $ACCEPT_ARTICA, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_web}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_WWWW-{$t}", $ACCEPT_WWWW, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_ldap}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_LDAP-{$t}", $ACCEPT_LDAP, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_mysql}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_MYSQL-{$t}", $ACCEPT_MYSQL, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_proxy}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_PROXY-{$t}", $ACCEPT_PROXY, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{accept_dns}:</td>\n\t\t<td>" . Field_array_Hash($ZONES, "ACCEPT_DNS-{$t}", $ACCEPT_DNS, null, null, 0, "font-size:16px") . "</td>\n\t</tr>\t\n\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 18) . "</td>\n\t</tr>\t\t\t\t\t\t\t\n\t</table>\n<script>\nvar xSave{$t}= function (obj) {\n\tvar res=obj.responseText;\n\tif (res.length>3){alert(res);}\n\tExecuteByClassName('SearchFunction');\n\tLoadjs('shorewall.php?apply-js=yes&ask=yes');\n}\n\nfunction Save{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('eth',  '{$_GET["eth"]}');\n\t\n\tXHR.appendData('ACCEPT_SSH',  encodeURIComponent(document.getElementById('ACCEPT_SSH-{$t}').value));\n\tXHR.appendData('ACCEPT_PING',  encodeURIComponent(document.getElementById('ACCEPT_PING-{$t}').value));\n\tXHR.appendData('ACCEPT_SMTP',  encodeURIComponent(document.getElementById('ACCEPT_SMTP-{$t}').value));\n\tXHR.appendData('ACCEPT_ARTICA',  encodeURIComponent(document.getElementById('ACCEPT_ARTICA-{$t}').value));\n\tXHR.appendData('ACCEPT_WWWW',  encodeURIComponent(document.getElementById('ACCEPT_WWWW-{$t}').value));\n\tXHR.appendData('ACCEPT_LDAP',  encodeURIComponent(document.getElementById('ACCEPT_LDAP-{$t}').value));\n\tXHR.appendData('ACCEPT_MYSQL',  encodeURIComponent(document.getElementById('ACCEPT_MYSQL-{$t}').value));\n\tXHR.appendData('ACCEPT_PROXY',  encodeURIComponent(document.getElementById('ACCEPT_PROXY-{$t}').value));\n\tXHR.appendData('ACCEPT_IMAP',  encodeURIComponent(document.getElementById('ACCEPT_IMAP-{$t}').value));\n\tXHR.appendData('ACCEPT_DNS',  encodeURIComponent(document.getElementById('ACCEPT_DNS-{$t}').value));\n\tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n}\n</script>\t";
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 2
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_providers";
    $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) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}", 1);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $options_text = null;
        $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$ligne["ID"]}')");
        $ip = new system_nic($ligne["INTERFACE"]);
        $interface = "{$ip->NICNAME} - " . $ligne["INTERFACE"];
        $linkInterface = $q->JS_INTERFACE($ligne["INTERFACE"]);
        $linkprovider = $q->JS_PROVIDER($ligne["ID"]);
        $options = array();
        if ($ligne["track"] == 1) {
            $options[] = $tpl->_ENGINE_parse_body("{routing_track}");
        }
        if ($ligne["tproxy"] == 1) {
            $options[] = $tpl->_ENGINE_parse_body("{routing_tproxy}");
        }
        if ($ligne["fallback"] > -1) {
            $options[] = $tpl->_ENGINE_parse_body("{fallback}");
        }
        if ($ligne["balance"] > -1) {
            $options[] = $tpl->_ENGINE_parse_body("{balance}");
        }
        if (count($options) > 0) {
            $options_text = "<br><i style='font-size:12px'>" . @implode(", ", $options) . "</i>";
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkprovider}{$ligne["NAME"]}</a></span>{$options_text}", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkprovider}{$ligne["DUPLICATE"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkInterface}{$interface}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkprovider}{$ligne["GATEWAY"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 3
0
function build_providers()
{
    $unix = new unix();
    $filename = "/etc/shorewall/providers";
    @unlink($filename);
    return;
    $sql = "SELECT * FROM `fw_providers` ORDER BY NUMBER";
    $q = new mysql_shorewall();
    $results = $q->QUERY_SQL($sql);
    $f[] = "#";
    $f[] = "# Shorewall version 4 - Providers File " . date("Y-m-d H:i:s") . " by Artica";
    $f[] = "#";
    $f[] = "# For information about entries in this file, type \"man shorewall-providers\"";
    $f[] = "#";
    $f[] = "# For additional information, see http://shorewall.net/MultiISP.html";
    $f[] = "#";
    $f[] = "############################################################################################";
    $f[] = "#NAME\tNUMBER\tMARK\tDUPLICATE\tINTERFACE\tGATEWAY\t\tOPTIONS\t\tCOPY";
    while ($ligne = mysql_fetch_assoc($results)) {
        $NAME = $ligne["NAME"];
        $NUMBER = $ligne["NUMBER"];
        $MARK = $ligne["MARK"];
        $DUPLICATE = $ligne["DUPLICATE"];
        $INTERFACE = $ligne["INTERFACE"];
        $GATEWAY = $ligne["GATEWAY"];
        $prefix = null;
        if (!$unix->is_interface_available($INTERFACE)) {
            $prefix = "# ( Interface {$INTERFACE} not available ) ";
        }
        if (!is_numeric($MARK)) {
            $MARK = "-";
        }
        if ($DUPLICATE == null) {
            $DUPLICATE = "-";
        }
        if ($INTERFACE == null) {
            $INTERFACE = "-";
        }
        if ($GATEWAY == null) {
            $GATEWAY = "-";
        }
        $OPTION = "-";
        $options = array();
        if ($ligne["track"] == 1) {
            $options[] = "track";
        }
        if ($ligne["tproxy"] == 1) {
            $options[] = "tproxy";
        }
        if ($ligne["fallback"] > -1) {
            if ($ligne["fallback"] > 0) {
                $options[] = "fallback={$ligne["fallback"]}";
            } else {
                $options[] = "fallback";
            }
        }
        if ($ligne["balance"] > -1) {
            if ($ligne["balance"] > 0) {
                $options[] = "balance={$ligne["balance"]}";
            } else {
                $options[] = "balance";
            }
        }
        if (count($options) > 0) {
            $OPTION = @implode(",", $options);
        }
        $f[] = "{$prefix}{$NAME}\t{$NUMBER}\t{$MARK}\t{$DUPLICATE}\t{$INTERFACE}\t{$GATEWAY}\t{$OPTION}";
    }
    $f[] = "#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE\n";
    @file_put_contents($filename, @implode("\n", $f));
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$filename} done\n";
    }
}
Exemplo n.º 4
0
function port_save()
{
    $ID = $_POST["ID"];
    $shore = new mysql_shorewall();
    $ip = new IP();
    if (!$ip->isIPAddress($_POST["gateway"])) {
        $_POST["gateway"] = "";
    }
    if (!$ip->isIPAddress($_POST["ipaddr"])) {
        echo "{$_POST["ipaddr"]} -> FALSE\n";
        return;
    }
    if (!preg_match("#(.+?)\\/(.+)#", $_POST["cdir"])) {
        $_POST["cdir"] = "";
    }
    $q = new mysql();
    if (!$q->FIELD_EXISTS("nics_switch", "vlan", "artica_backup")) {
        $sql = "ALTER TABLE `nics_switch` ADD `vlan` smallint( 2 ) NOT NULL,ADD INDEX(`vlan`)";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    if (!$q->FIELD_EXISTS("nics_switch", "netzone", "artica_backup")) {
        $sql = "ALTER TABLE `nics_switch` ADD `netzone` VARCHAR( 10 ) NOT NULL,ADD UNIQUE KEY `netzone` (`netzone`)";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    if ($_POST["netzone"] == null) {
        echo "Network Zone must be defined\n";
        return;
    }
    if ($_POST["netzone"] != null) {
        if (strlen($_POST["netzone"]) > 5) {
            echo "NetZone {$_POST["netzone"]} at most 5 characters long\n";
            return;
        }
        if (is_numeric(substr($_POST["netzone"], 0, 1))) {
            echo "Network Zone Must start with a letter\n";
            return;
        }
        if ($ID == 0) {
            $ligne = @mysql_fetch_array($q->QUERY_SQL("SELECT netzone FROM nics_switch WHERE netzone='{$_POST["netzone"]}'", "artica_backup"));
            if ($ligne["netzone"] != null) {
                echo "Network Zone {$ligne["netzone"]} already defined\n";
                return;
            }
        }
    }
    if ($_POST["netzone"] == null) {
        if ($ID > 0) {
            $_POST["netzone"] = "virt{$ID}";
        }
    }
    $sql = "INSERT INTO nics_switch (`nic`,`netzone`, `ipaddr`,`netmask`,`cdir`,`gateway`,`metric`,`port`,`vlan`) \n\tVALUES\n\t('{$_POST["nic"]}','{$_POST["netzone"]}','{$_POST["ipaddr"]}','{$_POST["netmask"]}','{$_POST["cdir"]}',\n\t'{$_POST["gateway"]}','{$_POST["metric"]}','{$_POST["port"]}','{$_POST["vlan"]}')";
    $sql_edit = "UPDATE nics_switch SET `nic`='{$_POST["nic"]}',\n\t`ipaddr`='{$_POST["ipaddr"]}',\n\t`netzone`='{$_POST["netzone"]}',\n\t`netmask`='{$_POST["netmask"]}',\n\t`cdir`='{$_POST["cdir"]}',\n\t`gateway`='{$_POST["gateway"]}',\n\t`port`='{$_POST["port"]}',\n\t`vlan`='{$_POST["vlan"]}',\n\t`metric`='{$_POST["metric"]}' WHERE ID='{$_POST["ID"]}'";
    if ($_POST["ID"] > 0) {
        $sql = $sql_edit;
    }
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        echo $q->mysql_error;
        return;
    }
    if ($_POST["netzone"] == null) {
        $_POST["netzone"] = "virt{$q->last_id}";
        $q->QUERY_SQL("UPDATE nics_switch SET netzone='{$_POST["netzone"]}' WHERE ID={$q->last_id}");
    }
    if ($_POST["ID"] > 0) {
        $shore->NIC_UPDATE("virt{$_POST["ID"]}");
    } else {
        $shore->NIC_UPDATE("virt{$q->last_id}");
    }
    if ($_POST["ID"] > 0) {
        $ID = $_POST["ID"];
    } else {
        $ID = $q->last_id;
    }
    $sock = new sockets();
    $sock->getFrameWork("vde.php?port-reconfigure={$ID}");
}
Exemplo n.º 5
0
function explain_rule($ligne)
{
    $q = new mysql_shorewall();
    $tpl = new templates();
    $ACTION_CODE_TEXT = null;
    $zone_id_from = $ligne["zone_id_from"];
    $PROTO = $ligne["PROTO"];
    $ID = $ligne["ID"];
    $zone_id_to = $ligne["zone_id_to"];
    $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT zone FROM fw_zones WHERE ID='{$zone_id_from}'"));
    $zone_from = $ligne2["zone"];
    $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT zone FROM fw_zones WHERE ID='{$zone_id_to}'"));
    $zone_to = $ligne2["zone"];
    $log = $ligne["log"];
    //if($log==1){$event_text=" {and} {write_events}";}
    if ($ligne["RATELIM"] == 1) {
        $LIMIT_T["sec"] = "{second}";
        $LIMIT_T["min"] = "{minute}";
        $LIMIT_T["hour"] = "{hour}";
        $LIMIT_T["day"] = "{day}";
        $LIMIT_T["week"] = "{week}";
        $LIMIT_T["month"] = "{month}";
        $LIMITTD["a"] = "{all}";
        $LIMITTD["s"] = "{source}";
        $LIMITTD["d"] = "{destination}";
        if (preg_match("#^(s|d|a):([0-9]+)\\/(.+?):([0-9]+)#", $ligne["RATELIMIT"], $re)) {
            $LIMIT_D = $re[1];
            $connections = $re[2];
            $LIMIT_F = $re[3];
            $BURST = $re[4];
        }
        $limit = $tpl->_ENGINE_parse_body("<br>{and} {RATELIM} {$LIMITTD[$LIMIT_D]} {$connections} {per} {$LIMIT_T[$LIMIT_F]} {burst} {$BURST}");
    }
    $ACTION_CODE = $ligne["ACTION"];
    $action = $q->RULES_POLICIES[$ACTION_CODE];
    $sql = "SELECT fw_objects.groupname,fw_objects.grouptype,\n\t\t\tfw_objects_lnk.`ID` as linkid,\n\t\t\tfw_objects_lnk.`ruleid`,\n\t\t\tfw_objects_lnk.`reverse`,\n\t\t\t`fw_objects_lnk`.`groupid`,\n\t\t\tfw_objects_lnk.`INOUT` FROM `fw_objects_lnk`,`fw_objects`\n\t\t\tWHERE \n\t\t\t`fw_objects_lnk`.`groupid`=`fw_objects`.`ID`\n\t\t\tAND fw_objects_lnk.`ruleid`={$ID}";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        $IN = $q->mysql_error;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $not = null;
        $grouptype = $ligne["grouptype"];
        $grouptype = $tpl->javascript_parse_text($q->RULES_POLICIES_GROUP_TYPE[$grouptype]);
        $groupname = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('shorewall.groups.items.php?js=yes&groupid={$ligne['groupid']}&t={$_GET["t"]}',true);\"\n\t\tstyle='text-decoration:underline'\n\t\t>{$ligne["groupname"]} <i>{$grouptype}</i></a>";
        if ($ligne["reverse"] == 1) {
            $not = "{not} ";
        }
        $GPS[$ligne["INOUT"]][] = "{$not}{$groupname}";
    }
    if (count($GPS[0]) > 0) {
        $IN = " " . @implode("<br>{and} ", $GPS[0]) . "";
    }
    if (count($GPS[1]) > 0) {
        $OUT = " " . @implode("<br>{and} ", $GPS[1]) . "";
    }
    if ($ACTION_CODE == "DNAT") {
        $ACTION_CODE_TEXT = " {to} {$OUT}";
        $OUT = null;
    }
    $html = "{when_connections_came_from} {$zone_from} ({$PROTO}) {$IN}<br>{to} {$zone_to} ({$PROTO}) {$OUT}<br>{then} {$action}{$ACTION_CODE_TEXT}{$limit}";
    return $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 6
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_masq";
    $page = 1;
    $FORCE_FILTER = "AND `eth`='{$_GET["eth"]}'";
    $total = 0;
    if (!$q->FIELD_EXISTS("fw_masq", "zOrder")) {
        $sql = "ALTER TABLE `fw_masq` ADD `zOrder` INT( 3 ) NOT NULL DEFAULT '0'";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}", 1);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $options_text = null;
        $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$ligne["ID"]}')");
        $ip = new system_nic($ligne["INTERFACE"]);
        $interface = "{$ip->NICNAME} - " . $ligne["INTERFACE"];
        $linkprovider = "<a href=\"javascript:blur();\"\n\t\tstyle='font-size:{$fontsize}px;text-decoration:underline'\n\t\tOnClick=\"javascript:Loadjs('{$MyPage}?masq-js=yes&eth={$_GET["eth"]}&ID={$ligne["ID"]}&t={$_GET["t"]}');\">";
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkprovider}{$ligne["SOURCE"]}</a></span>", "<img src='img/arrow-right-24.png'>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$interface}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkInterface}{$ligne["ADDRESS"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 7
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql();
    $shorewall = new mysql_shorewall();
    $zmd5 = $_GET["zmd5"];
    $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT nic,roleconf FROM nics_roles WHERE zmd5='{$zmd5}'", "artica_backup"));
    $t = $_GET["t"];
    $search = '%';
    $page = 1;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $roleconf = unserialize(base64_decode($ligne["roleconf"]));
    if (count($roleconf) == 0) {
        $firstnet = $shorewall->FIND_NET($ligne["net"]);
        $roleconf[$firstnet] = $firstnet;
        $roleconfZ = base64_encode(serialize($roleconf));
        $q->QUERY_SQL("UPDATE nics_roles SET roleconf='{$roleconfZ}' WHERE zmd5='{$zmd5}'");
    }
    $total = count($roleconf);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $fontsize = "16";
    if (!is_array($roleconf)) {
        json_error_show("no data");
    }
    while (list($key, $value) = each($roleconf)) {
        $color = "black";
        $NICNAME = null;
        $NETENC = urlencode($key);
        $NETMD = md5($NETENC);
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?unlink-group-js=yes&linkid={$NETENC}&t={$_GET["t"]}&ruleid={$ruleid}')");
        $data['rows'][] = array('id' => $NETMD, 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$key}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 8
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_interfaces";
    $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) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error . "<br>{$sql}", 1);
    }
    if (mysql_num_rows($results) == 0) {
        json_error_show("no data", 1);
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$ligne["eth"]}')");
        $ip = new system_nic($ligne["eth"]);
        $interface = "{$ip->NICNAME} - " . $ligne["eth"];
        $linkinterface = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?interface-js=yes&ID={$ligne["eth"]}&t={$t}');\" style='font-size:{$fontsize}px;text-decoration:underline'>";
        $data['rows'][] = array('id' => $ligne['eth'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>\n\t\t\t\t\t\t\t<img src='img/32-win-nic.png'>\n\t\t\t\t\t\t</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$linkinterface}{$interface}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["comment"]}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 9
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_zones";
    $page = 1;
    $FORCE_FILTER = null;
    $total = 0;
    if ($q->COUNT_ROWS($table) == 0) {
        $q->CheckTables();
    }
    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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $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");
    }
    $fontsize = "16";
    if ($searchstring == null) {
        $shorewall_firewall = $tpl->_ENGINE_parse_body("{shorewall_firewall}");
        $data['total']++;
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;'>fw</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;'>firewall</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;'>{$shorewall_firewall}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;'></span>"));
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $NICNAME = null;
        if ($ligne['ID'] > 0) {
            $delete = imgsimple("delete-32.png", null, "Delete{$t}({$ligne["ID"]})");
        }
        $editjs = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?zone-js=yes&ID={$ligne['ID']}&t={$t}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>";
        if (trim($ligne["eth"]) != null) {
            $nic = new system_nic($ligne["eth"]);
            $jsinterface = "javascript:Loadjs('shorewall.interfaces.php?interface-js=yes&ID={$ligne["eth"]}&t={$t}');";
            if ($nic->NICNAME != null) {
                $NICNAME = "<i><a href=\"javascript:blur();\" OnClick=\"{$jsinterface}\"\n\t\t\tstyle='text-decoration:underline'>{$nic->NICNAME}</a></i>, ";
            }
        }
        if (isset($q->ZONES_RESERVED_WORDS[$ligne["zone"]])) {
            $delete = null;
            $editjs = null;
        }
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$ligne["zone"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["type"]}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$NICNAME}{$ligne["comment"]}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 10
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "( SELECT fw_zones1.zone as zone_from,fw_zones1.ID as ID1, \n\t\t\tfw_zones2.zone as zone_to,fw_zones2.ID as ID2, zones_policies.* \n\t\t\tFROM fw_zones as fw_zones1,fw_zones as fw_zones2,zones_policies \n\t\t\tWHERE fw_zones1.ID=zones_policies.zone_id_from AND fw_zones2.ID=zones_policies.zone_id_to ) as t";
    $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) {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} WHERE 1 {$FORCE_FILTER} {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS("zones_policies");
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $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 {$sql}");
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $NICNAME = null;
        $delete = imgsimple("delete-32.png", null, "Delete{$t}({$ligne["ID"]})");
        $editjs = "<a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$MyPage}?policy-js=yes&ID={$ligne['ID']}&t={$t}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $policy = $tpl->javascript_parse_text($q->POLICIES[$ligne["policy"]]);
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$ligne["policy_name"]}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["zone_from"]}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$ligne["zone_to"]}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$policy}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 11
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_objects";
    $page = 1;
    $FORCE_FILTER = null;
    $ruleid = $_GET["ruleid"];
    $total = 0;
    $FORCE_FILTER = null;
    if (!$q->TABLE_EXISTS("fw_objects")) {
        $q->QUERY_SQL("CREATE TABLE IF NOT EXISTS `fw_objects` (\n\t\t\t`ID` INT UNSIGNED AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t`groupname` VARCHAR( 255 ) NOT NULL,\n\t\t\t`grouptype` VARCHAR(20) NOT NULL,\n\t\t\t KEY `groupname` (`groupname`),\n\t\t\t KEY `grouptype` (`grouptype`)\n\t\t\t) ENGINE=MYISAM;");
    }
    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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS("fw_objects");
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $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 {$sql}");
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $NICNAME = null;
        $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?remove-group-js={$ligne["ID"]}&t={$_GET["t"]}&t-rule={$_GET["t-rule"]}&tt={$_GET["tt"]}')");
        $link = imgsimple("arrow-right-32.png", null, "Link{$_GET["tt"]}({$ligne["ID"]})");
        $editjs = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('shorewall.groups.items.php?js=yes&groupid={$ligne['ID']}&t={$_GET["t"]}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $groupname = utf8_encode($ligne["groupname"]);
        $grouptype = $tpl->_ENGINE_parse_body($q->RULES_POLICIES_GROUP_TYPE[$ligne["grouptype"]]);
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM fw_items WHERE groupid='{$ligne['ID']}'"));
        $itemsNum = $ligne2["tcount"];
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$groupname}</span>", "<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$grouptype}</a></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$itemsNum}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$link}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 12
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "(SELECT fw_objects.groupname,fw_objects.grouptype,\n\t\t\tfw_objects_lnk.`ID` as linkid,\n\t\t\tfw_objects_lnk.`ruleid`,\n\t\t\tfw_objects_lnk.`reverse`,\n\t\t\t`fw_objects_lnk`.`groupid`,\n\t\t\tfw_objects_lnk.`INOUT` FROM `fw_objects_lnk`,`fw_objects`\n\t\t\tWHERE `fw_objects_lnk`.`groupid`=`fw_objects`.`ID`) as t";
    $page = 1;
    $FORCE_FILTER = null;
    $ruleid = $_GET["ruleid"];
    $total = 0;
    $FORCE_FILTER = "AND `ruleid`={$ruleid}";
    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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS("fw_objects_lnk");
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $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 {$sql}");
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $NICNAME = null;
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?unlink-group-js=yes&linkid={$ligne["linkid"]}&groupid={$ligne["groupid"]}&t={$_GET["t"]}&ruleid={$ruleid}')");
        $editjs = "<a href=\"javascript:blur();\" \n\t\tOnClick=\"javascript:Loadjs('shorewall.groups.items.php?js=yes&groupid={$ligne['groupid']}&t={$_GET["t"]}',true);\"\n\t\tstyle='font-size:{$fontsize}px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $grouptype = $tpl->_ENGINE_parse_body($q->RULES_POLICIES_GROUP_TYPE[$ligne["grouptype"]]);
        $groupname = utf8_encode($ligne["groupname"]);
        $ID = $ligne["ID"];
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM fw_items WHERE groupid='{$ligne['groupid']}'"));
        $itemsNum = $ligne2["tcount"];
        if ($ligne["INOUT"] == 0) {
            $in = Field_checkbox("INOUT", 1, 1, "INOUT{$t}({$ligne["linkid"]})");
            $out = Field_checkbox("INOUT", 1, 0, "INOUT{$t}({$ligne["linkid"]})");
        } else {
            $in = Field_checkbox("INOUT", 1, 0, "INOUT{$t}({$ligne["linkid"]})");
            $out = Field_checkbox("INOUT", 1, 1, "INOUT{$t}({$ligne["linkid"]})");
        }
        $rev = Field_checkbox("reverse", 1, $ligne["reverse"], "reverse{$t}({$ligne["linkid"]})");
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$editjs}{$groupname}</a><br><i style='font-size:12px'>&nbsp;{$grouptype}</i></span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$itemsNum}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$in}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$out}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$rev}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}
Exemplo n.º 13
0
function items()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_shorewall();
    $t = $_GET["t"];
    $search = '%';
    $table = "fw_items";
    $page = 1;
    $FORCE_FILTER = null;
    $groupid = $_GET["groupid"];
    $total = 0;
    $FORCE_FILTER = "AND `groupid`={$groupid}";
    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));
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS("fw_items");
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    if (is_numeric($rp)) {
        $limitSql = "LIMIT {$pageStart}, {$rp}";
    }
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    $no_rule = $tpl->_ENGINE_parse_body("{no_rule}");
    $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 {$sql}");
    }
    $fontsize = "16";
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $NICNAME = null;
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?delete-item-js=yes&ID={$ligne["ID"]}&groupid={$ligne["groupid"]}&t={$_GET["t"]}')");
        $fw_items = utf8_encode($ligne["item"]);
        $ID = $ligne["ID"];
        $ligne2 = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(ID) as tcount FROM fw_items WHERE groupid='{$ligne['groupid']}'"));
        $itemsNum = $ligne2["tcount"];
        $data['rows'][] = array('id' => $ligne['ID'], 'cell' => array("<span style='font-size:{$fontsize}px;font-weight:bold;color:{$color}'>{$fw_items}</span>", "<span style='font-size:{$fontsize}px;font-weight:normal;color:{$color}'>{$delete}</span>"));
    }
    echo json_encode($data);
}