Not authenticated";
die;
}
$db = new SQLite3(CALIBRE_DB, SQLITE3_OPEN_READONLY);
if ($query) {
$query_esc = db_escape_string($query);
$search_qpart = "(LOWER(author_sort) LIKE LOWER('%$query_esc%') OR LOWER(title) LIKE LOWER('%$query_esc%'))";
} else {
$search_qpart = "1";
}
$limit = 60;
$offset = (int) $_REQUEST["offset"];
$result = $db->query("SELECT books.*,
(SELECT id FROM data WHERE book = books.id AND format = 'EPUB' LIMIT 1) AS epub_id FROM books
WHERE $search_qpart ORDER BY books.id DESC LIMIT $limit OFFSET $offset");
print "
";
while ($line = $result->fetchArray(SQLITE3_ASSOC)) {
$cover_link = "backend.php?" . http_build_query(["op" => "cover", "id" => $line["id"]]);
$author_link = "?" . http_build_query(["query" => $line["author_sort"]]);
$read_link = $line["epub_id"] ? "read.html?" . http_build_query(["id" => $line["epub_id"]]) : "";
print "
";
}
?>
$query, "offset" => $offset > 0 ? $offset - $limit : 0]);
$next_link = http_build_query(["query" => $query, "offset" => $offset + $limit]);
?>