public function httpErrorLogAction()
{
$this->checkPermission("http_errors");
$db = Db::get();
$limit = intval($this->getParam("limit"));
$offset = intval($this->getParam("start"));
$sort = $this->getParam("sort");
$dir = $this->getParam("dir");
$filter = $this->getParam("filter");
if (!$limit) {
$limit = 20;
}
if (!$offset) {
$offset = 0;
}
if (!$sort || !in_array($sort, ["code", "uri", "date", "count"])) {
$sort = "count";
}
if (!$dir || !in_array($dir, ["DESC", "ASC"])) {
$dir = "DESC";
}
$condition = "";
if ($filter) {
$filter = $db->quote("%" . $filter . "%");
$conditionParts = [];
foreach (["uri", "code", "parametersGet", "parametersPost", "serverVars", "cookies"] as $field) {
$conditionParts[] = $field . " LIKE " . $filter;
}
$condition = " WHERE " . implode(" OR ", $conditionParts);
}
$logs = $db->fetchAll("SELECT code,uri,`count`,date FROM http_error_log " . $condition . " ORDER BY " . $sort . " " . $dir . " LIMIT " . $offset . "," . $limit);
$total = $db->fetchOne("SELECT count(*) FROM http_error_log " . $condition);
$this->_helper->json(["items" => $logs, "total" => $total, "success" => true]);
}