예제 #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);
}
예제 #2
0
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);
}