Example #1
0
function search_store()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_storelogs();
    if ($q->MySQLSyslogType == 3) {
        json_error_show($tpl->javascript_parse_text("{syslog_used_nas_storage}"), 1);
    }
    $search = '%';
    $table = "files_info";
    $page = 1;
    $ORDER = "ORDER BY ID DESC";
    $sock = new sockets();
    $t = $_GET["t"];
    if (!$q->TABLE_EXISTS($table)) {
        $q->CheckTables();
    }
    $database = "files_store";
    $total = 0;
    if ($q->COUNT_ROWS($table, $database) == 0) {
        json_error_show("No data...");
    }
    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 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM `{$table}` WHERE 1";
        $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}` WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    $BackupSquidLogsUseNas = $sock->GET_INFO("BackupSquidLogsUseNas");
    if (!is_numeric($BackupSquidLogsUseNas)) {
        $BackupSquidLogsUseNas = 0;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $events = " ";
        $md5 = md5("RotateTask{$ligne['filename']}");
        $span = "<span style='font-size:16px'>";
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ID']}", "StorageTaskDelete('{$ligne['filename']}','{$md5}')");
        $jsEdit = "Loadjs('{$MyPage}?Rotate-js=yes&ID={$ligne['taskid']}&t={$t}');";
        $jstask = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jsEdit}\"\n\t\t style='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $jslloop = "Loadjs('{$MyPage}?log-js=yes&filename={$ligne['filename']}&t={$t}&storeid={$ligne["storeid"]}');";
        $view = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jslloop}\"\n\t\t style='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $ligne["filesize"] = FormatBytes($ligne["filesize"] / 1024);
        if ($ligne['taskid'] == 0) {
            $jstask = null;
        }
        $action = null;
        if (preg_match("#auth\\.log-.*?#", $ligne["filename"])) {
            $action = imgsimple("service-restart-32.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}')");
        }
        if ($BackupSquidLogsUseNas == 1) {
            $action = imgsimple("backup-tool-32.png", null, "Loadjs('{$MyPage}?backup-to-nas-js=yes&filename={$ligne['filename']}&t={$t}&storeid={$ligne["storeid"]}')");
        }
        //rowSquidTask
        $data['rows'][] = array('id' => $md5, 'cell' => array("{$span}{$ligne['filetime']}</a></span>", "{$span}{$view}{$ligne["hostname"]}</a></span>", "{$span}{$view}{$ligne["filename"]}</a></span>", "{$span}{$ligne["filesize"]}</a></span>", "{$span}{$jstask}{$ligne["taskid"]}</a></span>", $action, $delete));
    }
    echo json_encode($data);
}
function search_database()
{
    $page = 1;
    $MyPage = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_storelogs();
    if (!$q->BD_CONNECT()) {
        senderror($q->mysql_error);
    }
    if ($q->start_error != null) {
        senderror($q->start_error);
    }
    $table = "files_info";
    $tableOrg = $table;
    $database = $q->database;
    $t = time();
    $delete_alert = $tpl->javascript_parse_text("{delete_this_item}");
    $MySQLType = $tpl->_ENGINE_parse_body($q->MYSQLTypeText);
    //if(!$q->TABLE_EXISTS($table,$database)==0){senderror("{table_does_not_exists}: <strong>$database/$table</strong> $MySQLType: `$q->SocketName`!");}
    if ($q->COUNT_ROWS($table, $database) == 0) {
        senderror("{$table}/{$database} is empty");
    }
    $searchstring = string_to_flexquery("search-database");
    $limit = "LIMIT 0,250";
    if (is_numeric($_GET["xtime"])) {
        $WHERE1 = " (DATE_FORMAT(filetime,'%Y-%m-%d')='" . date("Y-m-d") . "') AND";
        unset($_SESSION["QUERY_SYSLOG_DATE"]);
    }
    if ($_SESSION["QUERY_SYSLOG_LIMIT"] > 0) {
        $limit = "LIMIT 0,{$_SESSION["QUERY_SYSLOG_LIMIT"]}";
    }
    $filters = array();
    $filters[] = SearchToSql("DATE_FORMAT(filetime,'%Y-%m-%d')", $_SESSION["QUERY_SYSLOG_DATE"]);
    $filters[] = SearchToSql("filename", $_SESSION["QUERY_SYSLOG_FILE"]);
    $filters[] = SearchToSql("hostname", $_SESSION["QUERY_SYSLOG_HOST"]);
    $table = "(SELECT `filename`,`taskid`,`storeid`,`filesize`,`filetime`,`hostname` FROM {$table}\n\t\t\tWHERE {$WHERE1} (`filename` LIKE 'auth.log%') OR (filename LIKE 'squid-access%')) as t";
    $sql = "SELECT *  FROM {$table} WHERE 1 {$searchstring} " . @implode(" ", $filters) . " ORDER BY `filetime` DESC LIMIT 0,250";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        senderror("{$q->mysql_error}");
    }
    if (mysql_num_rows($results) == 0) {
        senderror("Query return empty array");
    }
    $boot = new boostrap_form();
    while ($ligne = mysql_fetch_assoc($results)) {
        $md5S = md5(serialize($ligne));
        $filename = $ligne["filename"];
        $hostname = $ligne["hostname"];
        $storeid = $ligne["storeid"];
        $taskid = $ligne["taskid"];
        $filesize = FormatBytes($ligne["filesize"] / 1024);
        $filetime = $ligne["filetime"];
        $delete = imgsimple("delete-32.png", null, "Delete{$t}('{$storeid}','{$md5S}')");
        $action = "&nbsp;";
        if (preg_match("#auth\\.log-.*?#", $ligne["filename"])) {
            $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')");
        }
        if (preg_match("#squid-access-(.*?)\\.log\\.#", $ligne["filename"])) {
            $action = imgsimple("32-import.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}&storeid={$storeid}')");
        }
        $download = "<a href=\"{$MyPage}?download={$storeid}&filename={$ligne["filename"]}&storeid={$storeid}\"><img src='img/arrow-down-32.png'></a>";
        $js = "Loadjs('logrotate.php?log-js=yes&filename={$filename}&storeid={$storeid}&t=1368560783');";
        $trlink = $boot->trswitch($js);
        $tr[] = "\n\t\t<tr id='{$md5S}'>\n\t\t<td nowrap {$trlink}>{$filetime}</td>\n\t\t<td nowrap {$trlink}>{$filename}</td>\n\t\t<td nowrap {$trlink}>{$hostname}</td>\n\t\t<td nowrap {$trlink}>{$filesize}</td>\n\t\t<td width=1% align=center>{$download}</td>\n\t\t<td width=1% align=center>{$action}</td>\n\t\t<td width=1% align=center>{$delete}</td>\n\t\t</tr>\n\t\t";
    }
    echo $tpl->_ENGINE_parse_body("\n\n\t\t\t<table class='table table-bordered table-hover'>\n\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>{filename}</th>\n\t\t\t\t\t<th>{hostname}</th>\n\t\t\t\t\t<th>{size}</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t\t<th>&nbsp;</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("", $tr) . "</tbody></table>\n\t\t\t<script>\n\t\t\tvar memedb{$t}='';\n\t\t\tvar xDelete{$t}= function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif(results.length>2){alert(results);return;}\n\t\t\t\$('#'+memedb{$t}).remove();\n}\n\n\t\t\tfunction Delete{$t}(ID,md){\n\t\t\tmemedb{$t}=md;\n\t\t\tif(confirm('{$delete_alert} '+ID+' ?')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('syslog-delete',ID);\n\t\t\tXHR.sendAndLoad('{$MyPage}', 'POST', xDelete{$t});\n}\n}\n\t\t\t</script>";
}
function members_list()
{
    $page = 1;
    $MyPage = CurrentPageName();
    $users = new usersMenus();
    $tpl = new templates();
    $sock = new sockets();
    $q = new mysql_storelogs();
    $table = "user";
    $tableOrg = $table;
    $database = "mysql";
    $delete_alert = $tpl->javascript_parse_text("{delete}");
    $FORCE_FILTER = 1;
    $t = $_GET["t"];
    if (!is_numeric($t)) {
        $t = time();
    }
    if ($q->COUNT_ROWS($table, $database) == 0) {
        senderror("{$table}/{$database} is empty");
    }
    $searchstring = string_to_flexquery("search-members");
    $sql = "SELECT *  FROM `{$table}` WHERE  {$FORCE_FILTER} {$searchstring} ORDER BY `User`";
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $results = $q->QUERY_SQL($sql, $database);
    if (!$q->ok) {
        senderror("{$q->mysql_error}");
    }
    if (mysql_num_rows($results) == 0) {
        senderror("Query return empty array, {$sql}");
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $password = $ligne["Password"];
        $array = array("host" => $ligne["Host"], "user" => $ligne["User"]);
        $databaseText = null;
        if ($ligne["Host"] != "%") {
            if ($ligne["Host"] != "localhost") {
                if (!preg_match("#^[0-9\\%]+\\.[0-9\\%]+\\.[0-9\\%]+#", $ligne["Host"])) {
                }
            }
        }
        $ligne["Host"] = str_replace("%", "{all}", $ligne["Host"]);
        $md5S = md5("{$ligne["User"]}@{$ligne["Host"]}{$databaseText}");
        $delete = imgsimple("delete-32.png", "{delete}", "DeleteMysqlUser{$t}('" . base64_encode(serialize($array)) . "','{$ligne["User"]}@{$ligne["Host"]}','{$md5S}')");
        if ($ligne["User"] == "root") {
            $delete = null;
        }
        $js = "Loadjs('{$MyPage}?selectDB-js=yes&host={$ligne["Host"]}&user={$ligne["User"]}&instance-id={$_GET["instance-id"]}&t={$t}')";
        $tr[] = "\n\t\t\t<tr class='{$class}' id='{$md5S}'>\n\t\t\t<td nowrap>{$ligne["User"]}@{$ligne["Host"]}</td>\n\t\t\t<td width=95% align=center>{$delete}</td>\n\t\t\t</tr>\n\t\t\t";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<table class='table table-bordered'>\n\t\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th width=99%>{members}</th>\n\t\t\t\t\t<th width=1% align=center>&nbsp;</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>\n\t\t\n\t\t\t</table>\n\t\t\t<script>\nvar memedb{$t}='';\t\t\t\nvar x_DeleteMysqlUser= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>2){alert(results);return;}\n\t\$('#'+memedb{$t}).remove();\n}\t\t\n\t\nfunction DeleteMysqlUser{$t}(arra,user,md){\n\tmemedb{$t}=md;\n\tif(confirm('{$delete_alert} '+user+' ?')){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('members-delete',arra);\n\t\tXHR.sendAndLoad('{$MyPage}', 'POST',x_DeleteMysqlUser);\n\t}\n}\n</script>\n";
}
function squid_status_stats()
{
    $off = "<script>UnlockPage();</script>";
    if (!$GLOBALS["AS_ROOT"]) {
        $cachefile = "/usr/share/artica-postfix/ressources/logs/web/traffic.statistics.html";
        if (is_file($cachefile)) {
            $tpl = new templates();
            $cacheContent = @file_get_contents($cachefile);
            if (strlen($cacheContent) > 20) {
                echo $tpl->_ENGINE_parse_body(@file_get_contents($cachefile)) . $off;
                return;
            }
        }
    }
    if (CACHE_SESSION_GET(__FUNCTION__, __FILE__)) {
        return;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Loading classes<br>\n";
    }
    $sock = new sockets();
    $users = new usersMenus();
    $EnableRemoteStatisticsAppliance = $sock->GET_INFO("EnableRemoteStatisticsAppliance");
    $SquidActHasReverse = $sock->GET_INFO("SquidActHasReverse");
    if (!is_numeric($SquidActHasReverse)) {
        $SquidActHasReverse = 0;
    }
    if ($EnableRemoteStatisticsAppliance == 1) {
        return;
    }
    $DisableArticaProxyStatistics = $sock->GET_INFO("DisableArticaProxyStatistics");
    if (!is_numeric($DisableArticaProxyStatistics)) {
        $DisableArticaProxyStatistics = 0;
    }
    $MalwarePatrolDatabasesCount = $sock->getFrameWork("cmd.php?MalwarePatrolDatabasesCount=yes");
    $mouse = "OnMouseOver=\";this.style.cursor='pointer';\" OnMouseOut=\";this.style.cursor='default';\"";
    $EnableMacAddressFilter = $sock->GET_INFO("EnableMacAddressFilter");
    if (!is_numeric($EnableMacAddressFilter)) {
        $EnableMacAddressFilter = 1;
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Loading mysql_storelogs()<br>\n";
    }
    $syslogs = new mysql_storelogs();
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " Count accesslogs<br>\n";
    }
    $SyslogsFiles = $syslogs->COUNT_ROWS("accesslogs");
    $TR_ACCESSLOG = "\n\t<tr>\n\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' \n\t\tOnClick=\"javascript:Loadjs('squid.accesses.rotate.php')\"><b><span style='font-size:12px'>{$SyslogsFiles}</span></b><span style='font-size:12px'> {access_logs}</td>\n\t</tr>";
    $page = CurrentPageName();
    $tpl = new templates();
    $q = new mysql_squid_builder();
    if ($users->PROXYTINY_APPLIANCE) {
        $DisableArticaProxyStatistics = 1;
    }
    if ($DisableArticaProxyStatistics == 0) {
        $websitesnums = $q->COUNT_ROWS("visited_sites");
        $websitesnums = numberFormat($websitesnums, 0, "", " ");
        $sql = "DELETE FROM categorize WHERE LENGTH(pattern)=0";
        $q->QUERY_SQL($sql);
        $export = $q->COUNT_ROWS("categorize");
        $export = numberFormat($export, 0, "", " ");
    }
    $catz = new mysql_catz();
    $categories = $catz->COUNT_CATEGORIES();
    $categories = numberFormat($categories, 0, "", " ");
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " categories= {$categories}<br>\n";
    }
    $YourItems = $q->COUNT_CATEGORIES();
    $YourItems = numberFormat($YourItems, 0, "", " ");
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " LIST_TABLES_CATEGORIES()<br>\n";
    }
    $tablescat = $q->LIST_TABLES_CATEGORIES();
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " tablescat={$tablescat}<br>\n";
    }
    $tablescatNUM = numberFormat(count($tablescat), 0, "", " ");
    if ($DisableArticaProxyStatistics == 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " EVENTS_SUM()<br>\n";
        }
        $requests = $q->EVENTS_SUM();
        $requests = numberFormat($requests, 0, "", " ");
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " requests = {$requests}<br>\n";
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " no_license -> translate<br>\n";
    }
    $nolicense = $tpl->_ENGINE_parse_body("{no_license}");
    $PhishingURIS = $q->COUNT_ROWS("categoryuris_phishing");
    $PhishingURIS = numberFormat($PhishingURIS, 0, "", " ");
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " >COUNT_ROWS('categoryuris_malware')<br>\n";
    }
    $MalwaresURIS = $q->COUNT_ROWS("categoryuris_malware");
    $MalwaresURIS = numberFormat($MalwaresURIS, 0, "", " ");
    if (!$users->CORP_LICENSE) {
        $PhishingURIS = $nolicense;
        $MalwaresURIS = $nolicense;
    }
    if ($DisableArticaProxyStatistics == 0) {
        if ($EnableMacAddressFilter == 1) {
            $Computers = $q->COUNT_ROWS("webfilters_nodes");
            $Computers = numberFormat($Computers, 0, "", " ");
            $nodes = "\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.nodes.php',true)\"><b><span style='font-size:12px'>{$Computers}</span></b><span style='font-size:12px'> {computers}</td>\n\t\t\t</tr>";
        } else {
            $Computers = $q->COUNT_ROWS("UserAutDB");
            $Computers = numberFormat($Computers, 0, "", " ");
            $nodes = "\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.UserAutDB.php')\"><b><span style='font-size:12px'>{$Computers}</span></b><span style='font-size:12px'> {clients}</td>\n\t\t\t</tr>";
        }
        if (!$users->CORP_LICENSE) {
            $license_inactive = "<br><strong style='font-size:11px;font-weight:bolder;color:#BA1010'>{license_inactive}</strong>";
        }
        if (!$q->TABLE_EXISTS("tables_day")) {
            $q->CheckTables();
        }
        $DAYSNumbers = $q->COUNT_ROWS("tables_day");
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " DAYSNumbers = {$DAYSNumbers}<br>\n";
        }
        //$GLOBALS["FULL_DEBUG"]
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT SUM(totalsize) as tsize FROM tables_day"));
        $totalsize = FormatBytes($ligne["tsize"] / 1024);
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT AVG(cache_perfs) as pourc FROM tables_day"));
        $pref = round($ligne["pourc"]);
        $ligne = mysql_fetch_array($q->QUERY_SQL("SELECT COUNT(sitename) as tcount FROM visited_sites WHERE LENGTH(category)=0"));
        $websitesnumsNot = numberFormat($ligne["tcount"], 0, "", " ");
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " SELECT count(youtubeid),youtubeid FROM `youtube_dayz` GROUP BY youtubeid<br>\n";
        }
        $results = $q->QUERY_SQL("SELECT count(youtubeid),youtubeid FROM `youtube_dayz` GROUP BY youtubeid");
        $youtube_objects = mysql_num_rows($results);
        $youtube_objects = numberFormat($youtube_objects, 0, "", " ");
        $CachePermformance = $q->CachePerfHour();
        if ($GLOBALS["VERBOSE"]) {
            echo __LINE__ . " CachePermformance = {$CachePermformance}<br>\n";
        }
        if ($CachePermformance > -1) {
            $color = "#E01313";
            if ($CachePermformance > 20) {
                $color = "#6DBB6A";
            }
            $cachePerfText = "\n\t\t\t<tr>\n\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t<td valign='top' style='font-size:12px;'><b style='color:{$color}'>{$CachePermformance}%</span></b><span style='font-size:12px'> {cache_performance} ({now})</td>\n\t\t\t</tr>\n\t\t\t";
        }
        if ($SquidActHasReverse == 1) {
            $TR_CAT_NUMBER = null;
        }
        $TR_CAT_NUMBER = "\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><b><span style='font-size:12px'>{$categories}</span></b><span style='font-size:12px'> {websites_categorized}{$license_inactive}</td>\n\t</tr>\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><span style='font-size:12px'>{youritems}: <b>{$YourItems}</span></b><span style='font-size:12px'></td>\n\t</tr>";
        $TR_CATZ = "\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td width=99% valign='top' style='font-size:12px;text-decoration:underline' \n\t\t{$mouse} OnClick=\"javascript:Loadjs('squid.traffic.statistics.days.php?js=yes&with-purge=yes')\"><b><span style='font-size:12px'>{$DAYSNumbers}</span></b><span style='font-size:12px'> {daysOfStatistics}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$requests}</span></b><span style='font-size:12px'> {requests}</td>\n\t</tr>\n\t{$nodes}\n\t\t\n\t{$TR_CAT_NUMBER}\n";
        $TR_YOUTUBE = "\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline'\n\t\t{$mouse} OnClick=\"javascript:Loadjs('squid.youtube.all.php')\"\n\t\t><b><span style='font-size:12px'>{$youtube_objects}</span></b><span style='font-size:12px'> Youtube {objects}</td>\n\t</tr>";
        if ($DisableArticaProxyStatistics == 1) {
            $TR_YOUTUBE = null;
            $TR_CATZ = null;
        }
        if ($SquidActHasReverse == 1) {
            $TR_YOUTUBE = null;
        }
        $submenu = "\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$totalsize}</span></b><span style='font-size:12px'> {downloaded_flow}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' style='font-size:12px'><b><span style='font-size:12px'>{$pref}%</span></b><span style='font-size:12px'> {cache_performance}</td>\n\t</tr>\n\t\n\t{$cachePerfText}";
        $main_table = "\n\t\t\n\t\t{$TR_CATZ}\n\t\t{$TR_YOUTUBE}\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$PhishingURIS}</span></b><span style='font-size:12px'> {phishing_uris}</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwaresURIS}</span></b><span style='font-size:12px'> {viruses_uris}</td>\n\t</tr>\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwarePatrolDatabasesCount}</span></b><span style='font-size:12px'> Malware Patrol</td>\n\t</tr>\t\n\t\t\t\t\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.visited.php?onlyNot=yes')\"><b><span style='font-size:12px'>{$websitesnumsNot}</span></b><span style='font-size:12px'> {not_categorized}</td>\n\t</tr>\t\n\t\t\t\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.php')\"><b><span style='font-size:12px'>{$tablescatNUM}</span></b><span style='font-size:12px'> {categories}</td>\n\t</tr>\t\n\t\n\t<tr>\n\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"javascript:Loadjs('squid.categories.toexport.php')\"><b><span style='font-size:12px'>{$export}</span></b><span style='font-size:12px'> {websites_to_export}</td>\n\t</tr>";
    }
    if ($DisableArticaProxyStatistics == 1) {
        $main_table = "\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$PhishingURIS}</span></b><span style='font-size:12px'> {phishing_uris}</td>\n\t\t\t</tr>\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwaresURIS}</span></b><span style='font-size:12px'> {viruses_uris}</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td width=1%><img src='img/arrow-right-16.png'></td>\n\t\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' OnClick=\"blur()\"><b><span style='font-size:12px'>{$MalwarePatrolDatabasesCount}</span></b><span style='font-size:12px'> Malware Patrol</td>\n\t\t\t</tr>";
    }
    $addwebsites = "\n\t\t<tr>\n\t\t\t<td width=1%><img src='img/plus-16.png'></td>\n\t\t\t<td valign='top' {$mouse} style='font-size:12px;text-decoration:underline' \n\t\t\tOnClick=\"javascript:Loadjs('squid.visited.php?add-www=yes')\"><b><span style='font-size:12px'>{categorize_websites}</span></b><span style='font-size:12px'></td>\n\t\t</tr>\t";
    if ($users->PROXYTINY_APPLIANCE) {
        $addwebsites = null;
        $submenu = null;
    }
    $html = "\n<table style='width:100%'>\n\t<tbody>\n\t{$TR_ACCESSLOG}\n\t{$main_table}\t\n\t{$submenu}\n\t{$addwebsites}\n\t</tbody>\n\t</table>\n{$off}";
    if ($GLOBALS["VERBOSE"]) {
        echo __LINE__ . " tpl->_ENGINE_parse_body<br>\n";
    }
    $html = $tpl->_ENGINE_parse_body($html);
    if (!$GLOBALS["AS_ROOT"]) {
        CACHE_SESSION_SET(__FUNCTION__, __FILE__, $html);
    }
}
function search_store()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $q = new mysql_storelogs();
    $search = '%';
    $table = "accesslogs";
    $page = 1;
    $ORDER = "ORDER BY ID DESC";
    $sock = new sockets();
    $t = $_GET["t"];
    if (!$q->TABLE_EXISTS($table)) {
        $q->CheckTables();
    }
    $total = 0;
    if ($q->COUNT_ROWS($table) == 0) {
        json_error_show("No data...");
    }
    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 {$searchstring}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql, $database));
        $total = $ligne["TCOUNT"];
    } else {
        $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}";
        $ligne = mysql_fetch_array($q->QUERY_SQL($sql));
        $total = $ligne["TCOUNT"];
    }
    if (isset($_POST['rp'])) {
        $rp = $_POST['rp'];
    }
    $pageStart = ($page - 1) * $rp;
    $limitSql = "LIMIT {$pageStart}, {$rp}";
    $sql = "SELECT `filename`,`storeid`,`filesize`,`filetime` FROM {$table} WHERE 1 {$searchstring} {$ORDER} {$limitSql}";
    $results = $q->QUERY_SQL($sql);
    writelogs($sql, __FUNCTION__, __FILE__, __LINE__);
    $data = array();
    $data['page'] = $page;
    $data['total'] = $total;
    $data['rows'] = array();
    if (!$q->ok) {
        json_error_show($q->mysql_error, 1);
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $color = "black";
        $events = "&nbsp;";
        $md5 = md5("RotateTask{$ligne['filename']}");
        $span = "<span style='font-size:16px'>";
        $delete = imgtootltip("delete-24.png", "{delete} {$ligne['ID']}", "StorageTaskDelete{$t}('{$ligne['ID']}','{$md5}')");
        $jslloop = "Loadjs('{$MyPage}?log-js=yes&storeid={$ligne['storeid']}&t={$t}&filename={$ligne["filename"]}');";
        $view = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$jslloop}\"\n\t\tstyle='font-size:16px;font-weight:bold;color:{$color};text-decoration:underline'>";
        $ligne["filesize"] = FormatBytes($ligne["filesize"] / 1024);
        if ($ligne['taskid'] == 0) {
            $jstask = null;
        }
        $action = null;
        $action = imgsimple("service-restart-32.png", null, "Loadjs('squid.restoreSource.php?filename={$ligne["filename"]}')");
        $xtime = strtotime("{$ligne['filetime']}");
        $dateTex = date("Y {l} {F} d", $xtime);
        if ($tpl->language == "fr") {
            $dateTex = date("{l} d {F} Y", $xtime);
        }
        $dateTex = $tpl->_ENGINE_parse_body("{$dateTex}");
        $hostname = $ligne["hostname"];
        $data['rows'][] = array('id' => $md5, 'cell' => array("{$span}{$ligne['filetime']}</a></span><div style='font-size:11px'><i>{$dateTex}</i></div>", "{$span}{$view}{$ligne["filename"]}</a><div style='font-size:11px'><i>{$hostname}</i></div></span>", "{$span}{$ligne["filesize"]}</a></span>", $delete));
    }
    echo json_encode($data);
}