prepare("SELECT bookid FROM epube_favorites WHERE owner = ?");
$fav_sth->execute([$owner]);
$fav_ids = [];
while ($line = $fav_sth->fetch()) {
array_push($fav_ids, $line["bookid"]);
}
$ids_qpart = "books.id IN (" . implode(",", $fav_ids) . ")";
}
$limit = 60;
@$offset = (int) $_REQUEST["offset"];
$order_by = $query ? "author_sort, series_name, series_index, title, books.id" : "books.id DESC";
$sth = $db->prepare("SELECT books.*, s.name AS series_name,
(SELECT id FROM data WHERE book = books.id AND format = 'EPUB' LIMIT 1) AS epub_id FROM books
LEFT JOIN books_series_link AS bsl ON (bsl.book = books.id)
LEFT JOIN series AS s ON (bsl.series = s.id)
WHERE
((:query = '') OR
(
LOWER(books.author_sort) LIKE LOWER(:query) OR
LOWER(books.title) LIKE LOWER(:query) OR
LOWER(series_name) LIKE LOWER(:query)
))
AND $ids_qpart
ORDER BY $order_by LIMIT :limit OFFSET :offset");
$sth->execute([':limit' => $limit, ':offset' => $offset, ':query' => '%' . $query . '%']);
print "
";
$rows = 0;
while ($line = $sth->fetch()) {
++$rows;
$cover_link = "backend.php?" . http_build_query(["op" => "cover", "id" => $line["id"]]);
$author_link = "?" . http_build_query(["query" => $line["author_sort"]]);
$in_progress = false;
$is_read = false;
if ($line["epub_id"]) {
$read_link = "read.html?" . http_build_query(["id" => $line["epub_id"], "rt" => $mode, "b" => $line["id"]]);
$lastread_sth = $ldb->prepare("SELECT lastread, total_pages FROM epube_books, epube_pagination
WHERE epube_pagination.bookid = epube_books.bookid AND
epube_books.bookid = ? AND owner = ?");
$lastread_sth->execute([$line['epub_id'], $owner]);
if ($lastread_line = $lastread_sth->fetch()) {
$lastread = $lastread_line["lastread"];
$total_pages = $lastread_line["total_pages"];
$is_read = $total_pages - $lastread < 5;
$in_progress = $lastread > 1;
}
} else {
$read_link = "";
}
$cover_read = $is_read ? "read" : "";
print "
";
print "
";
if ($read_link) print "
";
if ($line["has_cover"]) {
print "";
} else {
print "";
}
if ($read_link) print "";
print "
";
$title_class = $in_progress ? "in_progress" : "";
print "
";
if ($line["series_name"]) {
$series_link = "?" . http_build_query(["query" => $line["series_name"]]);
$series_full = $line["series_name"] . " [" . $line["series_index"] . "]";
print "
";
}
print "
";
$data_sth = $db->prepare("SELECT * FROM data WHERE book = ? LIMIT 3");
$data_sth->execute([$line['id']]);
/*print "
";*/
print "";
?>
";
print "
";
}
?>
$mode, "query" => $query, "offset" => $offset - $limit]);
$next_link = http_build_query(["mode" => $mode, "query" => $query, "offset" => $offset + $limit]);
?>
Refresh cache