-
Notifications
You must be signed in to change notification settings - Fork 1
/
ajaxclipboard.php
50 lines (37 loc) · 1.51 KB
/
ajaxclipboard.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
<?php
include_once 'data.php';
include_once 'functions.php';
if (isset($_GET['file'])) {
database_connect($database_path, 'library');
$file_query = $dbHandle->quote($_GET['file']);
$result = $dbHandle->query("SELECT COUNT(*) FROM library WHERE id=$file_query");
$exists = $result->fetchColumn();
$result = null;
$dbHandle = null;
if ($exists !== '1')
die('Error! This item does not exist anymore.');
if (!isset($_SESSION['session_clipboard'])) {
$_SESSION['session_clipboard'][] = $_GET['file'];
echo "added";
} else {
if (!in_array($_GET['file'], $_SESSION['session_clipboard'])) {
$_SESSION['session_clipboard'][] = $_GET['file'];
$_SESSION['session_clipboard'] = array_unique($_SESSION['session_clipboard']);
echo "added";
} else {
$key = array_search($_GET['file'], $_SESSION['session_clipboard']);
unset($_SESSION['session_clipboard'][$key]);
if (isset($_GET['selection']) && $_GET['selection'] == 'clipboard') {
$export_files = read_export_files(0);
$id = array_search($_GET['file'], $export_files);
if ($id !== false) {
unset($export_files[$id]);
$export_files = array_values($export_files);
save_export_files($export_files);
}
}
echo "removed";
}
}
}
?>