getAttribute('page'); $bookid = (int) $request->getAttribute('id'); $timestamp = (int) $request->getAttribute('timestamp'); $cfi = $request->getAttribute('cfi', ''); $owner = $_SESSION["owner"] ?? ""; if ($bookid) { $book = ORM::for_table('epube_books') ->where('bookid', $bookid) ->where('owner', $owner) ->find_one(); if ($book) { if (($timestamp >= $book->lastts) && ($page >= $book->lastread || $page == PAGE_RESET_PROGRESS)) { $book->set([ 'lastread' => $page, 'lastcfi' => $cfi, 'lastts' => $timestamp, ]); } } else { $book = ORM::for_table('epube_books')->create(); $book->set([ 'bookid' => $bookid, 'owner' => $owner, 'lastread' => $page, 'lastcfi' => $cfi, 'lastts' => $timestamp, ]); } $book->save(); } return (new Response())->withBody(json_encode(["page" => $page, "cfi" => $cfi])); } }