Gazelle/sections/log/sql.php

40 lines
758 B
PHP
Raw Normal View History

2013-05-28 08:01:02 +00:00
<?php
list($Page, $Limit) = Format::page_limit(LOG_ENTRIES_PER_PAGE);
2012-08-30 08:00:17 +00:00
2013-05-04 08:00:48 +00:00
if (!empty($_GET['search'])) {
2012-08-30 08:00:17 +00:00
$Search = db_string($_GET['search']);
} else {
$Search = false;
}
$Words = explode(' ', $Search);
2013-05-04 08:00:48 +00:00
$sql = '
2013-05-29 08:00:51 +00:00
SELECT
SQL_CALC_FOUND_ROWS
2013-05-04 08:00:48 +00:00
ID,
Message,
Time
FROM log ';
if ($Search) {
2012-08-30 08:00:17 +00:00
$sql .= "WHERE Message LIKE '%";
$sql .= implode("%' AND Message LIKE '%", $Words);
$sql .= "%' ";
}
2013-05-04 08:00:48 +00:00
if (!check_perms('site_view_full_log')) {
if ($Search) {
$sql.=' AND ';
2012-08-30 08:00:17 +00:00
} else {
2013-05-04 08:00:48 +00:00
$sql.=' WHERE ';
2012-08-30 08:00:17 +00:00
}
2013-05-04 08:00:48 +00:00
$sql .= " Time>'".time_minus(3600 * 24 * 28)."' ";
2012-08-30 08:00:17 +00:00
}
2013-05-04 08:00:48 +00:00
$sql .= "
ORDER BY ID DESC
LIMIT $Limit";
2012-08-30 08:00:17 +00:00
$Log = $DB->query($sql);
$DB->query("SELECT FOUND_ROWS()");
list($NumResults) = $DB->next_record();
$TotalMatches = $NumResults;
$DB->set_query_id($Log);