39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
require '../header.php';
|
|
$validated = require_login(NOREDIRECT);
|
|
|
|
$data = array();
|
|
$data["error"] = false;
|
|
$data["message"] = "";
|
|
$data["validated"] = $validated;
|
|
|
|
if ( !$validated ) {
|
|
$data["error"] = true;
|
|
$data["message"] = "Clients must validate accounts";
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data);
|
|
exit();
|
|
}
|
|
|
|
if ( !isset($_REQUEST['page']) ) {
|
|
exit();
|
|
}
|
|
$page = intval($_REQUEST['page']);
|
|
|
|
$query = "INSERT INTO pagetracker (username, comic, issue, currentpage, lastupdate) ";
|
|
$query .= "VALUES(:username, :comic, :issue, :currentpage, NOW()) ";
|
|
$query .= "ON DUPLICATE KEY UPDATE currentpage=:currentpage, lastupdate=NOW()";
|
|
$sth = $globaldbh->prepare($query);
|
|
$sth->bindValue(":username", $_SESSION['username'], PDO::PARAM_STR);
|
|
$sth->bindValue(":comic", str_replace("/", "", $_SESSION['compath']), PDO::PARAM_STR);
|
|
$sth->bindValue(":issue", $_SESSION['comfile'], PDO::PARAM_STR);
|
|
$sth->bindValue(":currentpage", $page, PDO::PARAM_INT);
|
|
$sth->execute();
|
|
|
|
$data['message'] = "Page set to $page for {$_SESSION['username']} reading {$_SESSION['comfile']}";
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data);
|
|
exit();
|