示例#1
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);
}