Gazelle/sections/log/sql.php

40 lines
762 B
PHP
Raw Permalink 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-07-24 08:00:46 +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) {
2013-07-24 08:00:46 +00:00
$SQL .= "WHERE Message LIKE '%";
$SQL .= implode("%' AND Message LIKE '%", $Words);
$SQL .= "%' ";
2012-08-30 08:00:17 +00:00
}
2013-05-04 08:00:48 +00:00
if (!check_perms('site_view_full_log')) {
if ($Search) {
2013-07-24 08:00:46 +00:00
$SQL .= ' AND ';
2012-08-30 08:00:17 +00:00
} else {
2013-07-24 08:00:46 +00:00
$SQL .= ' WHERE ';
2012-08-30 08:00:17 +00:00
}
2013-07-24 08:00:46 +00:00
$SQL .= " Time>'".time_minus(3600 * 24 * 28)."' ";
2012-08-30 08:00:17 +00:00
}
2013-07-24 08:00:46 +00:00
$SQL .= "
2013-05-04 08:00:48 +00:00
ORDER BY ID DESC
LIMIT $Limit";
2012-08-30 08:00:17 +00:00
2013-07-24 08:00:46 +00:00
$Log = $DB->query($SQL);
2013-07-13 08:00:46 +00:00
$DB->query('SELECT FOUND_ROWS()');
2012-08-30 08:00:17 +00:00
list($NumResults) = $DB->next_record();
$TotalMatches = $NumResults;
$DB->set_query_id($Log);