Exemplo n.º 1
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $squid = new mysql_squid_builder();
    $total = 0;
    $pattern = base64_encode($_GET["search"]);
    $sock = new sockets();
    $removeService = false;
    $output = "/usr/share/artica-postfix/ressources/logs/web/nginx.query";
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $StatusCodes = $squid->LoadStatusCodes();
    $search = base64_encode($_POST["query"]);
    $sock->getFrameWork("nginx.php?access-query={$search}&rp={$_POST["rp"]}");
    $array = explode("\n", @file_get_contents($output));
    $total = count($array);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if ($_POST["sortname"] != null) {
        if ($_POST["sortorder"] == "desc") {
            krsort($array);
        } else {
            ksort($array);
        }
    }
    $today = $tpl->_ENGINE_parse_body("{today}");
    $c = 0;
    if ($GLOBALS["VERBOSE"]) {
        echo "<H1>Array of " . count($array) . " Lines</H1>\n";
    }
    $style = "<span style='font-size:16px'>";
    $styleoff = "</span>";
    while (list($key, $line) = each($array)) {
        $lines = array();
        $line = trim($line);
        $style = "<span style='font-size:16px;color:black'>";
        if ($line == null) {
            continue;
        }
        if (!preg_match('#ngx\\[(.*?)\\]\\s+(.+?)\\s+(.+?)\\s+(.*?)\\s+\\[(.+?)\\]\\s+([A-Z]+)\\s+(.+?)\\s+[A-Z]+\\/[0-9\\.]+\\s+"([0-9]+)"\\s+([0-9]+)#', $line, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$line} NO MATCHS<br>";
            }
        }
        $sitename = $re[1];
        $clientip = $re[2];
        $X_FORWARDED = $re[3];
        $time = strtotime($re[5]);
        $PROTO = $re[6];
        $uri = $re[7];
        $HTTP_CODE = $re[8];
        $size = $re[9];
        if (date("Y-m-d", $time) == date("Y-m-d")) {
            $zdate = date("H:i:s");
        } else {
            $zdate = date("Y-m-d H:i:s");
        }
        $uri = str_replace("HTTP/1.1", "", $uri);
        $uri = str_replace("HTTP/1.0", "", $uri);
        $size = FormatBytes($size / 1024);
        if ($HTTP_CODE > 399) {
            $style = "<span style='font-size:16px;color:d32d2d'>";
        }
        $lines[] = "{$style}{$zdate}{$styleoff}";
        $lines[] = "{$style}{$sitename}{$styleoff}";
        $lines[] = "{$style}{$clientip}{$styleoff}";
        $lines[] = "{$style}{$StatusCodes[$HTTP_CODE]} - {$size}{$styleoff}";
        $lines[] = "{$style}{$uri}{$styleoff}";
        $c++;
        $data['rows'][] = array('id' => md5($line), 'cell' => $lines);
    }
    if ($c == 0) {
        json_error_show("no data");
    }
    $data['total'] = $c;
    echo json_encode($data);
}
Exemplo n.º 2
0
function view_table()
{
    $q = new mysql_squid_builder();
    $Mypage = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $search = '%';
    $table = "squidtpls";
    $page = 1;
    $searchstring = null;
    if ($_GET["lang"] != null) {
        $FORCEQ = " AND lang='{$_GET["lang"]}'";
    }
    $choose_generic = $_GET["choose-generic"];
    if (!$q->FIELD_EXISTS($table, "template_time")) {
        $q->CheckTables();
    }
    if (!$q->TABLE_EXISTS($table)) {
        json_error_show("{$table} no such table", 2);
    }
    if ($q->COUNT_ROWS($table) == 0) {
        json_error_show("No data in {$table}", 2);
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if ($_POST["query"] != null) {
        $_POST["query"] = str_replace("*", "%", $_POST["query"]);
        $search = $_POST["query"];
        $searchstring = "AND (`{$_POST["qtype"]}` LIKE '{$search}')";
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1 {$FORCEQ}{$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}<hr>{$sql}", 2);
        }
        $total = $ligne["TCOUNT"];
    } else {
        $total = $q->COUNT_ROWS($table);
        if (!$q->ok) {
            json_error_show("{$q->mysql_error}", 2);
        }
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $data = array();
    $data['rows'] = array();
    $delete_icon = "delete-24.png";
    $fontsize = 12;
    if (isset($_GET["viatabs"])) {
        $fontsize = 14;
        $delete_icon = "delete-32.png";
    }
    $span = "<span style='font-size:{$fontsize}px'>";
    $EnableSplashScreen = $sock->GET_INFO("EnableSplashScreen");
    $EnableSplashScreenAsObject = $sock->GET_INFO("EnableSplashScreenAsObject");
    if (!is_numeric($EnableSplashScreen)) {
        $EnableSplashScreen = 0;
    }
    if (!is_numeric($EnableSplashScreenAsObject)) {
        $EnableSplashScreenAsObject = 0;
    }
    $SplashScreenURI = $sock->GET_INFO("SplashScreenURI");
    if (trim($SplashScreenURI) == null) {
        $EnableSplashScreen = 0;
    }
    $URLAR = parse_url($SplashScreenURI);
    if (isset($URLAR["host"])) {
        $SplashScreenURI = "http://{$SplashScreenURI}";
    }
    if (!preg_match("^http.*", $SplashScreenURI)) {
        $SplashScreenURI = "http://{$SplashScreenURI}";
    }
    if ($searchstring == null) {
        if ($EnableSplashScreen == 1) {
            if ($EnableSplashScreenAsObject == 1) {
                $linkZoom = null;
                $cell = array();
                $delete = "&nbsp;";
                $cell[] = $tpl->_ENGINE_parse_body("{all}</span>");
                $cell[] = "<span style='font-size:{$fontsize}px;font-weight:bold'>{$linkZoom}{$SplashScreenURI}</a></span>";
                $cell[] = $tpl->_ENGINE_parse_body("<span style='font-size:{$fontsize}px;fonct-weight:bold'>{$linkZoom}{hotspot_auth}</a></span>");
                $cell[] = "&nbsp;</span>";
                if ($_GET["choose-acl"] > 0) {
                    $cell[] = imgsimple("arrow-right-24.png", null, "ChooseAclsTplSquid('{$_GET["choose-acl"]}','ARTICA_SLASH_SCREEN')");
                }
                if (strlen($choose_generic) > 3) {
                    $cell[] = imgsimple("arrow-right-24.png", null, "ChooseGenericTemplate('ARTICA_SLASH_SCREEN')");
                }
                $cell[] = $delete;
                $data['rows'][] = array('id' => "SplashScreen", 'cell' => $cell);
                $total++;
            }
        }
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT *  FROM `{$table}` WHERE 1 {$FORCEQ}{$searchstring} {$ORDER} {$limitSql}";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data['page'] = $page;
    $data['total'] = $total;
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        json_error_show("{$q->mysql_error}", 2);
    }
    $statuscodes = $q->LoadStatusCodes();
    $empty_template = $tpl->_ENGINE_parse_body("{empty_template}");
    while ($ligne = mysql_fetch_assoc($results)) {
        $zmd5 = $ligne["zmd5"];
        $title = base64_encode($ligne["template_title"]);
        $linkZoom = "<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('{$Mypage}?Zoom-js={$ligne['zmd5']}&subject={$title}');\" style='font-size:{$fontsize}px;text-decoration:underline'>";
        if ($ligne["template_link"] == 1) {
            $ligne['lang'] = imgsimple("24-parameters.png", null, "NewTemplate('{$zmd5}')");
            if (preg_match("#^([0-9]+):(.+)#", $ligne["template_uri"], $ri)) {
                $ligne["template_uri"] = $ri[2];
                $ligne["template_uri"] = str_replace("%FREEWEBS%", "<div>+FreeWebs</div>", $ligne["template_uri"]);
                $ligne["template_uri"] = $ligne["template_uri"] . "<div>" . $statuscodes[$ri[1]] . "</div>";
            }
            $ligne["template_title"] = $ligne["template_uri"];
        }
        $cell = array();
        if ($ligne["template_title"] == null) {
            $ligne["template_title"] = $empty_template;
        }
        if ($ligne["emptytpl"] == 1) {
            $linkZoom = "<a href=\"javascript:blur()\" OnClick=\"javascript:Loadjs('{$Mypage}?template-settings-js=yes&zmd5={$ligne["zmd5"]}&t={$_GET["t"]}');\" style='font-size:{$fontsize}px;text-decoration:underline'>";
        }
        $ligne['template_name'] = utf8_encode($ligne['template_name']);
        $ligne['template_title'] = utf8_encode($ligne['template_title']);
        $delete = imgsimple($delete_icon, null, "TemplateDelete('{$ligne['zmd5']}')");
        $cell[] = "{$span}{$linkZoom}{$ligne['lang']}</a></span>";
        $cell[] = "{$span}{$linkZoom}{$ligne['template_name']}</a></span>";
        $cell[] = "{$span}{$linkZoom}{$ligne["template_title"]}</a></span>";
        $cell[] = "{$span}{$linkZoom}{$ligne["template_time"]}</a></span>";
        if ($_GET["choose-acl"] > 0) {
            $cell[] = imgsimple("arrow-right-24.png", null, "ChooseAclsTplSquid('{$_GET["choose-acl"]}','{$ligne['zmd5']}')");
        }
        if (strlen($choose_generic) > 3) {
            $cell[] = imgsimple("arrow-right-24.png", null, "ChooseGenericTemplate('{$ligne['template_name']}')");
        }
        $cell[] = $delete;
        $data['rows'][] = array('id' => $ligne['zmd5'], 'cell' => $cell);
    }
    echo json_encode($data);
}
Exemplo n.º 3
0
function search()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $squid = new mysql_squid_builder();
    $total = 0;
    $pattern = base64_encode($_GET["search"]);
    $sock = new sockets();
    $removeService = false;
    $output = "/usr/share/artica-postfix/ressources/logs/web/nginx.query.errors";
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    $StatusCodes = $squid->LoadStatusCodes();
    $search = base64_encode($_POST["query"]);
    $sock->getFrameWork("nginx.php?access-errors={$search}&rp={$_POST["rp"]}");
    $array = explode("\n", @file_get_contents($output));
    $total = count($array);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if ($_POST["sortname"] != null) {
        if ($_POST["sortorder"] == "desc") {
            krsort($array);
        } else {
            ksort($array);
        }
    }
    $today = $tpl->_ENGINE_parse_body("{today}");
    $c = 0;
    if ($GLOBALS["VERBOSE"]) {
        echo "<H1>Array of " . count($array) . " Lines</H1>\n";
    }
    $style = "<span style='font-size:16px'>";
    $styleoff = "</span>";
    while (list($key, $line) = each($array)) {
        $lines = array();
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        if (!preg_match("#(.+?)\\s+\\[(.+?)\\]\\s+(.+)#", $line, $re)) {
            continue;
        }
        $time = strtotime($re[1]);
        $service = $re[2];
        $line = $re[3];
        if (date("Y-m-d", $time) == date("Y-m-d")) {
            $zdate = date("H:i:s");
        } else {
            $zdate = date("Y-m-d H:i:s");
        }
        $lines[] = "{$style}{$zdate}{$styleoff}";
        $lines[] = "{$style}{$service}{$styleoff}";
        $lines[] = "{$style}{$line}{$styleoff}";
        $c++;
        $data['rows'][] = array('id' => md5($line), 'cell' => $lines);
    }
    if ($c == 0) {
        json_error_show("no data");
    }
    $data['total'] = $c;
    echo json_encode($data);
}