-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathajax.php
98 lines (91 loc) · 1.94 KB
/
ajax.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/* Copyright (c) 2014 Freeder
* Released under a MIT License.
* See the file LICENSE at the root of this repo for copying permission.
*/
require_once('inc/init.php');
require_once('inc/tags.php');
if (empty($_GET['do'])) {
http_response_code(400);
exit('No action specified.');
}
switch ($_GET['do']) {
case 'mark_read':
case 'mark_sticky':
case 'mark_private':
case 'mark_no_home':
$tag_do = str_replace_first('mark', '', $_GET['do']);
if (!empty($_GET['entry_id'])) {
add_tag_to_entry(intval($_GET['entry_id']), $tag_do);
exit();
}
elseif (!empty($_GET['feed_id'])) {
add_tag_from_feed(intval($_GET['feed_id']), $tag_do);
exit();
}
else {
http_response_code(400);
exit();
}
break;
case 'unmark_read':
case 'unmark_sticky':
case 'unmark_private':
case 'unmark_no_home':
$tag_do = str_replace_first('mark', '', $_GET['do']);
if (!empty($_GET['entry_id'])) {
remove_tag_to_entry(intval($_GET['entry_id']), $tag_do);
exit();
}
elseif (!empty($_GET['feed_id'])) {
remove_tag_from_feed(intval($_GET['feed_id']), $tag_do);
exit();
}
else {
http_response_code(400);
exit();
}
break;
case 'add_tag':
if (!empty($_GET['tag'])) {
if (!empty($_GET['entry_id'])) {
add_tag_to_entry(intval($_GET['entry_id']), $_GET['tag']);
exit();
}
elseif (!empty($_GET['feed_id'])) {
add_tag_to_feed(intval($_GET['entry_id']), $_GET['feed']);
exit();
}
else {
http_response_code(400);
exit();
}
}
else {
http_response_code(400);
exit();
}
break;
case 'remove_tag':
if (!empty($_GET['tag'])) {
if (!empty($_GET['entry_id'])) {
remove_tag_to_entry(intval($_GET['entry_id']), $_GET['tag']);
exit();
}
elseif (!empty($_GET['feed_id'])) {
remove_tag_to_feed(intval($_GET['entry_id']), $_GET['feed']);
exit();
}
else {
http_response_code(400);
exit();
}
}
else {
http_response_code(400);
exit();
}
break;
default:
exit('Unknown action: '.htmlspecialchars($_GET['do']).'.');
}