From bfbfed517b681fde380335bbb9d1d9c26abaa1fb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 25 Feb 2017 09:01:49 +0300 Subject: add favicon, store total pages --- .gitignore | 1 + backend.php | 12 +++++++----- img/favicon.png | Bin 0 -> 622 bytes index.php | 1 + read.html | 3 ++- schema.sql | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 img/favicon.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f4773f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.php diff --git a/backend.php b/backend.php index c353e5c..9ce0bfa 100644 --- a/backend.php +++ b/backend.php @@ -82,10 +82,11 @@ break; case "storepagination": - $payload = db_escape_string($_REQUEST["payload"]); $bookid = (int) $_REQUEST["id"]; + $payload = db_escape_string($_REQUEST["payload"]); + $total_pages = (int) $_REQUEST["total"]; - if ($bookid && $payload) { + if ($bookid && $payload && $total_pages) { db_query($link, "BEGIN"); @@ -94,11 +95,12 @@ if (db_num_rows($result) != 0) { $id = db_fetch_result($result, 0, "id"); - db_query($link, "UPDATE epube_pagination SET pagination = '$payload' WHERE id = '$id'"); + db_query($link, "UPDATE epube_pagination SET pagination = '$payload', + total_pages = '$total_pages' WHERE id = '$id'"); } else { - db_query($link, "INSERT INTO epube_pagination (bookid, pagination) VALUES - ('$bookid', '$payload')"); + db_query($link, "INSERT INTO epube_pagination (bookid, pagination, total_pages) VALUES + ('$bookid', '$payload', '$total_pages')"); } diff --git a/img/favicon.png b/img/favicon.png new file mode 100644 index 0000000..7d863f9 Binary files /dev/null and b/img/favicon.png differ diff --git a/index.php b/index.php index 1c2ca8e..d7e6397 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,7 @@ The Epube + diff --git a/read.html b/read.html index 49f57a9..bbb8d65 100644 --- a/read.html +++ b/read.html @@ -14,6 +14,7 @@ + @@ -248,7 +249,7 @@ console.log("storing pagination on server"); $.post("backend.php", { op: "storepagination", id: $.urlParam("id"), - payload: JSON.stringify(pageList) }); + payload: JSON.stringify(pageList), total: book.pagination.totalPages }); } $.get("backend.php", { op: "getlastread", id: $.urlParam("id") }, function(data) { diff --git a/schema.sql b/schema.sql index 8e425db..cd9cf95 100644 --- a/schema.sql +++ b/schema.sql @@ -12,6 +12,7 @@ drop table if exists epube_books; create table epube_pagination( id serial not null primary key, bookid integer not null, + total_pages integer not null, pagination text not null); create table epube_books( -- cgit v1.2.3