This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathhistory.php
54 lines (42 loc) · 1.8 KB
/
history.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
include_once 'data.php';
include_once 'functions.php';
session_write_close();
if (!empty($_GET['file'])) {
$userID = intval($_SESSION['user_id']);
$fileID = intval($_GET['file']);
database_connect(IL_DATABASE_PATH, 'history');
$dbHandle->exec("CREATE TABLE IF NOT EXISTS usersfiles (
id INTEGER PRIMARY KEY,
userID INTEGER NOT NULL DEFAULT '',
fileID INTEGER NOT NULL DEFAULT '',
viewed INTEGER NOT NULL DEFAULT '',
UNIQUE(userID,fileID)
)");
$dbHandle->beginTransaction();
$dbHandle->exec("DELETE FROM usersfiles WHERE userID=$userID AND fileID=$fileID");
$dbHandle->exec("INSERT INTO usersfiles (userID,fileID,viewed) VALUES ($userID,$fileID," . time() . ")");
$dbHandle->commit();
$dbHandle = null;
}
if (!empty($_GET['filename']) && !empty($_GET['page'])) {
if (substr($_GET['filename'], 0, 4) == 'lib_') die();
database_connect(IL_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)
)");
$userID = intval($_SESSION['user_id']);
$filename = $dbHandle->quote($_GET['filename']);
$page = intval($_GET['page']);
$dbHandle->beginTransaction();
$dbHandle->exec("DELETE FROM bookmarks WHERE userID=" . $userID . " AND file=" . $filename);
if ($page > 1)
$dbHandle->exec("INSERT INTO bookmarks (userID,file,page) VALUES (" . $userID . "," . $filename . "," . $page .")");
$dbHandle->commit();
$dbHandle = null;
}
?>