@@ -11,338 +11,338 @@ |
||
11 | 11 | */ |
12 | 12 | class Configuration |
13 | 13 | { |
14 | - use LoggerAwareTrait; |
|
15 | - |
|
16 | - /** |
|
17 | - * @var int |
|
18 | - */ |
|
19 | - protected $maxTopCandidates = 5; |
|
20 | - |
|
21 | - /** |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - protected $charThreshold = 500; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var bool |
|
28 | - */ |
|
29 | - protected $articleByLine = false; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
34 | - protected $stripUnlikelyCandidates = true; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var bool |
|
38 | - */ |
|
39 | - protected $cleanConditionally = true; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var bool |
|
43 | - */ |
|
44 | - protected $weightClasses = true; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var bool |
|
48 | - */ |
|
49 | - protected $fixRelativeURLs = false; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - protected $substituteEntities = false; |
|
55 | - |
|
56 | - /** |
|
57 | - * @var bool |
|
58 | - */ |
|
59 | - protected $normalizeEntities = false; |
|
60 | - |
|
61 | - /** |
|
62 | - * @var bool |
|
63 | - */ |
|
64 | - protected $summonCthulhu = false; |
|
65 | - |
|
66 | - /** |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $originalURL = 'http://fakehost'; |
|
70 | - |
|
71 | - /** |
|
72 | - * Configuration constructor. |
|
73 | - * |
|
74 | - * @param array $params |
|
75 | - */ |
|
76 | - public function __construct(array $params = []) |
|
77 | - { |
|
78 | - foreach ($params as $key => $value) { |
|
79 | - $setter = sprintf('set%s', $key); |
|
80 | - if (method_exists($this, $setter)) { |
|
81 | - call_user_func([$this, $setter], $value); |
|
82 | - } |
|
83 | - } |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Returns an array-representation of configuration. |
|
88 | - * |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public function toArray() |
|
92 | - { |
|
93 | - $out = []; |
|
94 | - foreach ($this as $key => $value) { |
|
95 | - $getter = sprintf('get%s', $key); |
|
96 | - if (!is_object($value) && method_exists($this, $getter)) { |
|
97 | - $out[$key] = call_user_func([$this, $getter]); |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - return $out; |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * @return LoggerInterface |
|
106 | - */ |
|
107 | - public function getLogger() |
|
108 | - { |
|
109 | - // If no logger has been set, just return a null logger |
|
110 | - if ($this->logger === null) { |
|
111 | - return new NullLogger(); |
|
112 | - } |
|
113 | - |
|
114 | - return $this->logger; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * @param LoggerInterface $logger |
|
119 | - * |
|
120 | - * @return Configuration |
|
121 | - */ |
|
122 | - public function setLogger(LoggerInterface $logger) |
|
123 | - { |
|
124 | - $this->logger = $logger; |
|
125 | - |
|
126 | - return $this; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @return int |
|
131 | - */ |
|
132 | - public function getMaxTopCandidates() |
|
133 | - { |
|
134 | - return $this->maxTopCandidates; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @param int $maxTopCandidates |
|
139 | - * |
|
140 | - * @return $this |
|
141 | - */ |
|
142 | - public function setMaxTopCandidates($maxTopCandidates) |
|
143 | - { |
|
144 | - $this->maxTopCandidates = $maxTopCandidates; |
|
145 | - |
|
146 | - return $this; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @return int |
|
151 | - */ |
|
152 | - public function getCharThreshold() |
|
153 | - { |
|
154 | - return $this->charThreshold; |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * @param int $charThreshold |
|
159 | - * |
|
160 | - * @return $this |
|
161 | - */ |
|
162 | - public function setCharThreshold($charThreshold) |
|
163 | - { |
|
164 | - $this->charThreshold = $charThreshold; |
|
165 | - |
|
166 | - return $this; |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @return bool |
|
171 | - */ |
|
172 | - public function getArticleByLine() |
|
173 | - { |
|
174 | - return $this->articleByLine; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param bool $articleByLine |
|
179 | - * |
|
180 | - * @return $this |
|
181 | - */ |
|
182 | - public function setArticleByLine($articleByLine) |
|
183 | - { |
|
184 | - $this->articleByLine = $articleByLine; |
|
185 | - |
|
186 | - return $this; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * @return bool |
|
191 | - */ |
|
192 | - public function getStripUnlikelyCandidates() |
|
193 | - { |
|
194 | - return $this->stripUnlikelyCandidates; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * @param bool $stripUnlikelyCandidates |
|
199 | - * |
|
200 | - * @return $this |
|
201 | - */ |
|
202 | - public function setStripUnlikelyCandidates($stripUnlikelyCandidates) |
|
203 | - { |
|
204 | - $this->stripUnlikelyCandidates = $stripUnlikelyCandidates; |
|
205 | - |
|
206 | - return $this; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * @return bool |
|
211 | - */ |
|
212 | - public function getCleanConditionally() |
|
213 | - { |
|
214 | - return $this->cleanConditionally; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * @param bool $cleanConditionally |
|
219 | - * |
|
220 | - * @return $this |
|
221 | - */ |
|
222 | - public function setCleanConditionally($cleanConditionally) |
|
223 | - { |
|
224 | - $this->cleanConditionally = $cleanConditionally; |
|
225 | - |
|
226 | - return $this; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @return bool |
|
231 | - */ |
|
232 | - public function getWeightClasses() |
|
233 | - { |
|
234 | - return $this->weightClasses; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @param bool $weightClasses |
|
239 | - * |
|
240 | - * @return $this |
|
241 | - */ |
|
242 | - public function setWeightClasses($weightClasses) |
|
243 | - { |
|
244 | - $this->weightClasses = $weightClasses; |
|
245 | - |
|
246 | - return $this; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * @return bool |
|
251 | - */ |
|
252 | - public function getFixRelativeURLs() |
|
253 | - { |
|
254 | - return $this->fixRelativeURLs; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * @param bool $fixRelativeURLs |
|
259 | - * |
|
260 | - * @return $this |
|
261 | - */ |
|
262 | - public function setFixRelativeURLs($fixRelativeURLs) |
|
263 | - { |
|
264 | - $this->fixRelativeURLs = $fixRelativeURLs; |
|
265 | - |
|
266 | - return $this; |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * @return bool |
|
271 | - */ |
|
272 | - public function getSubstituteEntities() |
|
273 | - { |
|
274 | - return $this->substituteEntities; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * @param bool $substituteEntities |
|
279 | - * |
|
280 | - * @return $this |
|
281 | - */ |
|
282 | - public function setSubstituteEntities($substituteEntities) |
|
283 | - { |
|
284 | - $this->substituteEntities = $substituteEntities; |
|
285 | - |
|
286 | - return $this; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * @return bool |
|
291 | - */ |
|
292 | - public function getNormalizeEntities() |
|
293 | - { |
|
294 | - return $this->normalizeEntities; |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * @param bool $normalizeEntities |
|
299 | - * |
|
300 | - * @return $this |
|
301 | - */ |
|
302 | - public function setNormalizeEntities($normalizeEntities) |
|
303 | - { |
|
304 | - $this->normalizeEntities = $normalizeEntities; |
|
305 | - |
|
306 | - return $this; |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - public function getOriginalURL() |
|
313 | - { |
|
314 | - return $this->originalURL; |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @param string $originalURL |
|
319 | - * |
|
320 | - * @return $this |
|
321 | - */ |
|
322 | - public function setOriginalURL($originalURL) |
|
323 | - { |
|
324 | - $this->originalURL = $originalURL; |
|
325 | - |
|
326 | - return $this; |
|
327 | - } |
|
328 | - |
|
329 | - /** |
|
330 | - * @return bool |
|
331 | - */ |
|
332 | - public function getSummonCthulhu() |
|
333 | - { |
|
334 | - return $this->summonCthulhu; |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * @param bool $summonCthulhu |
|
339 | - * |
|
340 | - * @return $this |
|
341 | - */ |
|
342 | - public function setSummonCthulhu($summonCthulhu) |
|
343 | - { |
|
344 | - $this->summonCthulhu = $summonCthulhu; |
|
345 | - |
|
346 | - return $this; |
|
347 | - } |
|
14 | + use LoggerAwareTrait; |
|
15 | + |
|
16 | + /** |
|
17 | + * @var int |
|
18 | + */ |
|
19 | + protected $maxTopCandidates = 5; |
|
20 | + |
|
21 | + /** |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + protected $charThreshold = 500; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var bool |
|
28 | + */ |
|
29 | + protected $articleByLine = false; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | + protected $stripUnlikelyCandidates = true; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var bool |
|
38 | + */ |
|
39 | + protected $cleanConditionally = true; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var bool |
|
43 | + */ |
|
44 | + protected $weightClasses = true; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var bool |
|
48 | + */ |
|
49 | + protected $fixRelativeURLs = false; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + protected $substituteEntities = false; |
|
55 | + |
|
56 | + /** |
|
57 | + * @var bool |
|
58 | + */ |
|
59 | + protected $normalizeEntities = false; |
|
60 | + |
|
61 | + /** |
|
62 | + * @var bool |
|
63 | + */ |
|
64 | + protected $summonCthulhu = false; |
|
65 | + |
|
66 | + /** |
|
67 | + * @var string |
|
68 | + */ |
|
69 | + protected $originalURL = 'http://fakehost'; |
|
70 | + |
|
71 | + /** |
|
72 | + * Configuration constructor. |
|
73 | + * |
|
74 | + * @param array $params |
|
75 | + */ |
|
76 | + public function __construct(array $params = []) |
|
77 | + { |
|
78 | + foreach ($params as $key => $value) { |
|
79 | + $setter = sprintf('set%s', $key); |
|
80 | + if (method_exists($this, $setter)) { |
|
81 | + call_user_func([$this, $setter], $value); |
|
82 | + } |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Returns an array-representation of configuration. |
|
88 | + * |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public function toArray() |
|
92 | + { |
|
93 | + $out = []; |
|
94 | + foreach ($this as $key => $value) { |
|
95 | + $getter = sprintf('get%s', $key); |
|
96 | + if (!is_object($value) && method_exists($this, $getter)) { |
|
97 | + $out[$key] = call_user_func([$this, $getter]); |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + return $out; |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * @return LoggerInterface |
|
106 | + */ |
|
107 | + public function getLogger() |
|
108 | + { |
|
109 | + // If no logger has been set, just return a null logger |
|
110 | + if ($this->logger === null) { |
|
111 | + return new NullLogger(); |
|
112 | + } |
|
113 | + |
|
114 | + return $this->logger; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * @param LoggerInterface $logger |
|
119 | + * |
|
120 | + * @return Configuration |
|
121 | + */ |
|
122 | + public function setLogger(LoggerInterface $logger) |
|
123 | + { |
|
124 | + $this->logger = $logger; |
|
125 | + |
|
126 | + return $this; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @return int |
|
131 | + */ |
|
132 | + public function getMaxTopCandidates() |
|
133 | + { |
|
134 | + return $this->maxTopCandidates; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @param int $maxTopCandidates |
|
139 | + * |
|
140 | + * @return $this |
|
141 | + */ |
|
142 | + public function setMaxTopCandidates($maxTopCandidates) |
|
143 | + { |
|
144 | + $this->maxTopCandidates = $maxTopCandidates; |
|
145 | + |
|
146 | + return $this; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @return int |
|
151 | + */ |
|
152 | + public function getCharThreshold() |
|
153 | + { |
|
154 | + return $this->charThreshold; |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * @param int $charThreshold |
|
159 | + * |
|
160 | + * @return $this |
|
161 | + */ |
|
162 | + public function setCharThreshold($charThreshold) |
|
163 | + { |
|
164 | + $this->charThreshold = $charThreshold; |
|
165 | + |
|
166 | + return $this; |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @return bool |
|
171 | + */ |
|
172 | + public function getArticleByLine() |
|
173 | + { |
|
174 | + return $this->articleByLine; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param bool $articleByLine |
|
179 | + * |
|
180 | + * @return $this |
|
181 | + */ |
|
182 | + public function setArticleByLine($articleByLine) |
|
183 | + { |
|
184 | + $this->articleByLine = $articleByLine; |
|
185 | + |
|
186 | + return $this; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * @return bool |
|
191 | + */ |
|
192 | + public function getStripUnlikelyCandidates() |
|
193 | + { |
|
194 | + return $this->stripUnlikelyCandidates; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * @param bool $stripUnlikelyCandidates |
|
199 | + * |
|
200 | + * @return $this |
|
201 | + */ |
|
202 | + public function setStripUnlikelyCandidates($stripUnlikelyCandidates) |
|
203 | + { |
|
204 | + $this->stripUnlikelyCandidates = $stripUnlikelyCandidates; |
|
205 | + |
|
206 | + return $this; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * @return bool |
|
211 | + */ |
|
212 | + public function getCleanConditionally() |
|
213 | + { |
|
214 | + return $this->cleanConditionally; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * @param bool $cleanConditionally |
|
219 | + * |
|
220 | + * @return $this |
|
221 | + */ |
|
222 | + public function setCleanConditionally($cleanConditionally) |
|
223 | + { |
|
224 | + $this->cleanConditionally = $cleanConditionally; |
|
225 | + |
|
226 | + return $this; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @return bool |
|
231 | + */ |
|
232 | + public function getWeightClasses() |
|
233 | + { |
|
234 | + return $this->weightClasses; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @param bool $weightClasses |
|
239 | + * |
|
240 | + * @return $this |
|
241 | + */ |
|
242 | + public function setWeightClasses($weightClasses) |
|
243 | + { |
|
244 | + $this->weightClasses = $weightClasses; |
|
245 | + |
|
246 | + return $this; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * @return bool |
|
251 | + */ |
|
252 | + public function getFixRelativeURLs() |
|
253 | + { |
|
254 | + return $this->fixRelativeURLs; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * @param bool $fixRelativeURLs |
|
259 | + * |
|
260 | + * @return $this |
|
261 | + */ |
|
262 | + public function setFixRelativeURLs($fixRelativeURLs) |
|
263 | + { |
|
264 | + $this->fixRelativeURLs = $fixRelativeURLs; |
|
265 | + |
|
266 | + return $this; |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * @return bool |
|
271 | + */ |
|
272 | + public function getSubstituteEntities() |
|
273 | + { |
|
274 | + return $this->substituteEntities; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * @param bool $substituteEntities |
|
279 | + * |
|
280 | + * @return $this |
|
281 | + */ |
|
282 | + public function setSubstituteEntities($substituteEntities) |
|
283 | + { |
|
284 | + $this->substituteEntities = $substituteEntities; |
|
285 | + |
|
286 | + return $this; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * @return bool |
|
291 | + */ |
|
292 | + public function getNormalizeEntities() |
|
293 | + { |
|
294 | + return $this->normalizeEntities; |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * @param bool $normalizeEntities |
|
299 | + * |
|
300 | + * @return $this |
|
301 | + */ |
|
302 | + public function setNormalizeEntities($normalizeEntities) |
|
303 | + { |
|
304 | + $this->normalizeEntities = $normalizeEntities; |
|
305 | + |
|
306 | + return $this; |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + public function getOriginalURL() |
|
313 | + { |
|
314 | + return $this->originalURL; |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @param string $originalURL |
|
319 | + * |
|
320 | + * @return $this |
|
321 | + */ |
|
322 | + public function setOriginalURL($originalURL) |
|
323 | + { |
|
324 | + $this->originalURL = $originalURL; |
|
325 | + |
|
326 | + return $this; |
|
327 | + } |
|
328 | + |
|
329 | + /** |
|
330 | + * @return bool |
|
331 | + */ |
|
332 | + public function getSummonCthulhu() |
|
333 | + { |
|
334 | + return $this->summonCthulhu; |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * @param bool $summonCthulhu |
|
339 | + * |
|
340 | + * @return $this |
|
341 | + */ |
|
342 | + public function setSummonCthulhu($summonCthulhu) |
|
343 | + { |
|
344 | + $this->summonCthulhu = $summonCthulhu; |
|
345 | + |
|
346 | + return $this; |
|
347 | + } |
|
348 | 348 | } |
@@ -280,36 +280,36 @@ |
||
280 | 280 | $found = true; |
281 | 281 | } |
282 | 282 | |
283 | - // imgur via link rel="image_src" href="..." |
|
284 | - if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) { |
|
283 | + // imgur via link rel="image_src" href="..." |
|
284 | + if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) { |
|
285 | 285 | |
286 | - Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE); |
|
286 | + Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE); |
|
287 | 287 | |
288 | - $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
289 | - "http_accept" => "text/*"]); |
|
288 | + $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
289 | + "http_accept" => "text/*"]); |
|
290 | 290 | |
291 | - if ($content) { |
|
292 | - $cdoc = new DOMDocument(); |
|
291 | + if ($content) { |
|
292 | + $cdoc = new DOMDocument(); |
|
293 | 293 | |
294 | - if (@$cdoc->loadHTML($content)) { |
|
295 | - $cxpath = new DOMXPath($cdoc); |
|
294 | + if (@$cdoc->loadHTML($content)) { |
|
295 | + $cxpath = new DOMXPath($cdoc); |
|
296 | 296 | |
297 | - $rel_image = $cxpath->query("//link[@rel='image_src']")->item(0); |
|
297 | + $rel_image = $cxpath->query("//link[@rel='image_src']")->item(0); |
|
298 | 298 | |
299 | - if ($rel_image) { |
|
299 | + if ($rel_image) { |
|
300 | 300 | |
301 | - $img = $doc->createElement('img'); |
|
302 | - $img->setAttribute("src", $rel_image->getAttribute("href")); |
|
301 | + $img = $doc->createElement('img'); |
|
302 | + $img->setAttribute("src", $rel_image->getAttribute("href")); |
|
303 | 303 | |
304 | - $br = $doc->createElement('br'); |
|
305 | - $entry->parentNode->insertBefore($img, $entry); |
|
306 | - $entry->parentNode->insertBefore($br, $entry); |
|
304 | + $br = $doc->createElement('br'); |
|
305 | + $entry->parentNode->insertBefore($img, $entry); |
|
306 | + $entry->parentNode->insertBefore($br, $entry); |
|
307 | 307 | |
308 | - $found = true; |
|
309 | - } |
|
310 | - } |
|
311 | - } |
|
312 | - } |
|
308 | + $found = true; |
|
309 | + } |
|
310 | + } |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | 314 | // wtf is this even |
315 | 315 | if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) { |
@@ -597,7 +597,7 @@ |
||
597 | 597 | "title" => $line["title"], |
598 | 598 | "unread" => $unread, |
599 | 599 | "is_cat" => true, |
600 | - "order_id" => (int) $line["order_id"] |
|
600 | + "order_id" => (int) $line["order_id"] |
|
601 | 601 | ); |
602 | 602 | array_push($feeds, $row); |
603 | 603 | } |
@@ -1060,8 +1060,8 @@ |
||
1060 | 1060 | $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]); |
1061 | 1061 | |
1062 | 1062 | if ($authenticator && |
1063 | - method_exists($authenticator, "check_password") && |
|
1064 | - $authenticator->check_password($_SESSION["uid"], "password")) { |
|
1063 | + method_exists($authenticator, "check_password") && |
|
1064 | + $authenticator->check_password($_SESSION["uid"], "password")) { |
|
1065 | 1065 | |
1066 | 1066 | return true; |
1067 | 1067 | } |
@@ -78,17 +78,17 @@ discard block |
||
78 | 78 | $scope_inner_qparts = []; |
79 | 79 | foreach ($rule["feed_id"] as $feed_id) { |
80 | 80 | |
81 | - if (strpos($feed_id, "CAT:") === 0) { |
|
82 | - $cat_id = (int) substr($feed_id, 4); |
|
83 | - array_push($scope_inner_qparts, "cat_id = " . $this->pdo->quote($cat_id)); |
|
84 | - } else if ($feed_id > 0) { |
|
85 | - array_push($scope_inner_qparts, "feed_id = " . $this->pdo->quote($feed_id)); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - if (count($scope_inner_qparts) > 0) { |
|
90 | - array_push($scope_qparts, "(" . implode(" OR ", $scope_inner_qparts) . ")"); |
|
91 | - } |
|
81 | + if (strpos($feed_id, "CAT:") === 0) { |
|
82 | + $cat_id = (int) substr($feed_id, 4); |
|
83 | + array_push($scope_inner_qparts, "cat_id = " . $this->pdo->quote($cat_id)); |
|
84 | + } else if ($feed_id > 0) { |
|
85 | + array_push($scope_inner_qparts, "feed_id = " . $this->pdo->quote($feed_id)); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + if (count($scope_inner_qparts) > 0) { |
|
90 | + array_push($scope_qparts, "(" . implode(" OR ", $scope_inner_qparts) . ")"); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | array_push($filter["rules"], $rule); |
94 | 94 | |
@@ -196,32 +196,32 @@ discard block |
||
196 | 196 | |
197 | 197 | while ($line = $sth->fetch()) { |
198 | 198 | |
199 | - if ($line["match_on"]) { |
|
200 | - $feeds = json_decode($line["match_on"], true); |
|
201 | - $feeds_fmt = []; |
|
199 | + if ($line["match_on"]) { |
|
200 | + $feeds = json_decode($line["match_on"], true); |
|
201 | + $feeds_fmt = []; |
|
202 | 202 | |
203 | - foreach ($feeds as $feed_id) { |
|
203 | + foreach ($feeds as $feed_id) { |
|
204 | 204 | |
205 | - if (strpos($feed_id, "CAT:") === 0) { |
|
206 | - $feed_id = (int)substr($feed_id, 4); |
|
207 | - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
|
208 | - } else { |
|
209 | - if ($feed_id) |
|
210 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
211 | - else |
|
212 | - array_push($feeds_fmt, __("All feeds")); |
|
213 | - } |
|
214 | - } |
|
205 | + if (strpos($feed_id, "CAT:") === 0) { |
|
206 | + $feed_id = (int)substr($feed_id, 4); |
|
207 | + array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
|
208 | + } else { |
|
209 | + if ($feed_id) |
|
210 | + array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
211 | + else |
|
212 | + array_push($feeds_fmt, __("All feeds")); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | - $where = implode(", ", $feeds_fmt); |
|
216 | + $where = implode(", ", $feeds_fmt); |
|
217 | 217 | |
218 | - } else { |
|
218 | + } else { |
|
219 | 219 | |
220 | - $where = $line["cat_filter"] ? |
|
221 | - Feeds::getCategoryTitle($line["cat_id"]) : |
|
222 | - ($line["feed_id"] ? |
|
223 | - Feeds::getFeedTitle($line["feed_id"]) : __("All feeds")); |
|
224 | - } |
|
220 | + $where = $line["cat_filter"] ? |
|
221 | + Feeds::getCategoryTitle($line["cat_id"]) : |
|
222 | + ($line["feed_id"] ? |
|
223 | + Feeds::getFeedTitle($line["feed_id"]) : __("All feeds")); |
|
224 | + } |
|
225 | 225 | |
226 | 226 | # $where = $line["cat_id"] . "/" . $line["feed_id"]; |
227 | 227 | |
@@ -527,18 +527,18 @@ discard block |
||
527 | 527 | |
528 | 528 | foreach ($feeds as $feed_id) { |
529 | 529 | |
530 | - if (strpos($feed_id, "CAT:") === 0) { |
|
531 | - $feed_id = (int)substr($feed_id, 4); |
|
532 | - array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
|
533 | - } else { |
|
534 | - if ($feed_id) |
|
535 | - array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
536 | - else |
|
537 | - array_push($feeds_fmt, __("All feeds")); |
|
538 | - } |
|
539 | - } |
|
540 | - |
|
541 | - $feed = implode(", ", $feeds_fmt); |
|
530 | + if (strpos($feed_id, "CAT:") === 0) { |
|
531 | + $feed_id = (int)substr($feed_id, 4); |
|
532 | + array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id)); |
|
533 | + } else { |
|
534 | + if ($feed_id) |
|
535 | + array_push($feeds_fmt, Feeds::getFeedTitle((int)$feed_id)); |
|
536 | + else |
|
537 | + array_push($feeds_fmt, __("All feeds")); |
|
538 | + } |
|
539 | + } |
|
540 | + |
|
541 | + $feed = implode(", ", $feeds_fmt); |
|
542 | 542 | |
543 | 543 | $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types |
544 | 544 | WHERE id = ?"); |
@@ -1,86 +1,86 @@ |
||
1 | 1 | <?php |
2 | 2 | class Debug { |
3 | 3 | public static $LOG_DISABLED = -1; |
4 | - public static $LOG_NORMAL = 0; |
|
5 | - public static $LOG_VERBOSE = 1; |
|
6 | - public static $LOG_EXTENDED = 2; |
|
4 | + public static $LOG_NORMAL = 0; |
|
5 | + public static $LOG_VERBOSE = 1; |
|
6 | + public static $LOG_EXTENDED = 2; |
|
7 | 7 | |
8 | - private static $enabled = false; |
|
9 | - private static $quiet = false; |
|
10 | - private static $logfile = false; |
|
11 | - private static $loglevel = 0; |
|
8 | + private static $enabled = false; |
|
9 | + private static $quiet = false; |
|
10 | + private static $logfile = false; |
|
11 | + private static $loglevel = 0; |
|
12 | 12 | |
13 | 13 | public static function set_logfile($logfile) { |
14 | - Debug::$logfile = $logfile; |
|
15 | - } |
|
14 | + Debug::$logfile = $logfile; |
|
15 | + } |
|
16 | 16 | |
17 | - public static function enabled() { |
|
18 | - return Debug::$enabled; |
|
19 | - } |
|
17 | + public static function enabled() { |
|
18 | + return Debug::$enabled; |
|
19 | + } |
|
20 | 20 | |
21 | - public static function set_enabled($enable) { |
|
22 | - Debug::$enabled = $enable; |
|
23 | - } |
|
21 | + public static function set_enabled($enable) { |
|
22 | + Debug::$enabled = $enable; |
|
23 | + } |
|
24 | 24 | |
25 | - public static function set_quiet($quiet) { |
|
26 | - Debug::$quiet = $quiet; |
|
27 | - } |
|
25 | + public static function set_quiet($quiet) { |
|
26 | + Debug::$quiet = $quiet; |
|
27 | + } |
|
28 | 28 | |
29 | - public static function set_loglevel($level) { |
|
30 | - Debug::$loglevel = $level; |
|
31 | - } |
|
29 | + public static function set_loglevel($level) { |
|
30 | + Debug::$loglevel = $level; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function get_loglevel() { |
|
34 | - return Debug::$loglevel; |
|
35 | - } |
|
33 | + public static function get_loglevel() { |
|
34 | + return Debug::$loglevel; |
|
35 | + } |
|
36 | 36 | |
37 | - public static function log($message, $level = 0) { |
|
37 | + public static function log($message, $level = 0) { |
|
38 | 38 | |
39 | - if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
39 | + if (!Debug::$enabled || Debug::$loglevel < $level) return false; |
|
40 | 40 | |
41 | - $ts = strftime("%H:%M:%S", time()); |
|
42 | - if (function_exists('posix_getpid')) { |
|
43 | - $ts = "$ts/" . posix_getpid(); |
|
44 | - } |
|
41 | + $ts = strftime("%H:%M:%S", time()); |
|
42 | + if (function_exists('posix_getpid')) { |
|
43 | + $ts = "$ts/" . posix_getpid(); |
|
44 | + } |
|
45 | 45 | |
46 | - if (Debug::$logfile) { |
|
47 | - $fp = fopen(Debug::$logfile, 'a+'); |
|
46 | + if (Debug::$logfile) { |
|
47 | + $fp = fopen(Debug::$logfile, 'a+'); |
|
48 | 48 | |
49 | - if ($fp) { |
|
50 | - $locked = false; |
|
49 | + if ($fp) { |
|
50 | + $locked = false; |
|
51 | 51 | |
52 | - if (function_exists("flock")) { |
|
53 | - $tries = 0; |
|
52 | + if (function_exists("flock")) { |
|
53 | + $tries = 0; |
|
54 | 54 | |
55 | - // try to lock logfile for writing |
|
56 | - while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { |
|
57 | - sleep(1); |
|
58 | - ++$tries; |
|
59 | - } |
|
55 | + // try to lock logfile for writing |
|
56 | + while ($tries < 5 && !$locked = flock($fp, LOCK_EX | LOCK_NB)) { |
|
57 | + sleep(1); |
|
58 | + ++$tries; |
|
59 | + } |
|
60 | 60 | |
61 | - if (!$locked) { |
|
62 | - fclose($fp); |
|
63 | - user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
64 | - return; |
|
65 | - } |
|
66 | - } |
|
61 | + if (!$locked) { |
|
62 | + fclose($fp); |
|
63 | + user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
64 | + return; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | - fputs($fp, "[$ts] $message\n"); |
|
68 | + fputs($fp, "[$ts] $message\n"); |
|
69 | 69 | |
70 | - if (function_exists("flock")) { |
|
71 | - flock($fp, LOCK_UN); |
|
72 | - } |
|
70 | + if (function_exists("flock")) { |
|
71 | + flock($fp, LOCK_UN); |
|
72 | + } |
|
73 | 73 | |
74 | - fclose($fp); |
|
74 | + fclose($fp); |
|
75 | 75 | |
76 | - if (Debug::$quiet) |
|
77 | - return; |
|
76 | + if (Debug::$quiet) |
|
77 | + return; |
|
78 | 78 | |
79 | - } else { |
|
80 | - user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
81 | - } |
|
82 | - } |
|
79 | + } else { |
|
80 | + user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - print "[$ts] $message\n"; |
|
85 | - } |
|
84 | + print "[$ts] $message\n"; |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | \ No newline at end of file |
@@ -702,7 +702,7 @@ |
||
702 | 702 | $entry_plugin_data .= mb_strtolower(get_class($plugin)) . ","; |
703 | 703 | } |
704 | 704 | |
705 | - if (Debug::get_loglevel() >= 3) { |
|
705 | + if (Debug::get_loglevel() >= 3) { |
|
706 | 706 | print "processed content: "; |
707 | 707 | print htmlspecialchars($article["content"]); |
708 | 708 | print "\n"; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | array_push($rv, [ "label" => $title, "value" => $id ]); |
287 | 287 | } |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | 290 | print json_encode($rv); |
291 | 291 | } |
@@ -358,37 +358,37 @@ discard block |
||
358 | 358 | |
359 | 359 | $enclosures = Article::get_article_enclosures($line["id"]); |
360 | 360 | |
361 | - header("Content-Type: text/html"); |
|
361 | + header("Content-Type: text/html"); |
|
362 | 362 | |
363 | - $rv .= "<!DOCTYPE html> |
|
363 | + $rv .= "<!DOCTYPE html> |
|
364 | 364 | <html><head> |
365 | 365 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> |
366 | 366 | <title>".$line["title"]."</title>". |
367 | - stylesheet_tag("css/default.css")." |
|
367 | + stylesheet_tag("css/default.css")." |
|
368 | 368 | <link rel='shortcut icon' type='image/png' href='images/favicon.png'> |
369 | 369 | <link rel='icon' type='image/png' sizes='72x72' href='images/favicon-72px.png'>"; |
370 | 370 | |
371 | - $rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n"; |
|
372 | - $rv .= "<meta property='og:description' content=\"". |
|
373 | - htmlspecialchars( |
|
374 | - truncate_string( |
|
375 | - preg_replace("/[\r\n\t]/", "", |
|
371 | + $rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n"; |
|
372 | + $rv .= "<meta property='og:description' content=\"". |
|
373 | + htmlspecialchars( |
|
374 | + truncate_string( |
|
375 | + preg_replace("/[\r\n\t]/", "", |
|
376 | 376 | preg_replace("/ {1,}/", " ", |
377 | 377 | strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401)) |
378 | 378 | ) |
379 | 379 | ), 500, "...") |
380 | 380 | )."\"/>\n"; |
381 | 381 | |
382 | - $rv .= "</head>"; |
|
382 | + $rv .= "</head>"; |
|
383 | 383 | |
384 | - list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]); |
|
384 | + list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $line["site_url"]); |
|
385 | 385 | |
386 | - if ($og_image) { |
|
387 | - $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>"; |
|
388 | - } |
|
386 | + if ($og_image) { |
|
387 | + $rv .= "<meta property='og:image' content=\"" . htmlspecialchars($og_image) . "\"/>"; |
|
388 | + } |
|
389 | 389 | |
390 | - $rv .= "<body class='flat ttrss_utility ttrss_zoom'>"; |
|
391 | - $rv .= "<div class='container'>"; |
|
390 | + $rv .= "<body class='flat ttrss_utility ttrss_zoom'>"; |
|
391 | + $rv .= "<div class='container'>"; |
|
392 | 392 | |
393 | 393 | if ($line["link"]) { |
394 | 394 | $rv .= "<h1><a target='_blank' rel='noopener noreferrer' |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $owner_uid, true); |
411 | 411 | |
412 | 412 | $rv .= "<div>".$line['author']."</div>"; |
413 | - $rv .= "<div>$parsed_updated</div>"; |
|
413 | + $rv .= "<div>$parsed_updated</div>"; |
|
414 | 414 | |
415 | 415 | $rv .= "</div>"; # row |
416 | 416 | |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | |
426 | 426 | $rv .= $line["content"]; |
427 | 427 | |
428 | - $rv .= Article::format_article_enclosures($id, |
|
429 | - $line["always_display_enclosures"], |
|
430 | - $line["content"], |
|
431 | - $line["hide_images"]); |
|
428 | + $rv .= Article::format_article_enclosures($id, |
|
429 | + $line["always_display_enclosures"], |
|
430 | + $line["content"], |
|
431 | + $line["hide_images"]); |
|
432 | 432 | |
433 | 433 | $rv .= "</div>"; # content |
434 | 434 | |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | if ($sth->fetch()) { |
676 | 676 | $_SESSION["profile"] = $profile; |
677 | 677 | } else { |
678 | - $_SESSION["profile"] = null; |
|
679 | - } |
|
678 | + $_SESSION["profile"] = null; |
|
679 | + } |
|
680 | 680 | } |
681 | 681 | } else { |
682 | 682 |
@@ -202,36 +202,36 @@ discard block |
||
202 | 202 | $cat_filter = $tmp_line["cat_filter"]; |
203 | 203 | |
204 | 204 | if (!$tmp_line["match_on"]) { |
205 | - if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) { |
|
206 | - $tmp_line["feed"] = Feeds::getFeedTitle( |
|
207 | - $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"], |
|
208 | - $cat_filter); |
|
209 | - } else { |
|
210 | - $tmp_line["feed"] = ""; |
|
211 | - } |
|
212 | - } else { |
|
213 | - $match = []; |
|
214 | - foreach (json_decode($tmp_line["match_on"], true) as $feed_id) { |
|
215 | - |
|
216 | - if (strpos($feed_id, "CAT:") === 0) { |
|
217 | - $feed_id = (int)substr($feed_id, 4); |
|
218 | - if ($feed_id) { |
|
219 | - array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]); |
|
220 | - } else { |
|
221 | - array_push($match, [0, true, true]); |
|
222 | - } |
|
223 | - } else { |
|
224 | - if ($feed_id) { |
|
225 | - array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]); |
|
226 | - } else { |
|
227 | - array_push($match, [0, false, true]); |
|
228 | - } |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - $tmp_line["match"] = $match; |
|
233 | - unset($tmp_line["match_on"]); |
|
234 | - } |
|
205 | + if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) { |
|
206 | + $tmp_line["feed"] = Feeds::getFeedTitle( |
|
207 | + $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"], |
|
208 | + $cat_filter); |
|
209 | + } else { |
|
210 | + $tmp_line["feed"] = ""; |
|
211 | + } |
|
212 | + } else { |
|
213 | + $match = []; |
|
214 | + foreach (json_decode($tmp_line["match_on"], true) as $feed_id) { |
|
215 | + |
|
216 | + if (strpos($feed_id, "CAT:") === 0) { |
|
217 | + $feed_id = (int)substr($feed_id, 4); |
|
218 | + if ($feed_id) { |
|
219 | + array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]); |
|
220 | + } else { |
|
221 | + array_push($match, [0, true, true]); |
|
222 | + } |
|
223 | + } else { |
|
224 | + if ($feed_id) { |
|
225 | + array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]); |
|
226 | + } else { |
|
227 | + array_push($match, [0, false, true]); |
|
228 | + } |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + $tmp_line["match"] = $match; |
|
233 | + unset($tmp_line["match_on"]); |
|
234 | + } |
|
235 | 235 | |
236 | 236 | unset($tmp_line["feed_id"]); |
237 | 237 | unset($tmp_line["cat_id"]); |
@@ -403,28 +403,28 @@ discard block |
||
403 | 403 | |
404 | 404 | if ($rule["match"]) { |
405 | 405 | |
406 | - $match_on = []; |
|
406 | + $match_on = []; |
|
407 | 407 | |
408 | - foreach ($rule["match"] as $match) { |
|
409 | - list ($name, $is_cat, $is_id) = $match; |
|
408 | + foreach ($rule["match"] as $match) { |
|
409 | + list ($name, $is_cat, $is_id) = $match; |
|
410 | 410 | |
411 | - if ($is_id) { |
|
412 | - array_push($match_on, ($is_cat ? "CAT:" : "") . $name); |
|
413 | - } else { |
|
411 | + if ($is_id) { |
|
412 | + array_push($match_on, ($is_cat ? "CAT:" : "") . $name); |
|
413 | + } else { |
|
414 | 414 | |
415 | - if (!$is_cat) { |
|
416 | - $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
|
415 | + if (!$is_cat) { |
|
416 | + $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
|
417 | 417 | WHERE title = ? AND owner_uid = ?"); |
418 | 418 | |
419 | - $tsth->execute([$name, $_SESSION['uid']]); |
|
419 | + $tsth->execute([$name, $_SESSION['uid']]); |
|
420 | 420 | |
421 | - if ($row = $tsth->fetch()) { |
|
422 | - $match_id = $row['id']; |
|
421 | + if ($row = $tsth->fetch()) { |
|
422 | + $match_id = $row['id']; |
|
423 | 423 | |
424 | 424 | array_push($match_on, $match_id); |
425 | - } |
|
426 | - } else { |
|
427 | - $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
425 | + } |
|
426 | + } else { |
|
427 | + $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories |
|
428 | 428 | WHERE title = ? AND owner_uid = ?"); |
429 | 429 | $tsth->execute([$name, $_SESSION['uid']]); |
430 | 430 | |
@@ -433,33 +433,33 @@ discard block |
||
433 | 433 | |
434 | 434 | array_push($match_on, "CAT:$match_id"); |
435 | 435 | } |
436 | - } |
|
437 | - } |
|
438 | - } |
|
436 | + } |
|
437 | + } |
|
438 | + } |
|
439 | 439 | |
440 | - $reg_exp = $rule["reg_exp"]; |
|
441 | - $filter_type = (int)$rule["filter_type"]; |
|
442 | - $inverse = bool_to_sql_bool($rule["inverse"]); |
|
443 | - $match_on = json_encode($match_on); |
|
440 | + $reg_exp = $rule["reg_exp"]; |
|
441 | + $filter_type = (int)$rule["filter_type"]; |
|
442 | + $inverse = bool_to_sql_bool($rule["inverse"]); |
|
443 | + $match_on = json_encode($match_on); |
|
444 | 444 | |
445 | - $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
445 | + $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
446 | 446 | (feed_id,cat_id,match_on,filter_id,filter_type,reg_exp,cat_filter,inverse) |
447 | 447 | VALUES |
448 | 448 | (NULL, NULL, ?, ?, ?, ?, false, ?)"); |
449 | - $usth->execute([$match_on, $filter_id, $filter_type, $reg_exp, $inverse]); |
|
449 | + $usth->execute([$match_on, $filter_id, $filter_type, $reg_exp, $inverse]); |
|
450 | 450 | |
451 | - } else { |
|
451 | + } else { |
|
452 | 452 | |
453 | - if (!$rule["cat_filter"]) { |
|
454 | - $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
|
453 | + if (!$rule["cat_filter"]) { |
|
454 | + $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feeds |
|
455 | 455 | WHERE title = ? AND owner_uid = ?"); |
456 | 456 | |
457 | - $tsth->execute([$rule['feed'], $_SESSION['uid']]); |
|
457 | + $tsth->execute([$rule['feed'], $_SESSION['uid']]); |
|
458 | 458 | |
459 | - if ($row = $tsth->fetch()) { |
|
460 | - $feed_id = $row['id']; |
|
461 | - } |
|
462 | - } else { |
|
459 | + if ($row = $tsth->fetch()) { |
|
460 | + $feed_id = $row['id']; |
|
461 | + } |
|
462 | + } else { |
|
463 | 463 | $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories |
464 | 464 | WHERE title = ? AND owner_uid = ?"); |
465 | 465 | |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | if ($row = $tsth->fetch()) { |
469 | 469 | $feed_id = $row['id']; |
470 | 470 | } |
471 | - } |
|
471 | + } |
|
472 | 472 | |
473 | - $cat_filter = bool_to_sql_bool($rule["cat_filter"]); |
|
474 | - $reg_exp = $rule["reg_exp"]; |
|
475 | - $filter_type = (int)$rule["filter_type"]; |
|
476 | - $inverse = bool_to_sql_bool($rule["inverse"]); |
|
473 | + $cat_filter = bool_to_sql_bool($rule["cat_filter"]); |
|
474 | + $reg_exp = $rule["reg_exp"]; |
|
475 | + $filter_type = (int)$rule["filter_type"]; |
|
476 | + $inverse = bool_to_sql_bool($rule["inverse"]); |
|
477 | 477 | |
478 | - $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
478 | + $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules |
|
479 | 479 | (feed_id,cat_id,filter_id,filter_type,reg_exp,cat_filter,inverse) |
480 | 480 | VALUES |
481 | 481 | (?, ?, ?, ?, ?, ?, ?)"); |
482 | - $usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]); |
|
483 | - } |
|
482 | + $usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]); |
|
483 | + } |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | foreach ($filter["actions"] as $action) { |