40 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.1 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()";
 | 
						|
$fields = array();
 | 
						|
$fields[':username'] = $_SESSION['username'];
 | 
						|
$fields[':comic'] = str_replace("/", "", $_SESSION['compath']);
 | 
						|
$fields[':issue'] = $_SESSION['comfile'];
 | 
						|
$fields[':currentpage'] = $page;
 | 
						|
$sth = $globaldbh->prepare($query);
 | 
						|
$sth->execute($fields);
 | 
						|
 | 
						|
$data['message'] = "Page set to $page for {$_SESSION['username']} reading {$_SESSION['comfile']}";
 | 
						|
 | 
						|
header('Content-Type: application/json');
 | 
						|
echo json_encode($data);
 | 
						|
exit();
 |