Пример #1
0
function table()
{
    include_once dirname(__FILE__) . "/ressources/class.squid.accesslogs.inc";
    $_GET["query"] = url_decode_special_tool($_GET["query"]);
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    if (!isset($_GET["rp"])) {
        $_GET["rp"] = 150;
    }
    if ($_GET["query-logs"] != null) {
        $search = base64_encode($_GET["query-logs"]);
        $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?accesslogs={$search}&rp={$_GET["rp"]}")));
        $total = count($datas);
    } else {
        $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?accesslogs=&rp={$_GET["rp"]}")));
        $total = count($datas);
    }
    $squidacc = new accesslogs();
    $c = 0;
    while (list($key, $line) = each($datas)) {
        $line = trim($line);
        $lineS = $line;
        $color = "black";
        $return_code_text = null;
        $ff = array();
        $color = "black";
        if (preg_match('#(.+?)\\s+(.+?)\\s+squid\\[.+?:\\s+MAC:(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+\\[(.+?)\\]\\s+\\"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#i', $line, $re)) {
            $re[6] = trim($re[6]);
            if ($re[5] == "-") {
                if ($re[6] != "-" && !is_null($re[6])) {
                    $re[5] = $re[6];
                    $re[6] = "-";
                }
            }
            //$ff[]="F=1";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $uri = $re[9];
            $date = date("Y-m-d H:i:s", strtotime($re[7]));
            $mac = $re[3];
            $ip = $re[4];
            $user = $re[5];
            $dom = $re[6];
            $proto = $re[8];
            $return_code = $re[10];
            $size = $re[11];
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $data['rows'][] = $squidacc->Buildline($array, true);
            continue;
        }
        if (preg_match('#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+.*?\\s+MAC:(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+\\[(.+?)\\]\\s+\\"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#', $line, $re)) {
            $time = $re[3];
            $prox = $re[4];
            $mac = $re[5];
            $date = date("Y-m-d H:i:s", strtotime($re[9]));
            $ip = $re[6];
            $user = $re[8];
            $proto = $re[10];
            $return_code = $re[12];
            $size = $re[13];
            $uri = $re[11];
            //$ff[]="F=2";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $array["PROXY"] = $prox;
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $data['rows'][] = $squidacc->Buildline($array, true);
            continue;
        }
        if (preg_match('#(.*?)\\s+([0-9]+)\\s+([0-9:]+).*?\\]:\\s+(.*?)\\s+(.+)\\s+(.+)\\s+.+?"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#', $line, $re)) {
            if (preg_match("#(TCP_DENIED|ERR_CONNECT_FAIL)#", $line)) {
                $color = "#BA0000";
            }
            $dates = "{$re[1]} {$re[2]} " . date('Y') . " {$re[3]}";
            $ip = $re[4];
            $user = $re[5];
            $re[6] = trim($re[6]);
            if ($re[5] == "-") {
                if ($re[6] != "-" && !is_null($re[6])) {
                    $re[5] = $re[6];
                    $re[6] = "-";
                }
            }
            //$ff[]="F=3";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $date = date("Y-m-d H:i:s", strtotime($dates));
            $uri = $re[8];
            $proto = $re[7];
            $return_code = $re[8];
            $size = $re[9];
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $data['rows'][] = $squidacc->Buildline($array, true);
            continue;
        }
    }
    $tr[] = @implode($data['rows'], "\n");
    echo $tpl->_ENGINE_parse_body("<table class='table table-bordered'>\n\t\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{date}</th>\n\t\t\t\t\t<th>{proto}</th>\n\t\t\t\t\t<th>{urls} ({$total})</th>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody></table>";
}
Пример #2
0
function events_search()
{
    $page = CurrentPageName();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_squid_builder();
    $GLOBALS["Q"] = $q;
    if (isset($_POST['page'])) {
        $page = $_POST['page'];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    if ($_POST["query"] != null) {
        $search = base64_encode($_POST["query"]);
        $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?accesslogs={$search}&rp={$_POST["rp"]}")));
        $total = count($datas);
    } else {
        $datas = unserialize(base64_decode($sock->getFrameWork("squid.php?accesslogs=&rp={$_POST["rp"]}")));
        $total = count($datas);
    }
    $pageStart = ($page - 1) * $rp;
    if (isset($_POST["sortname"])) {
        if ($_POST["sortname"] != null) {
            if ($_POST["sortname"] == "zDate") {
                if ($_POST["sortorder"] == "asc") {
                    krsort($datas);
                }
            }
            $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}";
        }
    }
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    $today = date("Y-m-d");
    $squidacc = new accesslogs();
    $squidacc->stats = false;
    $c = 0;
    while (list($key, $line) = each($datas)) {
        $color = "black";
        $return_code_text = null;
        $ff = array();
        $color = "black";
        if (preg_match('#(.+?)\\s+(.+?)\\s+squid\\[.+?:\\s+MAC:(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+\\[(.+?)\\]\\s+\\"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#i', $line, $re)) {
            $re[6] = trim($re[6]);
            if ($re[5] == "-") {
                if ($re[6] != "-" && !is_null($re[6])) {
                    $re[5] = $re[6];
                    $re[6] = "-";
                }
            }
            //$ff[]="F=1";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $uri = $re[9];
            $date = date("Y-m-d H:i:s", strtotime($re[7]));
            $mac = $re[3];
            $ip = $re[4];
            $user = $re[5];
            $dom = $re[6];
            $proto = $re[8];
            $return_code = $re[10];
            $size = $re[11];
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $mline = $squidacc->Buildline($array);
            if (is_array($mline)) {
                $data['rows'][] = $mline;
                $c++;
            }
            continue;
        }
        if (preg_match('#(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+.*?\\s+MAC:(.+?)\\s+(.+?)\\s+(.+?)\\s+(.+?)\\s+\\[(.+?)\\]\\s+\\"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#', $line, $re)) {
            $time = $re[3];
            $prox = $re[4];
            $mac = $re[5];
            $date = date("Y-m-d H:i:s", strtotime($re[9]));
            $ip = $re[6];
            $user = $re[8];
            $proto = $re[10];
            $return_code = $re[12];
            $size = $re[13];
            $uri = $re[11];
            //$ff[]="F=2";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $array["PROXY"] = $prox;
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $mline = $squidacc->Buildline($array);
            if (is_array($mline)) {
                $data['rows'][] = $mline;
                $c++;
            }
            continue;
        }
        if (preg_match('#(.*?)\\s+([0-9]+)\\s+([0-9:]+).*?\\]:\\s+(.*?)\\s+(.+)\\s+(.+)\\s+.+?"([A-Z]+)\\s+(.+?)\\s+.*?"\\s+([0-9]+)\\s+([0-9]+)#', $line, $re)) {
            if (preg_match("#(TCP_DENIED|ERR_CONNECT_FAIL)#", $line)) {
                $color = "#BA0000";
            }
            $dates = "{$re[1]} {$re[2]} " . date('Y') . " {$re[3]}";
            $ip = $re[4];
            $user = $re[5];
            $re[6] = trim($re[6]);
            if ($re[5] == "-") {
                if ($re[6] != "-" && !is_null($re[6])) {
                    $re[5] = $re[6];
                    $re[6] = "-";
                }
            }
            //$ff[]="F=3";
            //while (list ($a, $b) = each ($re) ){$ff[]="$a=$b";}
            //$array["RE"]=@implode("<br>", $ff);
            $date = date("Y-m-d H:i:s", strtotime($dates));
            $uri = $re[8];
            $proto = $re[7];
            $return_code = $re[8];
            $size = $re[9];
            $array["IP"] = $ip;
            $array["URI"] = $uri;
            $array["DATE"] = $date;
            $array["MAC"] = $mac;
            $array["USER"] = $user;
            $array["USER"] = $user;
            $array["PROTO"] = $proto;
            $array["CODE"] = $return_code;
            $array["SIZE"] = $size;
            $array["LINE"] = $line;
            $mline = $squidacc->Buildline($array);
            if (is_array($mline)) {
                $data['rows'][] = $mline;
                $c++;
            }
            continue;
        }
        writelogs("Not Filtered: {$line}", __FUNCTION__, __FILE__, __LINE__);
    }
    $data['total'] = $c;
    echo json_encode($data);
}