-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark.php
30 lines (24 loc) · 1015 Bytes
/
bookmark.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
include_once 'data.php';
include_once 'functions.php';
session_write_close();
if (!empty($_GET['file']) && !empty($_GET['page'])) {
if (substr($_GET['file'], 0, 4) == 'lib_') die();
$userID = intval($_SESSION['user_id']);
$page = intval($_GET['page']);
$file = preg_replace('/[^0-9\.pdf]/', '', $_GET['file']);
database_connect($database_path, 'history');
$dbHandle->exec("CREATE TABLE IF NOT EXISTS bookmarks (
id INTEGER PRIMARY KEY,
userID INTEGER NOT NULL DEFAULT '',
file TEXT NOT NULL DEFAULT '',
page INTEGER NOT NULL DEFAULT 1,
UNIQUE(userID,file)
)");
$dbHandle->beginTransaction();
$dbHandle->exec("DELETE FROM bookmarks WHERE userID=$userID AND file='$file'");
if ($page > 1) $dbHandle->exec("INSERT INTO bookmarks (userID,file,page) VALUES ($userID,'$file',$page)");
$dbHandle->commit();
$dbHandle = null;
}
?>