-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpostback.php
89 lines (77 loc) · 2.78 KB
/
postback.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
<?php
$path = "./";
require_once($path."functions.php");
require_once($path."smarty/Smarty.class.php");
require_once($path."db/SQLiteManager.php");
$db = SQLiteManager\SQLiteManager::getInstance();
$mode = $_REQUEST["mode"];
unset($_REQUEST["mode"]);
unset($_REQUEST["submit"]);
if($mode == "addFeed") {
require_once($path."autoloader.php");
$feed = new SimplePie();
$feed->enable_cache(false);
$feed->set_feed_url($_REQUEST["feed"]);
$feed->init();
if($feed->error()) {
throw new InvalidArgumentException($feed->error());
}
$db->insert("feeds", ["feed"=>$_REQUEST["feed"]]);
}
if($mode == "addAggregateFeed") {
$urls = explode("\n", $_REQUEST["feeds"]);
foreach($urls as $url) {
require_once($path."autoloader.php");
$feed = new SimplePie();
$feed->enable_cache(false);
$feed->set_feed_url($url);
$feed->init();
if($feed->error()) {
throw new InvalidArgumentException($feed->error());
}
}
$db->insert("aggregateFeeds", ["feeds"=>$_REQUEST["feeds"]]);
}
if($mode == "updateAggregateFeed") {
$urls = explode("\n", $_REQUEST["feeds"]);
foreach($urls as $url) {
require_once($path."autoloader.php");
$feed = new SimplePie();
$feed->enable_cache(false);
$feed->set_feed_url($url);
$feed->init();
if($feed->error()) {
throw new InvalidArgumentException($feed->error());
}
}
$id = $_REQUEST["id"];
$db->update("aggregateFeeds", ["feeds"=>$_REQUEST["feeds"]], ["ID"=>$id]);
}
if($mode == "addRegex") {
$regex = "/".$_REQUEST["regex"]."/s";
if($_REQUEST["caseInsensitive"]) {
$regex .= "i";
}
if(preg_match($regex, "") === false) {
throw new InvalidArgumentException($regex."<br>".preg_last_error());
}
$db->insert("filters", ["feedID"=>$_REQUEST["feedID"], "field"=>$_REQUEST["field"], "regex"=>$regex]);
}
if($mode == "deleteRegex") {
$db->delete("filters", ["ID"=>$_REQUEST["filterID"]]);
}
if($mode == "setFeedProperties") {
$anyOrAll = $_REQUEST["anyOrAll"];
if($anyOrAll != 'all') {
$anyOrAll = 'any';
}
$blockOrPermit = $_REQUEST["blockOrPermit"];
if($blockOrPermit != 'permit'){
$blockOrPermit = 'block';
}
$db->update("feeds", ["maxItems"=>$_REQUEST["maxItems"]], ["ID"=>$_REQUEST["feedID"]]);
$db->update("feeds", ["anyOrAll"=>$anyOrAll], ["ID"=>$_REQUEST["feedID"]]);
$db->update("feeds", ["blockOrPermit"=>$blockOrPermit], ["ID"=>$_REQUEST["feedID"]]);
}
header("location:admin.php");
?>