Ejemplo n.º 1
0
$where = join(" AND ", $where);
$offset = (int) $this->get_input('offset');
$query = "SELECT `latest`.`Timestamp`,\n                 `latest`.`QueryString`,\n                 `latest`.`ResultsCount`,\n                 `latest`.`IP`,\n                 `latest`.`User_ID`,\n                 `q`.`QueryCount`,\n                 `u`.`Login`\n            FROM (SELECT MAX(`Query_ID`) AS `Query_ID`,\n                         COUNT(`Query_ID`) AS `QueryCount`\n                    FROM `Search_Query`\n                   WHERE {$where}\n                   GROUP BY `QueryString`\n                   ORDER BY {$order_by}\n                   LIMIT {$per_page} OFFSET {$offset}) AS `q`\n            JOIN `Search_Query` AS `latest` ON (`q`.`Query_ID` = `latest`.`Query_ID`)\n            LEFT JOIN `User` AS `u` ON (`latest`.`User_ID` = `u`.`User_ID`)";
$res = $this->get_db()->get_results($query, ARRAY_A);
if ($res) {
    $found_rows = $this->get_db()->get_var("SELECT COUNT(DISTINCT(`QueryString`))\n                                              FROM `Search_Query`\n                                             WHERE {$where}");
    // строка с вариантами сортировки
    $sort_link = $this->make_page_query(array('sort_by'));
    echo '<div class="query_sort">', $this->link_if($sort_by != '', $sort_link, NETCAT_MODULE_SEARCH_ADMIN_QUERY_SORT_BY_RESULT_COUNT), " | ", $this->link_if($sort_by != 'time', "{$sort_link}&amp;sort_by=time", NETCAT_MODULE_SEARCH_ADMIN_QUERY_SORT_BY_TIME), " | ", $this->link_if($sort_by != 'query', "{$sort_link}&amp;sort_by=query", NETCAT_MODULE_SEARCH_ADMIN_QUERY_SORT_BY_QUERY), "</div>";
    // таблица с результатами
    echo "<table class='nc-table nc--large nc--hovered nc--striped list'>\n", "<tr>", "<th rowspan='2' width='40%'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_STRING, "</th>", "<th rowspan='2' width='10%' class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_COUNT, "</th>", "<th colspan='3' class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_LAST_QUERY, "</th>", "</tr>\n", "<tr>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_LAST_QUERY_TIME, "</th>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_LAST_QUERY_RESULT_COUNT, "</th>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_QUERY_LAST_QUERY_USER, "</th>", "</tr>\n";
    $result_link_title = "title='" . htmlspecialchars(NETCAT_MODULE_SEARCH_ADMIN_QUERY_OPEN_RESULTS_LINK_HINT) . "'";
    foreach ($res as $row) {
        // ссылка на страницу с результатами поиска
        $search_link = nc_search::get_object()->get_search_url($row['Catalogue_ID'], true) . "?nologging=1&amp;search_query=" . rawurlencode($row['QueryString']) . "&amp;area=" . rawurlencode($row['Area']);
        echo "<tr class='nc-text-center'>", "<td align='left'><a href='?view=queries_details&amp;query=", rawurlencode($row['QueryString']), "'>", htmlspecialchars($row['QueryString']), "</a></td>", "<td>", $row['QueryCount'], "</td>", "<td>", nc_search_util::format_time($row['Timestamp']), "</td>", "<td><a href='{$search_link}' target='_blank' {$result_link_title}>{$row['ResultsCount']}</a></td>", "<td>", long2ip($row['IP']), $row['User_ID'] ? " (" . $this->hash_link("#user.edit({$row['User_ID']})", $row["Login"]) . ")" : "", "</td>", "</tr>\n";
    }
    echo "</table>";
    echo $this->result_count($offset + 1, $per_page, $found_rows);
    // листалка по страницам
    $ui = $this->get_ui();
    $page_link = $this->make_page_query(array('offset'), true);
    if ($offset > 0) {
        $prev_page = $page_link . "&amp;offset=" . ($offset - $per_page);
        $ui->actionButtons[] = array("id" => "prev_page", "caption" => NETCAT_MODULE_SEARCH_ADMIN_QUERY_PREV_PAGE, "action" => "mainView.loadIframe('{$prev_page}')", "align" => "left");
    }
    if ($found_rows > $offset + $per_page) {
        $next_page = $page_link . "&amp;offset=" . ($offset + $per_page);
        $ui->actionButtons[] = array("id" => "next_page", "caption" => NETCAT_MODULE_SEARCH_ADMIN_QUERY_NEXT_PAGE, "action" => "mainView.loadIframe('{$next_page}')");
    }
} else {
Ejemplo n.º 2
0
    die;
}
$ui = $this->get_ui();
if (!nc_search::should('EnableSearch')) {
    nc_print_status(NETCAT_MODULE_SEARCH_ADMIN_SETTING_SEARCH_DISABLED, "error", array($this->hash_href("#module.search.generalsettings"), "_top"));
}
$rules = nc_search::load('nc_search_rule', "SELECT * FROM `%t%` ORDER BY `Rule_ID`")->set_output_encoding(nc_core('NC_CHARSET'));
if (count($rules)) {
    foreach ($rules as $r) {
        // строчка «последняя индексация»
        $last_start_time = $r->get('last_start_time');
        $last_finish_time = $r->get('last_finish_time');
        if (!$last_start_time) {
            $last_run = NETCAT_MODULE_SEARCH_ADMIN_RULE_NEVER_RUN . ".";
        } else {
            $last_run = NETCAT_MODULE_SEARCH_ADMIN_RULE_LAST_RUN . ": " . nc_search_util::format_time($last_start_time) . " (";
            if ($last_finish_time < $last_start_time) {
                $last_run .= NETCAT_MODULE_SEARCH_ADMIN_RULE_LAST_RUN_NOT_FINISHED;
            } else {
                $last_run .= NETCAT_MODULE_SEARCH_ADMIN_RULE_LAST_RUN_DURATION . " " . nc_search_util::format_seconds($last_finish_time - $last_start_time);
            }
            $last_run .= ").";
        }
        // конец формирования строчки «последняя индексация»
        // строчка с результатми последней индексации
        $stats = "";
        if ($last_start_time) {
            $result = $r->get('last_result');
            $stats = "<div class='stats'>" . sprintf(NETCAT_MODULE_SEARCH_ADMIN_RULE_STATISTICS, $result['processed'], $result['deleted'], $result['checked']) . ".</div>";
        }
        // конец формирования строчки с результатами
Ejemplo n.º 3
0
            foreach ($description["included"] as $item) {
                $hint .= "<div class='item'>" . NETCAT_MODULE_SEARCH_ADMIN_BULLET . " {$item}</div>\n";
            }
            $hint .= "</div>";
        }
        if ($description["excluded"]) {
            $hint .= "<div class='header'><strong>" . NETCAT_MODULE_SEARCH_ADMIN_QUERY_AREA_EXCLUDED . "</strong>:</div><div class='list'>";
            foreach ($description["excluded"] as $item) {
                $hint .= "<div class='item'>" . NETCAT_MODULE_SEARCH_ADMIN_BULLET . " {$item}</div>\n";
            }
            $hint .= "</div>";
        }
        $area_cell = "<td class='area_hint'><div>" . $area->to_string() . "</div>" . "<div class='inline_help area_description'>{$hint}</div>" . "</td>";
    }
    $search_link = nc_search::get_object()->get_search_url($row['Catalogue_ID'], true) . "?nologging=1&amp;search_query=" . rawurlencode($row['QueryString']) . "&amp;area=" . rawurlencode($row['Area']);
    echo "<tr class='nc-text-center'>", "<td>", nc_search_util::format_time($row['Timestamp']), "</td>", $area_cell, "<td><a href='{$search_link}' target='_blank' title='", htmlspecialchars(NETCAT_MODULE_SEARCH_ADMIN_QUERY_OPEN_RESULTS_LINK_HINT), "'>", $row['ResultsCount'], "</a></td>", "<td>", $row['User_ID'] ? $this->hash_link("#user.edit({$row['User_ID']})", $row["Login"]) : "&nbsp;", "</td>", "<td>", long2ip($row['IP']), "</td>", "</tr>\n";
}
$ui = $this->get_ui();
$ui->actionButtons[] = array("id" => "prev_page", "caption" => NETCAT_MODULE_SEARCH_ADMIN_QUERY_BACK_TO_LIST, "location" => "#module.search.queries", "align" => "left");
$page_link = $this->make_page_query(array('offset'), true);
if ($offset > 0) {
    $prev_page = $page_link . "&amp;offset=" . ($offset - $per_page);
    $ui->actionButtons[] = array("id" => "prev_page", "caption" => NETCAT_MODULE_SEARCH_ADMIN_QUERY_PREV_PAGE, "action" => "mainView.loadIframe('{$prev_page}')", "align" => "left");
}
if ($found_rows > $offset + $per_page) {
    $next_page = $page_link . "&amp;offset=" . ($offset + $per_page);
    $ui->actionButtons[] = array("id" => "next_page", "caption" => NETCAT_MODULE_SEARCH_ADMIN_QUERY_NEXT_PAGE, "action" => "mainView.loadIframe('{$next_page}')");
}
?>
<script type='text/javascript'>
$nc('td.area_hint').hover(
Ejemplo n.º 4
0
            $search_link = nc_search::get_object()->get_search_url($row['Catalogue_ID'], true) . "?nologging=1&amp;search_query=" . rawurlencode($row['QueryString']) . "&amp;area=" . rawurlencode($row['Area']);
            echo "<tr class='nc-text-center'>", "<td align='left'><a href='?view=queries_details&amp;query=", rawurlencode($row['QueryString']), "' {$query_link_title}>", htmlspecialchars($row['QueryString']), "</a></td>", "<td>", $row["Count"], "</td>", "</tr>\n";
        }
        echo "</table>\n";
    }
}
// -----------------------------------------------------------------------------
// ВРЕМЯ ПОСЛЕДНЕЙ ПЕРЕИНДЕКСАЦИИ, ЗАПУСК ПЕРЕИНДЕКСИРОВАНИЯ
$indexing_in_progress = $db->get_var("SELECT COUNT(*) FROM `Search_Task`");
if (count($rules)) {
    echo "<div class='legend'>", NETCAT_MODULE_SEARCH_ADMIN_STAT_INDEXING, "</div>", "<table class='nc-table nc--large nc--hovered nc--striped list'>", "<tr>", "<th width='30%'>", NETCAT_MODULE_SEARCH_ADMIN_RULE, "</th>", "<th>", NETCAT_MODULE_SEARCH_ADMIN_RULE_SITE, "</th>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_RULE_SCHEDULE, "</th>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_RULE_LAST_RUN, "</th>", "<th class='nc-text-center'>", NETCAT_MODULE_SEARCH_ADMIN_STAT_INDEX, "</th>", "</tr>\n";
    foreach ($rules as $r) {
        $rule_id = $r->get_id();
        $last_start_time = $r->get('last_start_time');
        $last_finish_time = $r->get('last_finish_time');
        $last_run = $last_start_time ? nc_search_util::format_time($last_start_time) : "&mdash;";
        $rule_name = $this->if_null($r->get('name'), NETCAT_MODULE_SEARCH_ADMIN_UNNAMED_RULE);
        $action_cell = "";
        if ($last_finish_time < $last_start_time) {
            $action_cell = NETCAT_MODULE_SEARCH_ADMIN_STAT_INDEXING_NOW;
        } else {
            $action_cell = "<a class='ajax' href='javascript:search_schedule({$rule_id})'>" . NETCAT_MODULE_SEARCH_ADMIN_STAT_INDEX_IN_BACKGROUND . "</a>";
            if (!$indexing_in_progress) {
                $action_cell .= " | <a href='javascript:search_index_now({$rule_id})'>" . NETCAT_MODULE_SEARCH_ADMIN_STAT_INDEX_IN_BROWSER . "</a>";
            }
        }
        echo "<tr>", "<td>", $this->hash_link("#module.search.rules_edit({$rule_id})", $rule_name), "</td>", "<td>", $r->get_site_name(), "</td>", "<td class='nc-text-center'>", $r->get_schedule_string(), "</td>", "<td class='nc-text-center'>", $last_run, "</td>", "<td class='nc-text-center nc--nowrap'>", $action_cell, "</td>", "</tr>\n";
    }
    echo "</table>\n";
}
// -----------------------------------------------------------------------------