From 885224d569d535b7e63ab301e4fd6cdc71c5c49b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 25 Feb 2017 00:27:31 +0300 Subject: initial --- index.php | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 index.php (limited to 'index.php') diff --git a/index.php b/index.php new file mode 100644 index 0000000..4cdd72a --- /dev/null +++ b/index.php @@ -0,0 +1,144 @@ + + + + + + + + + + + The Epube + + + + + + + + + +
+ +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 "
"; + print "
"; + + if ($read_link) print ""; + + if ($line["has_cover"]) { + print ""; + } else { + print ""; + } + + if ($read_link) print ""; + + print "
"; + + if ($read_link) { + print ""; + } else { + print "
" . $line["title"] . "
"; + } + + print ""; + + $data_result = $db->query("SELECT * FROM data WHERE book = " . $line["id"] . " LIMIT 3"); + + while ($data_line = $data_result->fetchArray(SQLITE3_ASSOC)) { + if ($data_line["format"] != "ORIGINAL_EPUB") { + $download_link = "backend.php?op=download&id=" . $data_line["id"]; + print "" . $data_line["format"] . " "; + } + } + + + print "
"; + print "
"; + print "
"; + + } + + ?> + +
+ + $query, "offset" => $offset > 0 ? $offset - $limit : 0]); + $next_link = http_build_query(["query" => $query, "offset" => $offset + $limit]); + ?> + + + +
+ + -- cgit v1.2.3