@@ -24,8 +24,9 @@ |
||
24 | 24 | ]; |
25 | 25 | |
26 | 26 | foreach ($server_params as $n => $p) { |
27 | - if (isset($_SERVER[$p])) |
|
28 | - $context .= "\n$n: ".$_SERVER[$p]; |
|
27 | + if (isset($_SERVER[$p])) { |
|
28 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
29 | + } |
|
29 | 30 | } |
30 | 31 | |
31 | 32 | // passed error message may contain invalid unicode characters, failing to insert an error here |
@@ -1,47 +1,47 @@ |
||
1 | 1 | <?php |
2 | 2 | class Logger_SQL { |
3 | 3 | |
4 | - private $pdo; |
|
4 | + private $pdo; |
|
5 | 5 | |
6 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
6 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
7 | 7 | |
8 | - // separate PDO connection object is used for logging |
|
9 | - if (!$this->pdo) { |
|
10 | - $this->pdo = Db::instance()->pdo_connect(); |
|
11 | - } |
|
8 | + // separate PDO connection object is used for logging |
|
9 | + if (!$this->pdo) { |
|
10 | + $this->pdo = Db::instance()->pdo_connect(); |
|
11 | + } |
|
12 | 12 | |
13 | - if ($this->pdo && get_schema_version() > 117) { |
|
13 | + if ($this->pdo && get_schema_version() > 117) { |
|
14 | 14 | |
15 | - $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
15 | + $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null; |
|
16 | 16 | |
17 | - // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
18 | - $context = mb_substr($context, 0, 8192); |
|
17 | + // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge |
|
18 | + $context = mb_substr($context, 0, 8192); |
|
19 | 19 | |
20 | - $server_params = [ |
|
21 | - "IP" => "REMOTE_ADDR", |
|
22 | - "Request URI" => "REQUEST_URI", |
|
23 | - "User agent" => "HTTP_USER_AGENT", |
|
24 | - ]; |
|
20 | + $server_params = [ |
|
21 | + "IP" => "REMOTE_ADDR", |
|
22 | + "Request URI" => "REQUEST_URI", |
|
23 | + "User agent" => "HTTP_USER_AGENT", |
|
24 | + ]; |
|
25 | 25 | |
26 | - foreach ($server_params as $n => $p) { |
|
27 | - if (isset($_SERVER[$p])) |
|
28 | - $context .= "\n$n: ".$_SERVER[$p]; |
|
29 | - } |
|
26 | + foreach ($server_params as $n => $p) { |
|
27 | + if (isset($_SERVER[$p])) |
|
28 | + $context .= "\n$n: ".$_SERVER[$p]; |
|
29 | + } |
|
30 | 30 | |
31 | - // passed error message may contain invalid unicode characters, failing to insert an error here |
|
32 | - // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
33 | - $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
34 | - $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
31 | + // passed error message may contain invalid unicode characters, failing to insert an error here |
|
32 | + // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc |
|
33 | + $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8'); |
|
34 | + $context = UConverter::transcode($context, 'UTF-8', 'UTF-8'); |
|
35 | 35 | |
36 | - $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
36 | + $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log |
|
37 | 37 | (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES |
38 | 38 | (?, ?, ?, ?, ?, ?, NOW())"); |
39 | - $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
39 | + $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]); |
|
40 | 40 | |
41 | - return $sth->rowCount(); |
|
42 | - } |
|
41 | + return $sth->rowCount(); |
|
42 | + } |
|
43 | 43 | |
44 | - return false; |
|
45 | - } |
|
44 | + return false; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -186,8 +186,9 @@ |
||
186 | 186 | $cat = clean(trim(mb_strtolower($srccat))); |
187 | 187 | |
188 | 188 | // we don't support numeric tags |
189 | - if (is_numeric($cat)) |
|
190 | - $cat = 't:'.$cat; |
|
189 | + if (is_numeric($cat)) { |
|
190 | + $cat = 't:'.$cat; |
|
191 | + } |
|
191 | 192 | |
192 | 193 | $cat = preg_replace('/[,\'\"]/', "", $cat); |
193 | 194 |
@@ -1,209 +1,209 @@ |
||
1 | 1 | <?php |
2 | 2 | abstract class FeedItem_Common extends FeedItem { |
3 | - protected $elem; |
|
4 | - protected $xpath; |
|
5 | - protected $doc; |
|
6 | - |
|
7 | - public function __construct($elem, $doc, $xpath) { |
|
8 | - $this->elem = $elem; |
|
9 | - $this->xpath = $xpath; |
|
10 | - $this->doc = $doc; |
|
11 | - |
|
12 | - try { |
|
3 | + protected $elem; |
|
4 | + protected $xpath; |
|
5 | + protected $doc; |
|
6 | + |
|
7 | + public function __construct($elem, $doc, $xpath) { |
|
8 | + $this->elem = $elem; |
|
9 | + $this->xpath = $xpath; |
|
10 | + $this->doc = $doc; |
|
11 | + |
|
12 | + try { |
|
13 | 13 | |
14 | - $source = $elem->getElementsByTagName("source")->item(0); |
|
14 | + $source = $elem->getElementsByTagName("source")->item(0); |
|
15 | 15 | |
16 | - // we don't need <source> element |
|
17 | - if ($source) { |
|
18 | - $elem->removeChild($source); |
|
19 | - } |
|
20 | - } catch (DOMException $e) { |
|
21 | - // |
|
22 | - } |
|
23 | - } |
|
16 | + // we don't need <source> element |
|
17 | + if ($source) { |
|
18 | + $elem->removeChild($source); |
|
19 | + } |
|
20 | + } catch (DOMException $e) { |
|
21 | + // |
|
22 | + } |
|
23 | + } |
|
24 | 24 | |
25 | - public function get_element() { |
|
26 | - return $this->elem; |
|
27 | - } |
|
25 | + public function get_element() { |
|
26 | + return $this->elem; |
|
27 | + } |
|
28 | 28 | |
29 | - public function get_author() { |
|
30 | - $author = $this->elem->getElementsByTagName("author")->item(0); |
|
29 | + public function get_author() { |
|
30 | + $author = $this->elem->getElementsByTagName("author")->item(0); |
|
31 | 31 | |
32 | - if ($author) { |
|
33 | - $name = $author->getElementsByTagName("name")->item(0); |
|
32 | + if ($author) { |
|
33 | + $name = $author->getElementsByTagName("name")->item(0); |
|
34 | 34 | |
35 | - if ($name) { |
|
36 | - return clean($name->nodeValue); |
|
37 | - } |
|
38 | - |
|
39 | - $email = $author->getElementsByTagName("email")->item(0); |
|
40 | - |
|
41 | - if ($email) { |
|
42 | - return clean($email->nodeValue); |
|
43 | - } |
|
44 | - |
|
45 | - if ($author->nodeValue) { |
|
46 | - return clean($author->nodeValue); |
|
47 | - } |
|
48 | - } |
|
49 | - |
|
50 | - $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
51 | - $authors = []; |
|
52 | - |
|
53 | - foreach ($author_elems as $author) { |
|
54 | - array_push($authors, clean($author->nodeValue)); |
|
55 | - } |
|
56 | - |
|
57 | - return implode(", ", $authors); |
|
58 | - } |
|
59 | - |
|
60 | - public function get_comments_url() { |
|
61 | - //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
62 | - //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
63 | - $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
35 | + if ($name) { |
|
36 | + return clean($name->nodeValue); |
|
37 | + } |
|
38 | + |
|
39 | + $email = $author->getElementsByTagName("email")->item(0); |
|
40 | + |
|
41 | + if ($email) { |
|
42 | + return clean($email->nodeValue); |
|
43 | + } |
|
44 | + |
|
45 | + if ($author->nodeValue) { |
|
46 | + return clean($author->nodeValue); |
|
47 | + } |
|
48 | + } |
|
49 | + |
|
50 | + $author_elems = $this->xpath->query("dc:creator", $this->elem); |
|
51 | + $authors = []; |
|
52 | + |
|
53 | + foreach ($author_elems as $author) { |
|
54 | + array_push($authors, clean($author->nodeValue)); |
|
55 | + } |
|
56 | + |
|
57 | + return implode(", ", $authors); |
|
58 | + } |
|
59 | + |
|
60 | + public function get_comments_url() { |
|
61 | + //RSS only. Use a query here to avoid namespace clashes (e.g. with slash). |
|
62 | + //might give a wrong result if a default namespace was declared (possible with XPath 2.0) |
|
63 | + $com_url = $this->xpath->query("comments", $this->elem)->item(0); |
|
64 | 64 | |
65 | - if ($com_url) { |
|
66 | - return clean($com_url->nodeValue); |
|
67 | - } |
|
65 | + if ($com_url) { |
|
66 | + return clean($com_url->nodeValue); |
|
67 | + } |
|
68 | 68 | |
69 | - //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
70 | - //'text/html' for type is too restrictive? |
|
71 | - $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
72 | - |
|
73 | - if ($com_url) { |
|
74 | - return clean($com_url->nodeValue); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - public function get_comments_count() { |
|
79 | - //also query for ATE stuff here |
|
80 | - $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
81 | - $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
82 | - |
|
83 | - if ($comments) { |
|
84 | - return clean($comments->nodeValue); |
|
85 | - } |
|
86 | - } |
|
69 | + //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common. |
|
70 | + //'text/html' for type is too restrictive? |
|
71 | + $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0); |
|
72 | + |
|
73 | + if ($com_url) { |
|
74 | + return clean($com_url->nodeValue); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + public function get_comments_count() { |
|
79 | + //also query for ATE stuff here |
|
80 | + $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count"; |
|
81 | + $comments = $this->xpath->query($query, $this->elem)->item(0); |
|
82 | + |
|
83 | + if ($comments) { |
|
84 | + return clean($comments->nodeValue); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - // this is common for both Atom and RSS types and deals with various media: elements |
|
89 | - public function get_enclosures() { |
|
90 | - $encs = []; |
|
88 | + // this is common for both Atom and RSS types and deals with various media: elements |
|
89 | + public function get_enclosures() { |
|
90 | + $encs = []; |
|
91 | 91 | |
92 | - $enclosures = $this->xpath->query("media:content", $this->elem); |
|
92 | + $enclosures = $this->xpath->query("media:content", $this->elem); |
|
93 | 93 | |
94 | - foreach ($enclosures as $enclosure) { |
|
95 | - $enc = new FeedEnclosure(); |
|
94 | + foreach ($enclosures as $enclosure) { |
|
95 | + $enc = new FeedEnclosure(); |
|
96 | 96 | |
97 | - $enc->type = clean($enclosure->getAttribute("type")); |
|
98 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
99 | - $enc->length = clean($enclosure->getAttribute("length")); |
|
100 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
101 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
97 | + $enc->type = clean($enclosure->getAttribute("type")); |
|
98 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
99 | + $enc->length = clean($enclosure->getAttribute("length")); |
|
100 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
101 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
102 | 102 | |
103 | - $medium = clean($enclosure->getAttribute("medium")); |
|
104 | - if (!$enc->type && $medium) { |
|
105 | - $enc->type = strtolower("$medium/generic"); |
|
106 | - } |
|
103 | + $medium = clean($enclosure->getAttribute("medium")); |
|
104 | + if (!$enc->type && $medium) { |
|
105 | + $enc->type = strtolower("$medium/generic"); |
|
106 | + } |
|
107 | 107 | |
108 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
109 | - if ($desc) { |
|
110 | - $enc->title = clean($desc->nodeValue); |
|
111 | - } |
|
108 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
109 | + if ($desc) { |
|
110 | + $enc->title = clean($desc->nodeValue); |
|
111 | + } |
|
112 | 112 | |
113 | - array_push($encs, $enc); |
|
114 | - } |
|
113 | + array_push($encs, $enc); |
|
114 | + } |
|
115 | 115 | |
116 | - $enclosures = $this->xpath->query("media:group", $this->elem); |
|
116 | + $enclosures = $this->xpath->query("media:group", $this->elem); |
|
117 | 117 | |
118 | - foreach ($enclosures as $enclosure) { |
|
119 | - $enc = new FeedEnclosure(); |
|
118 | + foreach ($enclosures as $enclosure) { |
|
119 | + $enc = new FeedEnclosure(); |
|
120 | 120 | |
121 | - $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
121 | + $content = $this->xpath->query("media:content", $enclosure)->item(0); |
|
122 | 122 | |
123 | - if ($content) { |
|
124 | - $enc->type = clean($content->getAttribute("type")); |
|
125 | - $enc->link = clean($content->getAttribute("url")); |
|
126 | - $enc->length = clean($content->getAttribute("length")); |
|
127 | - $enc->height = clean($content->getAttribute("height")); |
|
128 | - $enc->width = clean($content->getAttribute("width")); |
|
123 | + if ($content) { |
|
124 | + $enc->type = clean($content->getAttribute("type")); |
|
125 | + $enc->link = clean($content->getAttribute("url")); |
|
126 | + $enc->length = clean($content->getAttribute("length")); |
|
127 | + $enc->height = clean($content->getAttribute("height")); |
|
128 | + $enc->width = clean($content->getAttribute("width")); |
|
129 | 129 | |
130 | - $medium = clean($content->getAttribute("medium")); |
|
131 | - if (!$enc->type && $medium) { |
|
132 | - $enc->type = strtolower("$medium/generic"); |
|
133 | - } |
|
130 | + $medium = clean($content->getAttribute("medium")); |
|
131 | + if (!$enc->type && $medium) { |
|
132 | + $enc->type = strtolower("$medium/generic"); |
|
133 | + } |
|
134 | 134 | |
135 | - $desc = $this->xpath->query("media:description", $content)->item(0); |
|
136 | - if ($desc) { |
|
137 | - $enc->title = clean($desc->nodeValue); |
|
138 | - } else { |
|
139 | - $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
140 | - if ($desc) { |
|
141 | - $enc->title = clean($desc->nodeValue); |
|
142 | - } |
|
143 | - } |
|
135 | + $desc = $this->xpath->query("media:description", $content)->item(0); |
|
136 | + if ($desc) { |
|
137 | + $enc->title = clean($desc->nodeValue); |
|
138 | + } else { |
|
139 | + $desc = $this->xpath->query("media:description", $enclosure)->item(0); |
|
140 | + if ($desc) { |
|
141 | + $enc->title = clean($desc->nodeValue); |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - array_push($encs, $enc); |
|
146 | - } |
|
147 | - } |
|
145 | + array_push($encs, $enc); |
|
146 | + } |
|
147 | + } |
|
148 | 148 | |
149 | - $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
149 | + $enclosures = $this->xpath->query("media:thumbnail", $this->elem); |
|
150 | 150 | |
151 | - foreach ($enclosures as $enclosure) { |
|
152 | - $enc = new FeedEnclosure(); |
|
151 | + foreach ($enclosures as $enclosure) { |
|
152 | + $enc = new FeedEnclosure(); |
|
153 | 153 | |
154 | - $enc->type = "image/generic"; |
|
155 | - $enc->link = clean($enclosure->getAttribute("url")); |
|
156 | - $enc->height = clean($enclosure->getAttribute("height")); |
|
157 | - $enc->width = clean($enclosure->getAttribute("width")); |
|
154 | + $enc->type = "image/generic"; |
|
155 | + $enc->link = clean($enclosure->getAttribute("url")); |
|
156 | + $enc->height = clean($enclosure->getAttribute("height")); |
|
157 | + $enc->width = clean($enclosure->getAttribute("width")); |
|
158 | 158 | |
159 | - array_push($encs, $enc); |
|
160 | - } |
|
159 | + array_push($encs, $enc); |
|
160 | + } |
|
161 | 161 | |
162 | - return $encs; |
|
163 | - } |
|
162 | + return $encs; |
|
163 | + } |
|
164 | 164 | |
165 | - public function count_children($node) { |
|
166 | - return $node->getElementsByTagName("*")->length; |
|
167 | - } |
|
165 | + public function count_children($node) { |
|
166 | + return $node->getElementsByTagName("*")->length; |
|
167 | + } |
|
168 | 168 | |
169 | - public function subtree_or_text($node) { |
|
170 | - if ($this->count_children($node) == 0) { |
|
171 | - return $node->nodeValue; |
|
172 | - } else { |
|
173 | - return $node->c14n(); |
|
174 | - } |
|
175 | - } |
|
169 | + public function subtree_or_text($node) { |
|
170 | + if ($this->count_children($node) == 0) { |
|
171 | + return $node->nodeValue; |
|
172 | + } else { |
|
173 | + return $node->c14n(); |
|
174 | + } |
|
175 | + } |
|
176 | 176 | |
177 | - public static function normalize_categories($cats) { |
|
177 | + public static function normalize_categories($cats) { |
|
178 | 178 | |
179 | - $tmp = []; |
|
179 | + $tmp = []; |
|
180 | 180 | |
181 | - foreach ($cats as $rawcat) { |
|
182 | - $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
183 | - } |
|
181 | + foreach ($cats as $rawcat) { |
|
182 | + $tmp = array_merge($tmp, explode(",", $rawcat)); |
|
183 | + } |
|
184 | 184 | |
185 | - $tmp = array_map(function($srccat) { |
|
186 | - $cat = clean(trim(mb_strtolower($srccat))); |
|
185 | + $tmp = array_map(function($srccat) { |
|
186 | + $cat = clean(trim(mb_strtolower($srccat))); |
|
187 | 187 | |
188 | - // we don't support numeric tags |
|
189 | - if (is_numeric($cat)) |
|
190 | - $cat = 't:'.$cat; |
|
188 | + // we don't support numeric tags |
|
189 | + if (is_numeric($cat)) |
|
190 | + $cat = 't:'.$cat; |
|
191 | 191 | |
192 | - $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
192 | + $cat = preg_replace('/[,\'\"]/', "", $cat); |
|
193 | 193 | |
194 | - if (DB_TYPE == "mysql") { |
|
195 | - $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
196 | - } |
|
194 | + if (DB_TYPE == "mysql") { |
|
195 | + $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat); |
|
196 | + } |
|
197 | 197 | |
198 | - if (mb_strlen($cat) > 250) { |
|
199 | - $cat = mb_substr($cat, 0, 250); |
|
200 | - } |
|
198 | + if (mb_strlen($cat) > 250) { |
|
199 | + $cat = mb_substr($cat, 0, 250); |
|
200 | + } |
|
201 | 201 | |
202 | - return $cat; |
|
203 | - }, $tmp); |
|
202 | + return $cat; |
|
203 | + }, $tmp); |
|
204 | 204 | |
205 | - asort($tmp); |
|
205 | + asort($tmp); |
|
206 | 206 | |
207 | - return array_unique($tmp); |
|
208 | - } |
|
207 | + return array_unique($tmp); |
|
208 | + } |
|
209 | 209 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | while ($line = $sth->fetch()) { |
55 | 55 | |
56 | 56 | if (!$subject) { |
57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
57 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
@@ -1,96 +1,96 @@ |
||
1 | 1 | <?php |
2 | 2 | class MailTo extends Plugin { |
3 | - private $host; |
|
3 | + private $host; |
|
4 | 4 | |
5 | - public function about() { |
|
6 | - return array(1.0, |
|
7 | - "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | - "fox"); |
|
9 | - } |
|
5 | + public function about() { |
|
6 | + return array(1.0, |
|
7 | + "Share article via email (using mailto: links, invoking your mail client)", |
|
8 | + "fox"); |
|
9 | + } |
|
10 | 10 | |
11 | - public function init($host) { |
|
12 | - $this->host = $host; |
|
11 | + public function init($host) { |
|
12 | + $this->host = $host; |
|
13 | 13 | |
14 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | - } |
|
14 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
15 | + } |
|
16 | 16 | |
17 | - public function get_js() { |
|
18 | - return file_get_contents(dirname(__FILE__)."/init.js"); |
|
19 | - } |
|
17 | + public function get_js() { |
|
18 | + return file_get_contents(dirname(__FILE__)."/init.js"); |
|
19 | + } |
|
20 | 20 | |
21 | - public function hook_article_button($line) { |
|
22 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
21 | + public function hook_article_button($line) { |
|
22 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
23 | 23 | onclick=\"Plugins.Mailto.send(".$line["id"].")\" |
24 | 24 | title='".__('Forward by email')."'>mail_outline</i>"; |
25 | - } |
|
25 | + } |
|
26 | 26 | |
27 | - public function emailArticle() { |
|
27 | + public function emailArticle() { |
|
28 | 28 | |
29 | - $ids = explode(",", $_REQUEST['param']); |
|
30 | - $ids_qmarks = arr_qmarks($ids); |
|
29 | + $ids = explode(",", $_REQUEST['param']); |
|
30 | + $ids_qmarks = arr_qmarks($ids); |
|
31 | 31 | |
32 | - require_once "lib/MiniTemplator.class.php"; |
|
32 | + require_once "lib/MiniTemplator.class.php"; |
|
33 | 33 | |
34 | - $tpl = new MiniTemplator; |
|
34 | + $tpl = new MiniTemplator; |
|
35 | 35 | |
36 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
36 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
37 | 37 | |
38 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | - //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
38 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
39 | + //$tpl->setVariable('USER_EMAIL', $user_email, true); |
|
40 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
41 | 41 | |
42 | 42 | |
43 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
43 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title |
|
44 | 44 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
45 | 45 | id IN ($ids_qmarks) AND owner_uid = ?"); |
46 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
46 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
47 | 47 | |
48 | - if (count($ids) > 1) { |
|
49 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
50 | - } else { |
|
51 | - $subject = ""; |
|
52 | - } |
|
48 | + if (count($ids) > 1) { |
|
49 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
50 | + } else { |
|
51 | + $subject = ""; |
|
52 | + } |
|
53 | 53 | |
54 | - while ($line = $sth->fetch()) { |
|
54 | + while ($line = $sth->fetch()) { |
|
55 | 55 | |
56 | - if (!$subject) { |
|
57 | - $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
58 | - } |
|
56 | + if (!$subject) { |
|
57 | + $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]); |
|
58 | + } |
|
59 | 59 | |
60 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
61 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
60 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
61 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
62 | 62 | |
63 | - $tpl->addBlock('article'); |
|
64 | - } |
|
63 | + $tpl->addBlock('article'); |
|
64 | + } |
|
65 | 65 | |
66 | - $tpl->addBlock('email'); |
|
66 | + $tpl->addBlock('email'); |
|
67 | 67 | |
68 | - $content = ""; |
|
69 | - $tpl->generateOutputToString($content); |
|
68 | + $content = ""; |
|
69 | + $tpl->generateOutputToString($content); |
|
70 | 70 | |
71 | - $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
72 | - "&body=".rawurlencode($content)); |
|
71 | + $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject). |
|
72 | + "&body=".rawurlencode($content)); |
|
73 | 73 | |
74 | - print __("Clicking the following link to invoke your mail client:"); |
|
74 | + print __("Clicking the following link to invoke your mail client:"); |
|
75 | 75 | |
76 | - print "<div class='panel text-center'>"; |
|
77 | - print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
78 | - __("Forward selected article(s) by email.")."</a>"; |
|
79 | - print "</div>"; |
|
76 | + print "<div class='panel text-center'>"; |
|
77 | + print "<a target=\"_blank\" href=\"$mailto_link\">". |
|
78 | + __("Forward selected article(s) by email.")."</a>"; |
|
79 | + print "</div>"; |
|
80 | 80 | |
81 | - print __("You should be able to edit the message before sending in your mail client."); |
|
81 | + print __("You should be able to edit the message before sending in your mail client."); |
|
82 | 82 | |
83 | - print "<p>"; |
|
83 | + print "<p>"; |
|
84 | 84 | |
85 | - print "<footer class='text-center'>"; |
|
86 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
87 | - print "</footer>"; |
|
85 | + print "<footer class='text-center'>"; |
|
86 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>"; |
|
87 | + print "</footer>"; |
|
88 | 88 | |
89 | - //return; |
|
90 | - } |
|
89 | + //return; |
|
90 | + } |
|
91 | 91 | |
92 | - public function api_version() { |
|
93 | - return 2; |
|
94 | - } |
|
92 | + public function api_version() { |
|
93 | + return 2; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |
@@ -124,8 +124,9 @@ |
||
124 | 124 | |
125 | 125 | while ($line = $sth->fetch()) { |
126 | 126 | |
127 | - if (!$subject) |
|
128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
127 | + if (!$subject) { |
|
128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
129 | + } |
|
129 | 130 | |
130 | 131 | $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
131 | 132 | $tnote = strip_tags($line["note"]); |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Mail extends Plugin { |
3 | 3 | |
4 | - /* @var PluginHost $host */ |
|
5 | - private $host; |
|
4 | + /* @var PluginHost $host */ |
|
5 | + private $host; |
|
6 | 6 | |
7 | - public function about() { |
|
8 | - return array(1.0, |
|
9 | - "Share article via email", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(1.0, |
|
9 | + "Share article via email", |
|
10 | + "fox"); |
|
11 | + } |
|
12 | 12 | |
13 | - public function init($host) { |
|
14 | - $this->host = $host; |
|
13 | + public function init($host) { |
|
14 | + $this->host = $host; |
|
15 | 15 | |
16 | - $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
17 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
18 | - } |
|
16 | + $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this); |
|
17 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
18 | + } |
|
19 | 19 | |
20 | - public function get_js() { |
|
21 | - return file_get_contents(dirname(__FILE__)."/mail.js"); |
|
22 | - } |
|
20 | + public function get_js() { |
|
21 | + return file_get_contents(dirname(__FILE__)."/mail.js"); |
|
22 | + } |
|
23 | 23 | |
24 | - public function save() { |
|
25 | - $addresslist = $_POST["addresslist"]; |
|
24 | + public function save() { |
|
25 | + $addresslist = $_POST["addresslist"]; |
|
26 | 26 | |
27 | - $this->host->set($this, "addresslist", $addresslist); |
|
27 | + $this->host->set($this, "addresslist", $addresslist); |
|
28 | 28 | |
29 | - echo __("Mail addresses saved."); |
|
30 | - } |
|
29 | + echo __("Mail addresses saved."); |
|
30 | + } |
|
31 | 31 | |
32 | - public function hook_prefs_tab($args) { |
|
33 | - if ($args != "prefPrefs") { |
|
34 | - return; |
|
35 | - } |
|
32 | + public function hook_prefs_tab($args) { |
|
33 | + if ($args != "prefPrefs") { |
|
34 | + return; |
|
35 | + } |
|
36 | 36 | |
37 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
37 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
38 | 38 | title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">"; |
39 | 39 | |
40 | - print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>"; |
|
40 | + print "<p>".__("You can set predefined email addressed here (comma-separated list):")."</p>"; |
|
41 | 41 | |
42 | - print "<form dojoType=\"dijit.form.Form\">"; |
|
42 | + print "<form dojoType=\"dijit.form.Form\">"; |
|
43 | 43 | |
44 | - print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
44 | + print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\"> |
|
45 | 45 | evt.preventDefault(); |
46 | 46 | if (this.validate()) { |
47 | 47 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -55,140 +55,140 @@ discard block |
||
55 | 55 | } |
56 | 56 | </script>"; |
57 | 57 | |
58 | - print_hidden("op", "pluginhandler"); |
|
59 | - print_hidden("method", "save"); |
|
60 | - print_hidden("plugin", "mail"); |
|
58 | + print_hidden("op", "pluginhandler"); |
|
59 | + print_hidden("method", "save"); |
|
60 | + print_hidden("plugin", "mail"); |
|
61 | 61 | |
62 | - $addresslist = $this->host->get($this, "addresslist"); |
|
62 | + $addresslist = $this->host->get($this, "addresslist"); |
|
63 | 63 | |
64 | - print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
64 | + print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\" |
|
65 | 65 | name='addresslist'>$addresslist</textarea>"; |
66 | 66 | |
67 | - print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
68 | - __("Save")."</button>"; |
|
67 | + print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">". |
|
68 | + __("Save")."</button>"; |
|
69 | 69 | |
70 | - print "</form>"; |
|
70 | + print "</form>"; |
|
71 | 71 | |
72 | - print "</div>"; |
|
73 | - } |
|
72 | + print "</div>"; |
|
73 | + } |
|
74 | 74 | |
75 | - public function hook_article_button($line) { |
|
76 | - return "<i class='material-icons' style=\"cursor : pointer\" |
|
75 | + public function hook_article_button($line) { |
|
76 | + return "<i class='material-icons' style=\"cursor : pointer\" |
|
77 | 77 | onclick=\"Plugins.Mail.send(".$line["id"].")\" |
78 | 78 | title='".__('Forward by email')."'>mail</i>"; |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - public function emailArticle() { |
|
81 | + public function emailArticle() { |
|
82 | 82 | |
83 | - $ids = explode(",", $_REQUEST['param']); |
|
84 | - $ids_qmarks = arr_qmarks($ids); |
|
83 | + $ids = explode(",", $_REQUEST['param']); |
|
84 | + $ids_qmarks = arr_qmarks($ids); |
|
85 | 85 | |
86 | - print_hidden("op", "pluginhandler"); |
|
87 | - print_hidden("plugin", "mail"); |
|
88 | - print_hidden("method", "sendEmail"); |
|
86 | + print_hidden("op", "pluginhandler"); |
|
87 | + print_hidden("plugin", "mail"); |
|
88 | + print_hidden("method", "sendEmail"); |
|
89 | 89 | |
90 | - $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
90 | + $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE |
|
91 | 91 | id = ?"); |
92 | - $sth->execute([$_SESSION['uid']]); |
|
92 | + $sth->execute([$_SESSION['uid']]); |
|
93 | 93 | |
94 | - if ($row = $sth->fetch()) { |
|
95 | - $user_email = htmlspecialchars($row['email']); |
|
96 | - $user_name = htmlspecialchars($row['full_name']); |
|
97 | - } |
|
94 | + if ($row = $sth->fetch()) { |
|
95 | + $user_email = htmlspecialchars($row['email']); |
|
96 | + $user_name = htmlspecialchars($row['full_name']); |
|
97 | + } |
|
98 | 98 | |
99 | - if (!$user_name) { |
|
100 | - $user_name = $_SESSION['name']; |
|
101 | - } |
|
99 | + if (!$user_name) { |
|
100 | + $user_name = $_SESSION['name']; |
|
101 | + } |
|
102 | 102 | |
103 | - print_hidden("from_email", "$user_email"); |
|
104 | - print_hidden("from_name", "$user_name"); |
|
103 | + print_hidden("from_email", "$user_email"); |
|
104 | + print_hidden("from_name", "$user_name"); |
|
105 | 105 | |
106 | - require_once "lib/MiniTemplator.class.php"; |
|
106 | + require_once "lib/MiniTemplator.class.php"; |
|
107 | 107 | |
108 | - $tpl = new MiniTemplator; |
|
108 | + $tpl = new MiniTemplator; |
|
109 | 109 | |
110 | - $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
110 | + $tpl->readTemplateFromFile("templates/email_article_template.txt"); |
|
111 | 111 | |
112 | - $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
113 | - $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
114 | - $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
112 | + $tpl->setVariable('USER_NAME', $_SESSION["name"], true); |
|
113 | + $tpl->setVariable('USER_EMAIL', $user_email, true); |
|
114 | + $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true); |
|
115 | 115 | |
116 | - $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
116 | + $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note |
|
117 | 117 | FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND |
118 | 118 | id IN ($ids_qmarks) AND owner_uid = ?"); |
119 | - $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
119 | + $sth->execute(array_merge($ids, [$_SESSION['uid']])); |
|
120 | 120 | |
121 | - if (count($ids) > 1) { |
|
122 | - $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
123 | - } |
|
121 | + if (count($ids) > 1) { |
|
122 | + $subject = __("[Forwarded]")." ".__("Multiple articles"); |
|
123 | + } |
|
124 | 124 | |
125 | - while ($line = $sth->fetch()) { |
|
125 | + while ($line = $sth->fetch()) { |
|
126 | 126 | |
127 | - if (!$subject) |
|
128 | - $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
127 | + if (!$subject) |
|
128 | + $subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]); |
|
129 | 129 | |
130 | - $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
131 | - $tnote = strip_tags($line["note"]); |
|
132 | - if ($tnote != '') { |
|
133 | - $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
134 | - $tpl->addBlock('note'); |
|
135 | - } |
|
136 | - $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
130 | + $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"])); |
|
131 | + $tnote = strip_tags($line["note"]); |
|
132 | + if ($tnote != '') { |
|
133 | + $tpl->setVariable('ARTICLE_NOTE', $tnote, true); |
|
134 | + $tpl->addBlock('note'); |
|
135 | + } |
|
136 | + $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"])); |
|
137 | 137 | |
138 | - $tpl->addBlock('article'); |
|
139 | - } |
|
138 | + $tpl->addBlock('article'); |
|
139 | + } |
|
140 | 140 | |
141 | - $tpl->addBlock('email'); |
|
141 | + $tpl->addBlock('email'); |
|
142 | 142 | |
143 | - $content = ""; |
|
144 | - $tpl->generateOutputToString($content); |
|
143 | + $content = ""; |
|
144 | + $tpl->generateOutputToString($content); |
|
145 | 145 | |
146 | - print "<table width='100%'><tr><td>"; |
|
146 | + print "<table width='100%'><tr><td>"; |
|
147 | 147 | |
148 | - $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
148 | + $addresslist = explode(",", $this->host->get($this, "addresslist")); |
|
149 | 149 | |
150 | - print __('To:'); |
|
150 | + print __('To:'); |
|
151 | 151 | |
152 | - print "</td><td>"; |
|
152 | + print "</td><td>"; |
|
153 | 153 | |
154 | 154 | /* print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\" |
155 | 155 | style=\"width : 30em;\" |
156 | 156 | name=\"destination\" id=\"emailArticleDlg_destination\">"; */ |
157 | 157 | |
158 | - print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
158 | + print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"'); |
|
159 | 159 | |
160 | 160 | /* print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\" |
161 | 161 | style=\"z-index: 30; display : none\"></div>"; */ |
162 | 162 | |
163 | - print "</td></tr><tr><td>"; |
|
163 | + print "</td></tr><tr><td>"; |
|
164 | 164 | |
165 | - print __('Subject:'); |
|
165 | + print __('Subject:'); |
|
166 | 166 | |
167 | - print "</td><td>"; |
|
167 | + print "</td><td>"; |
|
168 | 168 | |
169 | - print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
169 | + print "<input dojoType='dijit.form.ValidationTextBox' required='true' |
|
170 | 170 | style='width : 30em;' name='subject' value=\"$subject\" id='subject'>"; |
171 | 171 | |
172 | - print "</td></tr>"; |
|
172 | + print "</td></tr>"; |
|
173 | 173 | |
174 | - print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
174 | + print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea' |
|
175 | 175 | style='height : 200px; font-size : 12px; width : 98%' rows=\"20\" |
176 | 176 | name='content'>$content</textarea>"; |
177 | 177 | |
178 | - print "</td></tr></table>"; |
|
178 | + print "</td></tr></table>"; |
|
179 | 179 | |
180 | - print "<footer>"; |
|
181 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
182 | - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
183 | - print "</footer>"; |
|
180 | + print "<footer>"; |
|
181 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> "; |
|
182 | + print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>"; |
|
183 | + print "</footer>"; |
|
184 | 184 | |
185 | - //return; |
|
186 | - } |
|
185 | + //return; |
|
186 | + } |
|
187 | 187 | |
188 | - public function sendEmail() { |
|
189 | - $reply = array(); |
|
188 | + public function sendEmail() { |
|
189 | + $reply = array(); |
|
190 | 190 | |
191 | - /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
191 | + /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']), |
|
192 | 192 | strip_tags($_REQUEST['from_name'])); |
193 | 193 | //$mail->AddAddress($_REQUEST['destination']); |
194 | 194 | $addresses = explode(';', $_REQUEST['destination']); |
@@ -201,29 +201,29 @@ discard block |
||
201 | 201 | |
202 | 202 | $rc = $mail->Send(); */ |
203 | 203 | |
204 | - $to = $_REQUEST["destination"]; |
|
205 | - $subject = strip_tags($_REQUEST["subject"]); |
|
206 | - $message = strip_tags($_REQUEST["content"]); |
|
207 | - $from = strip_tags($_REQUEST["from_email"]); |
|
204 | + $to = $_REQUEST["destination"]; |
|
205 | + $subject = strip_tags($_REQUEST["subject"]); |
|
206 | + $message = strip_tags($_REQUEST["content"]); |
|
207 | + $from = strip_tags($_REQUEST["from_email"]); |
|
208 | 208 | |
209 | - $mailer = new Mailer(); |
|
209 | + $mailer = new Mailer(); |
|
210 | 210 | |
211 | - $rc = $mailer->mail(["to_address" => $to, |
|
212 | - "headers" => ["Reply-To: $from"], |
|
213 | - "subject" => $subject, |
|
214 | - "message" => $message]); |
|
211 | + $rc = $mailer->mail(["to_address" => $to, |
|
212 | + "headers" => ["Reply-To: $from"], |
|
213 | + "subject" => $subject, |
|
214 | + "message" => $message]); |
|
215 | 215 | |
216 | - if (!$rc) { |
|
217 | - $reply['error'] = $mailer->error(); |
|
218 | - } else { |
|
219 | - //save_email_address($destination); |
|
220 | - $reply['message'] = "UPDATE_COUNTERS"; |
|
221 | - } |
|
216 | + if (!$rc) { |
|
217 | + $reply['error'] = $mailer->error(); |
|
218 | + } else { |
|
219 | + //save_email_address($destination); |
|
220 | + $reply['message'] = "UPDATE_COUNTERS"; |
|
221 | + } |
|
222 | 222 | |
223 | - print json_encode($reply); |
|
224 | - } |
|
223 | + print json_encode($reply); |
|
224 | + } |
|
225 | 225 | |
226 | - /* function completeEmails() { |
|
226 | + /* function completeEmails() { |
|
227 | 227 | $search = $_REQUEST["search"]; |
228 | 228 | |
229 | 229 | print "<ul>"; |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | print "</ul>"; |
238 | 238 | } */ |
239 | 239 | |
240 | - public function api_version() { |
|
241 | - return 2; |
|
242 | - } |
|
240 | + public function api_version() { |
|
241 | + return 2; |
|
242 | + } |
|
243 | 243 | |
244 | 244 | } |
@@ -1,133 +1,133 @@ |
||
1 | 1 | <?php |
2 | - set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
3 | - get_include_path()); |
|
4 | - |
|
5 | - $op = $_REQUEST["op"]; |
|
6 | - @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
|
7 | - |
|
8 | - if (!$method) { |
|
9 | - $method = 'index'; |
|
10 | - } else { |
|
11 | - $method = strtolower($method); |
|
12 | - } |
|
13 | - |
|
14 | - /* Public calls compatibility shim */ |
|
15 | - |
|
16 | - $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", |
|
17 | - "fbexport", "logout", "pubsub"); |
|
18 | - |
|
19 | - if (array_search($op, $public_calls) !== false) { |
|
20 | - header("Location: public.php?".$_SERVER['QUERY_STRING']); |
|
21 | - return; |
|
22 | - } |
|
23 | - |
|
24 | - @$csrf_token = $_REQUEST['csrf_token']; |
|
25 | - |
|
26 | - require_once "autoload.php"; |
|
27 | - require_once "sessions.php"; |
|
28 | - require_once "functions.php"; |
|
29 | - require_once "config.php"; |
|
30 | - require_once "db.php"; |
|
31 | - require_once "db-prefs.php"; |
|
32 | - |
|
33 | - startup_gettext(); |
|
34 | - |
|
35 | - $script_started = microtime(true); |
|
36 | - |
|
37 | - if (!init_plugins()) { |
|
38 | - return; |
|
39 | - } |
|
40 | - |
|
41 | - header("Content-Type: text/json; charset=utf-8"); |
|
42 | - |
|
43 | - if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
44 | - ob_start("ob_gzhandler"); |
|
45 | - } |
|
46 | - |
|
47 | - if (SINGLE_USER_MODE) { |
|
48 | - authenticate_user("admin", null); |
|
49 | - } |
|
50 | - |
|
51 | - if ($_SESSION["uid"]) { |
|
52 | - if (!validate_session()) { |
|
53 | - header("Content-Type: text/json"); |
|
54 | - print error_json(6); |
|
55 | - return; |
|
56 | - } |
|
57 | - load_user_plugins($_SESSION["uid"]); |
|
58 | - } |
|
59 | - |
|
60 | - $purge_intervals = array( |
|
61 | - 0 => __("Use default"), |
|
62 | - -1 => __("Never purge"), |
|
63 | - 5 => __("1 week old"), |
|
64 | - 14 => __("2 weeks old"), |
|
65 | - 31 => __("1 month old"), |
|
66 | - 60 => __("2 months old"), |
|
67 | - 90 => __("3 months old")); |
|
68 | - |
|
69 | - $update_intervals = array( |
|
70 | - 0 => __("Default interval"), |
|
71 | - -1 => __("Disable updates"), |
|
72 | - 15 => __("15 minutes"), |
|
73 | - 30 => __("30 minutes"), |
|
74 | - 60 => __("Hourly"), |
|
75 | - 240 => __("4 hours"), |
|
76 | - 720 => __("12 hours"), |
|
77 | - 1440 => __("Daily"), |
|
78 | - 10080 => __("Weekly")); |
|
79 | - |
|
80 | - $update_intervals_nodefault = array( |
|
81 | - -1 => __("Disable updates"), |
|
82 | - 15 => __("15 minutes"), |
|
83 | - 30 => __("30 minutes"), |
|
84 | - 60 => __("Hourly"), |
|
85 | - 240 => __("4 hours"), |
|
86 | - 720 => __("12 hours"), |
|
87 | - 1440 => __("Daily"), |
|
88 | - 10080 => __("Weekly")); |
|
89 | - |
|
90 | - $access_level_names = array( |
|
91 | - 0 => __("User"), |
|
92 | - 5 => __("Power User"), |
|
93 | - 10 => __("Administrator")); |
|
94 | - |
|
95 | - $op = str_replace("-", "_", $op); |
|
96 | - |
|
97 | - $override = PluginHost::getInstance()->lookup_handler($op, $method); |
|
98 | - |
|
99 | - if (class_exists($op) || $override) { |
|
100 | - |
|
101 | - if ($override) { |
|
102 | - $handler = $override; |
|
103 | - } else { |
|
104 | - $handler = new $op($_REQUEST); |
|
105 | - } |
|
106 | - |
|
107 | - if ($handler && implements_interface($handler, 'IHandler')) { |
|
108 | - if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
|
109 | - if ($handler->before($method)) { |
|
110 | - if ($method && method_exists($handler, $method)) { |
|
111 | - $handler->$method(); |
|
112 | - } else { |
|
113 | - if (method_exists($handler, "catchall")) { |
|
114 | - $handler->catchall($method); |
|
115 | - } |
|
116 | - } |
|
117 | - $handler->after(); |
|
118 | - return; |
|
119 | - } else { |
|
120 | - header("Content-Type: text/json"); |
|
121 | - print error_json(6); |
|
122 | - return; |
|
123 | - } |
|
124 | - } else { |
|
125 | - header("Content-Type: text/json"); |
|
126 | - print error_json(6); |
|
127 | - return; |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - header("Content-Type: text/json"); |
|
133 | - print error_json(13); |
|
2 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
3 | + get_include_path()); |
|
4 | + |
|
5 | + $op = $_REQUEST["op"]; |
|
6 | + @$method = $_REQUEST['subop'] ? $_REQUEST['subop'] : $_REQUEST["method"]; |
|
7 | + |
|
8 | + if (!$method) { |
|
9 | + $method = 'index'; |
|
10 | + } else { |
|
11 | + $method = strtolower($method); |
|
12 | + } |
|
13 | + |
|
14 | + /* Public calls compatibility shim */ |
|
15 | + |
|
16 | + $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", |
|
17 | + "fbexport", "logout", "pubsub"); |
|
18 | + |
|
19 | + if (array_search($op, $public_calls) !== false) { |
|
20 | + header("Location: public.php?".$_SERVER['QUERY_STRING']); |
|
21 | + return; |
|
22 | + } |
|
23 | + |
|
24 | + @$csrf_token = $_REQUEST['csrf_token']; |
|
25 | + |
|
26 | + require_once "autoload.php"; |
|
27 | + require_once "sessions.php"; |
|
28 | + require_once "functions.php"; |
|
29 | + require_once "config.php"; |
|
30 | + require_once "db.php"; |
|
31 | + require_once "db-prefs.php"; |
|
32 | + |
|
33 | + startup_gettext(); |
|
34 | + |
|
35 | + $script_started = microtime(true); |
|
36 | + |
|
37 | + if (!init_plugins()) { |
|
38 | + return; |
|
39 | + } |
|
40 | + |
|
41 | + header("Content-Type: text/json; charset=utf-8"); |
|
42 | + |
|
43 | + if (ENABLE_GZIP_OUTPUT && function_exists("ob_gzhandler")) { |
|
44 | + ob_start("ob_gzhandler"); |
|
45 | + } |
|
46 | + |
|
47 | + if (SINGLE_USER_MODE) { |
|
48 | + authenticate_user("admin", null); |
|
49 | + } |
|
50 | + |
|
51 | + if ($_SESSION["uid"]) { |
|
52 | + if (!validate_session()) { |
|
53 | + header("Content-Type: text/json"); |
|
54 | + print error_json(6); |
|
55 | + return; |
|
56 | + } |
|
57 | + load_user_plugins($_SESSION["uid"]); |
|
58 | + } |
|
59 | + |
|
60 | + $purge_intervals = array( |
|
61 | + 0 => __("Use default"), |
|
62 | + -1 => __("Never purge"), |
|
63 | + 5 => __("1 week old"), |
|
64 | + 14 => __("2 weeks old"), |
|
65 | + 31 => __("1 month old"), |
|
66 | + 60 => __("2 months old"), |
|
67 | + 90 => __("3 months old")); |
|
68 | + |
|
69 | + $update_intervals = array( |
|
70 | + 0 => __("Default interval"), |
|
71 | + -1 => __("Disable updates"), |
|
72 | + 15 => __("15 minutes"), |
|
73 | + 30 => __("30 minutes"), |
|
74 | + 60 => __("Hourly"), |
|
75 | + 240 => __("4 hours"), |
|
76 | + 720 => __("12 hours"), |
|
77 | + 1440 => __("Daily"), |
|
78 | + 10080 => __("Weekly")); |
|
79 | + |
|
80 | + $update_intervals_nodefault = array( |
|
81 | + -1 => __("Disable updates"), |
|
82 | + 15 => __("15 minutes"), |
|
83 | + 30 => __("30 minutes"), |
|
84 | + 60 => __("Hourly"), |
|
85 | + 240 => __("4 hours"), |
|
86 | + 720 => __("12 hours"), |
|
87 | + 1440 => __("Daily"), |
|
88 | + 10080 => __("Weekly")); |
|
89 | + |
|
90 | + $access_level_names = array( |
|
91 | + 0 => __("User"), |
|
92 | + 5 => __("Power User"), |
|
93 | + 10 => __("Administrator")); |
|
94 | + |
|
95 | + $op = str_replace("-", "_", $op); |
|
96 | + |
|
97 | + $override = PluginHost::getInstance()->lookup_handler($op, $method); |
|
98 | + |
|
99 | + if (class_exists($op) || $override) { |
|
100 | + |
|
101 | + if ($override) { |
|
102 | + $handler = $override; |
|
103 | + } else { |
|
104 | + $handler = new $op($_REQUEST); |
|
105 | + } |
|
106 | + |
|
107 | + if ($handler && implements_interface($handler, 'IHandler')) { |
|
108 | + if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { |
|
109 | + if ($handler->before($method)) { |
|
110 | + if ($method && method_exists($handler, $method)) { |
|
111 | + $handler->$method(); |
|
112 | + } else { |
|
113 | + if (method_exists($handler, "catchall")) { |
|
114 | + $handler->catchall($method); |
|
115 | + } |
|
116 | + } |
|
117 | + $handler->after(); |
|
118 | + return; |
|
119 | + } else { |
|
120 | + header("Content-Type: text/json"); |
|
121 | + print error_json(6); |
|
122 | + return; |
|
123 | + } |
|
124 | + } else { |
|
125 | + header("Content-Type: text/json"); |
|
126 | + print error_json(6); |
|
127 | + return; |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + header("Content-Type: text/json"); |
|
133 | + print error_json(13); |
@@ -1,197 +1,197 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics extends Plugin { |
3 | 3 | |
4 | - private $host; |
|
5 | - private $filters = array(); |
|
4 | + private $host; |
|
5 | + private $filters = array(); |
|
6 | 6 | |
7 | - public function about() { |
|
8 | - return array(2.0, |
|
9 | - "Fixes RSS feeds of assorted comic strips", |
|
10 | - "fox"); |
|
11 | - } |
|
7 | + public function about() { |
|
8 | + return array(2.0, |
|
9 | + "Fixes RSS feeds of assorted comic strips", |
|
10 | + "fox"); |
|
11 | + } |
|
12 | 12 | |
13 | - public function init($host) { |
|
14 | - $this->host = $host; |
|
13 | + public function init($host) { |
|
14 | + $this->host = $host; |
|
15 | 15 | |
16 | - $host->add_hook($host::HOOK_FETCH_FEED, $this); |
|
17 | - $host->add_hook($host::HOOK_FEED_BASIC_INFO, $this); |
|
18 | - $host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this); |
|
19 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
16 | + $host->add_hook($host::HOOK_FETCH_FEED, $this); |
|
17 | + $host->add_hook($host::HOOK_FEED_BASIC_INFO, $this); |
|
18 | + $host->add_hook($host::HOOK_SUBSCRIBE_FEED, $this); |
|
19 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
20 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
21 | 21 | |
22 | - require_once __DIR__."/filter_base.php"; |
|
22 | + require_once __DIR__."/filter_base.php"; |
|
23 | 23 | |
24 | - $filters = array_merge(glob(__DIR__."/filters.local/*.php"), glob(__DIR__."/filters/*.php")); |
|
25 | - $names = []; |
|
24 | + $filters = array_merge(glob(__DIR__."/filters.local/*.php"), glob(__DIR__."/filters/*.php")); |
|
25 | + $names = []; |
|
26 | 26 | |
27 | - foreach ($filters as $file) { |
|
28 | - $filter_name = preg_replace("/\..*$/", "", basename($file)); |
|
27 | + foreach ($filters as $file) { |
|
28 | + $filter_name = preg_replace("/\..*$/", "", basename($file)); |
|
29 | 29 | |
30 | - if (array_search($filter_name, $names) === false) { |
|
31 | - if (!class_exists($filter_name)) { |
|
32 | - require_once $file; |
|
33 | - } |
|
30 | + if (array_search($filter_name, $names) === false) { |
|
31 | + if (!class_exists($filter_name)) { |
|
32 | + require_once $file; |
|
33 | + } |
|
34 | 34 | |
35 | - array_push($names, $filter_name); |
|
35 | + array_push($names, $filter_name); |
|
36 | 36 | |
37 | - $filter = new $filter_name(); |
|
37 | + $filter = new $filter_name(); |
|
38 | 38 | |
39 | - if (is_subclass_of($filter, "Af_ComicFilter")) { |
|
40 | - array_push($this->filters, $filter); |
|
41 | - array_push($names, $filter_name); |
|
42 | - } |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
39 | + if (is_subclass_of($filter, "Af_ComicFilter")) { |
|
40 | + array_push($this->filters, $filter); |
|
41 | + array_push($names, $filter_name); |
|
42 | + } |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - public function hook_prefs_tab($args) { |
|
48 | - if ($args != "prefFeeds") { |
|
49 | - return; |
|
50 | - } |
|
47 | + public function hook_prefs_tab($args) { |
|
48 | + if ($args != "prefFeeds") { |
|
49 | + return; |
|
50 | + } |
|
51 | 51 | |
52 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
52 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
53 | 53 | title=\"<i class='material-icons'>photo</i> ".__('Feeds supported by af_comics')."\">"; |
54 | 54 | |
55 | - print "<p>".__("The following comics are currently supported:")."</p>"; |
|
55 | + print "<p>".__("The following comics are currently supported:")."</p>"; |
|
56 | 56 | |
57 | - $comics = array("GoComics"); |
|
57 | + $comics = array("GoComics"); |
|
58 | 58 | |
59 | - foreach ($this->filters as $f) { |
|
60 | - foreach ($f->supported() as $comic) { |
|
61 | - array_push($comics, $comic); |
|
62 | - } |
|
63 | - } |
|
59 | + foreach ($this->filters as $f) { |
|
60 | + foreach ($f->supported() as $comic) { |
|
61 | + array_push($comics, $comic); |
|
62 | + } |
|
63 | + } |
|
64 | 64 | |
65 | - asort($comics); |
|
65 | + asort($comics); |
|
66 | 66 | |
67 | - print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
68 | - foreach ($comics as $comic) { |
|
69 | - print "<li>$comic</li>"; |
|
70 | - } |
|
71 | - print "</ul>"; |
|
67 | + print "<ul class='panel panel-scrollable list list-unstyled'>"; |
|
68 | + foreach ($comics as $comic) { |
|
69 | + print "<li>$comic</li>"; |
|
70 | + } |
|
71 | + print "</ul>"; |
|
72 | 72 | |
73 | - print "<p>".__("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the <em>Garfield</em> comic use <code>http://www.gocomics.com/garfield</code>).")."</p>"; |
|
73 | + print "<p>".__("To subscribe to GoComics use the comic's regular web page as the feed URL (e.g. for the <em>Garfield</em> comic use <code>http://www.gocomics.com/garfield</code>).")."</p>"; |
|
74 | 74 | |
75 | - print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>"; |
|
75 | + print "<p>".__('Drop any updated filters into <code>filters.local</code> in plugin directory.')."</p>"; |
|
76 | 76 | |
77 | - print "</div>"; |
|
78 | - } |
|
77 | + print "</div>"; |
|
78 | + } |
|
79 | 79 | |
80 | - public function hook_article_filter($article) { |
|
81 | - foreach ($this->filters as $f) { |
|
82 | - if ($f->process($article)) { |
|
83 | - break; |
|
84 | - } |
|
85 | - } |
|
80 | + public function hook_article_filter($article) { |
|
81 | + foreach ($this->filters as $f) { |
|
82 | + if ($f->process($article)) { |
|
83 | + break; |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - return $article; |
|
88 | - } |
|
87 | + return $article; |
|
88 | + } |
|
89 | 89 | |
90 | - // GoComics dropped feed support so it needs to be handled when fetching the feed. |
|
91 | - /** |
|
92 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
93 | - */ |
|
94 | - public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) { |
|
95 | - if ($auth_login || $auth_pass) { |
|
96 | - return $feed_data; |
|
97 | - } |
|
90 | + // GoComics dropped feed support so it needs to be handled when fetching the feed. |
|
91 | + /** |
|
92 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
93 | + */ |
|
94 | + public function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_article_timestamp, $auth_login, $auth_pass) { |
|
95 | + if ($auth_login || $auth_pass) { |
|
96 | + return $feed_data; |
|
97 | + } |
|
98 | 98 | |
99 | - if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
|
100 | - $site_url = 'https://www.gocomics.com/'.$comic[1]; |
|
99 | + if (preg_match('#^https?://(?:feeds\.feedburner\.com/uclick|www\.gocomics\.com)/([-a-z0-9]+)$#i', $fetch_url, $comic)) { |
|
100 | + $site_url = 'https://www.gocomics.com/'.$comic[1]; |
|
101 | 101 | |
102 | - $article_link = $site_url.date('/Y/m/d'); |
|
102 | + $article_link = $site_url.date('/Y/m/d'); |
|
103 | 103 | |
104 | - $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); |
|
104 | + $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); |
|
105 | 105 | |
106 | - require_once 'lib/MiniTemplator.class.php'; |
|
106 | + require_once 'lib/MiniTemplator.class.php'; |
|
107 | 107 | |
108 | - $feed_title = htmlspecialchars($comic[1]); |
|
109 | - $site_url = htmlspecialchars($site_url); |
|
110 | - $article_link = htmlspecialchars($article_link); |
|
108 | + $feed_title = htmlspecialchars($comic[1]); |
|
109 | + $site_url = htmlspecialchars($site_url); |
|
110 | + $article_link = htmlspecialchars($article_link); |
|
111 | 111 | |
112 | - $tpl = new MiniTemplator(); |
|
112 | + $tpl = new MiniTemplator(); |
|
113 | 113 | |
114 | - $tpl->readTemplateFromFile('templates/generated_feed.txt'); |
|
114 | + $tpl->readTemplateFromFile('templates/generated_feed.txt'); |
|
115 | 115 | |
116 | - $tpl->setVariable('FEED_TITLE', $feed_title, true); |
|
117 | - $tpl->setVariable('VERSION', get_version(), true); |
|
118 | - $tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true); |
|
119 | - $tpl->setVariable('SELF_URL', $site_url, true); |
|
116 | + $tpl->setVariable('FEED_TITLE', $feed_title, true); |
|
117 | + $tpl->setVariable('VERSION', get_version(), true); |
|
118 | + $tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true); |
|
119 | + $tpl->setVariable('SELF_URL', $site_url, true); |
|
120 | 120 | |
121 | - if ($body) { |
|
122 | - $doc = new DOMDocument(); |
|
121 | + if ($body) { |
|
122 | + $doc = new DOMDocument(); |
|
123 | 123 | |
124 | - if (@$doc->loadHTML($body)) { |
|
125 | - $xpath = new DOMXPath($doc); |
|
124 | + if (@$doc->loadHTML($body)) { |
|
125 | + $xpath = new DOMXPath($doc); |
|
126 | 126 | |
127 | - $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); |
|
127 | + $node = $xpath->query('//picture[contains(@class, "item-comic-image")]/img')->item(0); |
|
128 | 128 | |
129 | - if ($node) { |
|
130 | - $title = $xpath->query('//h1')->item(0); |
|
129 | + if ($node) { |
|
130 | + $title = $xpath->query('//h1')->item(0); |
|
131 | 131 | |
132 | - if ($title) { |
|
133 | - $title = clean(trim($title->nodeValue)); |
|
134 | - } else { |
|
135 | - $title = date('l, F d, Y'); |
|
136 | - } |
|
132 | + if ($title) { |
|
133 | + $title = clean(trim($title->nodeValue)); |
|
134 | + } else { |
|
135 | + $title = date('l, F d, Y'); |
|
136 | + } |
|
137 | 137 | |
138 | - foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr) { |
|
139 | - $node->removeAttribute($attr); |
|
140 | - } |
|
138 | + foreach (['srcset', 'sizes', 'data-srcset', 'width'] as $attr) { |
|
139 | + $node->removeAttribute($attr); |
|
140 | + } |
|
141 | 141 | |
142 | - $tpl->setVariable('ARTICLE_ID', $article_link, true); |
|
143 | - $tpl->setVariable('ARTICLE_LINK', $article_link, true); |
|
144 | - $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', mktime(11, 0, 0)), true); |
|
145 | - $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($title), true); |
|
146 | - $tpl->setVariable('ARTICLE_EXCERPT', '', true); |
|
147 | - $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true); |
|
142 | + $tpl->setVariable('ARTICLE_ID', $article_link, true); |
|
143 | + $tpl->setVariable('ARTICLE_LINK', $article_link, true); |
|
144 | + $tpl->setVariable('ARTICLE_UPDATED_ATOM', date('c', mktime(11, 0, 0)), true); |
|
145 | + $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($title), true); |
|
146 | + $tpl->setVariable('ARTICLE_EXCERPT', '', true); |
|
147 | + $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true); |
|
148 | 148 | |
149 | - $tpl->setVariable('ARTICLE_AUTHOR', '', true); |
|
150 | - $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true); |
|
151 | - $tpl->setVariable('ARTICLE_SOURCE_TITLE', $feed_title, true); |
|
149 | + $tpl->setVariable('ARTICLE_AUTHOR', '', true); |
|
150 | + $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true); |
|
151 | + $tpl->setVariable('ARTICLE_SOURCE_TITLE', $feed_title, true); |
|
152 | 152 | |
153 | - $tpl->addBlock('entry'); |
|
154 | - } |
|
155 | - } |
|
156 | - } |
|
153 | + $tpl->addBlock('entry'); |
|
154 | + } |
|
155 | + } |
|
156 | + } |
|
157 | 157 | |
158 | - $tpl->addBlock('feed'); |
|
158 | + $tpl->addBlock('feed'); |
|
159 | 159 | |
160 | - if ($tpl->generateOutputToString($tmp_data)) { |
|
161 | - $feed_data = $tmp_data; |
|
162 | - } |
|
163 | - } |
|
160 | + if ($tpl->generateOutputToString($tmp_data)) { |
|
161 | + $feed_data = $tmp_data; |
|
162 | + } |
|
163 | + } |
|
164 | 164 | |
165 | - return $feed_data; |
|
166 | - } |
|
165 | + return $feed_data; |
|
166 | + } |
|
167 | 167 | |
168 | - public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { |
|
169 | - if ($auth_login || $auth_pass) { |
|
170 | - return $contents; |
|
171 | - } |
|
168 | + public function hook_subscribe_feed($contents, $url, $auth_login, $auth_pass) { |
|
169 | + if ($auth_login || $auth_pass) { |
|
170 | + return $contents; |
|
171 | + } |
|
172 | 172 | |
173 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) { |
|
174 | - return '<?xml version="1.0" encoding="utf-8"?>'; |
|
175 | - } |
|
176 | - // Get is_html() to return false. |
|
173 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $url)) { |
|
174 | + return '<?xml version="1.0" encoding="utf-8"?>'; |
|
175 | + } |
|
176 | + // Get is_html() to return false. |
|
177 | 177 | |
178 | - return $contents; |
|
179 | - } |
|
178 | + return $contents; |
|
179 | + } |
|
180 | 180 | |
181 | - public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) { |
|
182 | - if ($auth_login || $auth_pass) { |
|
183 | - return $basic_info; |
|
184 | - } |
|
181 | + public function hook_feed_basic_info($basic_info, $fetch_url, $owner_uid, $feed, $auth_login, $auth_pass) { |
|
182 | + if ($auth_login || $auth_pass) { |
|
183 | + return $basic_info; |
|
184 | + } |
|
185 | 185 | |
186 | - if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) { |
|
187 | - $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
188 | - } |
|
186 | + if (preg_match('#^https?://www\.gocomics\.com/([-a-z0-9]+)$#i', $fetch_url, $matches)) { |
|
187 | + $basic_info = array('title' => ucfirst($matches[1]), 'site_url' => $matches[0]); |
|
188 | + } |
|
189 | 189 | |
190 | - return $basic_info; |
|
191 | - } |
|
190 | + return $basic_info; |
|
191 | + } |
|
192 | 192 | |
193 | - public function api_version() { |
|
194 | - return 2; |
|
195 | - } |
|
193 | + public function api_version() { |
|
194 | + return 2; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | } |
@@ -1,37 +1,37 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics_Whomp extends Af_ComicFilter { |
3 | 3 | |
4 | - public function supported() { |
|
5 | - return array("Whomp!"); |
|
6 | - } |
|
4 | + public function supported() { |
|
5 | + return array("Whomp!"); |
|
6 | + } |
|
7 | 7 | |
8 | - public function process(&$article) { |
|
9 | - if (strpos($article["guid"], "whompcomic.com") !== false) { |
|
8 | + public function process(&$article) { |
|
9 | + if (strpos($article["guid"], "whompcomic.com") !== false) { |
|
10 | 10 | |
11 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
12 | - false, false, 0, |
|
13 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
11 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
12 | + false, false, 0, |
|
13 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
14 | 14 | |
15 | - global $fetch_last_error_content; |
|
15 | + global $fetch_last_error_content; |
|
16 | 16 | |
17 | - if (!$res && $fetch_last_error_content) { |
|
18 | - $res = $fetch_last_error_content; |
|
19 | - } |
|
17 | + if (!$res && $fetch_last_error_content) { |
|
18 | + $res = $fetch_last_error_content; |
|
19 | + } |
|
20 | 20 | |
21 | - $doc = new DOMDocument(); |
|
21 | + $doc = new DOMDocument(); |
|
22 | 22 | |
23 | - if (@$doc->loadHTML($res)) { |
|
24 | - $xpath = new DOMXPath($doc); |
|
25 | - $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); |
|
23 | + if (@$doc->loadHTML($res)) { |
|
24 | + $xpath = new DOMXPath($doc); |
|
25 | + $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); |
|
26 | 26 | |
27 | - if ($basenode) { |
|
28 | - $article["content"] = $doc->saveHTML($basenode); |
|
29 | - } |
|
30 | - } |
|
27 | + if ($basenode) { |
|
28 | + $article["content"] = $doc->saveHTML($basenode); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | - return true; |
|
33 | - } |
|
32 | + return true; |
|
33 | + } |
|
34 | 34 | |
35 | - return false; |
|
36 | - } |
|
35 | + return false; |
|
36 | + } |
|
37 | 37 | } |
@@ -1,68 +1,68 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics_Pa extends Af_ComicFilter { |
3 | 3 | |
4 | - public function supported() { |
|
5 | - return array("Penny Arcade"); |
|
6 | - } |
|
4 | + public function supported() { |
|
5 | + return array("Penny Arcade"); |
|
6 | + } |
|
7 | 7 | |
8 | - public function process(&$article) { |
|
9 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
8 | + public function process(&$article) { |
|
9 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
10 | 10 | |
11 | - $doc = new DOMDocument(); |
|
11 | + $doc = new DOMDocument(); |
|
12 | 12 | |
13 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
14 | - $xpath = new DOMXPath($doc); |
|
15 | - $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
13 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
14 | + $xpath = new DOMXPath($doc); |
|
15 | + $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
16 | 16 | |
17 | - if ($basenode) { |
|
18 | - $article["content"] = $doc->saveHTML($basenode); |
|
19 | - } |
|
20 | - } |
|
17 | + if ($basenode) { |
|
18 | + $article["content"] = $doc->saveHTML($basenode); |
|
19 | + } |
|
20 | + } |
|
21 | 21 | |
22 | - return true; |
|
23 | - } |
|
22 | + return true; |
|
23 | + } |
|
24 | 24 | |
25 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
26 | - $doc = new DOMDocument(); |
|
25 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
26 | + $doc = new DOMDocument(); |
|
27 | 27 | |
28 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
29 | - $xpath = new DOMXPath($doc); |
|
30 | - $entries = $xpath->query('(//div[@class="post"])'); |
|
28 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
29 | + $xpath = new DOMXPath($doc); |
|
30 | + $entries = $xpath->query('(//div[@class="post"])'); |
|
31 | 31 | |
32 | - $basenode = false; |
|
32 | + $basenode = false; |
|
33 | 33 | |
34 | - foreach ($entries as $entry) { |
|
35 | - $basenode = $entry; |
|
36 | - } |
|
34 | + foreach ($entries as $entry) { |
|
35 | + $basenode = $entry; |
|
36 | + } |
|
37 | 37 | |
38 | - $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
39 | - if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
38 | + $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
39 | + if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
40 | 40 | |
41 | - $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
42 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
41 | + $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
42 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
43 | 43 | |
44 | - $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
45 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
44 | + $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
45 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
46 | 46 | |
47 | - $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
|
47 | + $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
|
48 | 48 | |
49 | - if ($basenode) { |
|
50 | - $basenode->insertBefore($avatar, $basenode->firstChild); |
|
51 | - } |
|
49 | + if ($basenode) { |
|
50 | + $basenode->insertBefore($avatar, $basenode->firstChild); |
|
51 | + } |
|
52 | 52 | |
53 | - $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
54 | - foreach ($uninteresting as $i) { |
|
55 | - $i->parentNode->removeChild($i); |
|
56 | - } |
|
53 | + $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
54 | + foreach ($uninteresting as $i) { |
|
55 | + $i->parentNode->removeChild($i); |
|
56 | + } |
|
57 | 57 | |
58 | - if ($basenode) { |
|
59 | - $article["content"] = $doc->saveHTML($basenode); |
|
60 | - } |
|
61 | - } |
|
58 | + if ($basenode) { |
|
59 | + $article["content"] = $doc->saveHTML($basenode); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | - return true; |
|
64 | - } |
|
63 | + return true; |
|
64 | + } |
|
65 | 65 | |
66 | - return false; |
|
67 | - } |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | } |
@@ -1,39 +1,39 @@ |
||
1 | 1 | <?php |
2 | 2 | class Af_Comics_DarkLegacy extends Af_ComicFilter { |
3 | 3 | |
4 | - public function supported() { |
|
5 | - return array("Dark Legacy Comics"); |
|
6 | - } |
|
4 | + public function supported() { |
|
5 | + return array("Dark Legacy Comics"); |
|
6 | + } |
|
7 | 7 | |
8 | - public function process(&$article) { |
|
8 | + public function process(&$article) { |
|
9 | 9 | |
10 | - if (strpos($article["guid"], "darklegacycomics.com") !== false) { |
|
10 | + if (strpos($article["guid"], "darklegacycomics.com") !== false) { |
|
11 | 11 | |
12 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
13 | - false, false, 0, |
|
14 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
12 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
13 | + false, false, 0, |
|
14 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
15 | 15 | |
16 | - global $fetch_last_error_content; |
|
16 | + global $fetch_last_error_content; |
|
17 | 17 | |
18 | - if (!$res && $fetch_last_error_content) { |
|
19 | - $res = $fetch_last_error_content; |
|
20 | - } |
|
18 | + if (!$res && $fetch_last_error_content) { |
|
19 | + $res = $fetch_last_error_content; |
|
20 | + } |
|
21 | 21 | |
22 | - $doc = new DOMDocument(); |
|
22 | + $doc = new DOMDocument(); |
|
23 | 23 | |
24 | - if (@$doc->loadHTML($res)) { |
|
25 | - $xpath = new DOMXPath($doc); |
|
26 | - $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
24 | + if (@$doc->loadHTML($res)) { |
|
25 | + $xpath = new DOMXPath($doc); |
|
26 | + $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
27 | 27 | |
28 | - if ($basenode) { |
|
28 | + if ($basenode) { |
|
29 | 29 | |
30 | - $article["content"] = $doc->saveHTML($basenode); |
|
31 | - } |
|
32 | - } |
|
30 | + $article["content"] = $doc->saveHTML($basenode); |
|
31 | + } |
|
32 | + } |
|
33 | 33 | |
34 | - return true; |
|
35 | - } |
|
34 | + return true; |
|
35 | + } |
|
36 | 36 | |
37 | - return false; |
|
38 | - } |
|
37 | + return false; |
|
38 | + } |
|
39 | 39 | } |