Passed
Push — master ( 678db7...164b32 )
by Cody
06:12 queued 03:06
created
classes/opml.php 1 patch
Indentation   +430 added lines, -430 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Opml extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("export", "import");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("export", "import");
6 6
 
7
-		return array_search($method, $csrf_ignored) !== false;
8
-	}
7
+        return array_search($method, $csrf_ignored) !== false;
8
+    }
9 9
 
10
-	public function export() {
11
-		$output_name = "tt-rss_".date("Y-m-d").".opml";
12
-		$include_settings = $_REQUEST["include_settings"] == "1";
13
-		$owner_uid = $_SESSION["uid"];
10
+    public function export() {
11
+        $output_name = "tt-rss_".date("Y-m-d").".opml";
12
+        $include_settings = $_REQUEST["include_settings"] == "1";
13
+        $owner_uid = $_SESSION["uid"];
14 14
 
15
-		$rc = $this->opml_export($output_name, $owner_uid, false, $include_settings);
15
+        $rc = $this->opml_export($output_name, $owner_uid, false, $include_settings);
16 16
 
17
-		return $rc;
18
-	}
17
+        return $rc;
18
+    }
19 19
 
20
-	public function import() {
21
-		$owner_uid = $_SESSION["uid"];
20
+    public function import() {
21
+        $owner_uid = $_SESSION["uid"];
22 22
 
23
-		header('Content-Type: text/html; charset=utf-8');
23
+        header('Content-Type: text/html; charset=utf-8');
24 24
 
25
-		print "<html>
25
+        print "<html>
26 26
 			<head>
27 27
 				".stylesheet_tag("css/default.css")."
28 28
 				<title>".__("OPML Utility")."</title>
@@ -31,184 +31,184 @@  discard block
 block discarded – undo
31 31
 			<body class='claro ttrss_utility'>
32 32
 			<h1>".__('OPML Utility')."</h1><div class='content'>";
33 33
 
34
-		Feeds::add_feed_category("Imported feeds");
34
+        Feeds::add_feed_category("Imported feeds");
35 35
 
36
-		$this->opml_notice(__("Importing OPML..."));
36
+        $this->opml_notice(__("Importing OPML..."));
37 37
 
38
-		$this->opml_import($owner_uid);
38
+        $this->opml_import($owner_uid);
39 39
 
40
-		print "<br><form method=\"GET\" action=\"prefs.php\">
40
+        print "<br><form method=\"GET\" action=\"prefs.php\">
41 41
 			<input type=\"submit\" value=\"".__("Return to preferences")."\">
42 42
 			</form>";
43 43
 
44
-		print "</div></body></html>";
44
+        print "</div></body></html>";
45 45
 
46 46
 
47
-	}
47
+    }
48 48
 
49
-	// Export
49
+    // Export
50 50
 
51
-	private function opml_export_category($owner_uid, $cat_id, $hide_private_feeds = false, $include_settings = true) {
51
+    private function opml_export_category($owner_uid, $cat_id, $hide_private_feeds = false, $include_settings = true) {
52 52
 
53
-		$cat_id = (int) $cat_id;
53
+        $cat_id = (int) $cat_id;
54 54
 
55
-		if ($hide_private_feeds) {
56
-					$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
-		} else {
58
-					$hide_qpart = "true";
59
-		}
55
+        if ($hide_private_feeds) {
56
+                    $hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
+        } else {
58
+                    $hide_qpart = "true";
59
+        }
60 60
 
61
-		$out = "";
61
+        $out = "";
62 62
 
63
-		$ttrss_specific_qpart = "";
63
+        $ttrss_specific_qpart = "";
64 64
 
65
-		if ($cat_id) {
66
-			$sth = $this->pdo->prepare("SELECT title,order_id
65
+        if ($cat_id) {
66
+            $sth = $this->pdo->prepare("SELECT title,order_id
67 67
 				FROM ttrss_feed_categories WHERE id = ?
68 68
 					AND owner_uid = ?");
69
-			$sth->execute([$cat_id, $owner_uid]);
70
-			$row = $sth->fetch();
71
-			$cat_title = htmlspecialchars($row['title']);
72
-
73
-			if ($include_settings) {
74
-				$order_id = (int) $row["order_id"];
75
-				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
76
-			}
77
-		} else {
78
-			$cat_title = "";
79
-		}
80
-
81
-		if ($cat_title) {
82
-		    $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
83
-		}
84
-
85
-		$sth = $this->pdo->prepare("SELECT id,title
69
+            $sth->execute([$cat_id, $owner_uid]);
70
+            $row = $sth->fetch();
71
+            $cat_title = htmlspecialchars($row['title']);
72
+
73
+            if ($include_settings) {
74
+                $order_id = (int) $row["order_id"];
75
+                $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
76
+            }
77
+        } else {
78
+            $cat_title = "";
79
+        }
80
+
81
+        if ($cat_title) {
82
+            $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
83
+        }
84
+
85
+        $sth = $this->pdo->prepare("SELECT id,title
86 86
 			FROM ttrss_feed_categories WHERE
87 87
 				(parent_cat = :cat OR (:cat = 0 AND parent_cat IS NULL)) AND
88 88
 				owner_uid = :uid ORDER BY order_id, title");
89 89
 
90
-		$sth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
90
+        $sth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
91 91
 
92
-		while ($line = $sth->fetch()) {
93
-			$out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds, $include_settings);
94
-		}
92
+        while ($line = $sth->fetch()) {
93
+            $out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds, $include_settings);
94
+        }
95 95
 
96
-		$fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id
96
+        $fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id
97 97
 				FROM ttrss_feeds WHERE
98 98
 					(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND owner_uid = :uid AND $hide_qpart
99 99
 				ORDER BY order_id, title");
100 100
 
101
-		$fsth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
101
+        $fsth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
102 102
 
103
-		while ($fline = $fsth->fetch()) {
104
-			$title = htmlspecialchars($fline["title"]);
105
-			$url = htmlspecialchars($fline["feed_url"]);
106
-			$site_url = htmlspecialchars($fline["site_url"]);
103
+        while ($fline = $fsth->fetch()) {
104
+            $title = htmlspecialchars($fline["title"]);
105
+            $url = htmlspecialchars($fline["feed_url"]);
106
+            $site_url = htmlspecialchars($fline["site_url"]);
107 107
 
108
-			if ($include_settings) {
109
-				$update_interval = (int) $fline["update_interval"];
110
-				$order_id = (int) $fline["order_id"];
108
+            if ($include_settings) {
109
+                $update_interval = (int) $fline["update_interval"];
110
+                $order_id = (int) $fline["order_id"];
111 111
 
112
-				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
113
-			} else {
114
-				$ttrss_specific_qpart = "";
115
-			}
112
+                $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
113
+            } else {
114
+                $ttrss_specific_qpart = "";
115
+            }
116 116
 
117
-			if ($site_url) {
118
-				$html_url_qpart = "htmlUrl=\"$site_url\"";
119
-			} else {
120
-				$html_url_qpart = "";
121
-			}
117
+            if ($site_url) {
118
+                $html_url_qpart = "htmlUrl=\"$site_url\"";
119
+            } else {
120
+                $html_url_qpart = "";
121
+            }
122 122
 
123
-			$out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
124
-		}
123
+            $out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
124
+        }
125 125
 
126
-		if ($cat_title) {
127
-		    $out .= "</outline>\n";
128
-		}
126
+        if ($cat_title) {
127
+            $out .= "</outline>\n";
128
+        }
129 129
 
130
-		return $out;
131
-	}
130
+        return $out;
131
+    }
132 132
 
133
-	public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
134
-		if (!$owner_uid) {
135
-		    return;
136
-		}
133
+    public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
134
+        if (!$owner_uid) {
135
+            return;
136
+        }
137 137
 
138
-		if (!isset($_REQUEST["debug"])) {
139
-			header("Content-type: application/xml+opml");
140
-			header("Content-Disposition: attachment; filename=".$name);
141
-		} else {
142
-			header("Content-type: text/xml");
143
-		}
138
+        if (!isset($_REQUEST["debug"])) {
139
+            header("Content-type: application/xml+opml");
140
+            header("Content-Disposition: attachment; filename=".$name);
141
+        } else {
142
+            header("Content-type: text/xml");
143
+        }
144 144
 
145
-		$out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
145
+        $out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
146 146
 
147
-		$out .= "<opml version=\"1.0\">";
148
-		$out .= "<head>
147
+        $out .= "<opml version=\"1.0\">";
148
+        $out .= "<head>
149 149
 			<dateCreated>" . date("r", time())."</dateCreated>
150 150
 			<title>Tiny Tiny RSS Feed Export</title>
151 151
 		</head>";
152
-		$out .= "<body>";
152
+        $out .= "<body>";
153 153
 
154
-		$out .= $this->opml_export_category($owner_uid, 0, $hide_private_feeds, $include_settings);
154
+        $out .= $this->opml_export_category($owner_uid, 0, $hide_private_feeds, $include_settings);
155 155
 
156
-		# export tt-rss settings
156
+        # export tt-rss settings
157 157
 
158
-		if ($include_settings) {
159
-			$out .= "<outline text=\"tt-rss-prefs\" schema-version=\"".SCHEMA_VERSION."\">";
158
+        if ($include_settings) {
159
+            $out .= "<outline text=\"tt-rss-prefs\" schema-version=\"".SCHEMA_VERSION."\">";
160 160
 
161
-			$sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs WHERE
161
+            $sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs WHERE
162 162
 			   profile IS NULL AND owner_uid = ? ORDER BY pref_name");
163
-			$sth->execute([$owner_uid]);
163
+            $sth->execute([$owner_uid]);
164 164
 
165
-			while ($line = $sth->fetch()) {
166
-				$name = $line["pref_name"];
167
-				$value = htmlspecialchars($line["value"]);
165
+            while ($line = $sth->fetch()) {
166
+                $name = $line["pref_name"];
167
+                $value = htmlspecialchars($line["value"]);
168 168
 
169
-				$out .= "<outline pref-name=\"$name\" value=\"$value\"/>";
170
-			}
169
+                $out .= "<outline pref-name=\"$name\" value=\"$value\"/>";
170
+            }
171 171
 
172
-			$out .= "</outline>";
172
+            $out .= "</outline>";
173 173
 
174
-			$out .= "<outline text=\"tt-rss-labels\" schema-version=\"".SCHEMA_VERSION."\">";
174
+            $out .= "<outline text=\"tt-rss-labels\" schema-version=\"".SCHEMA_VERSION."\">";
175 175
 
176
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
176
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
177 177
 				owner_uid = ?");
178
-			$sth->execute([$owner_uid]);
178
+            $sth->execute([$owner_uid]);
179 179
 
180
-			while ($line = $sth->fetch()) {
181
-				$name = htmlspecialchars($line['caption']);
182
-				$fg_color = htmlspecialchars($line['fg_color']);
183
-				$bg_color = htmlspecialchars($line['bg_color']);
180
+            while ($line = $sth->fetch()) {
181
+                $name = htmlspecialchars($line['caption']);
182
+                $fg_color = htmlspecialchars($line['fg_color']);
183
+                $bg_color = htmlspecialchars($line['bg_color']);
184 184
 
185
-				$out .= "<outline label-name=\"$name\" label-fg-color=\"$fg_color\" label-bg-color=\"$bg_color\"/>";
185
+                $out .= "<outline label-name=\"$name\" label-fg-color=\"$fg_color\" label-bg-color=\"$bg_color\"/>";
186 186
 
187
-			}
187
+            }
188 188
 
189
-			$out .= "</outline>";
189
+            $out .= "</outline>";
190 190
 
191
-			$out .= "<outline text=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
191
+            $out .= "<outline text=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
192 192
 
193
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
193
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
194 194
 				WHERE owner_uid = ? ORDER BY id");
195
-			$sth->execute([$owner_uid]);
195
+            $sth->execute([$owner_uid]);
196 196
 
197
-			while ($line = $sth->fetch()) {
198
-				$line["rules"] = array();
199
-				$line["actions"] = array();
197
+            while ($line = $sth->fetch()) {
198
+                $line["rules"] = array();
199
+                $line["actions"] = array();
200 200
 
201
-				$tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
201
+                $tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
202 202
 					WHERE filter_id = ?");
203
-				$tmph->execute([$line['id']]);
203
+                $tmph->execute([$line['id']]);
204 204
 
205
-				while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
206
-					unset($tmp_line["id"]);
207
-					unset($tmp_line["filter_id"]);
205
+                while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
206
+                    unset($tmp_line["id"]);
207
+                    unset($tmp_line["filter_id"]);
208 208
 
209
-					$cat_filter = $tmp_line["cat_filter"];
209
+                    $cat_filter = $tmp_line["cat_filter"];
210 210
 
211
-					if (!$tmp_line["match_on"]) {
211
+                    if (!$tmp_line["match_on"]) {
212 212
                         if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
213 213
                             $tmp_line["feed"] = Feeds::getFeedTitle(
214 214
                                 $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
                             $tmp_line["feed"] = "";
218 218
                         }
219 219
                     } else {
220
-					    $match = [];
221
-					    foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
220
+                        $match = [];
221
+                        foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
222 222
 
223 223
                             if (strpos($feed_id, "CAT:") === 0) {
224 224
                                 $feed_id = (int) substr($feed_id, 4);
@@ -237,57 +237,57 @@  discard block
 block discarded – undo
237 237
                         }
238 238
 
239 239
                         $tmp_line["match"] = $match;
240
-					    unset($tmp_line["match_on"]);
240
+                        unset($tmp_line["match_on"]);
241 241
                     }
242 242
 
243
-					unset($tmp_line["feed_id"]);
244
-					unset($tmp_line["cat_id"]);
243
+                    unset($tmp_line["feed_id"]);
244
+                    unset($tmp_line["cat_id"]);
245 245
 
246
-					array_push($line["rules"], $tmp_line);
247
-				}
246
+                    array_push($line["rules"], $tmp_line);
247
+                }
248 248
 
249
-				$tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
249
+                $tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
250 250
 					WHERE filter_id = ?");
251
-				$tmph->execute([$line['id']]);
251
+                $tmph->execute([$line['id']]);
252 252
 
253
-				while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
254
-					unset($tmp_line["id"]);
255
-					unset($tmp_line["filter_id"]);
253
+                while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
254
+                    unset($tmp_line["id"]);
255
+                    unset($tmp_line["filter_id"]);
256 256
 
257
-					array_push($line["actions"], $tmp_line);
258
-				}
257
+                    array_push($line["actions"], $tmp_line);
258
+                }
259 259
 
260
-				unset($line["id"]);
261
-				unset($line["owner_uid"]);
262
-				$filter = json_encode($line);
260
+                unset($line["id"]);
261
+                unset($line["owner_uid"]);
262
+                $filter = json_encode($line);
263 263
 
264
-				$out .= "<outline filter-type=\"2\"><![CDATA[$filter]]></outline>";
264
+                $out .= "<outline filter-type=\"2\"><![CDATA[$filter]]></outline>";
265 265
 
266
-			}
266
+            }
267 267
 
268 268
 
269
-			$out .= "</outline>";
270
-		}
269
+            $out .= "</outline>";
270
+        }
271 271
 
272
-		$out .= "</body></opml>";
272
+        $out .= "</body></opml>";
273 273
 
274
-		// Format output.
275
-		$doc = new DOMDocument();
276
-		$doc->formatOutput = true;
277
-		$doc->preserveWhiteSpace = false;
278
-		$doc->loadXML($out);
274
+        // Format output.
275
+        $doc = new DOMDocument();
276
+        $doc->formatOutput = true;
277
+        $doc->preserveWhiteSpace = false;
278
+        $doc->loadXML($out);
279 279
 
280
-		$xpath = new DOMXpath($doc);
281
-		$outlines = $xpath->query("//outline[@title]");
280
+        $xpath = new DOMXpath($doc);
281
+        $outlines = $xpath->query("//outline[@title]");
282 282
 
283
-		// cleanup empty categories
284
-		foreach ($outlines as $node) {
285
-			if ($node->getElementsByTagName('outline')->length == 0) {
286
-							$node->parentNode->removeChild($node);
287
-			}
288
-		}
283
+        // cleanup empty categories
284
+        foreach ($outlines as $node) {
285
+            if ($node->getElementsByTagName('outline')->length == 0) {
286
+                            $node->parentNode->removeChild($node);
287
+            }
288
+        }
289 289
 
290
-		$res = $doc->saveXML();
290
+        $res = $doc->saveXML();
291 291
 
292 292
 /*		// saveXML uses a two-space indent.  Change to tabs.
293 293
 		$res = preg_replace_callback('/^(?:  )+/mu',
@@ -296,140 +296,140 @@  discard block
 block discarded – undo
296 296
 				'return str_repeat("\t", intval(strlen($matches[0])/2));'),
297 297
 			$res); */
298 298
 
299
-		print $res;
300
-	}
299
+        print $res;
300
+    }
301 301
 
302
-	// Import
302
+    // Import
303 303
 
304
-	private function opml_import_feed($node, $cat_id, $owner_uid) {
305
-		$attrs = $node->attributes;
304
+    private function opml_import_feed($node, $cat_id, $owner_uid) {
305
+        $attrs = $node->attributes;
306 306
 
307
-		$feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
308
-		if (!$feed_title) {
309
-		    $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
310
-		}
307
+        $feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
308
+        if (!$feed_title) {
309
+            $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
310
+        }
311 311
 
312
-		$feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
313
-		if (!$feed_url) {
314
-		    $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
315
-		}
312
+        $feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
313
+        if (!$feed_url) {
314
+            $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
315
+        }
316 316
 
317
-		$site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
317
+        $site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
318 318
 
319
-		if ($feed_url) {
320
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
319
+        if ($feed_url) {
320
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
321 321
 				feed_url = ? AND owner_uid = ?");
322
-			$sth->execute([$feed_url, $owner_uid]);
322
+            $sth->execute([$feed_url, $owner_uid]);
323 323
 
324
-			if (!$feed_title) {
325
-			    $feed_title = '[Unknown]';
326
-			}
324
+            if (!$feed_title) {
325
+                $feed_title = '[Unknown]';
326
+            }
327 327
 
328
-			if (!$sth->fetch()) {
329
-				#$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
330
-				$this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
328
+            if (!$sth->fetch()) {
329
+                #$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
330
+                $this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
331 331
 
332
-				if (!$cat_id) {
333
-				    $cat_id = null;
334
-				}
332
+                if (!$cat_id) {
333
+                    $cat_id = null;
334
+                }
335 335
 
336
-				$update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
337
-				if (!$update_interval) {
338
-				    $update_interval = 0;
339
-				}
336
+                $update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
337
+                if (!$update_interval) {
338
+                    $update_interval = 0;
339
+                }
340 340
 
341
-				$order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
342
-				if (!$order_id) {
343
-				    $order_id = 0;
344
-				}
341
+                $order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
342
+                if (!$order_id) {
343
+                    $order_id = 0;
344
+                }
345 345
 
346
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
346
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
347 347
 					(title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES
348 348
 					(?, ?, ?, ?, ?, ?, ?)");
349 349
 
350
-				$sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval]);
350
+                $sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval]);
351 351
 
352
-			} else {
353
-				$this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
354
-			}
355
-		}
356
-	}
352
+            } else {
353
+                $this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
354
+            }
355
+        }
356
+    }
357 357
 
358
-	private function opml_import_label($node, $owner_uid) {
359
-		$attrs = $node->attributes;
360
-		$label_name = $attrs->getNamedItem('label-name')->nodeValue;
358
+    private function opml_import_label($node, $owner_uid) {
359
+        $attrs = $node->attributes;
360
+        $label_name = $attrs->getNamedItem('label-name')->nodeValue;
361 361
 
362
-		if ($label_name) {
363
-			$fg_color = $attrs->getNamedItem('label-fg-color')->nodeValue;
364
-			$bg_color = $attrs->getNamedItem('label-bg-color')->nodeValue;
362
+        if ($label_name) {
363
+            $fg_color = $attrs->getNamedItem('label-fg-color')->nodeValue;
364
+            $bg_color = $attrs->getNamedItem('label-bg-color')->nodeValue;
365 365
 
366
-			if (!Labels::find_id($label_name, $_SESSION['uid'])) {
367
-				$this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
368
-				Labels::create($label_name, $fg_color, $bg_color, $owner_uid);
369
-			} else {
370
-				$this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
371
-			}
372
-		}
373
-	}
366
+            if (!Labels::find_id($label_name, $_SESSION['uid'])) {
367
+                $this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
368
+                Labels::create($label_name, $fg_color, $bg_color, $owner_uid);
369
+            } else {
370
+                $this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
371
+            }
372
+        }
373
+    }
374 374
 
375
-	private function opml_import_preference($node) {
376
-		$attrs = $node->attributes;
377
-		$pref_name = $attrs->getNamedItem('pref-name')->nodeValue;
375
+    private function opml_import_preference($node) {
376
+        $attrs = $node->attributes;
377
+        $pref_name = $attrs->getNamedItem('pref-name')->nodeValue;
378 378
 
379
-		if ($pref_name) {
380
-			$pref_value = $attrs->getNamedItem('value')->nodeValue;
379
+        if ($pref_name) {
380
+            $pref_value = $attrs->getNamedItem('value')->nodeValue;
381 381
 
382
-			$this->opml_notice(T_sprintf("Setting preference key %s to %s",
383
-				$pref_name, $pref_value));
382
+            $this->opml_notice(T_sprintf("Setting preference key %s to %s",
383
+                $pref_name, $pref_value));
384 384
 
385
-			set_pref($pref_name, $pref_value);
386
-		}
387
-	}
385
+            set_pref($pref_name, $pref_value);
386
+        }
387
+    }
388 388
 
389
-	private function opml_import_filter($node) {
390
-		$attrs = $node->attributes;
389
+    private function opml_import_filter($node) {
390
+        $attrs = $node->attributes;
391 391
 
392
-		$filter_type = $attrs->getNamedItem('filter-type')->nodeValue;
392
+        $filter_type = $attrs->getNamedItem('filter-type')->nodeValue;
393 393
 
394
-		if ($filter_type == '2') {
395
-			$filter = json_decode($node->nodeValue, true);
394
+        if ($filter_type == '2') {
395
+            $filter = json_decode($node->nodeValue, true);
396 396
 
397
-			if ($filter) {
398
-				$match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
399
-				$enabled = bool_to_sql_bool($filter["enabled"]);
400
-				$inverse = bool_to_sql_bool($filter["inverse"]);
401
-				$title = $filter["title"];
397
+            if ($filter) {
398
+                $match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
399
+                $enabled = bool_to_sql_bool($filter["enabled"]);
400
+                $inverse = bool_to_sql_bool($filter["inverse"]);
401
+                $title = $filter["title"];
402 402
 
403
-				//print "F: $title, $inverse, $enabled, $match_any_rule";
403
+                //print "F: $title, $inverse, $enabled, $match_any_rule";
404 404
 
405
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 (match_any_rule,enabled,inverse,title,owner_uid)
405
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 (match_any_rule,enabled,inverse,title,owner_uid)
406 406
 					VALUES (?, ?, ?, ?, ?)");
407 407
 
408
-				$sth->execute([$match_any_rule, $enabled, $inverse, $title, $_SESSION['uid']]);
408
+                $sth->execute([$match_any_rule, $enabled, $inverse, $title, $_SESSION['uid']]);
409 409
 
410
-				$sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
410
+                $sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
411 411
 					owner_uid = ?");
412
-				$sth->execute([$_SESSION['uid']]);
412
+                $sth->execute([$_SESSION['uid']]);
413 413
 
414
-				$row = $sth->fetch();
415
-				$filter_id = $row['id'];
414
+                $row = $sth->fetch();
415
+                $filter_id = $row['id'];
416 416
 
417
-				if ($filter_id) {
418
-					$this->opml_notice(T_sprintf("Adding filter %s...", $title));
417
+                if ($filter_id) {
418
+                    $this->opml_notice(T_sprintf("Adding filter %s...", $title));
419 419
 
420
-					foreach ($filter["rules"] as $rule) {
421
-						$feed_id = null;
422
-						$cat_id = null;
420
+                    foreach ($filter["rules"] as $rule) {
421
+                        $feed_id = null;
422
+                        $cat_id = null;
423 423
 
424
-						if ($rule["match"]) {
424
+                        if ($rule["match"]) {
425 425
 
426 426
                             $match_on = [];
427 427
 
428
-						    foreach ($rule["match"] as $match) {
429
-						        list ($name, $is_cat, $is_id) = $match;
428
+                            foreach ($rule["match"] as $match) {
429
+                                list ($name, $is_cat, $is_id) = $match;
430 430
 
431
-						        if ($is_id) {
432
-						            array_push($match_on, ($is_cat ? "CAT:" : "").$name);
431
+                                if ($is_id) {
432
+                                    array_push($match_on, ($is_cat ? "CAT:" : "").$name);
433 433
                                 } else {
434 434
 
435 435
                                     if (!$is_cat) {
@@ -441,18 +441,18 @@  discard block
 block discarded – undo
441 441
                                         if ($row = $tsth->fetch()) {
442 442
                                             $match_id = $row['id'];
443 443
 
444
-											array_push($match_on, $match_id);
444
+                                            array_push($match_on, $match_id);
445 445
                                         }
446 446
                                     } else {
447 447
                                         $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
448 448
                                     		WHERE title = ? AND owner_uid = ?");
449
-										$tsth->execute([$name, $_SESSION['uid']]);
449
+                                        $tsth->execute([$name, $_SESSION['uid']]);
450 450
 
451
-										if ($row = $tsth->fetch()) {
452
-											$match_id = $row['id'];
451
+                                        if ($row = $tsth->fetch()) {
452
+                                            $match_id = $row['id'];
453 453
 
454
-											array_push($match_on, "CAT:$match_id");
455
-										}
454
+                                            array_push($match_on, "CAT:$match_id");
455
+                                        }
456 456
                                     }
457 457
                                 }
458 458
                             }
@@ -480,14 +480,14 @@  discard block
 block discarded – undo
480 480
                                     $feed_id = $row['id'];
481 481
                                 }
482 482
                             } else {
483
-								$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
483
+                                $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
484 484
                                     WHERE title = ? AND owner_uid = ?");
485 485
 
486
-								$tsth->execute([$rule['feed'], $_SESSION['uid']]);
486
+                                $tsth->execute([$rule['feed'], $_SESSION['uid']]);
487 487
 
488
-								if ($row = $tsth->fetch()) {
489
-									$feed_id = $row['id'];
490
-								}
488
+                                if ($row = $tsth->fetch()) {
489
+                                    $feed_id = $row['id'];
490
+                                }
491 491
                             }
492 492
 
493 493
                             $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
@@ -501,180 +501,180 @@  discard block
 block discarded – undo
501 501
                                 (?, ?, ?, ?, ?, ?, ?)");
502 502
                             $usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]);
503 503
                         }
504
-					}
504
+                    }
505 505
 
506
-					foreach ($filter["actions"] as $action) {
506
+                    foreach ($filter["actions"] as $action) {
507 507
 
508
-						$action_id = (int) $action["action_id"];
509
-						$action_param = $action["action_param"];
508
+                        $action_id = (int) $action["action_id"];
509
+                        $action_param = $action["action_param"];
510 510
 
511
-						$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
511
+                        $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
512 512
 							(filter_id,action_id,action_param)
513 513
 							VALUES
514 514
 							(?, ?, ?)");
515
-						$usth->execute([$filter_id, $action_id, $action_param]);
516
-					}
517
-				}
518
-			}
519
-		}
520
-	}
521
-
522
-	private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
523
-		$default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
524
-
525
-		if ($root_node) {
526
-			$cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
527
-
528
-			if (!$cat_title) {
529
-							$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
530
-			}
531
-
532
-			if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
533
-				$cat_id = $this->get_feed_category($cat_title, $parent_id);
534
-
535
-				if ($cat_id === false) {
536
-					$order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
537
-					if (!$order_id) {
538
-					    $order_id = 0;
539
-					}
540
-
541
-					Feeds::add_feed_category($cat_title, $parent_id, $order_id);
542
-					$cat_id = $this->get_feed_category($cat_title, $parent_id);
543
-				}
544
-
545
-			} else {
546
-				$cat_id = 0;
547
-			}
548
-
549
-			$outlines = $root_node->childNodes;
550
-
551
-		} else {
552
-			$xpath = new DOMXpath($doc);
553
-			$outlines = $xpath->query("//opml/body/outline");
554
-
555
-			$cat_id = 0;
556
-		}
557
-
558
-		#$this->opml_notice("[CAT] $cat_title id: $cat_id P_id: $parent_id");
559
-		$this->opml_notice(T_sprintf("Processing category: %s", $cat_title ? $cat_title : __("Uncategorized")));
560
-
561
-		foreach ($outlines as $node) {
562
-			if ($node->hasAttributes() && strtolower($node->tagName) == "outline") {
563
-				$attrs = $node->attributes;
564
-				$node_cat_title = $attrs->getNamedItem('text')->nodeValue;
565
-
566
-				if (!$node_cat_title) {
567
-									$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
568
-				}
569
-
570
-				$node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
571
-
572
-				if ($node_cat_title && !$node_feed_url) {
573
-					$this->opml_import_category($doc, $node, $owner_uid, $cat_id);
574
-				} else {
575
-
576
-					if (!$cat_id) {
577
-						$dst_cat_id = $default_cat_id;
578
-					} else {
579
-						$dst_cat_id = $cat_id;
580
-					}
581
-
582
-					switch ($cat_title) {
583
-					case "tt-rss-prefs":
584
-						$this->opml_import_preference($node);
585
-						break;
586
-					case "tt-rss-labels":
587
-						$this->opml_import_label($node, $owner_uid);
588
-						break;
589
-					case "tt-rss-filters":
590
-						$this->opml_import_filter($node);
591
-						break;
592
-					default:
593
-						$this->opml_import_feed($node, $dst_cat_id, $owner_uid);
594
-					}
595
-				}
596
-			}
597
-		}
598
-	}
599
-
600
-	public function opml_import($owner_uid) {
601
-		if (!$owner_uid) {
602
-		    return;
603
-		}
604
-
605
-		$doc = false;
606
-
607
-		if ($_FILES['opml_file']['error'] != 0) {
608
-			print_error(T_sprintf("Upload failed with error code %d",
609
-				$_FILES['opml_file']['error']));
610
-			return;
611
-		}
612
-
613
-		if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
614
-			$tmp_file = tempnam(CACHE_DIR.'/upload', 'opml');
615
-
616
-			$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
617
-				$tmp_file);
618
-
619
-			if (!$result) {
620
-				print_error(__("Unable to move uploaded file."));
621
-				return;
622
-			}
623
-		} else {
624
-			print_error(__('Error: please upload OPML file.'));
625
-			return;
626
-		}
627
-
628
-		if (is_file($tmp_file)) {
629
-			$doc = new DOMDocument();
630
-			libxml_disable_entity_loader(false);
631
-			$doc->load($tmp_file);
632
-			libxml_disable_entity_loader(true);
633
-			unlink($tmp_file);
634
-		} else if (!$doc) {
635
-			print_error(__('Error: unable to find moved OPML file.'));
636
-			return;
637
-		}
638
-
639
-		if ($doc) {
640
-			$this->pdo->beginTransaction();
641
-			$this->opml_import_category($doc, false, $owner_uid, false);
642
-			$this->pdo->commit();
643
-		} else {
644
-			print_error(__('Error while parsing document.'));
645
-		}
646
-	}
647
-
648
-	private function opml_notice($msg) {
649
-		print "$msg<br/>";
650
-	}
651
-
652
-	public static function opml_publish_url() {
653
-
654
-		$url_path = get_self_url_prefix();
655
-		$url_path .= "/opml.php?op=publish&key=".
656
-			Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
657
-
658
-		return $url_path;
659
-	}
660
-
661
-	public function get_feed_category($feed_cat, $parent_cat_id = false) {
662
-
663
-		$parent_cat_id = (int) $parent_cat_id;
664
-
665
-		$sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
515
+                        $usth->execute([$filter_id, $action_id, $action_param]);
516
+                    }
517
+                }
518
+            }
519
+        }
520
+    }
521
+
522
+    private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
523
+        $default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
524
+
525
+        if ($root_node) {
526
+            $cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
527
+
528
+            if (!$cat_title) {
529
+                            $cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
530
+            }
531
+
532
+            if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
533
+                $cat_id = $this->get_feed_category($cat_title, $parent_id);
534
+
535
+                if ($cat_id === false) {
536
+                    $order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
537
+                    if (!$order_id) {
538
+                        $order_id = 0;
539
+                    }
540
+
541
+                    Feeds::add_feed_category($cat_title, $parent_id, $order_id);
542
+                    $cat_id = $this->get_feed_category($cat_title, $parent_id);
543
+                }
544
+
545
+            } else {
546
+                $cat_id = 0;
547
+            }
548
+
549
+            $outlines = $root_node->childNodes;
550
+
551
+        } else {
552
+            $xpath = new DOMXpath($doc);
553
+            $outlines = $xpath->query("//opml/body/outline");
554
+
555
+            $cat_id = 0;
556
+        }
557
+
558
+        #$this->opml_notice("[CAT] $cat_title id: $cat_id P_id: $parent_id");
559
+        $this->opml_notice(T_sprintf("Processing category: %s", $cat_title ? $cat_title : __("Uncategorized")));
560
+
561
+        foreach ($outlines as $node) {
562
+            if ($node->hasAttributes() && strtolower($node->tagName) == "outline") {
563
+                $attrs = $node->attributes;
564
+                $node_cat_title = $attrs->getNamedItem('text')->nodeValue;
565
+
566
+                if (!$node_cat_title) {
567
+                                    $node_cat_title = $attrs->getNamedItem('title')->nodeValue;
568
+                }
569
+
570
+                $node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
571
+
572
+                if ($node_cat_title && !$node_feed_url) {
573
+                    $this->opml_import_category($doc, $node, $owner_uid, $cat_id);
574
+                } else {
575
+
576
+                    if (!$cat_id) {
577
+                        $dst_cat_id = $default_cat_id;
578
+                    } else {
579
+                        $dst_cat_id = $cat_id;
580
+                    }
581
+
582
+                    switch ($cat_title) {
583
+                    case "tt-rss-prefs":
584
+                        $this->opml_import_preference($node);
585
+                        break;
586
+                    case "tt-rss-labels":
587
+                        $this->opml_import_label($node, $owner_uid);
588
+                        break;
589
+                    case "tt-rss-filters":
590
+                        $this->opml_import_filter($node);
591
+                        break;
592
+                    default:
593
+                        $this->opml_import_feed($node, $dst_cat_id, $owner_uid);
594
+                    }
595
+                }
596
+            }
597
+        }
598
+    }
599
+
600
+    public function opml_import($owner_uid) {
601
+        if (!$owner_uid) {
602
+            return;
603
+        }
604
+
605
+        $doc = false;
606
+
607
+        if ($_FILES['opml_file']['error'] != 0) {
608
+            print_error(T_sprintf("Upload failed with error code %d",
609
+                $_FILES['opml_file']['error']));
610
+            return;
611
+        }
612
+
613
+        if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
614
+            $tmp_file = tempnam(CACHE_DIR.'/upload', 'opml');
615
+
616
+            $result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
617
+                $tmp_file);
618
+
619
+            if (!$result) {
620
+                print_error(__("Unable to move uploaded file."));
621
+                return;
622
+            }
623
+        } else {
624
+            print_error(__('Error: please upload OPML file.'));
625
+            return;
626
+        }
627
+
628
+        if (is_file($tmp_file)) {
629
+            $doc = new DOMDocument();
630
+            libxml_disable_entity_loader(false);
631
+            $doc->load($tmp_file);
632
+            libxml_disable_entity_loader(true);
633
+            unlink($tmp_file);
634
+        } else if (!$doc) {
635
+            print_error(__('Error: unable to find moved OPML file.'));
636
+            return;
637
+        }
638
+
639
+        if ($doc) {
640
+            $this->pdo->beginTransaction();
641
+            $this->opml_import_category($doc, false, $owner_uid, false);
642
+            $this->pdo->commit();
643
+        } else {
644
+            print_error(__('Error while parsing document.'));
645
+        }
646
+    }
647
+
648
+    private function opml_notice($msg) {
649
+        print "$msg<br/>";
650
+    }
651
+
652
+    public static function opml_publish_url() {
653
+
654
+        $url_path = get_self_url_prefix();
655
+        $url_path .= "/opml.php?op=publish&key=".
656
+            Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
657
+
658
+        return $url_path;
659
+    }
660
+
661
+    public function get_feed_category($feed_cat, $parent_cat_id = false) {
662
+
663
+        $parent_cat_id = (int) $parent_cat_id;
664
+
665
+        $sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
666 666
 			WHERE title = :title
667 667
 			AND (parent_cat = :parent OR (:parent = 0 AND parent_cat IS NULL))
668 668
 			AND owner_uid = :uid");
669 669
 
670
-		$sth->execute([':title' => $feed_cat, ':parent' => $parent_cat_id, ':uid' => $_SESSION['uid']]);
670
+        $sth->execute([':title' => $feed_cat, ':parent' => $parent_cat_id, ':uid' => $_SESSION['uid']]);
671 671
 
672
-		if ($row = $sth->fetch()) {
673
-			return $row['id'];
674
-		} else {
675
-			return false;
676
-		}
677
-	}
672
+        if ($row = $sth->fetch()) {
673
+            return $row['id'];
674
+        } else {
675
+            return false;
676
+        }
677
+    }
678 678
 
679 679
 
680 680
 }
Please login to merge, or discard this patch.
classes/feedparser.php 2 patches
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -1,243 +1,243 @@
 block discarded – undo
1 1
 <?php
2 2
 class FeedParser {
3
-	private $doc;
4
-	private $error;
5
-	private $libxml_errors = array();
6
-	private $items;
7
-	private $link;
8
-	private $title;
9
-	private $type;
10
-	private $xpath;
11
-
12
-	const FEED_RDF = 0;
13
-	const FEED_RSS = 1;
14
-	const FEED_ATOM = 2;
15
-
16
-	public function __construct($data) {
17
-		libxml_use_internal_errors(true);
18
-		libxml_clear_errors();
19
-		$this->doc = new DOMDocument();
20
-		$this->doc->loadXML($data);
21
-
22
-		mb_substitute_character("none");
23
-
24
-		$error = libxml_get_last_error();
25
-
26
-		if ($error) {
27
-			foreach (libxml_get_errors() as $error) {
28
-				if ($error->level == LIBXML_ERR_FATAL) {
29
-					if (!isset($this->error)) //currently only the first error is reported
30
-						$this->error = $this->format_error($error);
31
-					$this->libxml_errors [] = $this->format_error($error);
32
-				}
33
-			}
34
-		}
35
-		libxml_clear_errors();
36
-
37
-		$this->items = array();
38
-	}
39
-
40
-	public function init() {
41
-		$xpath = new DOMXPath($this->doc);
42
-		$xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
43
-		$xpath->registerNamespace('atom03', 'http://purl.org/atom/ns#');
44
-		$xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
45
-		$xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
46
-		$xpath->registerNamespace('slash', 'http://purl.org/rss/1.0/modules/slash/');
47
-		$xpath->registerNamespace('dc', 'http://purl.org/dc/elements/1.1/');
48
-		$xpath->registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
49
-		$xpath->registerNamespace('thread', 'http://purl.org/syndication/thread/1.0');
50
-
51
-		$this->xpath = $xpath;
52
-
53
-		$root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)");
54
-
55
-		if ($root && $root->length > 0) {
56
-			$root = $root->item(0);
57
-
58
-			if ($root) {
59
-				switch (mb_strtolower($root->tagName)) {
60
-				case "rdf:rdf":
61
-					$this->type = $this::FEED_RDF;
62
-					break;
63
-				case "channel":
64
-					$this->type = $this::FEED_RSS;
65
-					break;
66
-				case "feed":
67
-				case "atom:feed":
68
-					$this->type = $this::FEED_ATOM;
69
-					break;
70
-				default:
71
-					if (!isset($this->error)) {
72
-						$this->error = "Unknown/unsupported feed type";
73
-					}
74
-					return;
75
-				}
76
-			}
77
-
78
-			switch ($this->type) {
79
-			case $this::FEED_ATOM:
80
-
81
-				$title = $xpath->query("//atom:feed/atom:title")->item(0);
82
-
83
-				if (!$title) {
84
-									$title = $xpath->query("//atom03:feed/atom03:title")->item(0);
85
-				}
86
-
87
-
88
-				if ($title) {
89
-					$this->title = $title->nodeValue;
90
-				}
91
-
92
-				$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
93
-
94
-				if (!$link) {
95
-									$link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
96
-				}
97
-
98
-				if (!$link) {
99
-									$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
100
-				}
101
-
102
-				if (!$link) {
103
-									$link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
104
-				}
105
-
106
-				if ($link && $link->hasAttributes()) {
107
-					$this->link = $link->getAttribute("href");
108
-				}
109
-
110
-				$articles = $xpath->query("//atom:entry");
111
-
112
-				if (!$articles || $articles->length == 0) {
113
-									$articles = $xpath->query("//atom03:entry");
114
-				}
115
-
116
-				foreach ($articles as $article) {
117
-					array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
118
-				}
119
-
120
-				break;
121
-			case $this::FEED_RSS:
122
-				$title = $xpath->query("//channel/title")->item(0);
123
-
124
-				if ($title) {
125
-					$this->title = $title->nodeValue;
126
-				}
127
-
128
-				$link = $xpath->query("//channel/link")->item(0);
129
-
130
-				if ($link) {
131
-					if ($link->getAttribute("href")) {
132
-											$this->link = $link->getAttribute("href");
133
-					} else if ($link->nodeValue) {
134
-											$this->link = $link->nodeValue;
135
-					}
136
-				}
137
-
138
-				$articles = $xpath->query("//channel/item");
139
-
140
-				foreach ($articles as $article) {
141
-					array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
142
-				}
143
-
144
-				break;
145
-			case $this::FEED_RDF:
146
-				$xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
147
-
148
-				$title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
149
-
150
-				if ($title) {
151
-					$this->title = $title->nodeValue;
152
-				}
153
-
154
-				$link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
155
-
156
-				if ($link) {
157
-					$this->link = $link->nodeValue;
158
-				}
159
-
160
-				$articles = $xpath->query("//rssfake:item");
161
-
162
-				foreach ($articles as $article) {
163
-					array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
164
-				}
165
-
166
-				break;
167
-
168
-			}
169
-
170
-			if ($this->title) {
171
-			    $this->title = trim($this->title);
172
-			}
173
-			if ($this->link) {
174
-			    $this->link = trim($this->link);
175
-			}
3
+    private $doc;
4
+    private $error;
5
+    private $libxml_errors = array();
6
+    private $items;
7
+    private $link;
8
+    private $title;
9
+    private $type;
10
+    private $xpath;
11
+
12
+    const FEED_RDF = 0;
13
+    const FEED_RSS = 1;
14
+    const FEED_ATOM = 2;
15
+
16
+    public function __construct($data) {
17
+        libxml_use_internal_errors(true);
18
+        libxml_clear_errors();
19
+        $this->doc = new DOMDocument();
20
+        $this->doc->loadXML($data);
21
+
22
+        mb_substitute_character("none");
23
+
24
+        $error = libxml_get_last_error();
25
+
26
+        if ($error) {
27
+            foreach (libxml_get_errors() as $error) {
28
+                if ($error->level == LIBXML_ERR_FATAL) {
29
+                    if (!isset($this->error)) //currently only the first error is reported
30
+                        $this->error = $this->format_error($error);
31
+                    $this->libxml_errors [] = $this->format_error($error);
32
+                }
33
+            }
34
+        }
35
+        libxml_clear_errors();
36
+
37
+        $this->items = array();
38
+    }
39
+
40
+    public function init() {
41
+        $xpath = new DOMXPath($this->doc);
42
+        $xpath->registerNamespace('atom', 'http://www.w3.org/2005/Atom');
43
+        $xpath->registerNamespace('atom03', 'http://purl.org/atom/ns#');
44
+        $xpath->registerNamespace('media', 'http://search.yahoo.com/mrss/');
45
+        $xpath->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
46
+        $xpath->registerNamespace('slash', 'http://purl.org/rss/1.0/modules/slash/');
47
+        $xpath->registerNamespace('dc', 'http://purl.org/dc/elements/1.1/');
48
+        $xpath->registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
49
+        $xpath->registerNamespace('thread', 'http://purl.org/syndication/thread/1.0');
50
+
51
+        $this->xpath = $xpath;
52
+
53
+        $root = $xpath->query("(//atom03:feed|//atom:feed|//channel|//rdf:rdf|//rdf:RDF)");
54
+
55
+        if ($root && $root->length > 0) {
56
+            $root = $root->item(0);
57
+
58
+            if ($root) {
59
+                switch (mb_strtolower($root->tagName)) {
60
+                case "rdf:rdf":
61
+                    $this->type = $this::FEED_RDF;
62
+                    break;
63
+                case "channel":
64
+                    $this->type = $this::FEED_RSS;
65
+                    break;
66
+                case "feed":
67
+                case "atom:feed":
68
+                    $this->type = $this::FEED_ATOM;
69
+                    break;
70
+                default:
71
+                    if (!isset($this->error)) {
72
+                        $this->error = "Unknown/unsupported feed type";
73
+                    }
74
+                    return;
75
+                }
76
+            }
77
+
78
+            switch ($this->type) {
79
+            case $this::FEED_ATOM:
80
+
81
+                $title = $xpath->query("//atom:feed/atom:title")->item(0);
82
+
83
+                if (!$title) {
84
+                                    $title = $xpath->query("//atom03:feed/atom03:title")->item(0);
85
+                }
86
+
87
+
88
+                if ($title) {
89
+                    $this->title = $title->nodeValue;
90
+                }
91
+
92
+                $link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
93
+
94
+                if (!$link) {
95
+                                    $link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
96
+                }
97
+
98
+                if (!$link) {
99
+                                    $link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
100
+                }
101
+
102
+                if (!$link) {
103
+                                    $link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
104
+                }
105
+
106
+                if ($link && $link->hasAttributes()) {
107
+                    $this->link = $link->getAttribute("href");
108
+                }
109
+
110
+                $articles = $xpath->query("//atom:entry");
111
+
112
+                if (!$articles || $articles->length == 0) {
113
+                                    $articles = $xpath->query("//atom03:entry");
114
+                }
115
+
116
+                foreach ($articles as $article) {
117
+                    array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
118
+                }
119
+
120
+                break;
121
+            case $this::FEED_RSS:
122
+                $title = $xpath->query("//channel/title")->item(0);
123
+
124
+                if ($title) {
125
+                    $this->title = $title->nodeValue;
126
+                }
127
+
128
+                $link = $xpath->query("//channel/link")->item(0);
129
+
130
+                if ($link) {
131
+                    if ($link->getAttribute("href")) {
132
+                                            $this->link = $link->getAttribute("href");
133
+                    } else if ($link->nodeValue) {
134
+                                            $this->link = $link->nodeValue;
135
+                    }
136
+                }
137
+
138
+                $articles = $xpath->query("//channel/item");
139
+
140
+                foreach ($articles as $article) {
141
+                    array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
142
+                }
143
+
144
+                break;
145
+            case $this::FEED_RDF:
146
+                $xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
147
+
148
+                $title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
149
+
150
+                if ($title) {
151
+                    $this->title = $title->nodeValue;
152
+                }
153
+
154
+                $link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
155
+
156
+                if ($link) {
157
+                    $this->link = $link->nodeValue;
158
+                }
159
+
160
+                $articles = $xpath->query("//rssfake:item");
161
+
162
+                foreach ($articles as $article) {
163
+                    array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
164
+                }
165
+
166
+                break;
167
+
168
+            }
169
+
170
+            if ($this->title) {
171
+                $this->title = trim($this->title);
172
+            }
173
+            if ($this->link) {
174
+                $this->link = trim($this->link);
175
+            }
176 176
 
177
-		} else {
178
-			if (!isset($this->error)) {
179
-				$this->error = "Unknown/unsupported feed type";
180
-			}
181
-			return;
182
-		}
183
-	}
184
-
185
-	public function format_error($error) {
186
-		if ($error) {
187
-			return sprintf("LibXML error %s at line %d (column %d): %s",
188
-				$error->code, $error->line, $error->column,
189
-				$error->message);
190
-		} else {
191
-			return "";
192
-		}
193
-	}
194
-
195
-	// libxml may have invalid unicode data in error messages
196
-	public function error() {
197
-		return UConverter::transcode($this->error, 'UTF-8', 'UTF-8');
198
-	}
199
-
200
-	// WARNING: may return invalid unicode data
201
-	public function errors() {
202
-		return $this->libxml_errors;
203
-	}
204
-
205
-	public function get_link() {
206
-		return clean($this->link);
207
-	}
208
-
209
-	public function get_title() {
210
-		return clean($this->title);
211
-	}
212
-
213
-	public function get_items() {
214
-		return $this->items;
215
-	}
216
-
217
-	public function get_links($rel) {
218
-		$rv = array();
219
-
220
-		switch ($this->type) {
221
-		case $this::FEED_ATOM:
222
-			$links = $this->xpath->query("//atom:feed/atom:link");
223
-
224
-			foreach ($links as $link) {
225
-				if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
226
-					array_push($rv, clean(trim($link->getAttribute('href'))));
227
-				}
228
-			}
229
-			break;
230
-		case $this::FEED_RSS:
231
-			$links = $this->xpath->query("//atom:link");
232
-
233
-			foreach ($links as $link) {
234
-				if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
235
-					array_push($rv, clean(trim($link->getAttribute('href'))));
236
-				}
237
-			}
238
-			break;
239
-		}
240
-
241
-		return $rv;
242
-	}
177
+        } else {
178
+            if (!isset($this->error)) {
179
+                $this->error = "Unknown/unsupported feed type";
180
+            }
181
+            return;
182
+        }
183
+    }
184
+
185
+    public function format_error($error) {
186
+        if ($error) {
187
+            return sprintf("LibXML error %s at line %d (column %d): %s",
188
+                $error->code, $error->line, $error->column,
189
+                $error->message);
190
+        } else {
191
+            return "";
192
+        }
193
+    }
194
+
195
+    // libxml may have invalid unicode data in error messages
196
+    public function error() {
197
+        return UConverter::transcode($this->error, 'UTF-8', 'UTF-8');
198
+    }
199
+
200
+    // WARNING: may return invalid unicode data
201
+    public function errors() {
202
+        return $this->libxml_errors;
203
+    }
204
+
205
+    public function get_link() {
206
+        return clean($this->link);
207
+    }
208
+
209
+    public function get_title() {
210
+        return clean($this->title);
211
+    }
212
+
213
+    public function get_items() {
214
+        return $this->items;
215
+    }
216
+
217
+    public function get_links($rel) {
218
+        $rv = array();
219
+
220
+        switch ($this->type) {
221
+        case $this::FEED_ATOM:
222
+            $links = $this->xpath->query("//atom:feed/atom:link");
223
+
224
+            foreach ($links as $link) {
225
+                if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
226
+                    array_push($rv, clean(trim($link->getAttribute('href'))));
227
+                }
228
+            }
229
+            break;
230
+        case $this::FEED_RSS:
231
+            $links = $this->xpath->query("//atom:link");
232
+
233
+            foreach ($links as $link) {
234
+                if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
235
+                    array_push($rv, clean(trim($link->getAttribute('href'))));
236
+                }
237
+            }
238
+            break;
239
+        }
240
+
241
+        return $rv;
242
+    }
243 243
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,8 +26,10 @@
 block discarded – undo
26 26
 		if ($error) {
27 27
 			foreach (libxml_get_errors() as $error) {
28 28
 				if ($error->level == LIBXML_ERR_FATAL) {
29
-					if (!isset($this->error)) //currently only the first error is reported
29
+					if (!isset($this->error)) {
30
+					    //currently only the first error is reported
30 31
 						$this->error = $this->format_error($error);
32
+					}
31 33
 					$this->libxml_errors [] = $this->format_error($error);
32 34
 				}
33 35
 			}
Please login to merge, or discard this patch.
classes/pref/feeds.php 2 patches
Indentation   +1167 added lines, -1167 removed lines patch added patch discarded remove patch
@@ -1,89 +1,89 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Feeds extends Handler_Protected {
3
-	public function csrf_ignore($method) {
4
-		$csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
5
-			"savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds",
6
-			"batchsubscribe");
3
+    public function csrf_ignore($method) {
4
+        $csrf_ignored = array("index", "getfeedtree", "add", "editcats", "editfeed",
5
+            "savefeedorder", "uploadicon", "feedswitherrors", "inactivefeeds",
6
+            "batchsubscribe");
7 7
 
8
-		return array_search($method, $csrf_ignored) !== false;
9
-	}
8
+        return array_search($method, $csrf_ignored) !== false;
9
+    }
10 10
 
11
-	public static function get_ts_languages() {
12
-		$rv = [];
11
+    public static function get_ts_languages() {
12
+        $rv = [];
13 13
 
14
-		if (DB_TYPE == "pgsql") {
15
-			$dbh = Db::pdo();
14
+        if (DB_TYPE == "pgsql") {
15
+            $dbh = Db::pdo();
16 16
 
17
-			$res = $dbh->query("SELECT cfgname FROM pg_ts_config");
17
+            $res = $dbh->query("SELECT cfgname FROM pg_ts_config");
18 18
 
19
-			while ($row = $res->fetch()) {
20
-				array_push($rv, ucfirst($row['cfgname']));
21
-			}
22
-		}
19
+            while ($row = $res->fetch()) {
20
+                array_push($rv, ucfirst($row['cfgname']));
21
+            }
22
+        }
23 23
 
24
-		return $rv;
25
-	}
24
+        return $rv;
25
+    }
26 26
 
27
-	public function batch_edit_cbox($elem, $label = false) {
28
-		print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
27
+    public function batch_edit_cbox($elem, $label = false) {
28
+        print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
29 29
 			onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
30
-	}
30
+    }
31 31
 
32
-	public function renamecat() {
33
-		$title = clean($_REQUEST['title']);
34
-		$id = clean($_REQUEST['id']);
32
+    public function renamecat() {
33
+        $title = clean($_REQUEST['title']);
34
+        $id = clean($_REQUEST['id']);
35 35
 
36
-		if ($title) {
37
-			$sth = $this->pdo->prepare("UPDATE ttrss_feed_categories SET
36
+        if ($title) {
37
+            $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories SET
38 38
 				title = ? WHERE id = ? AND owner_uid = ?");
39
-			$sth->execute([$title, $id, $_SESSION['uid']]);
40
-		}
41
-	}
39
+            $sth->execute([$title, $id, $_SESSION['uid']]);
40
+        }
41
+    }
42 42
 
43
-	private function get_category_items($cat_id) {
43
+    private function get_category_items($cat_id) {
44 44
 
45
-		if (clean($_REQUEST['mode']) != 2) {
46
-					$search = $_SESSION["prefs_feed_search"];
47
-		} else {
48
-					$search = "";
49
-		}
45
+        if (clean($_REQUEST['mode']) != 2) {
46
+                    $search = $_SESSION["prefs_feed_search"];
47
+        } else {
48
+                    $search = "";
49
+        }
50 50
 
51
-		// first one is set by API
52
-		$show_empty_cats = clean($_REQUEST['force_show_empty']) ||
53
-			(clean($_REQUEST['mode']) != 2 && !$search);
51
+        // first one is set by API
52
+        $show_empty_cats = clean($_REQUEST['force_show_empty']) ||
53
+            (clean($_REQUEST['mode']) != 2 && !$search);
54 54
 
55
-		$items = array();
55
+        $items = array();
56 56
 
57
-		$sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
57
+        $sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
58 58
 				WHERE owner_uid = ? AND parent_cat = ? ORDER BY order_id, title");
59
-		$sth->execute([$_SESSION['uid'], $cat_id]);
59
+        $sth->execute([$_SESSION['uid'], $cat_id]);
60 60
 
61
-		while ($line = $sth->fetch()) {
61
+        while ($line = $sth->fetch()) {
62 62
 
63
-			$cat = array();
64
-			$cat['id'] = 'CAT:'.$line['id'];
65
-			$cat['bare_id'] = (int) $line['id'];
66
-			$cat['name'] = $line['title'];
67
-			$cat['items'] = array();
68
-			$cat['checkbox'] = false;
69
-			$cat['type'] = 'category';
70
-			$cat['unread'] = -1;
71
-			$cat['child_unread'] = -1;
72
-			$cat['auxcounter'] = -1;
73
-			$cat['parent_id'] = $cat_id;
63
+            $cat = array();
64
+            $cat['id'] = 'CAT:'.$line['id'];
65
+            $cat['bare_id'] = (int) $line['id'];
66
+            $cat['name'] = $line['title'];
67
+            $cat['items'] = array();
68
+            $cat['checkbox'] = false;
69
+            $cat['type'] = 'category';
70
+            $cat['unread'] = -1;
71
+            $cat['child_unread'] = -1;
72
+            $cat['auxcounter'] = -1;
73
+            $cat['parent_id'] = $cat_id;
74 74
 
75
-			$cat['items'] = $this->get_category_items($line['id']);
75
+            $cat['items'] = $this->get_category_items($line['id']);
76 76
 
77
-			$num_children = $this->calculate_children_count($cat);
78
-			$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
77
+            $num_children = $this->calculate_children_count($cat);
78
+            $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
79 79
 
80
-			if ($num_children > 0 || $show_empty_cats) {
81
-							array_push($items, $cat);
82
-			}
80
+            if ($num_children > 0 || $show_empty_cats) {
81
+                            array_push($items, $cat);
82
+            }
83 83
 
84
-		}
84
+        }
85 85
 
86
-		$fsth = $this->pdo->prepare("SELECT id, title, last_error,
86
+        $fsth = $this->pdo->prepare("SELECT id, title, last_error,
87 87
 			".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated, update_interval
88 88
 			FROM ttrss_feeds
89 89
 			WHERE cat_id = :cat AND
@@ -91,687 +91,687 @@  discard block
 block discarded – undo
91 91
 			(:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
92 92
 			ORDER BY order_id, title");
93 93
 
94
-		$fsth->execute([":cat" => $cat_id, ":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
95
-
96
-		while ($feed_line = $fsth->fetch()) {
97
-			$feed = array();
98
-			$feed['id'] = 'FEED:'.$feed_line['id'];
99
-			$feed['bare_id'] = (int) $feed_line['id'];
100
-			$feed['auxcounter'] = -1;
101
-			$feed['name'] = $feed_line['title'];
102
-			$feed['checkbox'] = false;
103
-			$feed['unread'] = -1;
104
-			$feed['error'] = $feed_line['last_error'];
105
-			$feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
106
-			$feed['param'] = make_local_datetime(
107
-				$feed_line['last_updated'], true);
108
-			$feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
109
-
110
-			array_push($items, $feed);
111
-		}
112
-
113
-		return $items;
114
-	}
115
-
116
-	public function getfeedtree() {
117
-		print json_encode($this->makefeedtree());
118
-	}
119
-
120
-	public function makefeedtree() {
121
-
122
-		if (clean($_REQUEST['mode']) != 2) {
123
-					$search = $_SESSION["prefs_feed_search"];
124
-		} else {
125
-					$search = "";
126
-		}
127
-
128
-		$root = array();
129
-		$root['id'] = 'root';
130
-		$root['name'] = __('Feeds');
131
-		$root['items'] = array();
132
-		$root['type'] = 'category';
133
-
134
-		$enable_cats = get_pref('ENABLE_FEED_CATS');
135
-
136
-		if (clean($_REQUEST['mode']) == 2) {
137
-
138
-			if ($enable_cats) {
139
-				$cat = $this->feedlist_init_cat(-1);
140
-			} else {
141
-				$cat['items'] = array();
142
-			}
143
-
144
-			foreach (array(-4, -3, -1, -2, 0, -6) as $i) {
145
-				array_push($cat['items'], $this->feedlist_init_feed($i));
146
-			}
147
-
148
-			/* Plugin feeds for -1 */
149
-
150
-			$feeds = PluginHost::getInstance()->get_feeds(-1);
151
-
152
-			if ($feeds) {
153
-				foreach ($feeds as $feed) {
154
-					$feed_id = PluginHost::pfeed_to_feed_id($feed['id']);
155
-
156
-					$item = array();
157
-					$item['id'] = 'FEED:'.$feed_id;
158
-					$item['bare_id'] = (int) $feed_id;
159
-					$item['auxcounter'] = -1;
160
-					$item['name'] = $feed['title'];
161
-					$item['checkbox'] = false;
162
-					$item['error'] = '';
163
-					$item['icon'] = $feed['icon'];
164
-
165
-					$item['param'] = '';
166
-					$item['unread'] = -1;
167
-					$item['type'] = 'feed';
168
-
169
-					array_push($cat['items'], $item);
170
-				}
171
-			}
172
-
173
-			if ($enable_cats) {
174
-				array_push($root['items'], $cat);
175
-			} else {
176
-				$root['items'] = array_merge($root['items'], $cat['items']);
177
-			}
178
-
179
-			$sth = $this->pdo->prepare("SELECT * FROM
94
+        $fsth->execute([":cat" => $cat_id, ":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
95
+
96
+        while ($feed_line = $fsth->fetch()) {
97
+            $feed = array();
98
+            $feed['id'] = 'FEED:'.$feed_line['id'];
99
+            $feed['bare_id'] = (int) $feed_line['id'];
100
+            $feed['auxcounter'] = -1;
101
+            $feed['name'] = $feed_line['title'];
102
+            $feed['checkbox'] = false;
103
+            $feed['unread'] = -1;
104
+            $feed['error'] = $feed_line['last_error'];
105
+            $feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
106
+            $feed['param'] = make_local_datetime(
107
+                $feed_line['last_updated'], true);
108
+            $feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
109
+
110
+            array_push($items, $feed);
111
+        }
112
+
113
+        return $items;
114
+    }
115
+
116
+    public function getfeedtree() {
117
+        print json_encode($this->makefeedtree());
118
+    }
119
+
120
+    public function makefeedtree() {
121
+
122
+        if (clean($_REQUEST['mode']) != 2) {
123
+                    $search = $_SESSION["prefs_feed_search"];
124
+        } else {
125
+                    $search = "";
126
+        }
127
+
128
+        $root = array();
129
+        $root['id'] = 'root';
130
+        $root['name'] = __('Feeds');
131
+        $root['items'] = array();
132
+        $root['type'] = 'category';
133
+
134
+        $enable_cats = get_pref('ENABLE_FEED_CATS');
135
+
136
+        if (clean($_REQUEST['mode']) == 2) {
137
+
138
+            if ($enable_cats) {
139
+                $cat = $this->feedlist_init_cat(-1);
140
+            } else {
141
+                $cat['items'] = array();
142
+            }
143
+
144
+            foreach (array(-4, -3, -1, -2, 0, -6) as $i) {
145
+                array_push($cat['items'], $this->feedlist_init_feed($i));
146
+            }
147
+
148
+            /* Plugin feeds for -1 */
149
+
150
+            $feeds = PluginHost::getInstance()->get_feeds(-1);
151
+
152
+            if ($feeds) {
153
+                foreach ($feeds as $feed) {
154
+                    $feed_id = PluginHost::pfeed_to_feed_id($feed['id']);
155
+
156
+                    $item = array();
157
+                    $item['id'] = 'FEED:'.$feed_id;
158
+                    $item['bare_id'] = (int) $feed_id;
159
+                    $item['auxcounter'] = -1;
160
+                    $item['name'] = $feed['title'];
161
+                    $item['checkbox'] = false;
162
+                    $item['error'] = '';
163
+                    $item['icon'] = $feed['icon'];
164
+
165
+                    $item['param'] = '';
166
+                    $item['unread'] = -1;
167
+                    $item['type'] = 'feed';
168
+
169
+                    array_push($cat['items'], $item);
170
+                }
171
+            }
172
+
173
+            if ($enable_cats) {
174
+                array_push($root['items'], $cat);
175
+            } else {
176
+                $root['items'] = array_merge($root['items'], $cat['items']);
177
+            }
178
+
179
+            $sth = $this->pdo->prepare("SELECT * FROM
180 180
 				ttrss_labels2 WHERE owner_uid = ? ORDER by caption");
181
-			$sth->execute([$_SESSION['uid']]);
181
+            $sth->execute([$_SESSION['uid']]);
182 182
 
183
-			if (get_pref('ENABLE_FEED_CATS')) {
184
-				$cat = $this->feedlist_init_cat(-2);
185
-			} else {
186
-				$cat['items'] = array();
187
-			}
183
+            if (get_pref('ENABLE_FEED_CATS')) {
184
+                $cat = $this->feedlist_init_cat(-2);
185
+            } else {
186
+                $cat['items'] = array();
187
+            }
188 188
 
189
-			$num_labels = 0;
190
-			while ($line = $sth->fetch()) {
191
-				++$num_labels;
189
+            $num_labels = 0;
190
+            while ($line = $sth->fetch()) {
191
+                ++$num_labels;
192 192
 
193
-				$label_id = Labels::label_to_feed_id($line['id']);
193
+                $label_id = Labels::label_to_feed_id($line['id']);
194 194
 
195
-				$feed = $this->feedlist_init_feed($label_id, false, 0);
195
+                $feed = $this->feedlist_init_feed($label_id, false, 0);
196 196
 
197
-				$feed['fg_color'] = $line['fg_color'];
198
-				$feed['bg_color'] = $line['bg_color'];
197
+                $feed['fg_color'] = $line['fg_color'];
198
+                $feed['bg_color'] = $line['bg_color'];
199 199
 
200
-				array_push($cat['items'], $feed);
201
-			}
200
+                array_push($cat['items'], $feed);
201
+            }
202 202
 
203
-			if ($num_labels) {
204
-				if ($enable_cats) {
205
-					array_push($root['items'], $cat);
206
-				} else {
207
-					$root['items'] = array_merge($root['items'], $cat['items']);
208
-				}
209
-			}
210
-		}
203
+            if ($num_labels) {
204
+                if ($enable_cats) {
205
+                    array_push($root['items'], $cat);
206
+                } else {
207
+                    $root['items'] = array_merge($root['items'], $cat['items']);
208
+                }
209
+            }
210
+        }
211 211
 
212
-		if ($enable_cats) {
213
-			$show_empty_cats = clean($_REQUEST['force_show_empty']) ||
214
-				(clean($_REQUEST['mode']) != 2 && !$search);
212
+        if ($enable_cats) {
213
+            $show_empty_cats = clean($_REQUEST['force_show_empty']) ||
214
+                (clean($_REQUEST['mode']) != 2 && !$search);
215 215
 
216
-			$sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
216
+            $sth = $this->pdo->prepare("SELECT id, title FROM ttrss_feed_categories
217 217
 				WHERE owner_uid = ? AND parent_cat IS NULL ORDER BY order_id, title");
218
-			$sth->execute([$_SESSION['uid']]);
219
-
220
-			while ($line = $sth->fetch()) {
221
-				$cat = array();
222
-				$cat['id'] = 'CAT:'.$line['id'];
223
-				$cat['bare_id'] = (int) $line['id'];
224
-				$cat['auxcounter'] = -1;
225
-				$cat['name'] = $line['title'];
226
-				$cat['items'] = array();
227
-				$cat['checkbox'] = false;
228
-				$cat['type'] = 'category';
229
-				$cat['unread'] = -1;
230
-				$cat['child_unread'] = -1;
231
-
232
-				$cat['items'] = $this->get_category_items($line['id']);
233
-
234
-				$num_children = $this->calculate_children_count($cat);
235
-				$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
236
-
237
-				if ($num_children > 0 || $show_empty_cats) {
238
-									array_push($root['items'], $cat);
239
-				}
240
-
241
-				$root['param'] += count($cat['items']);
242
-			}
243
-
244
-			/* Uncategorized is a special case */
245
-
246
-			$cat = array();
247
-			$cat['id'] = 'CAT:0';
248
-			$cat['bare_id'] = 0;
249
-			$cat['auxcounter'] = -1;
250
-			$cat['name'] = __("Uncategorized");
251
-			$cat['items'] = array();
252
-			$cat['type'] = 'category';
253
-			$cat['checkbox'] = false;
254
-			$cat['unread'] = -1;
255
-			$cat['child_unread'] = -1;
256
-
257
-			$fsth = $this->pdo->prepare("SELECT id, title,last_error,
218
+            $sth->execute([$_SESSION['uid']]);
219
+
220
+            while ($line = $sth->fetch()) {
221
+                $cat = array();
222
+                $cat['id'] = 'CAT:'.$line['id'];
223
+                $cat['bare_id'] = (int) $line['id'];
224
+                $cat['auxcounter'] = -1;
225
+                $cat['name'] = $line['title'];
226
+                $cat['items'] = array();
227
+                $cat['checkbox'] = false;
228
+                $cat['type'] = 'category';
229
+                $cat['unread'] = -1;
230
+                $cat['child_unread'] = -1;
231
+
232
+                $cat['items'] = $this->get_category_items($line['id']);
233
+
234
+                $num_children = $this->calculate_children_count($cat);
235
+                $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
236
+
237
+                if ($num_children > 0 || $show_empty_cats) {
238
+                                    array_push($root['items'], $cat);
239
+                }
240
+
241
+                $root['param'] += count($cat['items']);
242
+            }
243
+
244
+            /* Uncategorized is a special case */
245
+
246
+            $cat = array();
247
+            $cat['id'] = 'CAT:0';
248
+            $cat['bare_id'] = 0;
249
+            $cat['auxcounter'] = -1;
250
+            $cat['name'] = __("Uncategorized");
251
+            $cat['items'] = array();
252
+            $cat['type'] = 'category';
253
+            $cat['checkbox'] = false;
254
+            $cat['unread'] = -1;
255
+            $cat['child_unread'] = -1;
256
+
257
+            $fsth = $this->pdo->prepare("SELECT id, title,last_error,
258 258
 				".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated, update_interval
259 259
 				FROM ttrss_feeds
260 260
 				WHERE cat_id IS NULL AND
261 261
 				owner_uid = :uid AND
262 262
 				(:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
263 263
 				ORDER BY order_id, title");
264
-			$fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
265
-
266
-			while ($feed_line = $fsth->fetch()) {
267
-				$feed = array();
268
-				$feed['id'] = 'FEED:'.$feed_line['id'];
269
-				$feed['bare_id'] = (int) $feed_line['id'];
270
-				$feed['auxcounter'] = -1;
271
-				$feed['name'] = $feed_line['title'];
272
-				$feed['checkbox'] = false;
273
-				$feed['error'] = $feed_line['last_error'];
274
-				$feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
275
-				$feed['param'] = make_local_datetime(
276
-					$feed_line['last_updated'], true);
277
-				$feed['unread'] = -1;
278
-				$feed['type'] = 'feed';
279
-				$feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
280
-
281
-				array_push($cat['items'], $feed);
282
-			}
283
-
284
-			$cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
285
-
286
-			if (count($cat['items']) > 0 || $show_empty_cats) {
287
-							array_push($root['items'], $cat);
288
-			}
289
-
290
-			$num_children = $this->calculate_children_count($root);
291
-			$root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
292
-
293
-		} else {
294
-			$fsth = $this->pdo->prepare("SELECT id, title, last_error,
264
+            $fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
265
+
266
+            while ($feed_line = $fsth->fetch()) {
267
+                $feed = array();
268
+                $feed['id'] = 'FEED:'.$feed_line['id'];
269
+                $feed['bare_id'] = (int) $feed_line['id'];
270
+                $feed['auxcounter'] = -1;
271
+                $feed['name'] = $feed_line['title'];
272
+                $feed['checkbox'] = false;
273
+                $feed['error'] = $feed_line['last_error'];
274
+                $feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
275
+                $feed['param'] = make_local_datetime(
276
+                    $feed_line['last_updated'], true);
277
+                $feed['unread'] = -1;
278
+                $feed['type'] = 'feed';
279
+                $feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
280
+
281
+                array_push($cat['items'], $feed);
282
+            }
283
+
284
+            $cat['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($cat['items'])), count($cat['items']));
285
+
286
+            if (count($cat['items']) > 0 || $show_empty_cats) {
287
+                            array_push($root['items'], $cat);
288
+            }
289
+
290
+            $num_children = $this->calculate_children_count($root);
291
+            $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', (int) $num_children), $num_children);
292
+
293
+        } else {
294
+            $fsth = $this->pdo->prepare("SELECT id, title, last_error,
295 295
 				".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated, update_interval
296 296
 				FROM ttrss_feeds
297 297
 				WHERE owner_uid = :uid AND
298 298
 				(:search = '' OR (LOWER(title) LIKE :search OR LOWER(feed_url) LIKE :search))
299 299
 				ORDER BY order_id, title");
300
-			$fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
301
-
302
-			while ($feed_line = $fsth->fetch()) {
303
-				$feed = array();
304
-				$feed['id'] = 'FEED:'.$feed_line['id'];
305
-				$feed['bare_id'] = (int) $feed_line['id'];
306
-				$feed['auxcounter'] = -1;
307
-				$feed['name'] = $feed_line['title'];
308
-				$feed['checkbox'] = false;
309
-				$feed['error'] = $feed_line['last_error'];
310
-				$feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
311
-				$feed['param'] = make_local_datetime(
312
-					$feed_line['last_updated'], true);
313
-				$feed['unread'] = -1;
314
-				$feed['type'] = 'feed';
315
-				$feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
316
-
317
-				array_push($root['items'], $feed);
318
-			}
319
-
320
-			$root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items']));
321
-		}
322
-
323
-		$fl = array();
324
-		$fl['identifier'] = 'id';
325
-		$fl['label'] = 'name';
326
-
327
-		if (clean($_REQUEST['mode']) != 2) {
328
-			$fl['items'] = array($root);
329
-		} else {
330
-			$fl['items'] = $root['items'];
331
-		}
332
-
333
-		return $fl;
334
-	}
335
-
336
-	public function catsortreset() {
337
-		$sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
300
+            $fsth->execute([":uid" => $_SESSION['uid'], ":search" => $search ? "%$search%" : ""]);
301
+
302
+            while ($feed_line = $fsth->fetch()) {
303
+                $feed = array();
304
+                $feed['id'] = 'FEED:'.$feed_line['id'];
305
+                $feed['bare_id'] = (int) $feed_line['id'];
306
+                $feed['auxcounter'] = -1;
307
+                $feed['name'] = $feed_line['title'];
308
+                $feed['checkbox'] = false;
309
+                $feed['error'] = $feed_line['last_error'];
310
+                $feed['icon'] = Feeds::getFeedIcon($feed_line['id']);
311
+                $feed['param'] = make_local_datetime(
312
+                    $feed_line['last_updated'], true);
313
+                $feed['unread'] = -1;
314
+                $feed['type'] = 'feed';
315
+                $feed['updates_disabled'] = (int) ($feed_line['update_interval'] < 0);
316
+
317
+                array_push($root['items'], $feed);
318
+            }
319
+
320
+            $root['param'] = vsprintf(_ngettext('(%d feed)', '(%d feeds)', count($root['items'])), count($root['items']));
321
+        }
322
+
323
+        $fl = array();
324
+        $fl['identifier'] = 'id';
325
+        $fl['label'] = 'name';
326
+
327
+        if (clean($_REQUEST['mode']) != 2) {
328
+            $fl['items'] = array($root);
329
+        } else {
330
+            $fl['items'] = $root['items'];
331
+        }
332
+
333
+        return $fl;
334
+    }
335
+
336
+    public function catsortreset() {
337
+        $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
338 338
 				SET order_id = 0 WHERE owner_uid = ?");
339
-		$sth->execute([$_SESSION['uid']]);
340
-	}
339
+        $sth->execute([$_SESSION['uid']]);
340
+    }
341 341
 
342
-	public function feedsortreset() {
343
-		$sth = $this->pdo->prepare("UPDATE ttrss_feeds
342
+    public function feedsortreset() {
343
+        $sth = $this->pdo->prepare("UPDATE ttrss_feeds
344 344
 				SET order_id = 0 WHERE owner_uid = ?");
345
-		$sth->execute([$_SESSION['uid']]);
346
-	}
345
+        $sth->execute([$_SESSION['uid']]);
346
+    }
347 347
 
348
-	private function process_category_order(&$data_map, $item_id, $parent_id = false, $nest_level = 0) {
348
+    private function process_category_order(&$data_map, $item_id, $parent_id = false, $nest_level = 0) {
349 349
 
350
-		$prefix = "";
351
-		for ($i = 0; $i < $nest_level; $i++) {
352
-					$prefix .= "   ";
353
-		}
350
+        $prefix = "";
351
+        for ($i = 0; $i < $nest_level; $i++) {
352
+                    $prefix .= "   ";
353
+        }
354 354
 
355
-		Debug::log("$prefix C: $item_id P: $parent_id");
355
+        Debug::log("$prefix C: $item_id P: $parent_id");
356 356
 
357
-		$bare_item_id = substr($item_id, strpos($item_id, ':') + 1);
357
+        $bare_item_id = substr($item_id, strpos($item_id, ':') + 1);
358 358
 
359
-		if ($item_id != 'root') {
360
-			if ($parent_id && $parent_id != 'root') {
361
-				$parent_bare_id = substr($parent_id, strpos($parent_id, ':') + 1);
362
-				$parent_qpart = $parent_bare_id;
363
-			} else {
364
-				$parent_qpart = null;
365
-			}
359
+        if ($item_id != 'root') {
360
+            if ($parent_id && $parent_id != 'root') {
361
+                $parent_bare_id = substr($parent_id, strpos($parent_id, ':') + 1);
362
+                $parent_qpart = $parent_bare_id;
363
+            } else {
364
+                $parent_qpart = null;
365
+            }
366 366
 
367
-			$sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
367
+            $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
368 368
 				SET parent_cat = ? WHERE id = ? AND
369 369
 				owner_uid = ?");
370
-			$sth->execute([$parent_qpart, $bare_item_id, $_SESSION['uid']]);
371
-		}
370
+            $sth->execute([$parent_qpart, $bare_item_id, $_SESSION['uid']]);
371
+        }
372 372
 
373
-		$order_id = 1;
373
+        $order_id = 1;
374 374
 
375
-		$cat = $data_map[$item_id];
375
+        $cat = $data_map[$item_id];
376 376
 
377
-		if ($cat && is_array($cat)) {
378
-			foreach ($cat as $item) {
379
-				$id = $item['_reference'];
380
-				$bare_id = substr($id, strpos($id, ':') + 1);
377
+        if ($cat && is_array($cat)) {
378
+            foreach ($cat as $item) {
379
+                $id = $item['_reference'];
380
+                $bare_id = substr($id, strpos($id, ':') + 1);
381 381
 
382
-				Debug::log("$prefix [$order_id] $id/$bare_id");
382
+                Debug::log("$prefix [$order_id] $id/$bare_id");
383 383
 
384
-				if ($item['_reference']) {
384
+                if ($item['_reference']) {
385 385
 
386
-					if (strpos($id, "FEED") === 0) {
386
+                    if (strpos($id, "FEED") === 0) {
387 387
 
388
-						$cat_id = ($item_id != "root") ? $bare_item_id : null;
388
+                        $cat_id = ($item_id != "root") ? $bare_item_id : null;
389 389
 
390
-						$sth = $this->pdo->prepare("UPDATE ttrss_feeds
390
+                        $sth = $this->pdo->prepare("UPDATE ttrss_feeds
391 391
 							SET order_id = ?, cat_id = ?
392 392
 							WHERE id = ? AND owner_uid = ?");
393 393
 
394
-						$sth->execute([$order_id, $cat_id ? $cat_id : null, $bare_id, $_SESSION['uid']]);
394
+                        $sth->execute([$order_id, $cat_id ? $cat_id : null, $bare_id, $_SESSION['uid']]);
395 395
 
396
-					} else if (strpos($id, "CAT:") === 0) {
397
-						$this->process_category_order($data_map, $item['_reference'], $item_id,
398
-							$nest_level + 1);
396
+                    } else if (strpos($id, "CAT:") === 0) {
397
+                        $this->process_category_order($data_map, $item['_reference'], $item_id,
398
+                            $nest_level + 1);
399 399
 
400
-						$sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
400
+                        $sth = $this->pdo->prepare("UPDATE ttrss_feed_categories
401 401
 								SET order_id = ? WHERE id = ? AND
402 402
 								owner_uid = ?");
403
-						$sth->execute([$order_id, $bare_id, $_SESSION['uid']]);
404
-					}
405
-				}
403
+                        $sth->execute([$order_id, $bare_id, $_SESSION['uid']]);
404
+                    }
405
+                }
406 406
 
407
-				++$order_id;
408
-			}
409
-		}
410
-	}
407
+                ++$order_id;
408
+            }
409
+        }
410
+    }
411 411
 
412
-	public function savefeedorder() {
413
-		$data = json_decode($_POST['payload'], true);
412
+    public function savefeedorder() {
413
+        $data = json_decode($_POST['payload'], true);
414 414
 
415
-		#file_put_contents("/tmp/saveorder.json", clean($_POST['payload']));
416
-		#$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
415
+        #file_put_contents("/tmp/saveorder.json", clean($_POST['payload']));
416
+        #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
417 417
 
418
-		if (!is_array($data['items'])) {
419
-					$data['items'] = json_decode($data['items'], true);
420
-		}
418
+        if (!is_array($data['items'])) {
419
+                    $data['items'] = json_decode($data['items'], true);
420
+        }
421 421
 
422 422
 #		print_r($data['items']);
423 423
 
424
-		if (is_array($data) && is_array($data['items'])) {
424
+        if (is_array($data) && is_array($data['items'])) {
425 425
 #			$cat_order_id = 0;
426 426
 
427
-			$data_map = array();
428
-			$root_item = false;
427
+            $data_map = array();
428
+            $root_item = false;
429 429
 
430
-			foreach ($data['items'] as $item) {
430
+            foreach ($data['items'] as $item) {
431 431
 
432 432
 #				if ($item['id'] != 'root') {
433
-					if (is_array($item['items'])) {
434
-						if (isset($item['items']['_reference'])) {
435
-							$data_map[$item['id']] = array($item['items']);
436
-						} else {
437
-							$data_map[$item['id']] = $item['items'];
438
-						}
439
-					}
440
-				if ($item['id'] == 'root') {
441
-					$root_item = $item['id'];
442
-				}
443
-			}
444
-
445
-			$this->process_category_order($data_map, $root_item);
446
-		}
447
-	}
448
-
449
-	public function removeicon() {
450
-		$feed_id = clean($_REQUEST["feed_id"]);
451
-
452
-		$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
453
-		$sth->execute([$feed_id, $_SESSION['uid']]);
454
-
455
-		if ($sth->fetch()) {
456
-			@unlink(ICONS_DIR."/$feed_id.ico");
457
-
458
-			$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL where id = ?");
459
-			$sth->execute([$feed_id]);
460
-		}
461
-	}
462
-
463
-	public function uploadicon() {
464
-		header("Content-type: text/html");
465
-
466
-		if (is_uploaded_file($_FILES['icon_file']['tmp_name'])) {
467
-			$tmp_file = tempnam(CACHE_DIR.'/upload', 'icon');
468
-
469
-			$result = move_uploaded_file($_FILES['icon_file']['tmp_name'],
470
-				$tmp_file);
471
-
472
-			if (!$result) {
473
-				return;
474
-			}
475
-		} else {
476
-			return;
477
-		}
433
+                    if (is_array($item['items'])) {
434
+                        if (isset($item['items']['_reference'])) {
435
+                            $data_map[$item['id']] = array($item['items']);
436
+                        } else {
437
+                            $data_map[$item['id']] = $item['items'];
438
+                        }
439
+                    }
440
+                if ($item['id'] == 'root') {
441
+                    $root_item = $item['id'];
442
+                }
443
+            }
444
+
445
+            $this->process_category_order($data_map, $root_item);
446
+        }
447
+    }
448
+
449
+    public function removeicon() {
450
+        $feed_id = clean($_REQUEST["feed_id"]);
451
+
452
+        $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
453
+        $sth->execute([$feed_id, $_SESSION['uid']]);
454
+
455
+        if ($sth->fetch()) {
456
+            @unlink(ICONS_DIR."/$feed_id.ico");
457
+
458
+            $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL where id = ?");
459
+            $sth->execute([$feed_id]);
460
+        }
461
+    }
462
+
463
+    public function uploadicon() {
464
+        header("Content-type: text/html");
465
+
466
+        if (is_uploaded_file($_FILES['icon_file']['tmp_name'])) {
467
+            $tmp_file = tempnam(CACHE_DIR.'/upload', 'icon');
468
+
469
+            $result = move_uploaded_file($_FILES['icon_file']['tmp_name'],
470
+                $tmp_file);
471
+
472
+            if (!$result) {
473
+                return;
474
+            }
475
+        } else {
476
+            return;
477
+        }
478 478
 
479
-		$icon_file = $tmp_file;
480
-		$feed_id = clean($_REQUEST["feed_id"]);
481
-		$rc = 2; // failed
479
+        $icon_file = $tmp_file;
480
+        $feed_id = clean($_REQUEST["feed_id"]);
481
+        $rc = 2; // failed
482 482
 
483
-		if (is_file($icon_file) && $feed_id) {
484
-			if (filesize($icon_file) < 65535) {
483
+        if (is_file($icon_file) && $feed_id) {
484
+            if (filesize($icon_file) < 65535) {
485 485
 
486
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
487
-				$sth->execute([$feed_id, $_SESSION['uid']]);
486
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?");
487
+                $sth->execute([$feed_id, $_SESSION['uid']]);
488 488
 
489
-				if ($sth->fetch()) {
490
-					@unlink(ICONS_DIR."/$feed_id.ico");
491
-					if (rename($icon_file, ICONS_DIR."/$feed_id.ico")) {
489
+                if ($sth->fetch()) {
490
+                    @unlink(ICONS_DIR."/$feed_id.ico");
491
+                    if (rename($icon_file, ICONS_DIR."/$feed_id.ico")) {
492 492
 
493
-						$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = '' WHERE id = ?");
494
-						$sth->execute([$feed_id]);
493
+                        $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = '' WHERE id = ?");
494
+                        $sth->execute([$feed_id]);
495 495
 
496
-						$rc = 0;
497
-					}
498
-				}
499
-			} else {
500
-				$rc = 1;
501
-			}
502
-		}
496
+                        $rc = 0;
497
+                    }
498
+                }
499
+            } else {
500
+                $rc = 1;
501
+            }
502
+        }
503 503
 
504
-		if (is_file($icon_file)) {
505
-		    @unlink($icon_file);
506
-		}
504
+        if (is_file($icon_file)) {
505
+            @unlink($icon_file);
506
+        }
507 507
 
508
-		print $rc;
509
-		return;
510
-	}
508
+        print $rc;
509
+        return;
510
+    }
511 511
 
512
-	public function editfeed() {
513
-		global $purge_intervals;
514
-		global $update_intervals;
512
+    public function editfeed() {
513
+        global $purge_intervals;
514
+        global $update_intervals;
515 515
 
516 516
 
517
-		$feed_id = clean($_REQUEST["id"]);
517
+        $feed_id = clean($_REQUEST["id"]);
518 518
 
519
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_feeds WHERE id = ? AND
519
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_feeds WHERE id = ? AND
520 520
 				owner_uid = ?");
521
-		$sth->execute([$feed_id, $_SESSION['uid']]);
521
+        $sth->execute([$feed_id, $_SESSION['uid']]);
522 522
 
523
-		if ($row = $sth->fetch()) {
524
-			print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
523
+        if ($row = $sth->fetch()) {
524
+            print '<div dojoType="dijit.layout.TabContainer" style="height : 450px">
525 525
         		<div dojoType="dijit.layout.ContentPane" title="'.__('General').'">';
526 526
 
527
-			$title = htmlspecialchars($row["title"]);
527
+            $title = htmlspecialchars($row["title"]);
528 528
 
529
-			print_hidden("id", "$feed_id");
530
-			print_hidden("op", "pref-feeds");
531
-			print_hidden("method", "editSave");
529
+            print_hidden("id", "$feed_id");
530
+            print_hidden("op", "pref-feeds");
531
+            print_hidden("method", "editSave");
532 532
 
533
-			print "<header>".__("Feed")."</header>";
534
-			print "<section>";
533
+            print "<header>".__("Feed")."</header>";
534
+            print "<section>";
535 535
 
536
-			/* Title */
536
+            /* Title */
537 537
 
538
-			print "<fieldset>";
538
+            print "<fieldset>";
539 539
 
540
-			print "<input dojoType='dijit.form.ValidationTextBox' required='1'
540
+            print "<input dojoType='dijit.form.ValidationTextBox' required='1'
541 541
 				placeHolder=\"".__("Feed Title")."\"
542 542
 				style='font-size : 16px; width: 500px' name='title' value=\"$title\">";
543 543
 
544
-			print "</fieldset>";
544
+            print "</fieldset>";
545 545
 
546
-			/* Feed URL */
546
+            /* Feed URL */
547 547
 
548
-			$feed_url = htmlspecialchars($row["feed_url"]);
548
+            $feed_url = htmlspecialchars($row["feed_url"]);
549 549
 
550
-			print "<fieldset>";
550
+            print "<fieldset>";
551 551
 
552
-			print "<label>".__('URL:')."</label> ";
553
-			print "<input dojoType='dijit.form.ValidationTextBox' required='1'
552
+            print "<label>".__('URL:')."</label> ";
553
+            print "<input dojoType='dijit.form.ValidationTextBox' required='1'
554 554
 				placeHolder=\"".__("Feed URL")."\"
555 555
 				regExp='^(http|https)://.*' style='width : 300px'
556 556
 				name='feed_url' value=\"$feed_url\">";
557 557
 
558
-			$last_error = $row["last_error"];
558
+            $last_error = $row["last_error"];
559 559
 
560
-			if ($last_error) {
561
-				print "&nbsp;<i class=\"material-icons\"
560
+            if ($last_error) {
561
+                print "&nbsp;<i class=\"material-icons\"
562 562
 					title=\"".htmlspecialchars($last_error)."\">error</i>";
563
-			}
563
+            }
564 564
 
565
-			print "</fieldset>";
565
+            print "</fieldset>";
566 566
 
567
-			/* Category */
567
+            /* Category */
568 568
 
569
-			if (get_pref('ENABLE_FEED_CATS')) {
569
+            if (get_pref('ENABLE_FEED_CATS')) {
570 570
 
571
-				$cat_id = $row["cat_id"];
571
+                $cat_id = $row["cat_id"];
572 572
 
573
-				print "<fieldset>";
573
+                print "<fieldset>";
574 574
 
575
-				print "<label>".__('Place in category:')."</label> ";
575
+                print "<label>".__('Place in category:')."</label> ";
576 576
 
577
-				print_feed_cat_select("cat_id", $cat_id,
578
-					'dojoType="fox.form.Select"');
577
+                print_feed_cat_select("cat_id", $cat_id,
578
+                    'dojoType="fox.form.Select"');
579 579
 
580
-				print "</fieldset>";
581
-			}
580
+                print "</fieldset>";
581
+            }
582 582
 
583
-			/* Site URL  */
583
+            /* Site URL  */
584 584
 
585
-			$site_url = htmlspecialchars($row["site_url"]);
585
+            $site_url = htmlspecialchars($row["site_url"]);
586 586
 
587
-			print "<fieldset>";
587
+            print "<fieldset>";
588 588
 
589
-			print "<label>".__('Site URL:')."</label> ";
590
-			print "<input dojoType='dijit.form.ValidationTextBox' required='1'
589
+            print "<label>".__('Site URL:')."</label> ";
590
+            print "<input dojoType='dijit.form.ValidationTextBox' required='1'
591 591
 				placeHolder=\"".__("Site URL")."\"
592 592
 				regExp='^(http|https)://.*' style='width : 300px'
593 593
 				name='site_url' value=\"$site_url\">";
594 594
 
595
-			print "</fieldset>";
595
+            print "</fieldset>";
596 596
 
597
-			/* FTS Stemming Language */
597
+            /* FTS Stemming Language */
598 598
 
599
-			if (DB_TYPE == "pgsql") {
600
-				$feed_language = $row["feed_language"];
599
+            if (DB_TYPE == "pgsql") {
600
+                $feed_language = $row["feed_language"];
601 601
 
602
-				if (!$feed_language) {
603
-									$feed_language = get_pref('DEFAULT_SEARCH_LANGUAGE');
604
-				}
602
+                if (!$feed_language) {
603
+                                    $feed_language = get_pref('DEFAULT_SEARCH_LANGUAGE');
604
+                }
605 605
 
606
-				print "<fieldset>";
606
+                print "<fieldset>";
607 607
 
608
-				print "<label>".__('Language:')."</label> ";
609
-				print_select("feed_language", $feed_language, $this::get_ts_languages(),
610
-					'dojoType="fox.form.Select"');
608
+                print "<label>".__('Language:')."</label> ";
609
+                print_select("feed_language", $feed_language, $this::get_ts_languages(),
610
+                    'dojoType="fox.form.Select"');
611 611
 
612
-				print "</fieldset>";
613
-			}
612
+                print "</fieldset>";
613
+            }
614 614
 
615
-			print "</section>";
615
+            print "</section>";
616 616
 
617
-			print "<header>".__("Update")."</header>";
618
-			print "<section>";
617
+            print "<header>".__("Update")."</header>";
618
+            print "<section>";
619 619
 
620
-			/* Update Interval */
620
+            /* Update Interval */
621 621
 
622
-			$update_interval = $row["update_interval"];
622
+            $update_interval = $row["update_interval"];
623 623
 
624
-			print "<fieldset>";
624
+            print "<fieldset>";
625 625
 
626
-			print "<label>".__("Interval:")."</label> ";
626
+            print "<label>".__("Interval:")."</label> ";
627 627
 
628
-			print_select_hash("update_interval", $update_interval, $update_intervals,
629
-				'dojoType="fox.form.Select"');
628
+            print_select_hash("update_interval", $update_interval, $update_intervals,
629
+                'dojoType="fox.form.Select"');
630 630
 
631
-			print "</fieldset>";
631
+            print "</fieldset>";
632 632
 
633
-			/* Purge intl */
633
+            /* Purge intl */
634 634
 
635
-			$purge_interval = $row["purge_interval"];
635
+            $purge_interval = $row["purge_interval"];
636 636
 
637
-			print "<fieldset>";
637
+            print "<fieldset>";
638 638
 
639
-			print "<label>".__('Article purging:')."</label> ";
639
+            print "<label>".__('Article purging:')."</label> ";
640 640
 
641
-			print_select_hash("purge_interval", $purge_interval, $purge_intervals,
642
-				'dojoType="fox.form.Select" '.
643
-				((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"'));
641
+            print_select_hash("purge_interval", $purge_interval, $purge_intervals,
642
+                'dojoType="fox.form.Select" '.
643
+                ((FORCE_ARTICLE_PURGE == 0) ? "" : 'disabled="1"'));
644 644
 
645
-			print "</fieldset>";
645
+            print "</fieldset>";
646 646
 
647
-			print "</section>";
647
+            print "</section>";
648 648
 
649
-			$auth_login = htmlspecialchars($row["auth_login"]);
650
-			$auth_pass = htmlspecialchars($row["auth_pass"]);
649
+            $auth_login = htmlspecialchars($row["auth_login"]);
650
+            $auth_pass = htmlspecialchars($row["auth_pass"]);
651 651
 
652
-			$auth_enabled = $auth_login !== '' || $auth_pass !== '';
652
+            $auth_enabled = $auth_login !== '' || $auth_pass !== '';
653 653
 
654
-			$auth_style = $auth_enabled ? '' : 'display: none';
655
-			print "<div id='feedEditDlg_loginContainer' style='$auth_style'>";
656
-			print "<header>".__("Authentication")."</header>";
657
-			print "<section>";
654
+            $auth_style = $auth_enabled ? '' : 'display: none';
655
+            print "<div id='feedEditDlg_loginContainer' style='$auth_style'>";
656
+            print "<header>".__("Authentication")."</header>";
657
+            print "<section>";
658 658
 
659
-			print "<fieldset>";
659
+            print "<fieldset>";
660 660
 
661
-			print "<input dojoType='dijit.form.TextBox' id='feedEditDlg_login'
661
+            print "<input dojoType='dijit.form.TextBox' id='feedEditDlg_login'
662 662
 				placeHolder='".__("Login")."'
663 663
 				autocomplete='new-password'
664 664
 				name='auth_login' value=\"$auth_login\">";
665 665
 
666
-			print "</fieldset><fieldset>";
666
+            print "</fieldset><fieldset>";
667 667
 
668
-			print "<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
668
+            print "<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
669 669
 				autocomplete='new-password'
670 670
 				placeHolder='".__("Password")."'
671 671
 				value=\"$auth_pass\">";
672 672
 
673
-			print "<div dojoType='dijit.Tooltip' connectId='feedEditDlg_login' position='below'>
673
+            print "<div dojoType='dijit.Tooltip' connectId='feedEditDlg_login' position='below'>
674 674
 				".__('<b>Hint:</b> you need to fill in your login information if your feed requires authentication, except for Twitter feeds.')."
675 675
 				</div>";
676 676
 
677
-			print "</fieldset>";
677
+            print "</fieldset>";
678 678
 
679
-			print "</section></div>";
679
+            print "</section></div>";
680 680
 
681
-			$auth_checked = $auth_enabled ? 'checked' : '';
682
-			print "<label class='checkbox'>
681
+            $auth_checked = $auth_enabled ? 'checked' : '';
682
+            print "<label class='checkbox'>
683 683
 				<input type='checkbox' $auth_checked name='need_auth' dojoType='dijit.form.CheckBox' id='feedEditDlg_loginCheck'
684 684
 						onclick='displayIfChecked(this, \"feedEditDlg_loginContainer\")'>
685 685
 					".__('This feed requires authentication.')."</label>";
686 686
 
687
-			print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">';
687
+            print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">';
688 688
 
689
-			print "<section class='narrow'>";
689
+            print "<section class='narrow'>";
690 690
 
691
-			$include_in_digest = $row["include_in_digest"];
691
+            $include_in_digest = $row["include_in_digest"];
692 692
 
693
-			if ($include_in_digest) {
694
-				$checked = "checked=\"1\"";
695
-			} else {
696
-				$checked = "";
697
-			}
693
+            if ($include_in_digest) {
694
+                $checked = "checked=\"1\"";
695
+            } else {
696
+                $checked = "";
697
+            }
698 698
 
699
-			print "<fieldset class='narrow'>";
699
+            print "<fieldset class='narrow'>";
700 700
 
701
-			print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"
701
+            print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"include_in_digest\"
702 702
 				name=\"include_in_digest\"
703 703
 				$checked> ".__('Include in e-mail digest')."</label>";
704 704
 
705
-			print "</fieldset>";
705
+            print "</fieldset>";
706 706
 
707
-			$always_display_enclosures = $row["always_display_enclosures"];
707
+            $always_display_enclosures = $row["always_display_enclosures"];
708 708
 
709
-			if ($always_display_enclosures) {
710
-				$checked = "checked";
711
-			} else {
712
-				$checked = "";
713
-			}
709
+            if ($always_display_enclosures) {
710
+                $checked = "checked";
711
+            } else {
712
+                $checked = "";
713
+            }
714 714
 
715
-			print "<fieldset class='narrow'>";
715
+            print "<fieldset class='narrow'>";
716 716
 
717
-			print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"
717
+            print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" id=\"always_display_enclosures\"
718 718
 				name=\"always_display_enclosures\"
719 719
 				$checked> ".__('Always display image attachments')."</label>";
720 720
 
721
-			print "</fieldset>";
721
+            print "</fieldset>";
722 722
 
723
-			$hide_images = $row["hide_images"];
723
+            $hide_images = $row["hide_images"];
724 724
 
725
-			if ($hide_images) {
726
-				$checked = "checked=\"1\"";
727
-			} else {
728
-				$checked = "";
729
-			}
725
+            if ($hide_images) {
726
+                $checked = "checked=\"1\"";
727
+            } else {
728
+                $checked = "";
729
+            }
730 730
 
731
-			print "<fieldset class='narrow'>";
731
+            print "<fieldset class='narrow'>";
732 732
 
733
-			print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='hide_images'
733
+            print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='hide_images'
734 734
 				name='hide_images' $checked> ".__('Do not embed media')."</label>";
735 735
 
736
-			print "</fieldset>";
736
+            print "</fieldset>";
737 737
 
738
-			$cache_images = $row["cache_images"];
738
+            $cache_images = $row["cache_images"];
739 739
 
740
-			if ($cache_images) {
741
-				$checked = "checked=\"1\"";
742
-			} else {
743
-				$checked = "";
744
-			}
740
+            if ($cache_images) {
741
+                $checked = "checked=\"1\"";
742
+            } else {
743
+                $checked = "";
744
+            }
745 745
 
746
-			print "<fieldset class='narrow'>";
746
+            print "<fieldset class='narrow'>";
747 747
 
748
-			print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='cache_images'
748
+            print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='cache_images'
749 749
 				name='cache_images' $checked> ".__('Cache media')."</label>";
750 750
 
751
-			print "</fieldset>";
751
+            print "</fieldset>";
752 752
 
753
-			$mark_unread_on_update = $row["mark_unread_on_update"];
753
+            $mark_unread_on_update = $row["mark_unread_on_update"];
754 754
 
755
-			if ($mark_unread_on_update) {
756
-				$checked = "checked";
757
-			} else {
758
-				$checked = "";
759
-			}
755
+            if ($mark_unread_on_update) {
756
+                $checked = "checked";
757
+            } else {
758
+                $checked = "";
759
+            }
760 760
 
761
-			print "<fieldset class='narrow'>";
761
+            print "<fieldset class='narrow'>";
762 762
 
763
-			print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='mark_unread_on_update'
763
+            print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='mark_unread_on_update'
764 764
 				name='mark_unread_on_update' $checked> ".__('Mark updated articles as unread')."</label>";
765 765
 
766
-			print "</fieldset>";
766
+            print "</fieldset>";
767 767
 
768
-			print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Icon').'">';
768
+            print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Icon').'">';
769 769
 
770
-			/* Icon */
770
+            /* Icon */
771 771
 
772
-			print "<img class='feedIcon feed-editor-icon' src=\"".Feeds::getFeedIcon($feed_id)."\">";
772
+            print "<img class='feedIcon feed-editor-icon' src=\"".Feeds::getFeedIcon($feed_id)."\">";
773 773
 
774
-			print "<form onsubmit='return false;' id='feed_icon_upload_form'
774
+            print "<form onsubmit='return false;' id='feed_icon_upload_form'
775 775
 				enctype='multipart/form-data' method='POST'>
776 776
 			<label class='dijitButton'>".__("Choose file...")."
777 777
 				<input style='display: none' id='icon_file' size='10' name='icon_file' type='file'>
@@ -785,231 +785,231 @@  discard block
 block discarded – undo
785 785
 				type='submit'>".__('Remove')."</button>
786 786
 			</form>";
787 787
 
788
-			print "</section>";
788
+            print "</section>";
789 789
 
790
-			print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Plugins').'">';
790
+            print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Plugins').'">';
791 791
 
792
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED,
793
-				"hook_prefs_edit_feed", $feed_id);
792
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_EDIT_FEED,
793
+                "hook_prefs_edit_feed", $feed_id);
794 794
 
795
-			print "</div></div>";
795
+            print "</div></div>";
796 796
 
797
-			$title = htmlspecialchars($title, ENT_QUOTES);
797
+            $title = htmlspecialchars($title, ENT_QUOTES);
798 798
 
799
-			print "<footer>
799
+            print "<footer>
800 800
 				<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='return CommonDialogs.unsubscribeFeed($feed_id, \"$title\")'>".
801
-					__('Unsubscribe')."</button>
801
+                    __('Unsubscribe')."</button>
802 802
 				<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return dijit.byId('feedEditDlg').execute()\">".__('Save')."</button>
803 803
 				<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('feedEditDlg').hide()\">".__('Cancel')."</button>
804 804
 				</footer>";
805
-		}
806
-	}
805
+        }
806
+    }
807 807
 
808
-	public function editfeeds() {
809
-		global $purge_intervals;
810
-		global $update_intervals;
808
+    public function editfeeds() {
809
+        global $purge_intervals;
810
+        global $update_intervals;
811 811
 
812
-		$feed_ids = clean($_REQUEST["ids"]);
812
+        $feed_ids = clean($_REQUEST["ids"]);
813 813
 
814
-		print_notice("Enable the options you wish to apply using checkboxes on the right:");
814
+        print_notice("Enable the options you wish to apply using checkboxes on the right:");
815 815
 
816
-		print "<p>";
816
+        print "<p>";
817 817
 
818
-		print_hidden("ids", "$feed_ids");
819
-		print_hidden("op", "pref-feeds");
820
-		print_hidden("method", "batchEditSave");
818
+        print_hidden("ids", "$feed_ids");
819
+        print_hidden("op", "pref-feeds");
820
+        print_hidden("method", "batchEditSave");
821 821
 
822
-		print "<header>".__("Feed")."</header>";
823
-		print "<section>";
822
+        print "<header>".__("Feed")."</header>";
823
+        print "<section>";
824 824
 
825
-		/* Category */
825
+        /* Category */
826 826
 
827
-		if (get_pref('ENABLE_FEED_CATS')) {
827
+        if (get_pref('ENABLE_FEED_CATS')) {
828 828
 
829
-			print "<fieldset>";
829
+            print "<fieldset>";
830 830
 
831
-			print "<label>".__('Place in category:')."</label> ";
831
+            print "<label>".__('Place in category:')."</label> ";
832 832
 
833
-			print_feed_cat_select("cat_id", false,
834
-				'disabled="1" dojoType="fox.form.Select"');
833
+            print_feed_cat_select("cat_id", false,
834
+                'disabled="1" dojoType="fox.form.Select"');
835 835
 
836
-			$this->batch_edit_cbox("cat_id");
836
+            $this->batch_edit_cbox("cat_id");
837 837
 
838
-			print "</fieldset>";
839
-		}
838
+            print "</fieldset>";
839
+        }
840 840
 
841
-		/* FTS Stemming Language */
841
+        /* FTS Stemming Language */
842 842
 
843
-		if (DB_TYPE == "pgsql") {
844
-			print "<fieldset>";
843
+        if (DB_TYPE == "pgsql") {
844
+            print "<fieldset>";
845 845
 
846
-			print "<label>".__('Language:')."</label> ";
847
-			print_select("feed_language", "", $this::get_ts_languages(),
848
-				'disabled="1" dojoType="fox.form.Select"');
846
+            print "<label>".__('Language:')."</label> ";
847
+            print_select("feed_language", "", $this::get_ts_languages(),
848
+                'disabled="1" dojoType="fox.form.Select"');
849 849
 
850
-			$this->batch_edit_cbox("feed_language");
850
+            $this->batch_edit_cbox("feed_language");
851 851
 
852
-			print "</fieldset>";
853
-		}
852
+            print "</fieldset>";
853
+        }
854 854
 
855
-		print "</section>";
855
+        print "</section>";
856 856
 
857
-		print "<header>".__("Update")."</header>";
858
-		print "<section>";
857
+        print "<header>".__("Update")."</header>";
858
+        print "<section>";
859 859
 
860
-		/* Update Interval */
860
+        /* Update Interval */
861 861
 
862
-		print "<fieldset>";
862
+        print "<fieldset>";
863 863
 
864
-		print "<label>".__("Interval:")."</label> ";
864
+        print "<label>".__("Interval:")."</label> ";
865 865
 
866
-		print_select_hash("update_interval", "", $update_intervals,
867
-			'disabled="1" dojoType="fox.form.Select"');
866
+        print_select_hash("update_interval", "", $update_intervals,
867
+            'disabled="1" dojoType="fox.form.Select"');
868 868
 
869
-		$this->batch_edit_cbox("update_interval");
869
+        $this->batch_edit_cbox("update_interval");
870 870
 
871
-		print "</fieldset>";
871
+        print "</fieldset>";
872 872
 
873
-		/* Purge intl */
873
+        /* Purge intl */
874 874
 
875
-		if (FORCE_ARTICLE_PURGE == 0) {
875
+        if (FORCE_ARTICLE_PURGE == 0) {
876 876
 
877
-			print "<fieldset>";
877
+            print "<fieldset>";
878 878
 
879
-			print "<label>".__('Article purging:')."</label> ";
879
+            print "<label>".__('Article purging:')."</label> ";
880 880
 
881
-			print_select_hash("purge_interval", "", $purge_intervals,
882
-				'disabled="1" dojoType="fox.form.Select"');
881
+            print_select_hash("purge_interval", "", $purge_intervals,
882
+                'disabled="1" dojoType="fox.form.Select"');
883 883
 
884
-			$this->batch_edit_cbox("purge_interval");
884
+            $this->batch_edit_cbox("purge_interval");
885 885
 
886
-			print "</fieldset>";
887
-		}
886
+            print "</fieldset>";
887
+        }
888 888
 
889
-		print "</section>";
890
-		print "<header>".__("Authentication")."</header>";
891
-		print "<section>";
889
+        print "</section>";
890
+        print "<header>".__("Authentication")."</header>";
891
+        print "<section>";
892 892
 
893
-		print "<fieldset>";
893
+        print "<fieldset>";
894 894
 
895
-		print "<input dojoType='dijit.form.TextBox'
895
+        print "<input dojoType='dijit.form.TextBox'
896 896
 			placeHolder=\"".__("Login")."\" disabled='1'
897 897
 			autocomplete='new-password'
898 898
 			name='auth_login' value=''>";
899 899
 
900
-		$this->batch_edit_cbox("auth_login");
900
+        $this->batch_edit_cbox("auth_login");
901 901
 
902
-		print "<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
902
+        print "<input dojoType='dijit.form.TextBox' type='password' name='auth_pass'
903 903
 			autocomplete='new-password'
904 904
 			placeHolder=\"".__("Password")."\" disabled='1'
905 905
 			value=''>";
906 906
 
907
-		$this->batch_edit_cbox("auth_pass");
907
+        $this->batch_edit_cbox("auth_pass");
908 908
 
909
-		print "</fieldset>";
909
+        print "</fieldset>";
910 910
 
911
-		print "</section>";
912
-		print "<header>".__("Options")."</header>";
913
-		print "<section>";
911
+        print "</section>";
912
+        print "<header>".__("Options")."</header>";
913
+        print "<section>";
914 914
 
915
-		print "<fieldset class='narrow'>";
916
-		print "<label class='checkbox'><input disabled='1' type='checkbox' id='include_in_digest'
915
+        print "<fieldset class='narrow'>";
916
+        print "<label class='checkbox'><input disabled='1' type='checkbox' id='include_in_digest'
917 917
 			name='include_in_digest' dojoType='dijit.form.CheckBox'>&nbsp;".__('Include in e-mail digest')."</label>";
918 918
 
919
-		print "&nbsp;"; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l");
919
+        print "&nbsp;"; $this->batch_edit_cbox("include_in_digest", "include_in_digest_l");
920 920
 
921
-		print "</fieldset><fieldset class='narrow'>";
921
+        print "</fieldset><fieldset class='narrow'>";
922 922
 
923
-		print "<label class='checkbox'><input disabled='1' type='checkbox' id='always_display_enclosures'
923
+        print "<label class='checkbox'><input disabled='1' type='checkbox' id='always_display_enclosures'
924 924
 			name='always_display_enclosures' dojoType='dijit.form.CheckBox'>&nbsp;".__('Always display image attachments')."</label>";
925 925
 
926
-		print "&nbsp;"; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
926
+        print "&nbsp;"; $this->batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
927 927
 
928
-		print "</fieldset><fieldset class='narrow'>";
928
+        print "</fieldset><fieldset class='narrow'>";
929 929
 
930
-		print "<label class='checkbox'><input disabled='1' type='checkbox' id='hide_images'
930
+        print "<label class='checkbox'><input disabled='1' type='checkbox' id='hide_images'
931 931
 			name='hide_images' dojoType='dijit.form.CheckBox'>&nbsp;". __('Do not embed media')."</label>";
932 932
 
933
-		print "&nbsp;"; $this->batch_edit_cbox("hide_images", "hide_images_l");
933
+        print "&nbsp;"; $this->batch_edit_cbox("hide_images", "hide_images_l");
934 934
 
935
-		print "</fieldset><fieldset class='narrow'>";
935
+        print "</fieldset><fieldset class='narrow'>";
936 936
 
937
-		print "<label class='checkbox'><input disabled='1' type='checkbox' id='cache_images'
937
+        print "<label class='checkbox'><input disabled='1' type='checkbox' id='cache_images'
938 938
 			name='cache_images' dojoType='dijit.form.CheckBox'>&nbsp;".__('Cache media')."</label>";
939 939
 
940
-		print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
940
+        print "&nbsp;"; $this->batch_edit_cbox("cache_images", "cache_images_l");
941 941
 
942
-		print "</fieldset><fieldset class='narrow'>";
942
+        print "</fieldset><fieldset class='narrow'>";
943 943
 
944
-		print "<label class='checkbox'><input disabled='1' type='checkbox' id='mark_unread_on_update'
944
+        print "<label class='checkbox'><input disabled='1' type='checkbox' id='mark_unread_on_update'
945 945
 			name='mark_unread_on_update' dojoType='dijit.form.CheckBox'>&nbsp;".__('Mark updated articles as unread')."</label>";
946 946
 
947
-		print "&nbsp;"; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l");
947
+        print "&nbsp;"; $this->batch_edit_cbox("mark_unread_on_update", "mark_unread_on_update_l");
948 948
 
949
-		print "</fieldset>";
949
+        print "</fieldset>";
950 950
 
951
-		print "</section>";
951
+        print "</section>";
952 952
 
953
-		print "<footer>
953
+        print "<footer>
954 954
 			<button dojoType='dijit.form.Button' type='submit' class='alt-primary'
955 955
 				onclick=\"return dijit.byId('feedEditDlg').execute()\">".
956
-				__('Save')."</button>
956
+                __('Save')."</button>
957 957
 			<button dojoType='dijit.form.Button'
958 958
 			onclick=\"return dijit.byId('feedEditDlg').hide()\">".
959
-				__('Cancel')."</button>
959
+                __('Cancel')."</button>
960 960
 			</footer>";
961 961
 
962
-		return;
963
-	}
964
-
965
-	public function batchEditSave() {
966
-		return $this->editsaveops(true);
967
-	}
968
-
969
-	public function editSave() {
970
-		return $this->editsaveops(false);
971
-	}
972
-
973
-	public function editsaveops($batch) {
974
-
975
-		$feed_title = trim(clean($_POST["title"]));
976
-		$feed_url = trim(clean($_POST["feed_url"]));
977
-		$site_url = trim(clean($_POST["site_url"]));
978
-		$upd_intl = (int) clean($_POST["update_interval"]);
979
-		$purge_intl = (int) clean($_POST["purge_interval"]);
980
-		$feed_id = (int) clean($_POST["id"]); /* editSave */
981
-		$feed_ids = explode(",", clean($_POST["ids"])); /* batchEditSave */
982
-		$cat_id = (int) clean($_POST["cat_id"]);
983
-		$auth_login = trim(clean($_POST["auth_login"]));
984
-		$auth_pass = trim(clean($_POST["auth_pass"]));
985
-		$private = checkbox_to_sql_bool(clean($_POST["private"]));
986
-		$include_in_digest = checkbox_to_sql_bool(
987
-			clean($_POST["include_in_digest"]));
988
-		$cache_images = checkbox_to_sql_bool(
989
-			clean($_POST["cache_images"]));
990
-		$hide_images = checkbox_to_sql_bool(
991
-			clean($_POST["hide_images"]));
992
-		$always_display_enclosures = checkbox_to_sql_bool(
993
-			clean($_POST["always_display_enclosures"]));
994
-
995
-		$mark_unread_on_update = checkbox_to_sql_bool(
996
-			clean($_POST["mark_unread_on_update"]));
997
-
998
-		$feed_language = trim(clean($_POST["feed_language"]));
999
-
1000
-		if (!$batch) {
1001
-			if (clean($_POST["need_auth"]) !== 'on') {
1002
-				$auth_login = '';
1003
-				$auth_pass = '';
1004
-			}
1005
-
1006
-			/* $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?");
962
+        return;
963
+    }
964
+
965
+    public function batchEditSave() {
966
+        return $this->editsaveops(true);
967
+    }
968
+
969
+    public function editSave() {
970
+        return $this->editsaveops(false);
971
+    }
972
+
973
+    public function editsaveops($batch) {
974
+
975
+        $feed_title = trim(clean($_POST["title"]));
976
+        $feed_url = trim(clean($_POST["feed_url"]));
977
+        $site_url = trim(clean($_POST["site_url"]));
978
+        $upd_intl = (int) clean($_POST["update_interval"]);
979
+        $purge_intl = (int) clean($_POST["purge_interval"]);
980
+        $feed_id = (int) clean($_POST["id"]); /* editSave */
981
+        $feed_ids = explode(",", clean($_POST["ids"])); /* batchEditSave */
982
+        $cat_id = (int) clean($_POST["cat_id"]);
983
+        $auth_login = trim(clean($_POST["auth_login"]));
984
+        $auth_pass = trim(clean($_POST["auth_pass"]));
985
+        $private = checkbox_to_sql_bool(clean($_POST["private"]));
986
+        $include_in_digest = checkbox_to_sql_bool(
987
+            clean($_POST["include_in_digest"]));
988
+        $cache_images = checkbox_to_sql_bool(
989
+            clean($_POST["cache_images"]));
990
+        $hide_images = checkbox_to_sql_bool(
991
+            clean($_POST["hide_images"]));
992
+        $always_display_enclosures = checkbox_to_sql_bool(
993
+            clean($_POST["always_display_enclosures"]));
994
+
995
+        $mark_unread_on_update = checkbox_to_sql_bool(
996
+            clean($_POST["mark_unread_on_update"]));
997
+
998
+        $feed_language = trim(clean($_POST["feed_language"]));
999
+
1000
+        if (!$batch) {
1001
+            if (clean($_POST["need_auth"]) !== 'on') {
1002
+                $auth_login = '';
1003
+                $auth_pass = '';
1004
+            }
1005
+
1006
+            /* $sth = $this->pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?");
1007 1007
 			$sth->execute([$feed_id]);
1008 1008
 			$row = $sth->fetch();$orig_feed_url = $row["feed_url"];
1009 1009
 
1010 1010
 			$reset_basic_info = $orig_feed_url != $feed_url; */
1011 1011
 
1012
-			$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET
1012
+            $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET
1013 1013
 				cat_id = :cat_id,
1014 1014
 				title = :title,
1015 1015
 				feed_url = :feed_url,
@@ -1028,253 +1028,253 @@  discard block
 block discarded – undo
1028 1028
 				feed_language = :feed_language
1029 1029
 			WHERE id = :id AND owner_uid = :uid");
1030 1030
 
1031
-			$sth->execute([":title" => $feed_title,
1032
-					":cat_id" => $cat_id ? $cat_id : null,
1033
-					":feed_url" => $feed_url,
1034
-					":site_url" => $site_url,
1035
-					":upd_intl" => $upd_intl,
1036
-					":purge_intl" => $purge_intl,
1037
-					":auth_login" => $auth_login,
1038
-					":auth_pass" => $auth_pass,
1039
-					":private" => (int) $private,
1040
-					":cache_images" => (int) $cache_images,
1041
-					":hide_images" => (int) $hide_images,
1042
-					":include_in_digest" => (int) $include_in_digest,
1043
-					":always_display_enclosures" => (int) $always_display_enclosures,
1044
-					":mark_unread_on_update" => (int) $mark_unread_on_update,
1045
-					":feed_language" => $feed_language,
1046
-					":id" => $feed_id,
1047
-					":uid" => $_SESSION['uid']]);
1031
+            $sth->execute([":title" => $feed_title,
1032
+                    ":cat_id" => $cat_id ? $cat_id : null,
1033
+                    ":feed_url" => $feed_url,
1034
+                    ":site_url" => $site_url,
1035
+                    ":upd_intl" => $upd_intl,
1036
+                    ":purge_intl" => $purge_intl,
1037
+                    ":auth_login" => $auth_login,
1038
+                    ":auth_pass" => $auth_pass,
1039
+                    ":private" => (int) $private,
1040
+                    ":cache_images" => (int) $cache_images,
1041
+                    ":hide_images" => (int) $hide_images,
1042
+                    ":include_in_digest" => (int) $include_in_digest,
1043
+                    ":always_display_enclosures" => (int) $always_display_enclosures,
1044
+                    ":mark_unread_on_update" => (int) $mark_unread_on_update,
1045
+                    ":feed_language" => $feed_language,
1046
+                    ":id" => $feed_id,
1047
+                    ":uid" => $_SESSION['uid']]);
1048 1048
 
1049 1049
 /*			if ($reset_basic_info) {
1050 1050
 				RSSUtils::set_basic_feed_info($feed_id);
1051 1051
 			} */
1052 1052
 
1053
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_SAVE_FEED,
1054
-				"hook_prefs_save_feed", $feed_id);
1053
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_SAVE_FEED,
1054
+                "hook_prefs_save_feed", $feed_id);
1055 1055
 
1056
-		} else {
1057
-			$feed_data = array();
1056
+        } else {
1057
+            $feed_data = array();
1058 1058
 
1059
-			foreach (array_keys($_POST) as $k) {
1060
-				if ($k != "op" && $k != "method" && $k != "ids") {
1061
-					$feed_data[$k] = clean($_POST[$k]);
1062
-				}
1063
-			}
1059
+            foreach (array_keys($_POST) as $k) {
1060
+                if ($k != "op" && $k != "method" && $k != "ids") {
1061
+                    $feed_data[$k] = clean($_POST[$k]);
1062
+                }
1063
+            }
1064 1064
 
1065
-			$this->pdo->beginTransaction();
1065
+            $this->pdo->beginTransaction();
1066 1066
 
1067
-			$feed_ids_qmarks = arr_qmarks($feed_ids);
1067
+            $feed_ids_qmarks = arr_qmarks($feed_ids);
1068 1068
 
1069
-			foreach (array_keys($feed_data) as $k) {
1069
+            foreach (array_keys($feed_data) as $k) {
1070 1070
 
1071
-				$qpart = "";
1071
+                $qpart = "";
1072 1072
 
1073
-				switch ($k) {
1074
-					case "title":
1075
-						$qpart = "title = ".$this->pdo->quote($feed_title);
1076
-						break;
1073
+                switch ($k) {
1074
+                    case "title":
1075
+                        $qpart = "title = ".$this->pdo->quote($feed_title);
1076
+                        break;
1077 1077
 
1078
-					case "feed_url":
1079
-						$qpart = "feed_url = ".$this->pdo->quote($feed_url);
1080
-						break;
1078
+                    case "feed_url":
1079
+                        $qpart = "feed_url = ".$this->pdo->quote($feed_url);
1080
+                        break;
1081 1081
 
1082
-					case "update_interval":
1083
-						$qpart = "update_interval = ".$this->pdo->quote($upd_intl);
1084
-						break;
1082
+                    case "update_interval":
1083
+                        $qpart = "update_interval = ".$this->pdo->quote($upd_intl);
1084
+                        break;
1085 1085
 
1086
-					case "purge_interval":
1087
-						$qpart = "purge_interval =".$this->pdo->quote($purge_intl);
1088
-						break;
1086
+                    case "purge_interval":
1087
+                        $qpart = "purge_interval =".$this->pdo->quote($purge_intl);
1088
+                        break;
1089 1089
 
1090
-					case "auth_login":
1091
-						$qpart = "auth_login = ".$this->pdo->quote($auth_login);
1092
-						break;
1090
+                    case "auth_login":
1091
+                        $qpart = "auth_login = ".$this->pdo->quote($auth_login);
1092
+                        break;
1093 1093
 
1094
-					case "auth_pass":
1095
-						$qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false";
1096
-						break;
1094
+                    case "auth_pass":
1095
+                        $qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false";
1096
+                        break;
1097 1097
 
1098
-					case "private":
1099
-						$qpart = "private = ".$this->pdo->quote($private);
1100
-						break;
1098
+                    case "private":
1099
+                        $qpart = "private = ".$this->pdo->quote($private);
1100
+                        break;
1101 1101
 
1102
-					case "include_in_digest":
1103
-						$qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest);
1104
-						break;
1102
+                    case "include_in_digest":
1103
+                        $qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest);
1104
+                        break;
1105 1105
 
1106
-					case "always_display_enclosures":
1107
-						$qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures);
1108
-						break;
1106
+                    case "always_display_enclosures":
1107
+                        $qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures);
1108
+                        break;
1109 1109
 
1110
-					case "mark_unread_on_update":
1111
-						$qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update);
1112
-						break;
1110
+                    case "mark_unread_on_update":
1111
+                        $qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update);
1112
+                        break;
1113 1113
 
1114
-					case "cache_images":
1115
-						$qpart = "cache_images = ".$this->pdo->quote($cache_images);
1116
-						break;
1114
+                    case "cache_images":
1115
+                        $qpart = "cache_images = ".$this->pdo->quote($cache_images);
1116
+                        break;
1117 1117
 
1118
-					case "hide_images":
1119
-						$qpart = "hide_images = ".$this->pdo->quote($hide_images);
1120
-						break;
1118
+                    case "hide_images":
1119
+                        $qpart = "hide_images = ".$this->pdo->quote($hide_images);
1120
+                        break;
1121 1121
 
1122
-					case "cat_id":
1123
-						if (get_pref('ENABLE_FEED_CATS')) {
1124
-							if ($cat_id) {
1125
-								$qpart = "cat_id = ".$this->pdo->quote($cat_id);
1126
-							} else {
1127
-								$qpart = 'cat_id = NULL';
1128
-							}
1129
-						} else {
1130
-							$qpart = "";
1131
-						}
1122
+                    case "cat_id":
1123
+                        if (get_pref('ENABLE_FEED_CATS')) {
1124
+                            if ($cat_id) {
1125
+                                $qpart = "cat_id = ".$this->pdo->quote($cat_id);
1126
+                            } else {
1127
+                                $qpart = 'cat_id = NULL';
1128
+                            }
1129
+                        } else {
1130
+                            $qpart = "";
1131
+                        }
1132 1132
 
1133
-						break;
1133
+                        break;
1134 1134
 
1135
-					case "feed_language":
1136
-						$qpart = "feed_language = ".$this->pdo->quote($feed_language);
1137
-						break;
1135
+                    case "feed_language":
1136
+                        $qpart = "feed_language = ".$this->pdo->quote($feed_language);
1137
+                        break;
1138 1138
 
1139
-				}
1139
+                }
1140 1140
 
1141
-				if ($qpart) {
1142
-					$sth = $this->pdo->prepare("UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids_qmarks)
1141
+                if ($qpart) {
1142
+                    $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET $qpart WHERE id IN ($feed_ids_qmarks)
1143 1143
 						AND owner_uid = ?");
1144
-					$sth->execute(array_merge($feed_ids, [$_SESSION['uid']]));
1145
-				}
1146
-			}
1144
+                    $sth->execute(array_merge($feed_ids, [$_SESSION['uid']]));
1145
+                }
1146
+            }
1147 1147
 
1148
-			$this->pdo->commit();
1149
-		}
1150
-		return;
1151
-	}
1148
+            $this->pdo->commit();
1149
+        }
1150
+        return;
1151
+    }
1152 1152
 
1153
-	public function remove() {
1153
+    public function remove() {
1154 1154
 
1155
-		$ids = explode(",", clean($_REQUEST["ids"]));
1155
+        $ids = explode(",", clean($_REQUEST["ids"]));
1156 1156
 
1157
-		foreach ($ids as $id) {
1158
-			Pref_Feeds::remove_feed($id, $_SESSION["uid"]);
1159
-		}
1157
+        foreach ($ids as $id) {
1158
+            Pref_Feeds::remove_feed($id, $_SESSION["uid"]);
1159
+        }
1160 1160
 
1161
-		return;
1162
-	}
1161
+        return;
1162
+    }
1163 1163
 
1164
-	public function removeCat() {
1165
-		$ids = explode(",", clean($_REQUEST["ids"]));
1166
-		foreach ($ids as $id) {
1167
-			$this->remove_feed_category($id, $_SESSION["uid"]);
1168
-		}
1169
-	}
1164
+    public function removeCat() {
1165
+        $ids = explode(",", clean($_REQUEST["ids"]));
1166
+        foreach ($ids as $id) {
1167
+            $this->remove_feed_category($id, $_SESSION["uid"]);
1168
+        }
1169
+    }
1170 1170
 
1171
-	public function addCat() {
1172
-		$feed_cat = trim(clean($_REQUEST["cat"]));
1171
+    public function addCat() {
1172
+        $feed_cat = trim(clean($_REQUEST["cat"]));
1173 1173
 
1174
-		Feeds::add_feed_category($feed_cat);
1175
-	}
1174
+        Feeds::add_feed_category($feed_cat);
1175
+    }
1176 1176
 
1177
-	public function index() {
1177
+    public function index() {
1178 1178
 
1179
-		print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
1180
-		print "<div style='padding : 0px' dojoType='dijit.layout.AccordionPane'
1179
+        print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
1180
+        print "<div style='padding : 0px' dojoType='dijit.layout.AccordionPane'
1181 1181
 			title=\"<i class='material-icons'>rss_feed</i> ".__('Feeds')."\">";
1182 1182
 
1183
-		$sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors
1183
+        $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors
1184 1184
 			FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
1185
-		$sth->execute([$_SESSION['uid']]);
1185
+        $sth->execute([$_SESSION['uid']]);
1186 1186
 
1187
-		if ($row = $sth->fetch()) {
1188
-			$num_errors = $row["num_errors"];
1189
-		} else {
1190
-			$num_errors = 0;
1191
-		}
1187
+        if ($row = $sth->fetch()) {
1188
+            $num_errors = $row["num_errors"];
1189
+        } else {
1190
+            $num_errors = 0;
1191
+        }
1192 1192
 
1193
-		if ($num_errors > 0) {
1193
+        if ($num_errors > 0) {
1194 1194
 
1195
-			$error_button = "<button dojoType=\"dijit.form.Button\"
1195
+            $error_button = "<button dojoType=\"dijit.form.Button\"
1196 1196
 			  		onclick=\"CommonDialogs.showFeedsWithErrors()\" id=\"errorButton\">" .
1197
-				__("Feeds with errors")."</button>";
1198
-		}
1197
+                __("Feeds with errors")."</button>";
1198
+        }
1199 1199
 
1200
-		$inactive_button = "<button dojoType=\"dijit.form.Button\"
1200
+        $inactive_button = "<button dojoType=\"dijit.form.Button\"
1201 1201
 				id=\"pref_feeds_inactive_btn\"
1202 1202
 				style=\"display : none\"
1203 1203
 				onclick=\"dijit.byId('feedTree').showInactiveFeeds()\">" .
1204
-				__("Inactive feeds")."</button>";
1204
+                __("Inactive feeds")."</button>";
1205 1205
 
1206
-		$feed_search = clean($_REQUEST["search"]);
1206
+        $feed_search = clean($_REQUEST["search"]);
1207 1207
 
1208
-		if (array_key_exists("search", $_REQUEST)) {
1209
-			$_SESSION["prefs_feed_search"] = $feed_search;
1210
-		} else {
1211
-			$feed_search = $_SESSION["prefs_feed_search"];
1212
-		}
1208
+        if (array_key_exists("search", $_REQUEST)) {
1209
+            $_SESSION["prefs_feed_search"] = $feed_search;
1210
+        } else {
1211
+            $feed_search = $_SESSION["prefs_feed_search"];
1212
+        }
1213 1213
 
1214
-		print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
1214
+        print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
1215 1215
 
1216
-		print "<div region='top' dojoType=\"fox.Toolbar\">"; #toolbar
1216
+        print "<div region='top' dojoType=\"fox.Toolbar\">"; #toolbar
1217 1217
 
1218
-		print "<div style='float : right; padding-right : 4px;'>
1218
+        print "<div style='float : right; padding-right : 4px;'>
1219 1219
 			<input dojoType=\"dijit.form.TextBox\" id=\"feed_search\" size=\"20\" type=\"search\"
1220 1220
 				value=\"$feed_search\">
1221 1221
 			<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedTree').reload()\">".
1222
-				__('Search')."</button>
1222
+                __('Search')."</button>
1223 1223
 			</div>";
1224 1224
 
1225
-		print "<div dojoType=\"fox.form.DropDownButton\">".
1226
-				"<span>".__('Select')."</span>";
1227
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1228
-		print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"
1225
+        print "<div dojoType=\"fox.form.DropDownButton\">".
1226
+                "<span>".__('Select')."</span>";
1227
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1228
+        print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(true)\"
1229 1229
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
1230
-		print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"
1230
+        print "<div onclick=\"dijit.byId('feedTree').model.setAllChecked(false)\"
1231 1231
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
1232
-		print "</div></div>";
1232
+        print "</div></div>";
1233 1233
 
1234
-		print "<div dojoType=\"fox.form.DropDownButton\">".
1235
-				"<span>".__('Feeds')."</span>";
1236
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1237
-		print "<div onclick=\"CommonDialogs.quickAddFeed()\"
1234
+        print "<div dojoType=\"fox.form.DropDownButton\">".
1235
+                "<span>".__('Feeds')."</span>";
1236
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1237
+        print "<div onclick=\"CommonDialogs.quickAddFeed()\"
1238 1238
 			dojoType=\"dijit.MenuItem\">".__('Subscribe to feed')."</div>";
1239
-		print "<div onclick=\"dijit.byId('feedTree').editSelectedFeed()\"
1239
+        print "<div onclick=\"dijit.byId('feedTree').editSelectedFeed()\"
1240 1240
 			dojoType=\"dijit.MenuItem\">".__('Edit selected feeds')."</div>";
1241
-		print "<div onclick=\"dijit.byId('feedTree').resetFeedOrder()\"
1241
+        print "<div onclick=\"dijit.byId('feedTree').resetFeedOrder()\"
1242 1242
 			dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
1243
-		print "<div onclick=\"dijit.byId('feedTree').batchSubscribe()\"
1243
+        print "<div onclick=\"dijit.byId('feedTree').batchSubscribe()\"
1244 1244
 			dojoType=\"dijit.MenuItem\">".__('Batch subscribe')."</div>";
1245
-		print "<div dojoType=\"dijit.MenuItem\" onclick=\"dijit.byId('feedTree').removeSelectedFeeds()\">"
1246
-			.__('Unsubscribe')."</div> ";
1247
-		print "</div></div>";
1248
-
1249
-		if (get_pref('ENABLE_FEED_CATS')) {
1250
-			print "<div dojoType=\"fox.form.DropDownButton\">".
1251
-					"<span>".__('Categories')."</span>";
1252
-			print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1253
-			print "<div onclick=\"dijit.byId('feedTree').createCategory()\"
1245
+        print "<div dojoType=\"dijit.MenuItem\" onclick=\"dijit.byId('feedTree').removeSelectedFeeds()\">"
1246
+            .__('Unsubscribe')."</div> ";
1247
+        print "</div></div>";
1248
+
1249
+        if (get_pref('ENABLE_FEED_CATS')) {
1250
+            print "<div dojoType=\"fox.form.DropDownButton\">".
1251
+                    "<span>".__('Categories')."</span>";
1252
+            print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1253
+            print "<div onclick=\"dijit.byId('feedTree').createCategory()\"
1254 1254
 				dojoType=\"dijit.MenuItem\">".__('Add category')."</div>";
1255
-			print "<div onclick=\"dijit.byId('feedTree').resetCatOrder()\"
1255
+            print "<div onclick=\"dijit.byId('feedTree').resetCatOrder()\"
1256 1256
 				dojoType=\"dijit.MenuItem\">".__('Reset sort order')."</div>";
1257
-			print "<div onclick=\"dijit.byId('feedTree').removeSelectedCategories()\"
1257
+            print "<div onclick=\"dijit.byId('feedTree').removeSelectedCategories()\"
1258 1258
 				dojoType=\"dijit.MenuItem\">".__('Remove selected')."</div>";
1259
-			print "</div></div>";
1259
+            print "</div></div>";
1260 1260
 
1261
-		}
1261
+        }
1262 1262
 
1263
-		print $error_button;
1264
-		print $inactive_button;
1263
+        print $error_button;
1264
+        print $inactive_button;
1265 1265
 
1266
-		print "</div>"; # toolbar
1266
+        print "</div>"; # toolbar
1267 1267
 
1268
-		//print '</div>';
1269
-		print '<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">';
1268
+        //print '</div>';
1269
+        print '<div style="padding : 0px" dojoType="dijit.layout.ContentPane" region="center">';
1270 1270
 
1271
-		print "<div id=\"feedlistLoading\">
1271
+        print "<div id=\"feedlistLoading\">
1272 1272
 		<img src='images/indicator_tiny.gif'>".
1273
-		 __("Loading, please wait...")."</div>";
1273
+            __("Loading, please wait...")."</div>";
1274 1274
 
1275
-		$auto_expand = $feed_search != "" ? "true" : "false";
1275
+        $auto_expand = $feed_search != "" ? "true" : "false";
1276 1276
 
1277
-		print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"
1277
+        print "<div dojoType=\"fox.PrefFeedStore\" jsId=\"feedStore\"
1278 1278
 			url=\"backend.php?op=pref-feeds&method=getfeedtree\">
1279 1279
 		</div>
1280 1280
 		<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"feedModel\" store=\"feedStore\"
@@ -1307,23 +1307,23 @@  discard block
 block discarded – undo
1307 1307
 #			".__('<b>Hint:</b> you can drag feeds and categories around.')."
1308 1308
 #			</div>";
1309 1309
 
1310
-		print '</div>';
1311
-		print '</div>';
1310
+        print '</div>';
1311
+        print '</div>';
1312 1312
 
1313
-		print "</div>"; # feeds pane
1313
+        print "</div>"; # feeds pane
1314 1314
 
1315
-		print "<div dojoType='dijit.layout.AccordionPane'
1315
+        print "<div dojoType='dijit.layout.AccordionPane'
1316 1316
 			title='<i class=\"material-icons\">import_export</i> ".__('OPML')."'>";
1317 1317
 
1318
-		print "<h3>".__("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.")."</h3>";
1318
+        print "<h3>".__("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.")."</h3>";
1319 1319
 
1320
-		print_notice("Only main settings profile can be migrated using OPML.");
1320
+        print_notice("Only main settings profile can be migrated using OPML.");
1321 1321
 
1322
-		print "<iframe id=\"upload_iframe\"
1322
+        print "<iframe id=\"upload_iframe\"
1323 1323
 			name=\"upload_iframe\" onload=\"Helpers.OPML.onImportComplete(this)\"
1324 1324
 			style=\"width: 400px; height: 100px; display: none;\"></iframe>";
1325 1325
 
1326
-		print "<form  name='opml_form' style='display : inline-block' target='upload_iframe'
1326
+        print "<form  name='opml_form' style='display : inline-block' target='upload_iframe'
1327 1327
 			enctype='multipart/form-data' method='POST'
1328 1328
 			action='backend.php'>
1329 1329
 			<label class='dijitButton'>".__("Choose file...")."
@@ -1332,118 +1332,118 @@  discard block
 block discarded – undo
1332 1332
 			<input type='hidden' name='op' value='dlg'>
1333 1333
 			<input type='hidden' name='method' value='importOpml'>
1334 1334
 			<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return Helpers.OPML.import();\" type=\"submit\">" .
1335
-			__('Import OPML')."</button>";
1335
+            __('Import OPML')."</button>";
1336 1336
 
1337
-		print "</form>";
1337
+        print "</form>";
1338 1338
 
1339
-		print "<form dojoType='dijit.form.Form' id='opmlExportForm' style='display : inline-block'>";
1339
+        print "<form dojoType='dijit.form.Form' id='opmlExportForm' style='display : inline-block'>";
1340 1340
 
1341
-		print "<button dojoType='dijit.form.Button'
1341
+        print "<button dojoType='dijit.form.Button'
1342 1342
 			onclick='Helpers.OPML.export()' >" .
1343
-			__('Export OPML')."</button>";
1343
+            __('Export OPML')."</button>";
1344 1344
 
1345
-		print " <label class='checkbox'>";
1346
-		print_checkbox("include_settings", true, "1", "");
1347
-		print " ".__("Include settings");
1348
-		print "</label>";
1345
+        print " <label class='checkbox'>";
1346
+        print_checkbox("include_settings", true, "1", "");
1347
+        print " ".__("Include settings");
1348
+        print "</label>";
1349 1349
 
1350
-		print "</form>";
1350
+        print "</form>";
1351 1351
 
1352
-		print "<p/>";
1352
+        print "<p/>";
1353 1353
 
1354
-		print "<h2>".__("Published OPML")."</h2>";
1354
+        print "<h2>".__("Published OPML")."</h2>";
1355 1355
 
1356
-		print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.').
1357
-			" ".
1358
-			__("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.")."</p>";
1356
+        print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.').
1357
+            " ".
1358
+            __("Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.")."</p>";
1359 1359
 
1360
-		print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
1361
-			__('Display published OPML URL')."</button> ";
1360
+        print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Public OPML URL")."','pubOPMLUrl')\">".
1361
+            __('Display published OPML URL')."</button> ";
1362 1362
 
1363
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
1364
-			"hook_prefs_tab_section", "prefFeedsOPML");
1363
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
1364
+            "hook_prefs_tab_section", "prefFeedsOPML");
1365 1365
 
1366
-		print "</div>"; # pane
1366
+        print "</div>"; # pane
1367 1367
 
1368
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
1368
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
1369 1369
 			title=\"<i class='material-icons'>share</i> ".__('Published & shared articles / Generated feeds')."\">";
1370 1370
 
1371
-		print "<h3>".__('Published articles can be subscribed by anyone who knows the following URL:')."</h3>";
1371
+        print "<h3>".__('Published articles can be subscribed by anyone who knows the following URL:')."</h3>";
1372 1372
 
1373
-		$rss_url = '-2::'.htmlspecialchars(get_self_url_prefix().
1374
-				"/public.php?op=rss&id=-2&view-mode=all_articles"); ;
1373
+        $rss_url = '-2::'.htmlspecialchars(get_self_url_prefix().
1374
+                "/public.php?op=rss&id=-2&view-mode=all_articles"); ;
1375 1375
 
1376
-		print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Show as feed")."','generatedFeed', '$rss_url')\">".
1377
-			__('Display URL')."</button> ";
1376
+        print "<button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return App.displayDlg('".__("Show as feed")."','generatedFeed', '$rss_url')\">".
1377
+            __('Display URL')."</button> ";
1378 1378
 
1379
-		print "<button class=\"alt-danger\" dojoType=\"dijit.form.Button\" onclick=\"return Helpers.clearFeedAccessKeys()\">".
1380
-			__('Clear all generated URLs')."</button> ";
1379
+        print "<button class=\"alt-danger\" dojoType=\"dijit.form.Button\" onclick=\"return Helpers.clearFeedAccessKeys()\">".
1380
+            __('Clear all generated URLs')."</button> ";
1381 1381
 
1382
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
1383
-			"hook_prefs_tab_section", "prefFeedsPublishedGenerated");
1382
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
1383
+            "hook_prefs_tab_section", "prefFeedsPublishedGenerated");
1384 1384
 
1385
-		print "</div>"; #pane
1385
+        print "</div>"; #pane
1386 1386
 
1387
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
1388
-			"hook_prefs_tab", "prefFeeds");
1387
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
1388
+            "hook_prefs_tab", "prefFeeds");
1389 1389
 
1390
-		print "</div>"; #container
1391
-	}
1390
+        print "</div>"; #container
1391
+    }
1392 1392
 
1393
-	private function feedlist_init_cat($cat_id) {
1394
-		$obj = array();
1395
-		$cat_id = (int) $cat_id;
1393
+    private function feedlist_init_cat($cat_id) {
1394
+        $obj = array();
1395
+        $cat_id = (int) $cat_id;
1396 1396
 
1397
-		if ($cat_id > 0) {
1398
-			$cat_unread = CCache::find($cat_id, $_SESSION["uid"], true);
1399
-		} else if ($cat_id == 0 || $cat_id == -2) {
1400
-			$cat_unread = Feeds::getCategoryUnread($cat_id);
1401
-		}
1397
+        if ($cat_id > 0) {
1398
+            $cat_unread = CCache::find($cat_id, $_SESSION["uid"], true);
1399
+        } else if ($cat_id == 0 || $cat_id == -2) {
1400
+            $cat_unread = Feeds::getCategoryUnread($cat_id);
1401
+        }
1402 1402
 
1403
-		$obj['id'] = 'CAT:'.$cat_id;
1404
-		$obj['items'] = array();
1405
-		$obj['name'] = Feeds::getCategoryTitle($cat_id);
1406
-		$obj['type'] = 'category';
1407
-		$obj['unread'] = (int) $cat_unread;
1408
-		$obj['bare_id'] = $cat_id;
1403
+        $obj['id'] = 'CAT:'.$cat_id;
1404
+        $obj['items'] = array();
1405
+        $obj['name'] = Feeds::getCategoryTitle($cat_id);
1406
+        $obj['type'] = 'category';
1407
+        $obj['unread'] = (int) $cat_unread;
1408
+        $obj['bare_id'] = $cat_id;
1409 1409
 
1410
-		return $obj;
1411
-	}
1410
+        return $obj;
1411
+    }
1412 1412
 
1413
-	private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {
1414
-		$obj = array();
1415
-		$feed_id = (int) $feed_id;
1413
+    private function feedlist_init_feed($feed_id, $title = false, $unread = false, $error = '', $updated = '') {
1414
+        $obj = array();
1415
+        $feed_id = (int) $feed_id;
1416 1416
 
1417
-		if (!$title) {
1418
-					$title = Feeds::getFeedTitle($feed_id, false);
1419
-		}
1417
+        if (!$title) {
1418
+                    $title = Feeds::getFeedTitle($feed_id, false);
1419
+        }
1420 1420
 
1421
-		if ($unread === false) {
1422
-					$unread = getFeedUnread($feed_id, false);
1423
-		}
1421
+        if ($unread === false) {
1422
+                    $unread = getFeedUnread($feed_id, false);
1423
+        }
1424 1424
 
1425
-		$obj['id'] = 'FEED:'.$feed_id;
1426
-		$obj['name'] = $title;
1427
-		$obj['unread'] = (int) $unread;
1428
-		$obj['type'] = 'feed';
1429
-		$obj['error'] = $error;
1430
-		$obj['updated'] = $updated;
1431
-		$obj['icon'] = Feeds::getFeedIcon($feed_id);
1432
-		$obj['bare_id'] = $feed_id;
1433
-		$obj['auxcounter'] = 0;
1425
+        $obj['id'] = 'FEED:'.$feed_id;
1426
+        $obj['name'] = $title;
1427
+        $obj['unread'] = (int) $unread;
1428
+        $obj['type'] = 'feed';
1429
+        $obj['error'] = $error;
1430
+        $obj['updated'] = $updated;
1431
+        $obj['icon'] = Feeds::getFeedIcon($feed_id);
1432
+        $obj['bare_id'] = $feed_id;
1433
+        $obj['auxcounter'] = 0;
1434 1434
 
1435
-		return $obj;
1436
-	}
1435
+        return $obj;
1436
+    }
1437 1437
 
1438
-	public function inactiveFeeds() {
1438
+    public function inactiveFeeds() {
1439 1439
 
1440
-		if (DB_TYPE == "pgsql") {
1441
-			$interval_qpart = "NOW() - INTERVAL '3 months'";
1442
-		} else {
1443
-			$interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
1444
-		}
1440
+        if (DB_TYPE == "pgsql") {
1441
+            $interval_qpart = "NOW() - INTERVAL '3 months'";
1442
+        } else {
1443
+            $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
1444
+        }
1445 1445
 
1446
-		$sth = $this->pdo->prepare("SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1446
+        $sth = $this->pdo->prepare("SELECT ttrss_feeds.title, ttrss_feeds.site_url,
1447 1447
 		  		ttrss_feeds.feed_url, ttrss_feeds.id, MAX(updated) AS last_article
1448 1448
 			FROM ttrss_feeds, ttrss_entries, ttrss_user_entries WHERE
1449 1449
 				(SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
@@ -1454,358 +1454,358 @@  discard block
 block discarded – undo
1454 1454
 				ttrss_entries.id = ref_id
1455 1455
 			GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
1456 1456
 			ORDER BY last_article");
1457
-		$sth->execute([$_SESSION['uid']]);
1457
+        $sth->execute([$_SESSION['uid']]);
1458 1458
 
1459
-		print "<div dojoType='fox.Toolbar'>";
1460
-		print "<div dojoType='fox.form.DropDownButton'>".
1461
-				"<span>".__('Select')."</span>";
1462
-		print "<div dojoType='dijit.Menu' style='display: none'>";
1463
-		print "<div onclick=\"Tables.select('inactive-feeds-list', true)\"
1459
+        print "<div dojoType='fox.Toolbar'>";
1460
+        print "<div dojoType='fox.form.DropDownButton'>".
1461
+                "<span>".__('Select')."</span>";
1462
+        print "<div dojoType='dijit.Menu' style='display: none'>";
1463
+        print "<div onclick=\"Tables.select('inactive-feeds-list', true)\"
1464 1464
 			dojoType='dijit.MenuItem'>".__('All')."</div>";
1465
-		print "<div onclick=\"Tables.select('inactive-feeds-list', false)\"
1465
+        print "<div onclick=\"Tables.select('inactive-feeds-list', false)\"
1466 1466
 			dojoType='dijit.MenuItem'>".__('None')."</div>";
1467
-		print "</div></div>";
1468
-		print "</div>"; #toolbar
1467
+        print "</div></div>";
1468
+        print "</div>"; #toolbar
1469 1469
 
1470
-		print "<div class='panel panel-scrollable'>";
1471
-		print "<table width='100%' id='inactive-feeds-list'>";
1470
+        print "<div class='panel panel-scrollable'>";
1471
+        print "<table width='100%' id='inactive-feeds-list'>";
1472 1472
 
1473
-		$lnum = 1;
1473
+        $lnum = 1;
1474 1474
 
1475
-		while ($line = $sth->fetch()) {
1475
+        while ($line = $sth->fetch()) {
1476 1476
 
1477
-			$feed_id = $line["id"];
1477
+            $feed_id = $line["id"];
1478 1478
 
1479
-			print "<tr data-row-id='$feed_id'>";
1479
+            print "<tr data-row-id='$feed_id'>";
1480 1480
 
1481
-			print "<td width='5%' align='center'><input
1481
+            print "<td width='5%' align='center'><input
1482 1482
 				onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox'
1483 1483
 				type='checkbox'></td>";
1484
-			print "<td>";
1484
+            print "<td>";
1485 1485
 
1486
-			print "<a href='#' ".
1487
-				"title=\"".__("Click to edit feed")."\" ".
1488
-				"onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
1489
-				htmlspecialchars($line["title"])."</a>";
1486
+            print "<a href='#' ".
1487
+                "title=\"".__("Click to edit feed")."\" ".
1488
+                "onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
1489
+                htmlspecialchars($line["title"])."</a>";
1490 1490
 
1491
-			print "</td><td class='text-muted' align='right'>";
1492
-			print make_local_datetime($line['last_article'], false);
1493
-			print "</td>";
1494
-			print "</tr>";
1491
+            print "</td><td class='text-muted' align='right'>";
1492
+            print make_local_datetime($line['last_article'], false);
1493
+            print "</td>";
1494
+            print "</tr>";
1495 1495
 
1496
-			++$lnum;
1497
-		}
1496
+            ++$lnum;
1497
+        }
1498 1498
 
1499
-		print "</table>";
1500
-		print "</div>";
1499
+        print "</table>";
1500
+        print "</div>";
1501 1501
 
1502
-		print "<footer>
1502
+        print "<footer>
1503 1503
 			<button style='float : left' class=\"alt-danger\" dojoType='dijit.form.Button' onclick=\"dijit.byId('inactiveFeedsDlg').removeSelected()\">"
1504
-			.__('Unsubscribe from selected feeds')."</button>
1504
+            .__('Unsubscribe from selected feeds')."</button>
1505 1505
 			<button dojoType='dijit.form.Button' onclick=\"dijit.byId('inactiveFeedsDlg').hide()\">"
1506
-			.__('Close this window')."</button>
1506
+            .__('Close this window')."</button>
1507 1507
 			</footer>";
1508 1508
 
1509
-	}
1509
+    }
1510 1510
 
1511
-	public function feedsWithErrors() {
1512
-		$sth = $this->pdo->prepare("SELECT id,title,feed_url,last_error,site_url
1511
+    public function feedsWithErrors() {
1512
+        $sth = $this->pdo->prepare("SELECT id,title,feed_url,last_error,site_url
1513 1513
 			FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ?");
1514
-		$sth->execute([$_SESSION['uid']]);
1514
+        $sth->execute([$_SESSION['uid']]);
1515 1515
 
1516
-		print "<div dojoType=\"fox.Toolbar\">";
1517
-		print "<div dojoType=\"fox.form.DropDownButton\">".
1518
-				"<span>".__('Select')."</span>";
1519
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1520
-		print "<div onclick=\"Tables.select('error-feeds-list', true)\"
1516
+        print "<div dojoType=\"fox.Toolbar\">";
1517
+        print "<div dojoType=\"fox.form.DropDownButton\">".
1518
+                "<span>".__('Select')."</span>";
1519
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
1520
+        print "<div onclick=\"Tables.select('error-feeds-list', true)\"
1521 1521
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
1522
-		print "<div onclick=\"Tables.select('error-feeds-list', false)\"
1522
+        print "<div onclick=\"Tables.select('error-feeds-list', false)\"
1523 1523
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
1524
-		print "</div></div>";
1525
-		print "</div>"; #toolbar
1524
+        print "</div></div>";
1525
+        print "</div>"; #toolbar
1526 1526
 
1527
-		print "<div class='panel panel-scrollable'>";
1528
-		print "<table width='100%' id='error-feeds-list'>";
1527
+        print "<div class='panel panel-scrollable'>";
1528
+        print "<table width='100%' id='error-feeds-list'>";
1529 1529
 
1530
-		$lnum = 1;
1530
+        $lnum = 1;
1531 1531
 
1532
-		while ($line = $sth->fetch()) {
1532
+        while ($line = $sth->fetch()) {
1533 1533
 
1534
-			$feed_id = $line["id"];
1534
+            $feed_id = $line["id"];
1535 1535
 
1536
-			print "<tr data-row-id='$feed_id'>";
1536
+            print "<tr data-row-id='$feed_id'>";
1537 1537
 
1538
-			print "<td width='5%' align='center'><input
1538
+            print "<td width='5%' align='center'><input
1539 1539
 				onclick='Tables.onRowChecked(this);' dojoType=\"dijit.form.CheckBox\"
1540 1540
 				type=\"checkbox\"></td>";
1541
-			print "<td>";
1541
+            print "<td>";
1542 1542
 
1543
-			print "<a class=\"visibleLink\" href=\"#\" ".
1544
-				"title=\"".__("Click to edit feed")."\" ".
1545
-				"onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
1546
-				htmlspecialchars($line["title"])."</a>: ";
1543
+            print "<a class=\"visibleLink\" href=\"#\" ".
1544
+                "title=\"".__("Click to edit feed")."\" ".
1545
+                "onclick=\"CommonDialogs.editFeed(".$line["id"].")\">".
1546
+                htmlspecialchars($line["title"])."</a>: ";
1547 1547
 
1548
-			print "<span class=\"text-muted\">";
1549
-			print htmlspecialchars($line["last_error"]);
1550
-			print "</span>";
1548
+            print "<span class=\"text-muted\">";
1549
+            print htmlspecialchars($line["last_error"]);
1550
+            print "</span>";
1551 1551
 
1552
-			print "</td>";
1553
-			print "</tr>";
1552
+            print "</td>";
1553
+            print "</tr>";
1554 1554
 
1555
-			++$lnum;
1556
-		}
1555
+            ++$lnum;
1556
+        }
1557 1557
 
1558
-		print "</table>";
1559
-		print "</div>";
1558
+        print "</table>";
1559
+        print "</div>";
1560 1560
 
1561
-		print "<footer>";
1562
-		print "<button style='float : left' class=\"alt-danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
1563
-			.__('Unsubscribe from selected feeds')."</button> ";
1561
+        print "<footer>";
1562
+        print "<button style='float : left' class=\"alt-danger\" dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').removeSelected()\">"
1563
+            .__('Unsubscribe from selected feeds')."</button> ";
1564 1564
 
1565
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
1566
-			__('Close this window')."</button>";
1565
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('errorFeedsDlg').hide()\">".
1566
+            __('Close this window')."</button>";
1567 1567
 
1568
-		print "</footer>";
1569
-	}
1568
+        print "</footer>";
1569
+    }
1570 1570
 
1571
-	private function remove_feed_category($id, $owner_uid) {
1571
+    private function remove_feed_category($id, $owner_uid) {
1572 1572
 
1573
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_feed_categories
1573
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_feed_categories
1574 1574
 			WHERE id = ? AND owner_uid = ?");
1575
-		$sth->execute([$id, $owner_uid]);
1575
+        $sth->execute([$id, $owner_uid]);
1576 1576
 
1577
-		CCache::remove($id, $owner_uid, true);
1578
-	}
1577
+        CCache::remove($id, $owner_uid, true);
1578
+    }
1579 1579
 
1580
-	public static function remove_feed($id, $owner_uid) {
1581
-		foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) {
1582
-			if (!$p->hook_unsubscribe_feed($id, $owner_uid)) {
1580
+    public static function remove_feed($id, $owner_uid) {
1581
+        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) {
1582
+            if (!$p->hook_unsubscribe_feed($id, $owner_uid)) {
1583 1583
                 user_error("feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING);
1584 1584
                 return;
1585
-			}
1586
-		}
1585
+            }
1586
+        }
1587 1587
 
1588
-		$pdo = Db::pdo();
1588
+        $pdo = Db::pdo();
1589 1589
 
1590
-		if ($id > 0) {
1591
-			$pdo->beginTransaction();
1590
+        if ($id > 0) {
1591
+            $pdo->beginTransaction();
1592 1592
 
1593
-			/* save starred articles in Archived feed */
1593
+            /* save starred articles in Archived feed */
1594 1594
 
1595
-			/* prepare feed if necessary */
1595
+            /* prepare feed if necessary */
1596 1596
 
1597
-			$sth = $pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?
1597
+            $sth = $pdo->prepare("SELECT feed_url FROM ttrss_feeds WHERE id = ?
1598 1598
 				AND owner_uid = ?");
1599
-			$sth->execute([$id, $owner_uid]);
1599
+            $sth->execute([$id, $owner_uid]);
1600 1600
 
1601
-			if ($row = $sth->fetch()) {
1602
-				$feed_url = $row["feed_url"];
1601
+            if ($row = $sth->fetch()) {
1602
+                $feed_url = $row["feed_url"];
1603 1603
 
1604
-				$sth = $pdo->prepare("SELECT id FROM ttrss_archived_feeds
1604
+                $sth = $pdo->prepare("SELECT id FROM ttrss_archived_feeds
1605 1605
 					WHERE feed_url = ? AND owner_uid = ?");
1606
-				$sth->execute([$feed_url, $owner_uid]);
1606
+                $sth->execute([$feed_url, $owner_uid]);
1607 1607
 
1608
-				if ($row = $sth->fetch()) {
1609
-					$archive_id = $row["id"];
1610
-				} else {
1611
-					$res = $pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
1612
-					$row = $res->fetch();
1608
+                if ($row = $sth->fetch()) {
1609
+                    $archive_id = $row["id"];
1610
+                } else {
1611
+                    $res = $pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds");
1612
+                    $row = $res->fetch();
1613 1613
 
1614
-					$new_feed_id = (int) $row['id'] + 1;
1614
+                    $new_feed_id = (int) $row['id'] + 1;
1615 1615
 
1616
-					$sth = $pdo->prepare("INSERT INTO ttrss_archived_feeds
1616
+                    $sth = $pdo->prepare("INSERT INTO ttrss_archived_feeds
1617 1617
 						(id, owner_uid, title, feed_url, site_url, created)
1618 1618
 							SELECT ?, owner_uid, title, feed_url, site_url, NOW() from ttrss_feeds
1619 1619
 							WHERE id = ?");
1620
-					$sth->execute([$new_feed_id, $id]);
1620
+                    $sth->execute([$new_feed_id, $id]);
1621 1621
 
1622
-					$archive_id = $new_feed_id;
1623
-				}
1622
+                    $archive_id = $new_feed_id;
1623
+                }
1624 1624
 
1625
-				$sth = $pdo->prepare("UPDATE ttrss_user_entries SET feed_id = NULL,
1625
+                $sth = $pdo->prepare("UPDATE ttrss_user_entries SET feed_id = NULL,
1626 1626
 					orig_feed_id = ? WHERE feed_id = ? AND
1627 1627
 						marked = true AND owner_uid = ?");
1628 1628
 
1629
-				$sth->execute([$archive_id, $id, $owner_uid]);
1629
+                $sth->execute([$archive_id, $id, $owner_uid]);
1630 1630
 
1631
-				/* Remove access key for the feed */
1631
+                /* Remove access key for the feed */
1632 1632
 
1633
-				$sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE
1633
+                $sth = $pdo->prepare("DELETE FROM ttrss_access_keys WHERE
1634 1634
 					feed_id = ? AND owner_uid = ?");
1635
-				$sth->execute([$id, $owner_uid]);
1635
+                $sth->execute([$id, $owner_uid]);
1636 1636
 
1637
-				/* remove the feed */
1637
+                /* remove the feed */
1638 1638
 
1639
-				$sth = $pdo->prepare("DELETE FROM ttrss_feeds
1639
+                $sth = $pdo->prepare("DELETE FROM ttrss_feeds
1640 1640
 					WHERE id = ? AND owner_uid = ?");
1641
-				$sth->execute([$id, $owner_uid]);
1642
-			}
1641
+                $sth->execute([$id, $owner_uid]);
1642
+            }
1643 1643
 
1644
-			$pdo->commit();
1644
+            $pdo->commit();
1645 1645
 
1646
-			if (file_exists(ICONS_DIR."/$id.ico")) {
1647
-				unlink(ICONS_DIR."/$id.ico");
1648
-			}
1646
+            if (file_exists(ICONS_DIR."/$id.ico")) {
1647
+                unlink(ICONS_DIR."/$id.ico");
1648
+            }
1649 1649
 
1650
-			CCache::remove($id, $owner_uid);
1650
+            CCache::remove($id, $owner_uid);
1651 1651
 
1652
-		} else {
1653
-			Labels::remove(Labels::feed_to_label_id($id), $owner_uid);
1654
-			//CCache::remove($id, $owner_uid); don't think labels are cached
1655
-		}
1656
-	}
1652
+        } else {
1653
+            Labels::remove(Labels::feed_to_label_id($id), $owner_uid);
1654
+            //CCache::remove($id, $owner_uid); don't think labels are cached
1655
+        }
1656
+    }
1657 1657
 
1658
-	public function batchSubscribe() {
1659
-		print_hidden("op", "pref-feeds");
1660
-		print_hidden("method", "batchaddfeeds");
1658
+    public function batchSubscribe() {
1659
+        print_hidden("op", "pref-feeds");
1660
+        print_hidden("method", "batchaddfeeds");
1661 1661
 
1662
-		print "<header class='horizontal'>".__("One valid feed per line (no detection is done)")."</header>";
1663
-		print "<section>";
1662
+        print "<header class='horizontal'>".__("One valid feed per line (no detection is done)")."</header>";
1663
+        print "<section>";
1664 1664
 
1665
-		print "<textarea
1665
+        print "<textarea
1666 1666
 			style='font-size : 12px; width : 98%; height: 200px;'
1667 1667
 			dojoType='dijit.form.SimpleTextarea' name='feeds'></textarea>";
1668 1668
 
1669
-		if (get_pref('ENABLE_FEED_CATS')) {
1670
-			print "<fieldset>";
1671
-			print "<label>".__('Place in category:')."</label> ";
1672
-			print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"');
1673
-			print "</fieldset>";
1674
-		}
1669
+        if (get_pref('ENABLE_FEED_CATS')) {
1670
+            print "<fieldset>";
1671
+            print "<label>".__('Place in category:')."</label> ";
1672
+            print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"');
1673
+            print "</fieldset>";
1674
+        }
1675 1675
 
1676
-		print "</section>";
1676
+        print "</section>";
1677 1677
 
1678
-		print "<div id='feedDlg_loginContainer' style='display : none'>";
1678
+        print "<div id='feedDlg_loginContainer' style='display : none'>";
1679 1679
 
1680
-		print "<header>".__("Authentication")."</header>";
1681
-		print "<section>";
1680
+        print "<header>".__("Authentication")."</header>";
1681
+        print "<section>";
1682 1682
 
1683
-		print "<input dojoType='dijit.form.TextBox' name='login' placeHolder=\"".__("Login")."\">
1683
+        print "<input dojoType='dijit.form.TextBox' name='login' placeHolder=\"".__("Login")."\">
1684 1684
 			<input placeHolder=\"".__("Password")."\" dojoType=\"dijit.form.TextBox\" type='password'
1685 1685
 				autocomplete='new-password' name='pass''></div>";
1686 1686
 
1687
-		print "</section>";
1688
-		print "</div>";
1687
+        print "</section>";
1688
+        print "</div>";
1689 1689
 
1690
-		print "<fieldset class='narrow'>
1690
+        print "<fieldset class='narrow'>
1691 1691
 			<label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox'
1692 1692
 					onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'> ".
1693
-				__('Feeds require authentication.')."</label></div>";
1694
-		print "</fieldset>";
1693
+                __('Feeds require authentication.')."</label></div>";
1694
+        print "</fieldset>";
1695 1695
 
1696
-		print "<footer>
1696
+        print "<footer>
1697 1697
 			<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".__('Subscribe')."</button>
1698 1698
 			<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button>
1699 1699
 			</footer>";
1700
-	}
1700
+    }
1701 1701
 
1702
-	public function batchAddFeeds() {
1703
-		$cat_id = clean($_REQUEST['cat']);
1704
-		$feeds = explode("\n", clean($_REQUEST['feeds']));
1705
-		$login = clean($_REQUEST['login']);
1706
-		$pass = trim(clean($_REQUEST['pass']));
1702
+    public function batchAddFeeds() {
1703
+        $cat_id = clean($_REQUEST['cat']);
1704
+        $feeds = explode("\n", clean($_REQUEST['feeds']));
1705
+        $login = clean($_REQUEST['login']);
1706
+        $pass = trim(clean($_REQUEST['pass']));
1707 1707
 
1708
-		$csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
1708
+        $csth = $this->pdo->prepare("SELECT id FROM ttrss_feeds
1709 1709
 						WHERE feed_url = ? AND owner_uid = ?");
1710 1710
 
1711
-		$isth = $this->pdo->prepare("INSERT INTO ttrss_feeds
1711
+        $isth = $this->pdo->prepare("INSERT INTO ttrss_feeds
1712 1712
 							(owner_uid,feed_url,title,cat_id,auth_login,auth_pass,update_method,auth_pass_encrypted)
1713 1713
 						VALUES (?, ?, '[Unknown]', ?, ?, ?, 0, false)");
1714 1714
 
1715
-		foreach ($feeds as $feed) {
1716
-			$feed = trim($feed);
1715
+        foreach ($feeds as $feed) {
1716
+            $feed = trim($feed);
1717 1717
 
1718
-			if (Feeds::validate_feed_url($feed)) {
1718
+            if (Feeds::validate_feed_url($feed)) {
1719 1719
 
1720
-				$this->pdo->beginTransaction();
1720
+                $this->pdo->beginTransaction();
1721 1721
 
1722
-				$csth->execute([$feed, $_SESSION['uid']]);
1722
+                $csth->execute([$feed, $_SESSION['uid']]);
1723 1723
 
1724
-				if (!$csth->fetch()) {
1725
-					$isth->execute([$_SESSION['uid'], $feed, $cat_id ? $cat_id : null, $login, $pass]);
1726
-				}
1724
+                if (!$csth->fetch()) {
1725
+                    $isth->execute([$_SESSION['uid'], $feed, $cat_id ? $cat_id : null, $login, $pass]);
1726
+                }
1727 1727
 
1728
-				$this->pdo->commit();
1729
-			}
1730
-		}
1731
-	}
1728
+                $this->pdo->commit();
1729
+            }
1730
+        }
1731
+    }
1732 1732
 
1733
-	public function regenOPMLKey() {
1734
-		$this->update_feed_access_key('OPML:Publish',
1735
-		false, $_SESSION["uid"]);
1733
+    public function regenOPMLKey() {
1734
+        $this->update_feed_access_key('OPML:Publish',
1735
+        false, $_SESSION["uid"]);
1736 1736
 
1737
-		$new_link = Opml::opml_publish_url();
1737
+        $new_link = Opml::opml_publish_url();
1738 1738
 
1739
-		print json_encode(array("link" => $new_link));
1740
-	}
1739
+        print json_encode(array("link" => $new_link));
1740
+    }
1741 1741
 
1742
-	public function regenFeedKey() {
1743
-		$feed_id = clean($_REQUEST['id']);
1744
-		$is_cat = clean($_REQUEST['is_cat']);
1742
+    public function regenFeedKey() {
1743
+        $feed_id = clean($_REQUEST['id']);
1744
+        $is_cat = clean($_REQUEST['is_cat']);
1745 1745
 
1746
-		$new_key = $this->update_feed_access_key($feed_id, $is_cat);
1746
+        $new_key = $this->update_feed_access_key($feed_id, $is_cat);
1747 1747
 
1748
-		print json_encode(["link" => $new_key]);
1749
-	}
1748
+        print json_encode(["link" => $new_key]);
1749
+    }
1750 1750
 
1751 1751
 
1752
-	private function update_feed_access_key($feed_id, $is_cat, $owner_uid = false) {
1753
-		if (!$owner_uid) {
1754
-		    $owner_uid = $_SESSION["uid"];
1755
-		}
1752
+    private function update_feed_access_key($feed_id, $is_cat, $owner_uid = false) {
1753
+        if (!$owner_uid) {
1754
+            $owner_uid = $_SESSION["uid"];
1755
+        }
1756 1756
 
1757
-		// clear old value and generate new one
1758
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys
1757
+        // clear old value and generate new one
1758
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys
1759 1759
 			WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?");
1760
-		$sth->execute([$feed_id, bool_to_sql_bool($is_cat), $owner_uid]);
1760
+        $sth->execute([$feed_id, bool_to_sql_bool($is_cat), $owner_uid]);
1761 1761
 
1762
-		return Feeds::get_feed_access_key($feed_id, $is_cat, $owner_uid);
1763
-	}
1762
+        return Feeds::get_feed_access_key($feed_id, $is_cat, $owner_uid);
1763
+    }
1764 1764
 
1765
-	// Silent
1766
-	public function clearKeys() {
1767
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys WHERE
1765
+    // Silent
1766
+    public function clearKeys() {
1767
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys WHERE
1768 1768
 			owner_uid = ?");
1769
-		$sth->execute([$_SESSION['uid']]);
1770
-	}
1771
-
1772
-	private function calculate_children_count($cat) {
1773
-		$c = 0;
1774
-
1775
-		foreach ($cat['items'] as $child) {
1776
-			if ($child['type'] == 'category') {
1777
-				$c += $this->calculate_children_count($child);
1778
-			} else {
1779
-				$c += 1;
1780
-			}
1781
-		}
1782
-
1783
-		return $c;
1784
-	}
1785
-
1786
-	public function getinactivefeeds() {
1787
-		if (DB_TYPE == "pgsql") {
1788
-			$interval_qpart = "NOW() - INTERVAL '3 months'";
1789
-		} else {
1790
-			$interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
1791
-		}
1792
-
1793
-		$sth = $this->pdo->prepare("SELECT COUNT(id) AS num_inactive FROM ttrss_feeds WHERE
1769
+        $sth->execute([$_SESSION['uid']]);
1770
+    }
1771
+
1772
+    private function calculate_children_count($cat) {
1773
+        $c = 0;
1774
+
1775
+        foreach ($cat['items'] as $child) {
1776
+            if ($child['type'] == 'category') {
1777
+                $c += $this->calculate_children_count($child);
1778
+            } else {
1779
+                $c += 1;
1780
+            }
1781
+        }
1782
+
1783
+        return $c;
1784
+    }
1785
+
1786
+    public function getinactivefeeds() {
1787
+        if (DB_TYPE == "pgsql") {
1788
+            $interval_qpart = "NOW() - INTERVAL '3 months'";
1789
+        } else {
1790
+            $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
1791
+        }
1792
+
1793
+        $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_inactive FROM ttrss_feeds WHERE
1794 1794
 				(SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
1795 1795
 					ttrss_entries.id = ref_id AND
1796 1796
 						ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
1797 1797
 			  ttrss_feeds.owner_uid = ?");
1798
-		$sth->execute([$_SESSION['uid']]);
1799
-
1800
-		if ($row = $sth->fetch()) {
1801
-			print (int) $row["num_inactive"];
1802
-		}
1803
-	}
1804
-
1805
-	public static function subscribe_to_feed_url() {
1806
-		$url_path = get_self_url_prefix().
1807
-			"/public.php?op=subscribe&feed_url=%s";
1808
-		return $url_path;
1809
-	}
1798
+        $sth->execute([$_SESSION['uid']]);
1799
+
1800
+        if ($row = $sth->fetch()) {
1801
+            print (int) $row["num_inactive"];
1802
+        }
1803
+    }
1804
+
1805
+    public static function subscribe_to_feed_url() {
1806
+        $url_path = get_self_url_prefix().
1807
+            "/public.php?op=subscribe&feed_url=%s";
1808
+        return $url_path;
1809
+    }
1810 1810
 
1811 1811
 }
Please login to merge, or discard this patch.
Switch Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1071,70 +1071,70 @@
 block discarded – undo
1071 1071
 				$qpart = "";
1072 1072
 
1073 1073
 				switch ($k) {
1074
-					case "title":
1075
-						$qpart = "title = ".$this->pdo->quote($feed_title);
1076
-						break;
1077
-
1078
-					case "feed_url":
1079
-						$qpart = "feed_url = ".$this->pdo->quote($feed_url);
1080
-						break;
1081
-
1082
-					case "update_interval":
1083
-						$qpart = "update_interval = ".$this->pdo->quote($upd_intl);
1084
-						break;
1085
-
1086
-					case "purge_interval":
1087
-						$qpart = "purge_interval =".$this->pdo->quote($purge_intl);
1088
-						break;
1089
-
1090
-					case "auth_login":
1091
-						$qpart = "auth_login = ".$this->pdo->quote($auth_login);
1092
-						break;
1093
-
1094
-					case "auth_pass":
1095
-						$qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false";
1096
-						break;
1097
-
1098
-					case "private":
1099
-						$qpart = "private = ".$this->pdo->quote($private);
1100
-						break;
1101
-
1102
-					case "include_in_digest":
1103
-						$qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest);
1104
-						break;
1105
-
1106
-					case "always_display_enclosures":
1107
-						$qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures);
1108
-						break;
1109
-
1110
-					case "mark_unread_on_update":
1111
-						$qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update);
1112
-						break;
1113
-
1114
-					case "cache_images":
1115
-						$qpart = "cache_images = ".$this->pdo->quote($cache_images);
1116
-						break;
1117
-
1118
-					case "hide_images":
1119
-						$qpart = "hide_images = ".$this->pdo->quote($hide_images);
1120
-						break;
1121
-
1122
-					case "cat_id":
1123
-						if (get_pref('ENABLE_FEED_CATS')) {
1124
-							if ($cat_id) {
1125
-								$qpart = "cat_id = ".$this->pdo->quote($cat_id);
1126
-							} else {
1127
-								$qpart = 'cat_id = NULL';
1128
-							}
1074
+				case "title":
1075
+					$qpart = "title = ".$this->pdo->quote($feed_title);
1076
+					break;
1077
+
1078
+				case "feed_url":
1079
+					$qpart = "feed_url = ".$this->pdo->quote($feed_url);
1080
+					break;
1081
+
1082
+				case "update_interval":
1083
+					$qpart = "update_interval = ".$this->pdo->quote($upd_intl);
1084
+					break;
1085
+
1086
+				case "purge_interval":
1087
+					$qpart = "purge_interval =".$this->pdo->quote($purge_intl);
1088
+					break;
1089
+
1090
+				case "auth_login":
1091
+					$qpart = "auth_login = ".$this->pdo->quote($auth_login);
1092
+					break;
1093
+
1094
+				case "auth_pass":
1095
+					$qpart = "auth_pass =".$this->pdo->quote($auth_pass).", auth_pass_encrypted = false";
1096
+					break;
1097
+
1098
+				case "private":
1099
+					$qpart = "private = ".$this->pdo->quote($private);
1100
+					break;
1101
+
1102
+				case "include_in_digest":
1103
+					$qpart = "include_in_digest = ".$this->pdo->quote($include_in_digest);
1104
+					break;
1105
+
1106
+				case "always_display_enclosures":
1107
+					$qpart = "always_display_enclosures = ".$this->pdo->quote($always_display_enclosures);
1108
+					break;
1109
+
1110
+				case "mark_unread_on_update":
1111
+					$qpart = "mark_unread_on_update = ".$this->pdo->quote($mark_unread_on_update);
1112
+					break;
1113
+
1114
+				case "cache_images":
1115
+					$qpart = "cache_images = ".$this->pdo->quote($cache_images);
1116
+					break;
1117
+
1118
+				case "hide_images":
1119
+					$qpart = "hide_images = ".$this->pdo->quote($hide_images);
1120
+					break;
1121
+
1122
+				case "cat_id":
1123
+					if (get_pref('ENABLE_FEED_CATS')) {
1124
+						if ($cat_id) {
1125
+							$qpart = "cat_id = ".$this->pdo->quote($cat_id);
1129 1126
 						} else {
1130
-							$qpart = "";
1127
+							$qpart = 'cat_id = NULL';
1131 1128
 						}
1129
+					} else {
1130
+						$qpart = "";
1131
+					}
1132 1132
 
1133
-						break;
1133
+					break;
1134 1134
 
1135
-					case "feed_language":
1136
-						$qpart = "feed_language = ".$this->pdo->quote($feed_language);
1137
-						break;
1135
+				case "feed_language":
1136
+					$qpart = "feed_language = ".$this->pdo->quote($feed_language);
1137
+					break;
1138 1138
 
1139 1139
 				}
1140 1140
 
Please login to merge, or discard this patch.
classes/pref/users.php 1 patch
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -1,130 +1,130 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Users extends Handler_Protected {
3
-		public function before($method) {
4
-			if (parent::before($method)) {
5
-				if ($_SESSION["access_level"] < 10) {
6
-					print __("Your access level is insufficient to open this tab.");
7
-					return false;
8
-				}
9
-				return true;
10
-			}
11
-			return false;
12
-		}
3
+        public function before($method) {
4
+            if (parent::before($method)) {
5
+                if ($_SESSION["access_level"] < 10) {
6
+                    print __("Your access level is insufficient to open this tab.");
7
+                    return false;
8
+                }
9
+                return true;
10
+            }
11
+            return false;
12
+        }
13 13
 
14
-		public function csrf_ignore($method) {
15
-			$csrf_ignored = array("index", "edit", "userdetails");
14
+        public function csrf_ignore($method) {
15
+            $csrf_ignored = array("index", "edit", "userdetails");
16 16
 
17
-			return array_search($method, $csrf_ignored) !== false;
18
-		}
17
+            return array_search($method, $csrf_ignored) !== false;
18
+        }
19 19
 
20
-		public function edit() {
21
-			global $access_level_names;
20
+        public function edit() {
21
+            global $access_level_names;
22 22
 
23
-			print "<form id='user_edit_form' onsubmit='return false' dojoType='dijit.form.Form'>";
23
+            print "<form id='user_edit_form' onsubmit='return false' dojoType='dijit.form.Form'>";
24 24
 
25
-			print '<div dojoType="dijit.layout.TabContainer" style="height : 400px">
25
+            print '<div dojoType="dijit.layout.TabContainer" style="height : 400px">
26 26
         		<div dojoType="dijit.layout.ContentPane" title="'.__('Edit user').'">';
27 27
 
28
-			//print "<form id=\"user_edit_form\" onsubmit='return false' dojoType=\"dijit.form.Form\">";
28
+            //print "<form id=\"user_edit_form\" onsubmit='return false' dojoType=\"dijit.form.Form\">";
29 29
 
30
-			$id = (int) clean($_REQUEST["id"]);
30
+            $id = (int) clean($_REQUEST["id"]);
31 31
 
32
-			print_hidden("id", "$id");
33
-			print_hidden("op", "pref-users");
34
-			print_hidden("method", "editSave");
32
+            print_hidden("id", "$id");
33
+            print_hidden("op", "pref-users");
34
+            print_hidden("method", "editSave");
35 35
 
36
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_users WHERE id = ?");
37
-			$sth->execute([$id]);
36
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_users WHERE id = ?");
37
+            $sth->execute([$id]);
38 38
 
39
-			if ($row = $sth->fetch()) {
39
+            if ($row = $sth->fetch()) {
40 40
 
41
-				$login = $row["login"];
42
-				$access_level = $row["access_level"];
43
-				$email = $row["email"];
41
+                $login = $row["login"];
42
+                $access_level = $row["access_level"];
43
+                $email = $row["email"];
44 44
 
45
-				$sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : "";
45
+                $sel_disabled = ($id == $_SESSION["uid"] || $login == "admin") ? "disabled" : "";
46 46
 
47
-				print "<header>".__("User")."</header>";
48
-				print "<section>";
47
+                print "<header>".__("User")."</header>";
48
+                print "<section>";
49 49
 
50
-				if ($sel_disabled) {
51
-					print_hidden("login", "$login");
52
-				}
50
+                if ($sel_disabled) {
51
+                    print_hidden("login", "$login");
52
+                }
53 53
 
54
-				print "<fieldset>";
55
-				print "<label>".__("Login:")."</label>";
56
-				print "<input style='font-size : 16px'
54
+                print "<fieldset>";
55
+                print "<label>".__("Login:")."</label>";
56
+                print "<input style='font-size : 16px'
57 57
 					dojoType='dijit.form.ValidationTextBox' required='1'
58 58
 					$sel_disabled name='login' value=\"$login\">";
59
-				print "</fieldset>";
59
+                print "</fieldset>";
60 60
 
61
-				print "</section>";
61
+                print "</section>";
62 62
 
63
-				print "<header>".__("Authentication")."</header>";
64
-				print "<section>";
63
+                print "<header>".__("Authentication")."</header>";
64
+                print "<section>";
65 65
 
66
-				print "<fieldset>";
66
+                print "<fieldset>";
67 67
 
68
-				print "<label>".__('Access level: ')."</label> ";
68
+                print "<label>".__('Access level: ')."</label> ";
69 69
 
70
-				if (!$sel_disabled) {
71
-					print_select_hash("access_level", $access_level, $access_level_names,
72
-						"dojoType=\"fox.form.Select\" $sel_disabled");
73
-				} else {
74
-					print_select_hash("", $access_level, $access_level_names,
75
-						"dojoType=\"fox.form.Select\" $sel_disabled");
76
-					print_hidden("access_level", "$access_level");
77
-				}
70
+                if (!$sel_disabled) {
71
+                    print_select_hash("access_level", $access_level, $access_level_names,
72
+                        "dojoType=\"fox.form.Select\" $sel_disabled");
73
+                } else {
74
+                    print_select_hash("", $access_level, $access_level_names,
75
+                        "dojoType=\"fox.form.Select\" $sel_disabled");
76
+                    print_hidden("access_level", "$access_level");
77
+                }
78 78
 
79
-				print "</fieldset>";
80
-				print "<fieldset>";
79
+                print "</fieldset>";
80
+                print "<fieldset>";
81 81
 
82
-				print "<label>".__("New password:")."</label> ";
83
-				print "<input dojoType='dijit.form.TextBox' type='password' size='20' placeholder='Change password'
82
+                print "<label>".__("New password:")."</label> ";
83
+                print "<input dojoType='dijit.form.TextBox' type='password' size='20' placeholder='Change password'
84 84
 					name='password'>";
85 85
 
86
-				print "</fieldset>";
86
+                print "</fieldset>";
87 87
 
88
-				print "</section>";
88
+                print "</section>";
89 89
 
90
-				print "<header>".__("Options")."</header>";
91
-				print "<section>";
90
+                print "<header>".__("Options")."</header>";
91
+                print "<section>";
92 92
 
93
-				print "<fieldset>";
94
-				print "<label>".__("E-mail:")."</label> ";
95
-				print "<input dojoType='dijit.form.TextBox' size='30' name='email'
93
+                print "<fieldset>";
94
+                print "<label>".__("E-mail:")."</label> ";
95
+                print "<input dojoType='dijit.form.TextBox' size='30' name='email'
96 96
 					value=\"$email\">";
97
-				print "</fieldset>";
97
+                print "</fieldset>";
98 98
 
99
-				print "</section>";
99
+                print "</section>";
100 100
 
101
-				print "</table>";
101
+                print "</table>";
102 102
 
103
-			}
103
+            }
104 104
 
105
-			print '</div>'; #tab
106
-			print "<div href=\"backend.php?op=pref-users&method=userdetails&id=$id\"
105
+            print '</div>'; #tab
106
+            print "<div href=\"backend.php?op=pref-users&method=userdetails&id=$id\"
107 107
 				dojoType=\"dijit.layout.ContentPane\" title=\"".__('User details')."\">";
108 108
 
109
-			print '</div>';
110
-			print '</div>';
109
+            print '</div>';
110
+            print '</div>';
111 111
 
112
-			print "<footer>
112
+            print "<footer>
113 113
 				<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"dijit.byId('userEditDlg').execute()\">".
114
-				__('Save')."</button>
114
+                __('Save')."</button>
115 115
 				<button dojoType='dijit.form.Button' onclick=\"dijit.byId('userEditDlg').hide()\">".
116
-				__('Cancel')."</button>
116
+                __('Cancel')."</button>
117 117
 				</footer>";
118 118
 
119
-			print "</form>";
119
+            print "</form>";
120 120
 
121
-			return;
122
-		}
121
+            return;
122
+        }
123 123
 
124
-		public function userdetails() {
125
-			$id = (int) clean($_REQUEST["id"]);
124
+        public function userdetails() {
125
+            $id = (int) clean($_REQUEST["id"]);
126 126
 
127
-			$sth = $this->pdo->prepare("SELECT login,
127
+            $sth = $this->pdo->prepare("SELECT login,
128 128
 				".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login,
129 129
 				access_level,
130 130
 				(SELECT COUNT(int_id) FROM ttrss_user_entries
@@ -132,248 +132,248 @@  discard block
 block discarded – undo
132 132
 				".SUBSTRING_FOR_DATE."(created,1,16) AS created
133 133
 				FROM ttrss_users
134 134
 				WHERE id = ?");
135
-			$sth->execute([$id]);
135
+            $sth->execute([$id]);
136 136
 
137
-			if ($row = $sth->fetch()) {
138
-				print "<table width='100%'>";
137
+            if ($row = $sth->fetch()) {
138
+                print "<table width='100%'>";
139 139
 
140
-				$last_login = make_local_datetime(
141
-					$row["last_login"], true);
140
+                $last_login = make_local_datetime(
141
+                    $row["last_login"], true);
142 142
 
143
-				$created = make_local_datetime(
144
-					$row["created"], true);
143
+                $created = make_local_datetime(
144
+                    $row["created"], true);
145 145
 
146
-				$stored_articles = $row["stored_articles"];
146
+                $stored_articles = $row["stored_articles"];
147 147
 
148
-				print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
149
-				print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
148
+                print "<tr><td>".__('Registered')."</td><td>$created</td></tr>";
149
+                print "<tr><td>".__('Last logged in')."</td><td>$last_login</td></tr>";
150 150
 
151
-				$sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds
151
+                $sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds
152 152
 					WHERE owner_uid = ?");
153
-				$sth->execute([$id]);
154
-				$row = $sth->fetch();
155
-				$num_feeds = $row["num_feeds"];
153
+                $sth->execute([$id]);
154
+                $row = $sth->fetch();
155
+                $num_feeds = $row["num_feeds"];
156 156
 
157
-				print "<tr><td>".__('Subscribed feeds count')."</td><td>$num_feeds</td></tr>";
158
-				print "<tr><td>".__('Stored articles')."</td><td>$stored_articles</td></tr>";
157
+                print "<tr><td>".__('Subscribed feeds count')."</td><td>$num_feeds</td></tr>";
158
+                print "<tr><td>".__('Stored articles')."</td><td>$stored_articles</td></tr>";
159 159
 
160
-				print "</table>";
160
+                print "</table>";
161 161
 
162
-				print "<h1>".__('Subscribed feeds')."</h1>";
162
+                print "<h1>".__('Subscribed feeds')."</h1>";
163 163
 
164
-				$sth = $this->pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds
164
+                $sth = $this->pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds
165 165
 					WHERE owner_uid = ? ORDER BY title");
166
-				$sth->execute([$id]);
166
+                $sth->execute([$id]);
167 167
 
168
-				print "<ul class=\"panel panel-scrollable list list-unstyled\">";
168
+                print "<ul class=\"panel panel-scrollable list list-unstyled\">";
169 169
 
170
-				while ($line = $sth->fetch()) {
170
+                while ($line = $sth->fetch()) {
171 171
 
172
-					$icon_file = ICONS_URL."/".$line["id"].".ico";
172
+                    $icon_file = ICONS_URL."/".$line["id"].".ico";
173 173
 
174
-					if (file_exists($icon_file) && filesize($icon_file) > 0) {
175
-						$feed_icon = "<img class=\"icon\" src=\"$icon_file\">";
176
-					} else {
177
-						$feed_icon = "<img class=\"icon\" src=\"images/blank_icon.gif\">";
178
-					}
174
+                    if (file_exists($icon_file) && filesize($icon_file) > 0) {
175
+                        $feed_icon = "<img class=\"icon\" src=\"$icon_file\">";
176
+                    } else {
177
+                        $feed_icon = "<img class=\"icon\" src=\"images/blank_icon.gif\">";
178
+                    }
179 179
 
180
-					print "<li>$feed_icon&nbsp;<a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
180
+                    print "<li>$feed_icon&nbsp;<a href=\"".$line["site_url"]."\">".$line["title"]."</a></li>";
181 181
 
182
-				}
182
+                }
183 183
 
184
-				print "</ul>";
184
+                print "</ul>";
185 185
 
186 186
 
187
-			} else {
188
-				print "<h1>".__('User not found')."</h1>";
189
-			}
187
+            } else {
188
+                print "<h1>".__('User not found')."</h1>";
189
+            }
190 190
 
191
-		}
191
+        }
192 192
 
193
-		public function editSave() {
194
-			$login = trim(clean($_REQUEST["login"]));
195
-			$uid = clean($_REQUEST["id"]);
196
-			$access_level = (int) clean($_REQUEST["access_level"]);
197
-			$email = trim(clean($_REQUEST["email"]));
198
-			$password = clean($_REQUEST["password"]);
193
+        public function editSave() {
194
+            $login = trim(clean($_REQUEST["login"]));
195
+            $uid = clean($_REQUEST["id"]);
196
+            $access_level = (int) clean($_REQUEST["access_level"]);
197
+            $email = trim(clean($_REQUEST["email"]));
198
+            $password = clean($_REQUEST["password"]);
199 199
 
200
-			if ($password) {
201
-				$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
202
-				$pwd_hash = encrypt_password($password, $salt, true);
203
-				$pass_query_part = "pwd_hash = ".$this->pdo->quote($pwd_hash).",
200
+            if ($password) {
201
+                $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
202
+                $pwd_hash = encrypt_password($password, $salt, true);
203
+                $pass_query_part = "pwd_hash = ".$this->pdo->quote($pwd_hash).",
204 204
 					salt = ".$this->pdo->quote($salt).",";
205
-			} else {
206
-				$pass_query_part = "";
207
-			}
205
+            } else {
206
+                $pass_query_part = "";
207
+            }
208 208
 
209
-			$sth = $this->pdo->prepare("UPDATE ttrss_users SET $pass_query_part login = ?,
209
+            $sth = $this->pdo->prepare("UPDATE ttrss_users SET $pass_query_part login = ?,
210 210
 				access_level = ?, email = ?, otp_enabled = false WHERE id = ?");
211
-			$sth->execute([$login, $access_level, $email, $uid]);
211
+            $sth->execute([$login, $access_level, $email, $uid]);
212 212
 
213
-		}
213
+        }
214 214
 
215
-		public function remove() {
216
-			$ids = explode(",", clean($_REQUEST["ids"]));
215
+        public function remove() {
216
+            $ids = explode(",", clean($_REQUEST["ids"]));
217 217
 
218
-			foreach ($ids as $id) {
219
-				if ($id != $_SESSION["uid"] && $id != 1) {
220
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?");
221
-					$sth->execute([$id]);
218
+            foreach ($ids as $id) {
219
+                if ($id != $_SESSION["uid"] && $id != 1) {
220
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?");
221
+                    $sth->execute([$id]);
222 222
 
223
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?");
224
-					$sth->execute([$id]);
223
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?");
224
+                    $sth->execute([$id]);
225 225
 
226
-					$sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?");
227
-					$sth->execute([$id]);
228
-				}
229
-			}
230
-		}
226
+                    $sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?");
227
+                    $sth->execute([$id]);
228
+                }
229
+            }
230
+        }
231 231
 
232
-		public function add() {
233
-			$login = trim(clean($_REQUEST["login"]));
234
-			$tmp_user_pwd = make_password();
235
-			$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
236
-			$pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
232
+        public function add() {
233
+            $login = trim(clean($_REQUEST["login"]));
234
+            $tmp_user_pwd = make_password();
235
+            $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
236
+            $pwd_hash = encrypt_password($tmp_user_pwd, $salt, true);
237 237
 
238
-			if (!$login) {
239
-			    return;
240
-			}
241
-			// no blank usernames
238
+            if (!$login) {
239
+                return;
240
+            }
241
+            // no blank usernames
242 242
 
243
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
243
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
244 244
 				login = ?");
245
-			$sth->execute([$login]);
245
+            $sth->execute([$login]);
246 246
 
247
-			if (!$sth->fetch()) {
247
+            if (!$sth->fetch()) {
248 248
 
249
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_users
249
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_users
250 250
 					(login,pwd_hash,access_level,last_login,created, salt)
251 251
 					VALUES (?, ?, 0, null, NOW(), ?)");
252
-				$sth->execute([$login, $pwd_hash, $salt]);
252
+                $sth->execute([$login, $pwd_hash, $salt]);
253 253
 
254
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
254
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
255 255
 					login = ? AND pwd_hash = ?");
256
-				$sth->execute([$login, $pwd_hash]);
256
+                $sth->execute([$login, $pwd_hash]);
257 257
 
258
-				if ($row = $sth->fetch()) {
258
+                if ($row = $sth->fetch()) {
259 259
 
260
-					$new_uid = $row['id'];
260
+                    $new_uid = $row['id'];
261 261
 
262
-					print T_sprintf("Added user %s with password %s",
263
-						$login, $tmp_user_pwd);
262
+                    print T_sprintf("Added user %s with password %s",
263
+                        $login, $tmp_user_pwd);
264 264
 
265
-					initialize_user($new_uid);
265
+                    initialize_user($new_uid);
266 266
 
267
-				} else {
267
+                } else {
268 268
 
269
-					print T_sprintf("Could not create user %s", $login);
269
+                    print T_sprintf("Could not create user %s", $login);
270 270
 
271
-				}
272
-			} else {
273
-				print T_sprintf("User %s already exists.", $login);
274
-			}
275
-		}
271
+                }
272
+            } else {
273
+                print T_sprintf("User %s already exists.", $login);
274
+            }
275
+        }
276 276
 
277
-		public static function resetUserPassword($uid, $format_output = false) {
277
+        public static function resetUserPassword($uid, $format_output = false) {
278 278
 
279
-			$pdo = Db::pdo();
279
+            $pdo = Db::pdo();
280 280
 
281
-			$sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
282
-			$sth->execute([$uid]);
281
+            $sth = $pdo->prepare("SELECT login FROM ttrss_users WHERE id = ?");
282
+            $sth->execute([$uid]);
283 283
 
284
-			if ($row = $sth->fetch()) {
284
+            if ($row = $sth->fetch()) {
285 285
 
286
-				$login = $row["login"];
286
+                $login = $row["login"];
287 287
 
288
-				$new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
289
-				$tmp_user_pwd = make_password();
288
+                $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
289
+                $tmp_user_pwd = make_password();
290 290
 
291
-				$pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
291
+                $pwd_hash = encrypt_password($tmp_user_pwd, $new_salt, true);
292 292
 
293
-				$sth = $pdo->prepare("UPDATE ttrss_users
293
+                $sth = $pdo->prepare("UPDATE ttrss_users
294 294
 					  SET pwd_hash = ?, salt = ?, otp_enabled = false
295 295
 					WHERE id = ?");
296
-				$sth->execute([$pwd_hash, $new_salt, $uid]);
296
+                $sth->execute([$pwd_hash, $new_salt, $uid]);
297 297
 
298
-				$message = T_sprintf("Changed password of user %s to %s", "<strong>$login</strong>", "<strong>$tmp_user_pwd</strong>");
298
+                $message = T_sprintf("Changed password of user %s to %s", "<strong>$login</strong>", "<strong>$tmp_user_pwd</strong>");
299 299
 
300
-				if ($format_output) {
301
-									print_notice($message);
302
-				} else {
303
-									print $message;
304
-				}
300
+                if ($format_output) {
301
+                                    print_notice($message);
302
+                } else {
303
+                                    print $message;
304
+                }
305 305
 
306
-			}
307
-		}
306
+            }
307
+        }
308 308
 
309
-		public function resetPass() {
310
-			$uid = clean($_REQUEST["id"]);
311
-			Pref_Users::resetUserPassword($uid);
312
-		}
309
+        public function resetPass() {
310
+            $uid = clean($_REQUEST["id"]);
311
+            Pref_Users::resetUserPassword($uid);
312
+        }
313 313
 
314
-		public function index() {
314
+        public function index() {
315 315
 
316
-			global $access_level_names;
316
+            global $access_level_names;
317 317
 
318
-			print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
319
-			print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
320
-			print "<div dojoType='fox.Toolbar'>";
318
+            print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
319
+            print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
320
+            print "<div dojoType='fox.Toolbar'>";
321 321
 
322
-			$user_search = trim(clean($_REQUEST["search"]));
322
+            $user_search = trim(clean($_REQUEST["search"]));
323 323
 
324
-			if (array_key_exists("search", $_REQUEST)) {
325
-				$_SESSION["prefs_user_search"] = $user_search;
326
-			} else {
327
-				$user_search = $_SESSION["prefs_user_search"];
328
-			}
324
+            if (array_key_exists("search", $_REQUEST)) {
325
+                $_SESSION["prefs_user_search"] = $user_search;
326
+            } else {
327
+                $user_search = $_SESSION["prefs_user_search"];
328
+            }
329 329
 
330
-			print "<div style='float : right; padding-right : 4px;'>
330
+            print "<div style='float : right; padding-right : 4px;'>
331 331
 				<input dojoType='dijit.form.TextBox' id='user_search' size='20' type='search'
332 332
 					value=\"$user_search\">
333 333
 				<button dojoType='dijit.form.Button' onclick='Users.reload()'>".
334
-					__('Search')."</button>
334
+                    __('Search')."</button>
335 335
 				</div>";
336 336
 
337
-			$sort = clean($_REQUEST["sort"]);
337
+            $sort = clean($_REQUEST["sort"]);
338 338
 
339
-			if (!$sort || $sort == "undefined") {
340
-				$sort = "login";
341
-			}
339
+            if (!$sort || $sort == "undefined") {
340
+                $sort = "login";
341
+            }
342 342
 
343
-			print "<div dojoType='fox.form.DropDownButton'>".
344
-					"<span>".__('Select')."</span>";
345
-			print "<div dojoType='dijit.Menu' style='display: none'>";
346
-			print "<div onclick=\"Tables.select('prefUserList', true)\"
343
+            print "<div dojoType='fox.form.DropDownButton'>".
344
+                    "<span>".__('Select')."</span>";
345
+            print "<div dojoType='dijit.Menu' style='display: none'>";
346
+            print "<div onclick=\"Tables.select('prefUserList', true)\"
347 347
 				dojoType='dijit.MenuItem'>".__('All')."</div>";
348
-			print "<div onclick=\"Tables.select('prefUserList', false)\"
348
+            print "<div onclick=\"Tables.select('prefUserList', false)\"
349 349
 				dojoType='dijit.MenuItem'>".__('None')."</div>";
350
-			print "</div></div>";
350
+            print "</div></div>";
351 351
 
352
-			print "<button dojoType='dijit.form.Button' onclick='Users.add()'>".__('Create user')."</button>";
352
+            print "<button dojoType='dijit.form.Button' onclick='Users.add()'>".__('Create user')."</button>";
353 353
 
354
-			print "
354
+            print "
355 355
 				<button dojoType='dijit.form.Button' onclick='Users.editSelected()'>".
356
-				__('Edit')."</button dojoType=\"dijit.form.Button\">
356
+                __('Edit')."</button dojoType=\"dijit.form.Button\">
357 357
 				<button dojoType='dijit.form.Button' onclick='Users.removeSelected()'>".
358
-				__('Remove')."</button dojoType=\"dijit.form.Button\">
358
+                __('Remove')."</button dojoType=\"dijit.form.Button\">
359 359
 				<button dojoType='dijit.form.Button' onclick='Users.resetSelected()'>".
360
-				__('Reset password')."</button dojoType=\"dijit.form.Button\">";
360
+                __('Reset password')."</button dojoType=\"dijit.form.Button\">";
361 361
 
362
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
363
-				"hook_prefs_tab_section", "prefUsersToolbar");
362
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
363
+                "hook_prefs_tab_section", "prefUsersToolbar");
364 364
 
365
-			print "</div>"; #toolbar
366
-			print "</div>"; #pane
367
-			print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
365
+            print "</div>"; #toolbar
366
+            print "</div>"; #pane
367
+            print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
368 368
 
369
-			$sort = $this->validate_field($sort,
370
-				["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
369
+            $sort = $this->validate_field($sort,
370
+                ["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
371 371
 
372
-			if ($sort != "login") {
373
-			    $sort = "$sort DESC";
374
-			}
372
+            if ($sort != "login") {
373
+                $sort = "$sort DESC";
374
+            }
375 375
 
376
-			$sth = $this->pdo->prepare("SELECT
376
+            $sth = $this->pdo->prepare("SELECT
377 377
 					tu.id,
378 378
 					login,access_level,email,
379 379
 					".SUBSTRING_FOR_DATE."(last_login,1,16) as last_login,
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 				WHERE
385 385
 					(:search = '' OR login LIKE :search) AND tu.id > 0
386 386
 				ORDER BY $sort");
387
-			$sth->execute([":search" => $user_search ? "%$user_search%" : ""]);
387
+            $sth->execute([":search" => $user_search ? "%$user_search%" : ""]);
388 388
 
389
-			print "<p><table width='100%' cellspacing='0' class='prefUserList' id='prefUserList'>";
389
+            print "<p><table width='100%' cellspacing='0' class='prefUserList' id='prefUserList'>";
390 390
 
391
-			print "<tr class='title'>
391
+            print "<tr class='title'>
392 392
 						<td align='center' width='5%'>&nbsp;</td>
393 393
 						<td width='20%'><a href='#' onclick=\"Users.reload('login')\">".__('Login')."</a></td>
394 394
 						<td width='20%'><a href='#' onclick=\"Users.reload('access_level')\">".__('Access Level')."</a></td>
@@ -396,58 +396,58 @@  discard block
 block discarded – undo
396 396
 						<td width='20%'><a href='#' onclick=\"Users.reload('created')\">".__('Registered')."</a></td>
397 397
 						<td width='20%'><a href='#' onclick=\"Users.reload('last_login')\">".__('Last login')."</a></td></tr>";
398 398
 
399
-			$lnum = 0;
399
+            $lnum = 0;
400 400
 
401
-			while ($line = $sth->fetch()) {
401
+            while ($line = $sth->fetch()) {
402 402
 
403
-				$uid = $line["id"];
403
+                $uid = $line["id"];
404 404
 
405
-				print "<tr data-row-id='$uid' onclick='Users.edit($uid)'>";
405
+                print "<tr data-row-id='$uid' onclick='Users.edit($uid)'>";
406 406
 
407
-				$line["login"] = htmlspecialchars($line["login"]);
408
-				$line["created"] = make_local_datetime($line["created"], false);
409
-				$line["last_login"] = make_local_datetime($line["last_login"], false);
407
+                $line["login"] = htmlspecialchars($line["login"]);
408
+                $line["created"] = make_local_datetime($line["created"], false);
409
+                $line["last_login"] = make_local_datetime($line["last_login"], false);
410 410
 
411
-				print "<td align='center'><input onclick='Tables.onRowChecked(this); event.stopPropagation();'
411
+                print "<td align='center'><input onclick='Tables.onRowChecked(this); event.stopPropagation();'
412 412
 					dojoType='dijit.form.CheckBox' type='checkbox'></td>";
413 413
 
414
-				print "<td title='".__('Click to edit')."'><i class='material-icons'>person</i> ".$line["login"]."</td>";
414
+                print "<td title='".__('Click to edit')."'><i class='material-icons'>person</i> ".$line["login"]."</td>";
415 415
 
416
-				print "<td>".$access_level_names[$line["access_level"]]."</td>";
417
-				print "<td>".$line["num_feeds"]."</td>";
418
-				print "<td>".$line["created"]."</td>";
419
-				print "<td>".$line["last_login"]."</td>";
416
+                print "<td>".$access_level_names[$line["access_level"]]."</td>";
417
+                print "<td>".$line["num_feeds"]."</td>";
418
+                print "<td>".$line["created"]."</td>";
419
+                print "<td>".$line["last_login"]."</td>";
420 420
 
421
-				print "</tr>";
421
+                print "</tr>";
422 422
 
423
-				++$lnum;
424
-			}
423
+                ++$lnum;
424
+            }
425 425
 
426
-			print "</table>";
426
+            print "</table>";
427 427
 
428
-			if ($lnum == 0) {
429
-				if (!$user_search) {
430
-					print_warning(__('No users defined.'));
431
-				} else {
432
-					print_warning(__('No matching users found.'));
433
-				}
434
-			}
428
+            if ($lnum == 0) {
429
+                if (!$user_search) {
430
+                    print_warning(__('No users defined.'));
431
+                } else {
432
+                    print_warning(__('No matching users found.'));
433
+                }
434
+            }
435 435
 
436
-			print "</div>"; #pane
436
+            print "</div>"; #pane
437 437
 
438
-			PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
439
-				"hook_prefs_tab", "prefUsers");
438
+            PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
439
+                "hook_prefs_tab", "prefUsers");
440 440
 
441
-			print "</div>"; #container
441
+            print "</div>"; #container
442 442
 
443
-		}
443
+        }
444 444
 
445
-		public function validate_field($string, $allowed, $default = "") {
446
-			if (in_array($string, $allowed)) {
447
-							return $string;
448
-			} else {
449
-							return $default;
450
-			}
451
-		}
445
+        public function validate_field($string, $allowed, $default = "") {
446
+            if (in_array($string, $allowed)) {
447
+                            return $string;
448
+            } else {
449
+                            return $default;
450
+            }
451
+        }
452 452
 
453 453
 }
Please login to merge, or discard this patch.
classes/pref/system.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -2,50 +2,50 @@  discard block
 block discarded – undo
2 2
 
3 3
 class Pref_System extends Handler_Protected {
4 4
 
5
-	public function before($method) {
6
-		if (parent::before($method)) {
7
-			if ($_SESSION["access_level"] < 10) {
8
-				print __("Your access level is insufficient to open this tab.");
9
-				return false;
10
-			}
11
-			return true;
12
-		}
13
-		return false;
14
-	}
15
-
16
-	public function csrf_ignore($method) {
17
-		$csrf_ignored = array("index");
18
-
19
-		return array_search($method, $csrf_ignored) !== false;
20
-	}
21
-
22
-	public function clearLog() {
23
-		$this->pdo->query("DELETE FROM ttrss_error_log");
24
-	}
25
-
26
-	public function index() {
27
-
28
-		print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
29
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
5
+    public function before($method) {
6
+        if (parent::before($method)) {
7
+            if ($_SESSION["access_level"] < 10) {
8
+                print __("Your access level is insufficient to open this tab.");
9
+                return false;
10
+            }
11
+            return true;
12
+        }
13
+        return false;
14
+    }
15
+
16
+    public function csrf_ignore($method) {
17
+        $csrf_ignored = array("index");
18
+
19
+        return array_search($method, $csrf_ignored) !== false;
20
+    }
21
+
22
+    public function clearLog() {
23
+        $this->pdo->query("DELETE FROM ttrss_error_log");
24
+    }
25
+
26
+    public function index() {
27
+
28
+        print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
29
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
30 30
 			title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">";
31 31
 
32
-		if (LOG_DESTINATION == "sql") {
32
+        if (LOG_DESTINATION == "sql") {
33 33
 
34
-			$res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
34
+            $res = $this->pdo->query("SELECT errno, errstr, filename, lineno,
35 35
 				created_at, login, context FROM ttrss_error_log
36 36
 				LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id)
37 37
 				ORDER BY ttrss_error_log.id DESC
38 38
 				LIMIT 100");
39 39
 
40
-			print "<button dojoType=\"dijit.form.Button\"
40
+            print "<button dojoType=\"dijit.form.Button\"
41 41
 				onclick=\"Helpers.updateEventLog()\">".__('Refresh')."</button> ";
42 42
 
43
-			print "&nbsp;<button dojoType=\"dijit.form.Button\"
43
+            print "&nbsp;<button dojoType=\"dijit.form.Button\"
44 44
 				class=\"alt-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')."</button> ";
45 45
 
46
-			print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
46
+            print "<p><table width=\"100%\" cellspacing=\"10\" class=\"prefErrorLog\">";
47 47
 
48
-			print "<tr class=\"title\">
48
+            print "<tr class=\"title\">
49 49
 				<td width='5%'>".__("Error")."</td>
50 50
 				<td>".__("Filename")."</td>
51 51
 				<td>".__("Message")."</td>
@@ -53,52 +53,52 @@  discard block
 block discarded – undo
53 53
 				<td width='5%'>".__("Date")."</td>
54 54
 				</tr>";
55 55
 
56
-			while ($line = $res->fetch()) {
57
-				print "<tr>";
56
+            while ($line = $res->fetch()) {
57
+                print "<tr>";
58 58
 
59
-				foreach ($line as $k => $v) {
60
-					$line[$k] = htmlspecialchars($v);
61
-				}
59
+                foreach ($line as $k => $v) {
60
+                    $line[$k] = htmlspecialchars($v);
61
+                }
62 62
 
63
-				print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>";
64
-				print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>";
65
-				print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>";
66
-				print "<td class='login'>".$line["login"]."</td>";
63
+                print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>";
64
+                print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>";
65
+                print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>";
66
+                print "<td class='login'>".$line["login"]."</td>";
67 67
 
68
-				print "<td class='timestamp'>".
69
-					make_local_datetime(
70
-					$line["created_at"], false)."</td>";
68
+                print "<td class='timestamp'>".
69
+                    make_local_datetime(
70
+                    $line["created_at"], false)."</td>";
71 71
 
72
-				print "</tr>";
73
-			}
72
+                print "</tr>";
73
+            }
74 74
 
75
-			print "</table>";
76
-		} else {
75
+            print "</table>";
76
+        } else {
77 77
 
78
-			print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
78
+            print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
79 79
 
80
-		}
80
+        }
81 81
 
82
-		print "</div>";
82
+        print "</div>";
83 83
 
84
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
84
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
85 85
 			title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">";
86 86
 
87
-		ob_start();
88
-		phpinfo();
89
-		$info = ob_get_contents();
90
-		ob_end_clean();
87
+        ob_start();
88
+        phpinfo();
89
+        $info = ob_get_contents();
90
+        ob_end_clean();
91 91
 
92
-		print "<div class='phpinfo'>";
93
-		print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
94
-		print "</div>";
92
+        print "<div class='phpinfo'>";
93
+        print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info);
94
+        print "</div>";
95 95
 
96
-		print "</div>";
96
+        print "</div>";
97 97
 
98
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
99
-			"hook_prefs_tab", "prefSystem");
98
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
99
+            "hook_prefs_tab", "prefSystem");
100 100
 
101
-		print "</div>"; #container
102
-	}
101
+        print "</div>"; #container
102
+    }
103 103
 
104 104
 }
Please login to merge, or discard this patch.
classes/pref/filters.php 2 patches
Indentation   +758 added lines, -758 removed lines patch added patch discarded remove patch
@@ -1,83 +1,83 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Filters extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule",
6
-			"newaction", "savefilterorder");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule",
6
+            "newaction", "savefilterorder");
7 7
 
8
-		return array_search($method, $csrf_ignored) !== false;
9
-	}
8
+        return array_search($method, $csrf_ignored) !== false;
9
+    }
10 10
 
11
-	public function filtersortreset() {
12
-		$sth = $this->pdo->prepare("UPDATE ttrss_filters2
11
+    public function filtersortreset() {
12
+        $sth = $this->pdo->prepare("UPDATE ttrss_filters2
13 13
 				SET order_id = 0 WHERE owner_uid = ?");
14
-		$sth->execute([$_SESSION['uid']]);
15
-		return;
16
-	}
14
+        $sth->execute([$_SESSION['uid']]);
15
+        return;
16
+    }
17 17
 
18
-	public function savefilterorder() {
19
-		$data = json_decode($_POST['payload'], true);
18
+    public function savefilterorder() {
19
+        $data = json_decode($_POST['payload'], true);
20 20
 
21
-		#file_put_contents("/tmp/saveorder.json", clean($_POST['payload']));
22
-		#$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
21
+        #file_put_contents("/tmp/saveorder.json", clean($_POST['payload']));
22
+        #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true);
23 23
 
24
-		if (!is_array($data['items'])) {
25
-					$data['items'] = json_decode($data['items'], true);
26
-		}
24
+        if (!is_array($data['items'])) {
25
+                    $data['items'] = json_decode($data['items'], true);
26
+        }
27 27
 
28
-		$index = 0;
28
+        $index = 0;
29 29
 
30
-		if (is_array($data) && is_array($data['items'])) {
30
+        if (is_array($data) && is_array($data['items'])) {
31 31
 
32
-			$sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET
32
+            $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET
33 33
 						order_id = ? WHERE id = ? AND
34 34
 						owner_uid = ?");
35 35
 
36
-			foreach ($data['items'][0]['items'] as $item) {
37
-				$filter_id = (int) str_replace("FILTER:", "", $item['_reference']);
36
+            foreach ($data['items'][0]['items'] as $item) {
37
+                $filter_id = (int) str_replace("FILTER:", "", $item['_reference']);
38 38
 
39
-				if ($filter_id > 0) {
40
-					$sth->execute([$index, $filter_id, $_SESSION['uid']]);
41
-					++$index;
42
-				}
43
-			}
44
-		}
39
+                if ($filter_id > 0) {
40
+                    $sth->execute([$index, $filter_id, $_SESSION['uid']]);
41
+                    ++$index;
42
+                }
43
+            }
44
+        }
45 45
 
46
-		return;
47
-	}
46
+        return;
47
+    }
48 48
 
49
-	public function testFilterDo() {
50
-		$offset = (int) clean($_REQUEST["offset"]);
51
-		$limit = (int) clean($_REQUEST["limit"]);
49
+    public function testFilterDo() {
50
+        $offset = (int) clean($_REQUEST["offset"]);
51
+        $limit = (int) clean($_REQUEST["limit"]);
52 52
 
53
-		$filter = array();
53
+        $filter = array();
54 54
 
55
-		$filter["enabled"] = true;
56
-		$filter["match_any_rule"] = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
57
-		$filter["inverse"] = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
55
+        $filter["enabled"] = true;
56
+        $filter["match_any_rule"] = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
57
+        $filter["inverse"] = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
58 58
 
59
-		$filter["rules"] = array();
60
-		$filter["actions"] = array("dummy-action");
59
+        $filter["rules"] = array();
60
+        $filter["actions"] = array("dummy-action");
61 61
 
62
-		$res = $this->pdo->query("SELECT id,name FROM ttrss_filter_types");
62
+        $res = $this->pdo->query("SELECT id,name FROM ttrss_filter_types");
63 63
 
64
-		$filter_types = array();
65
-		while ($line = $res->fetch()) {
66
-			$filter_types[$line["id"]] = $line["name"];
67
-		}
64
+        $filter_types = array();
65
+        while ($line = $res->fetch()) {
66
+            $filter_types[$line["id"]] = $line["name"];
67
+        }
68 68
 
69
-		$scope_qparts = array();
69
+        $scope_qparts = array();
70 70
 
71
-		$rctr = 0;
72
-		foreach (clean($_REQUEST["rule"]) as $r) {
73
-			$rule = json_decode($r, true);
71
+        $rctr = 0;
72
+        foreach (clean($_REQUEST["rule"]) as $r) {
73
+            $rule = json_decode($r, true);
74 74
 
75
-			if ($rule && $rctr < 5) {
76
-				$rule["type"] = $filter_types[$rule["filter_type"]];
77
-				unset($rule["filter_type"]);
75
+            if ($rule && $rctr < 5) {
76
+                $rule["type"] = $filter_types[$rule["filter_type"]];
77
+                unset($rule["filter_type"]);
78 78
 
79
-				$scope_inner_qparts = [];
80
-				foreach ($rule["feed_id"] as $feed_id) {
79
+                $scope_inner_qparts = [];
80
+                foreach ($rule["feed_id"] as $feed_id) {
81 81
 
82 82
                     if (strpos($feed_id, "CAT:") === 0) {
83 83
                         $cat_id = (int) substr($feed_id, 4);
@@ -88,29 +88,29 @@  discard block
 block discarded – undo
88 88
                 }
89 89
 
90 90
                 if (count($scope_inner_qparts) > 0) {
91
-				    array_push($scope_qparts, "(".implode(" OR ", $scope_inner_qparts).")");
91
+                    array_push($scope_qparts, "(".implode(" OR ", $scope_inner_qparts).")");
92 92
                 }
93 93
 
94
-				array_push($filter["rules"], $rule);
94
+                array_push($filter["rules"], $rule);
95 95
 
96
-				++$rctr;
97
-			} else {
98
-				break;
99
-			}
100
-		}
96
+                ++$rctr;
97
+            } else {
98
+                break;
99
+            }
100
+        }
101 101
 
102
-		if (count($scope_qparts) == 0) $scope_qparts = ["true"];
102
+        if (count($scope_qparts) == 0) $scope_qparts = ["true"];
103 103
 
104
-		$glue = $filter['match_any_rule'] ? " OR " : " AND ";
105
-		$scope_qpart = join($glue, $scope_qparts);
104
+        $glue = $filter['match_any_rule'] ? " OR " : " AND ";
105
+        $scope_qpart = join($glue, $scope_qparts);
106 106
 
107
-		if (!$scope_qpart) $scope_qpart = "true";
107
+        if (!$scope_qpart) $scope_qpart = "true";
108 108
 
109
-		$rv = array();
109
+        $rv = array();
110 110
 
111
-		//while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {
111
+        //while ($found < $limit && $offset < $limit * 1000 && time() - $started < ini_get("max_execution_time") * 0.7) {
112 112
 
113
-		$sth = $this->pdo->prepare("SELECT ttrss_entries.id,
113
+        $sth = $this->pdo->prepare("SELECT ttrss_entries.id,
114 114
 				ttrss_entries.title,
115 115
 				ttrss_feeds.id AS feed_id,
116 116
 				ttrss_feeds.title AS feed_title,
@@ -130,58 +130,58 @@  discard block
 block discarded – undo
130 130
 				ttrss_user_entries.owner_uid = ?
131 131
 			ORDER BY date_entered DESC LIMIT $limit OFFSET $offset");
132 132
 
133
-		$sth->execute([$_SESSION['uid']]);
133
+        $sth->execute([$_SESSION['uid']]);
134 134
 
135
-		while ($line = $sth->fetch()) {
135
+        while ($line = $sth->fetch()) {
136 136
 
137
-			$rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'],
138
-				$line['author'], explode(",", $line['tag_cache']));
137
+            $rc = RSSUtils::get_article_filters(array($filter), $line['title'], $line['content'], $line['link'],
138
+                $line['author'], explode(",", $line['tag_cache']));
139 139
 
140
-			if (count($rc) > 0) {
140
+            if (count($rc) > 0) {
141 141
 
142
-				$line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
142
+                $line["content_preview"] = truncate_string(strip_tags($line["content"]), 200, '&hellip;');
143 143
 
144
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
145
-					$line = $p->hook_query_headlines($line, 100);
146
-				}
144
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
145
+                    $line = $p->hook_query_headlines($line, 100);
146
+                }
147 147
 
148
-				$content_preview = $line["content_preview"];
148
+                $content_preview = $line["content_preview"];
149 149
 
150
-				$tmp = "<li><span class='title'>".$line["title"]."</span><br/>".
151
-					"<span class='feed'>".$line['feed_title']."</span>, <span class='date'>".mb_substr($line["date_entered"], 0, 16)."</span>".
152
-					"<div class='preview text-muted'>".$content_preview."</div>".
153
-					"</li>";
150
+                $tmp = "<li><span class='title'>".$line["title"]."</span><br/>".
151
+                    "<span class='feed'>".$line['feed_title']."</span>, <span class='date'>".mb_substr($line["date_entered"], 0, 16)."</span>".
152
+                    "<div class='preview text-muted'>".$content_preview."</div>".
153
+                    "</li>";
154 154
 
155
-				array_push($rv, $tmp);
155
+                array_push($rv, $tmp);
156 156
 
157
-			}
158
-		}
157
+            }
158
+        }
159 159
 
160
-		print json_encode($rv);
161
-	}
160
+        print json_encode($rv);
161
+    }
162 162
 
163
-	public function testFilter() {
163
+    public function testFilter() {
164 164
 
165
-		if (isset($_REQUEST["offset"])) {
166
-		    return $this->testFilterDo();
167
-		}
165
+        if (isset($_REQUEST["offset"])) {
166
+            return $this->testFilterDo();
167
+        }
168 168
 
169
-		//print __("Articles matching this filter:");
169
+        //print __("Articles matching this filter:");
170 170
 
171
-		print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'>&nbsp;<span id='prefFilterProgressMsg'>Looking for articles...</span></div>";
171
+        print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'>&nbsp;<span id='prefFilterProgressMsg'>Looking for articles...</span></div>";
172 172
 
173
-		print "<ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'>";
174
-		print "</ul>";
173
+        print "<ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'>";
174
+        print "</ul>";
175 175
 
176
-		print "<footer class='text-center'>";
177
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('filterTestDlg').hide()\">".
178
-			__('Close this window')."</button>";
179
-		print "</footer>";
176
+        print "<footer class='text-center'>";
177
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('filterTestDlg').hide()\">".
178
+            __('Close this window')."</button>";
179
+        print "</footer>";
180 180
 
181
-	}
181
+    }
182 182
 
183
-	private function getfilterrules_list($filter_id) {
184
-		$sth = $this->pdo->prepare("SELECT reg_exp,
183
+    private function getfilterrules_list($filter_id) {
184
+        $sth = $this->pdo->prepare("SELECT reg_exp,
185 185
 			inverse,
186 186
 			match_on,
187 187
 			feed_id,
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
 			WHERE
194 194
 				filter_id = ? AND filter_type = ttrss_filter_types.id
195 195
 			ORDER BY reg_exp");
196
-		$sth->execute([$filter_id]);
196
+        $sth->execute([$filter_id]);
197 197
 
198
-		$rv = "";
198
+        $rv = "";
199 199
 
200
-		while ($line = $sth->fetch()) {
200
+        while ($line = $sth->fetch()) {
201 201
 
202
-		    if ($line["match_on"]) {
203
-		        $feeds = json_decode($line["match_on"], true);
204
-		        $feeds_fmt = [];
202
+            if ($line["match_on"]) {
203
+                $feeds = json_decode($line["match_on"], true);
204
+                $feeds_fmt = [];
205 205
 
206 206
                 foreach ($feeds as $feed_id) {
207 207
 
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
 
228 228
 #			$where = $line["cat_id"] . "/" . $line["feed_id"];
229 229
 
230
-			$inverse = $line["inverse"] ? "inverse" : "";
230
+            $inverse = $line["inverse"] ? "inverse" : "";
231 231
 
232
-			$rv .= "<li class='$inverse'>".T_sprintf("%s on %s in %s %s",
233
-				htmlspecialchars($line["reg_exp"]),
234
-				$line["field"],
235
-				$where,
236
-				$line["inverse"] ? __("(inverse)") : "")."</li>";
237
-		}
232
+            $rv .= "<li class='$inverse'>".T_sprintf("%s on %s in %s %s",
233
+                htmlspecialchars($line["reg_exp"]),
234
+                $line["field"],
235
+                $where,
236
+                $line["inverse"] ? __("(inverse)") : "")."</li>";
237
+        }
238 238
 
239
-		return $rv;
240
-	}
239
+        return $rv;
240
+    }
241 241
 
242
-	public function getfiltertree() {
243
-		$root = array();
244
-		$root['id'] = 'root';
245
-		$root['name'] = __('Filters');
246
-		$root['items'] = array();
242
+    public function getfiltertree() {
243
+        $root = array();
244
+        $root['id'] = 'root';
245
+        $root['name'] = __('Filters');
246
+        $root['items'] = array();
247 247
 
248
-		$filter_search = $_SESSION["prefs_filter_search"];
248
+        $filter_search = $_SESSION["prefs_filter_search"];
249 249
 
250
-		$sth = $this->pdo->prepare("SELECT *,
250
+        $sth = $this->pdo->prepare("SELECT *,
251 251
 			(SELECT action_param FROM ttrss_filters2_actions
252 252
 				WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS action_param,
253 253
 			(SELECT action_id FROM ttrss_filters2_actions
@@ -259,281 +259,281 @@  discard block
 block discarded – undo
259 259
 				WHERE filter_id = ttrss_filters2.id ORDER BY id LIMIT 1) AS reg_exp
260 260
 			FROM ttrss_filters2 WHERE
261 261
 			owner_uid = ? ORDER BY order_id, title");
262
-		$sth->execute([$_SESSION['uid']]);
262
+        $sth->execute([$_SESSION['uid']]);
263 263
 
264
-		$folder = array();
265
-		$folder['items'] = array();
264
+        $folder = array();
265
+        $folder['items'] = array();
266 266
 
267
-		while ($line = $sth->fetch()) {
267
+        while ($line = $sth->fetch()) {
268 268
 
269
-			$name = $this->getFilterName($line["id"]);
269
+            $name = $this->getFilterName($line["id"]);
270 270
 
271
-			$match_ok = false;
272
-			if ($filter_search) {
273
-				if (mb_strpos($line['title'], $filter_search) !== false) {
274
-					$match_ok = true;
275
-				}
271
+            $match_ok = false;
272
+            if ($filter_search) {
273
+                if (mb_strpos($line['title'], $filter_search) !== false) {
274
+                    $match_ok = true;
275
+                }
276 276
 
277
-				$rules_sth = $this->pdo->prepare("SELECT reg_exp
277
+                $rules_sth = $this->pdo->prepare("SELECT reg_exp
278 278
 					FROM ttrss_filters2_rules WHERE filter_id = ?");
279
-				$rules_sth->execute([$line['id']]);
280
-
281
-				while ($rule_line = $rules_sth->fetch()) {
282
-					if (mb_strpos($rule_line['reg_exp'], $filter_search) !== false) {
283
-						$match_ok = true;
284
-						break;
285
-					}
286
-				}
287
-			}
279
+                $rules_sth->execute([$line['id']]);
288 280
 
289
-			if ($line['action_id'] == 7) {
290
-				$label_sth = $this->pdo->prepare("SELECT fg_color, bg_color
281
+                while ($rule_line = $rules_sth->fetch()) {
282
+                    if (mb_strpos($rule_line['reg_exp'], $filter_search) !== false) {
283
+                        $match_ok = true;
284
+                        break;
285
+                    }
286
+                }
287
+            }
288
+
289
+            if ($line['action_id'] == 7) {
290
+                $label_sth = $this->pdo->prepare("SELECT fg_color, bg_color
291 291
 					FROM ttrss_labels2 WHERE caption = ? AND
292 292
 						owner_uid = ?");
293
-				$label_sth->execute([$line['action_param'], $_SESSION['uid']]);
293
+                $label_sth->execute([$line['action_param'], $_SESSION['uid']]);
294 294
 
295
-				if ($label_row = $label_sth->fetch()) {
296
-					//$fg_color = $label_row["fg_color"];
297
-					$bg_color = $label_row["bg_color"];
295
+                if ($label_row = $label_sth->fetch()) {
296
+                    //$fg_color = $label_row["fg_color"];
297
+                    $bg_color = $label_row["bg_color"];
298 298
 
299
-					$name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>".$name[1];
300
-				}
301
-			}
299
+                    $name[1] = "<i class=\"material-icons\" style='color : $bg_color; margin-right : 4px'>label</i>".$name[1];
300
+                }
301
+            }
302 302
 
303
-			$filter = array();
304
-			$filter['id'] = 'FILTER:'.$line['id'];
305
-			$filter['bare_id'] = $line['id'];
306
-			$filter['name'] = $name[0];
307
-			$filter['param'] = $name[1];
308
-			$filter['checkbox'] = false;
309
-			$filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null;
310
-			$filter['enabled'] = $line["enabled"];
311
-			$filter['rules'] = $this->getfilterrules_list($line['id']);
312
-
313
-			if (!$filter_search || $match_ok) {
314
-				array_push($folder['items'], $filter);
315
-			}
316
-		}
303
+            $filter = array();
304
+            $filter['id'] = 'FILTER:'.$line['id'];
305
+            $filter['bare_id'] = $line['id'];
306
+            $filter['name'] = $name[0];
307
+            $filter['param'] = $name[1];
308
+            $filter['checkbox'] = false;
309
+            $filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null;
310
+            $filter['enabled'] = $line["enabled"];
311
+            $filter['rules'] = $this->getfilterrules_list($line['id']);
312
+
313
+            if (!$filter_search || $match_ok) {
314
+                array_push($folder['items'], $filter);
315
+            }
316
+        }
317 317
 
318
-		$root['items'] = $folder['items'];
318
+        $root['items'] = $folder['items'];
319 319
 
320
-		$fl = array();
321
-		$fl['identifier'] = 'id';
322
-		$fl['label'] = 'name';
323
-		$fl['items'] = array($root);
320
+        $fl = array();
321
+        $fl['identifier'] = 'id';
322
+        $fl['label'] = 'name';
323
+        $fl['items'] = array($root);
324 324
 
325
-		print json_encode($fl);
326
-		return;
327
-	}
325
+        print json_encode($fl);
326
+        return;
327
+    }
328 328
 
329
-	public function edit() {
329
+    public function edit() {
330 330
 
331
-		$filter_id = clean($_REQUEST["id"]);
331
+        $filter_id = clean($_REQUEST["id"]);
332 332
 
333
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
333
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
334 334
 			WHERE id = ? AND owner_uid = ?");
335
-		$sth->execute([$filter_id, $_SESSION['uid']]);
335
+        $sth->execute([$filter_id, $_SESSION['uid']]);
336 336
 
337
-		if ($row = $sth->fetch()) {
337
+        if ($row = $sth->fetch()) {
338 338
 
339
-			$enabled = $row["enabled"];
340
-			$match_any_rule = $row["match_any_rule"];
341
-			$inverse = $row["inverse"];
342
-			$title = htmlspecialchars($row["title"]);
339
+            $enabled = $row["enabled"];
340
+            $match_any_rule = $row["match_any_rule"];
341
+            $inverse = $row["inverse"];
342
+            $title = htmlspecialchars($row["title"]);
343 343
 
344
-			print "<form id='filter_edit_form' onsubmit='return false'>";
344
+            print "<form id='filter_edit_form' onsubmit='return false'>";
345 345
 
346
-			print_hidden("op", "pref-filters");
347
-			print_hidden("id", "$filter_id");
348
-			print_hidden("method", "editSave");
349
-			print_hidden("csrf_token", $_SESSION['csrf_token']);
346
+            print_hidden("op", "pref-filters");
347
+            print_hidden("id", "$filter_id");
348
+            print_hidden("method", "editSave");
349
+            print_hidden("csrf_token", $_SESSION['csrf_token']);
350 350
 
351
-			print "<header>".__("Caption")."</header>";
352
-			print "<section>";
353
-			print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">";
354
-			print "</section>";
351
+            print "<header>".__("Caption")."</header>";
352
+            print "<section>";
353
+            print "<input required=\"true\" dojoType=\"dijit.form.ValidationTextBox\" style=\"width : 20em;\" name=\"title\" value=\"$title\">";
354
+            print "</section>";
355 355
 
356
-			print "<header class='horizontal'>".__("Match")."</header>";
357
-			print "<section>";
356
+            print "<header class='horizontal'>".__("Match")."</header>";
357
+            print "<section>";
358 358
 
359
-			print "<div dojoType=\"fox.Toolbar\">";
359
+            print "<div dojoType=\"fox.Toolbar\">";
360 360
 
361
-			print "<div dojoType=\"fox.form.DropDownButton\">".
362
-				"<span>".__('Select')."</span>";
363
-			print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
364
-			print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
361
+            print "<div dojoType=\"fox.form.DropDownButton\">".
362
+                "<span>".__('Select')."</span>";
363
+            print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
364
+            print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
365 365
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
366
-			print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
366
+            print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
367 367
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
368
-			print "</div></div>";
368
+            print "</div></div>";
369 369
 
370
-			print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
371
-				__('Add')."</button> ";
370
+            print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
371
+                __('Add')."</button> ";
372 372
 
373
-			print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
374
-				__('Delete')."</button> ";
373
+            print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
374
+                __('Delete')."</button> ";
375 375
 
376
-			print "</div>";
376
+            print "</div>";
377 377
 
378
-			print "<ul id='filterDlg_Matches'>";
378
+            print "<ul id='filterDlg_Matches'>";
379 379
 
380
-			$rules_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
380
+            $rules_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
381 381
 				  WHERE filter_id = ? ORDER BY reg_exp, id");
382
-			$rules_sth->execute([$filter_id]);
383
-
384
-			while ($line = $rules_sth->fetch()) {
385
-				if ($line["match_on"]) {
386
-					$line["feed_id"] = json_decode($line["match_on"], true);
387
-				} else {
388
-					if ($line["cat_filter"]) {
389
-						$feed_id = "CAT:".(int) $line["cat_id"];
390
-					} else {
391
-						$feed_id = (int) $line["feed_id"];
392
-					}
393
-
394
-					$line["feed_id"] = ["".$feed_id]; // set item type to string for in_array()
395
-				}
396
-
397
-				unset($line["cat_filter"]);
398
-				unset($line["cat_id"]);
399
-				unset($line["filter_id"]);
400
-				unset($line["id"]);
401
-				if (!$line["inverse"]) {
402
-				    unset($line["inverse"]);
403
-				}
404
-				unset($line["match_on"]);
405
-
406
-				$data = htmlspecialchars(json_encode($line));
407
-
408
-				print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>".
409
-					"<span onclick=\"dijit.byId('filterEditDlg').editRule(this)\">".$this->getRuleName($line)."</span>".
410
-					"<input type='hidden' name='rule[]' value=\"$data\"/></li>";
411
-			}
382
+            $rules_sth->execute([$filter_id]);
383
+
384
+            while ($line = $rules_sth->fetch()) {
385
+                if ($line["match_on"]) {
386
+                    $line["feed_id"] = json_decode($line["match_on"], true);
387
+                } else {
388
+                    if ($line["cat_filter"]) {
389
+                        $feed_id = "CAT:".(int) $line["cat_id"];
390
+                    } else {
391
+                        $feed_id = (int) $line["feed_id"];
392
+                    }
412 393
 
413
-			print "</ul>";
394
+                    $line["feed_id"] = ["".$feed_id]; // set item type to string for in_array()
395
+                }
414 396
 
415
-			print "</section>";
397
+                unset($line["cat_filter"]);
398
+                unset($line["cat_id"]);
399
+                unset($line["filter_id"]);
400
+                unset($line["id"]);
401
+                if (!$line["inverse"]) {
402
+                    unset($line["inverse"]);
403
+                }
404
+                unset($line["match_on"]);
416 405
 
417
-			print "<header class='horizontal'>".__("Apply actions")."</header>";
406
+                $data = htmlspecialchars(json_encode($line));
418 407
 
419
-			print "<section>";
408
+                print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>".
409
+                    "<span onclick=\"dijit.byId('filterEditDlg').editRule(this)\">".$this->getRuleName($line)."</span>".
410
+                    "<input type='hidden' name='rule[]' value=\"$data\"/></li>";
411
+            }
412
+
413
+            print "</ul>";
414
+
415
+            print "</section>";
420 416
 
421
-			print "<div dojoType=\"fox.Toolbar\">";
417
+            print "<header class='horizontal'>".__("Apply actions")."</header>";
422 418
 
423
-			print "<div dojoType=\"fox.form.DropDownButton\">".
424
-				"<span>".__('Select')."</span>";
425
-			print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
426
-			print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
419
+            print "<section>";
420
+
421
+            print "<div dojoType=\"fox.Toolbar\">";
422
+
423
+            print "<div dojoType=\"fox.form.DropDownButton\">".
424
+                "<span>".__('Select')."</span>";
425
+            print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
426
+            print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
427 427
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
428
-			print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
428
+            print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
429 429
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
430
-			print "</div></div>";
430
+            print "</div></div>";
431 431
 
432
-			print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
433
-				__('Add')."</button> ";
432
+            print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
433
+                __('Add')."</button> ";
434 434
 
435
-			print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
436
-				__('Delete')."</button> ";
435
+            print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
436
+                __('Delete')."</button> ";
437 437
 
438
-			print "</div>";
438
+            print "</div>";
439 439
 
440
-			print "<ul id='filterDlg_Actions'>";
440
+            print "<ul id='filterDlg_Actions'>";
441 441
 
442
-			$actions_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
442
+            $actions_sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
443 443
 				WHERE filter_id = ? ORDER BY id");
444
-			$actions_sth->execute([$filter_id]);
444
+            $actions_sth->execute([$filter_id]);
445 445
 
446
-			while ($line = $actions_sth->fetch()) {
447
-				$line["action_param_label"] = $line["action_param"];
446
+            while ($line = $actions_sth->fetch()) {
447
+                $line["action_param_label"] = $line["action_param"];
448 448
 
449
-				unset($line["filter_id"]);
450
-				unset($line["id"]);
449
+                unset($line["filter_id"]);
450
+                unset($line["id"]);
451 451
 
452
-				$data = htmlspecialchars(json_encode($line));
452
+                $data = htmlspecialchars(json_encode($line));
453 453
 
454
-				print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>".
455
-					"<span onclick=\"dijit.byId('filterEditDlg').editAction(this)\">".$this->getActionName($line)."</span>".
456
-					"<input type='hidden' name='action[]' value=\"$data\"/></li>";
457
-			}
454
+                print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>".
455
+                    "<span onclick=\"dijit.byId('filterEditDlg').editAction(this)\">".$this->getActionName($line)."</span>".
456
+                    "<input type='hidden' name='action[]' value=\"$data\"/></li>";
457
+            }
458 458
 
459
-			print "</ul>";
459
+            print "</ul>";
460 460
 
461
-			print "</section>";
461
+            print "</section>";
462 462
 
463
-			print "<header>".__("Options")."</header>";
464
-			print "<section>";
463
+            print "<header>".__("Options")."</header>";
464
+            print "<section>";
465 465
 
466
-			if ($enabled) {
467
-				$checked = "checked=\"1\"";
468
-			} else {
469
-				$checked = "";
470
-			}
466
+            if ($enabled) {
467
+                $checked = "checked=\"1\"";
468
+            } else {
469
+                $checked = "";
470
+            }
471 471
 
472
-			print "<fieldset class='narrow'>";
473
-			print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
472
+            print "<fieldset class='narrow'>";
473
+            print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"enabled\" id=\"enabled\" $checked>
474 474
 				".__('Enabled')."</label>";
475 475
 
476
-			if ($match_any_rule) {
477
-				$checked = "checked=\"1\"";
478
-			} else {
479
-				$checked = "";
480
-			}
476
+            if ($match_any_rule) {
477
+                $checked = "checked=\"1\"";
478
+            } else {
479
+                $checked = "";
480
+            }
481 481
 
482
-			print "</fieldset><fieldset class='narrow'>";
482
+            print "</fieldset><fieldset class='narrow'>";
483 483
 
484
-			print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\" $checked>
484
+            print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"match_any_rule\" id=\"match_any_rule\" $checked>
485 485
 				".__('Match any rule')."</label>";
486 486
 
487
-			print "</fieldset><fieldset class='narrow'>";
487
+            print "</fieldset><fieldset class='narrow'>";
488 488
 
489
-			if ($inverse) {
490
-				$checked = "checked=\"1\"";
491
-			} else {
492
-				$checked = "";
493
-			}
489
+            if ($inverse) {
490
+                $checked = "checked=\"1\"";
491
+            } else {
492
+                $checked = "";
493
+            }
494 494
 
495
-			print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
495
+            print "<label class='checkbox'><input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\" $checked>
496 496
 				".__('Inverse matching')."</label>";
497 497
 
498
-			print "</fieldset>";
498
+            print "</fieldset>";
499 499
 
500
-			print "</section>";
500
+            print "</section>";
501 501
 
502
-			print "<footer>";
502
+            print "<footer>";
503 503
 
504
-			print "<div style=\"float : left\">";
505
-			print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">".
506
-				__('Remove')."</button>";
507
-			print "</div>";
504
+            print "<div style=\"float : left\">";
505
+            print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">".
506
+                __('Remove')."</button>";
507
+            print "</div>";
508 508
 
509
-			print "<button dojoType=\"dijit.form.Button\" class=\"alt-info\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
510
-				__('Test')."</button> ";
509
+            print "<button dojoType=\"dijit.form.Button\" class=\"alt-info\" onclick=\"return dijit.byId('filterEditDlg').test()\">".
510
+                __('Test')."</button> ";
511 511
 
512
-			print "<button dojoType=\"dijit.form.Button\" type=\"submit\" class=\"alt-primary\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
513
-				__('Save')."</button> ";
512
+            print "<button dojoType=\"dijit.form.Button\" type=\"submit\" class=\"alt-primary\" onclick=\"return dijit.byId('filterEditDlg').execute()\">".
513
+                __('Save')."</button> ";
514 514
 
515
-			print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
516
-				__('Cancel')."</button>";
515
+            print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').hide()\">".
516
+                __('Cancel')."</button>";
517 517
 
518
-			print "</footer>";
519
-			print "</form>";
518
+            print "</footer>";
519
+            print "</form>";
520 520
 
521
-		}
522
-	}
521
+        }
522
+    }
523 523
 
524
-	private function getRuleName($rule) {
525
-		if (!$rule) {
526
-		    $rule = json_decode(clean($_REQUEST["rule"]), true);
527
-		}
524
+    private function getRuleName($rule) {
525
+        if (!$rule) {
526
+            $rule = json_decode(clean($_REQUEST["rule"]), true);
527
+        }
528 528
 
529
-		$feeds = $rule["feed_id"];
530
-		$feeds_fmt = [];
529
+        $feeds = $rule["feed_id"];
530
+        $feeds_fmt = [];
531 531
 
532
-		if (!is_array($feeds)) {
533
-		    $feeds = [$feeds];
534
-		}
532
+        if (!is_array($feeds)) {
533
+            $feeds = [$feeds];
534
+        }
535 535
 
536
-		foreach ($feeds as $feed_id) {
536
+        foreach ($feeds as $feed_id) {
537 537
 
538 538
             if (strpos($feed_id, "CAT:") === 0) {
539 539
                 $feed_id = (int) substr($feed_id, 4);
@@ -548,276 +548,276 @@  discard block
 block discarded – undo
548 548
 
549 549
         $feed = implode(", ", $feeds_fmt);
550 550
 
551
-		$sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types
551
+        $sth = $this->pdo->prepare("SELECT description FROM ttrss_filter_types
552 552
 			WHERE id = ?");
553
-		$sth->execute([(int) $rule["filter_type"]]);
553
+        $sth->execute([(int) $rule["filter_type"]]);
554 554
 
555
-		if ($row = $sth->fetch()) {
556
-			$filter_type = $row["description"];
557
-		} else {
558
-			$filter_type = "?UNKNOWN?";
559
-		}
555
+        if ($row = $sth->fetch()) {
556
+            $filter_type = $row["description"];
557
+        } else {
558
+            $filter_type = "?UNKNOWN?";
559
+        }
560 560
 
561
-		$inverse = isset($rule["inverse"]) ? "inverse" : "";
561
+        $inverse = isset($rule["inverse"]) ? "inverse" : "";
562 562
 
563
-		return "<span class='filterRule $inverse'>".
564
-			T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]),
565
-			$filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "")."</span>";
566
-	}
563
+        return "<span class='filterRule $inverse'>".
564
+            T_sprintf("%s on %s in %s %s", htmlspecialchars($rule["reg_exp"]),
565
+            $filter_type, $feed, isset($rule["inverse"]) ? __("(inverse)") : "")."</span>";
566
+    }
567 567
 
568
-	public function printRuleName() {
569
-		print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true));
570
-	}
568
+    public function printRuleName() {
569
+        print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true));
570
+    }
571 571
 
572
-	private function getActionName($action) {
573
-		$sth = $this->pdo->prepare("SELECT description FROM
572
+    private function getActionName($action) {
573
+        $sth = $this->pdo->prepare("SELECT description FROM
574 574
 			ttrss_filter_actions WHERE id = ?");
575
-		$sth->execute([(int) $action["action_id"]]);
575
+        $sth->execute([(int) $action["action_id"]]);
576 576
 
577
-		$title = "";
577
+        $title = "";
578 578
 
579
-		if ($row = $sth->fetch()) {
579
+        if ($row = $sth->fetch()) {
580 580
 
581
-			$title = __($row["description"]);
581
+            $title = __($row["description"]);
582 582
 
583
-			if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
584
-				$action["action_id"] == 7)
585
-				$title .= ": ".$action["action_param"];
583
+            if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
584
+                $action["action_id"] == 7)
585
+                $title .= ": ".$action["action_param"];
586 586
 
587
-			if ($action["action_id"] == 9) {
588
-				list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
587
+            if ($action["action_id"] == 9) {
588
+                list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
589 589
 
590
-				$filter_actions = PluginHost::getInstance()->get_filter_actions();
590
+                $filter_actions = PluginHost::getInstance()->get_filter_actions();
591 591
 
592
-				foreach ($filter_actions as $fclass => $factions) {
593
-					foreach ($factions as $faction) {
594
-						if ($pfaction == $faction["action"] && $pfclass == $fclass) {
595
-							$title .= ": ".$fclass.": ".$faction["description"];
596
-							break;
597
-						}
598
-					}
599
-				}
600
-			}
601
-		}
592
+                foreach ($filter_actions as $fclass => $factions) {
593
+                    foreach ($factions as $faction) {
594
+                        if ($pfaction == $faction["action"] && $pfclass == $fclass) {
595
+                            $title .= ": ".$fclass.": ".$faction["description"];
596
+                            break;
597
+                        }
598
+                    }
599
+                }
600
+            }
601
+        }
602 602
 
603
-		return $title;
604
-	}
603
+        return $title;
604
+    }
605 605
 
606
-	public function printActionName() {
607
-		print $this->getActionName(json_decode(clean($_REQUEST["action"]), true));
608
-	}
606
+    public function printActionName() {
607
+        print $this->getActionName(json_decode(clean($_REQUEST["action"]), true));
608
+    }
609 609
 
610
-	public function editSave() {
611
-		if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") {
612
-			return $this->testFilter();
613
-		}
610
+    public function editSave() {
611
+        if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") {
612
+            return $this->testFilter();
613
+        }
614 614
 
615
-		$filter_id = clean($_REQUEST["id"]);
616
-		$enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"]));
617
-		$match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
618
-		$inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
619
-		$title = clean($_REQUEST["title"]);
615
+        $filter_id = clean($_REQUEST["id"]);
616
+        $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"]));
617
+        $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
618
+        $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
619
+        $title = clean($_REQUEST["title"]);
620 620
 
621
-		$this->pdo->beginTransaction();
621
+        $this->pdo->beginTransaction();
622 622
 
623
-		$sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET enabled = ?,
623
+        $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET enabled = ?,
624 624
 			match_any_rule = ?,
625 625
 			inverse = ?,
626 626
 			title = ?
627 627
 			WHERE id = ? AND owner_uid = ?");
628 628
 
629
-		$sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]);
629
+        $sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]);
630 630
 
631
-		$this->saveRulesAndActions($filter_id);
631
+        $this->saveRulesAndActions($filter_id);
632 632
 
633
-		$this->pdo->commit();
634
-	}
633
+        $this->pdo->commit();
634
+    }
635 635
 
636
-	public function remove() {
636
+    public function remove() {
637 637
 
638
-		$ids = explode(",", clean($_REQUEST["ids"]));
639
-		$ids_qmarks = arr_qmarks($ids);
638
+        $ids = explode(",", clean($_REQUEST["ids"]));
639
+        $ids_qmarks = arr_qmarks($ids);
640 640
 
641
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)
641
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)
642 642
 			AND owner_uid = ?");
643
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
644
-	}
643
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
644
+    }
645 645
 
646
-	private function saveRulesAndActions($filter_id)
647
-	{
646
+    private function saveRulesAndActions($filter_id)
647
+    {
648 648
 
649
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?");
650
-		$sth->execute([$filter_id]);
649
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?");
650
+        $sth->execute([$filter_id]);
651 651
 
652
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?");
653
-		$sth->execute([$filter_id]);
652
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_actions WHERE filter_id = ?");
653
+        $sth->execute([$filter_id]);
654 654
 
655
-		if (!is_array(clean($_REQUEST["rule"]))) {
656
-		    $_REQUEST["rule"] = [];
657
-		}
658
-		if (!is_array(clean($_REQUEST["action"]))) {
659
-		    $_REQUEST["action"] = [];
660
-		}
655
+        if (!is_array(clean($_REQUEST["rule"]))) {
656
+            $_REQUEST["rule"] = [];
657
+        }
658
+        if (!is_array(clean($_REQUEST["action"]))) {
659
+            $_REQUEST["action"] = [];
660
+        }
661 661
 
662
-		if ($filter_id) {
663
-			/* create rules */
662
+        if ($filter_id) {
663
+            /* create rules */
664 664
 
665
-			$rules = array();
666
-			$actions = array();
665
+            $rules = array();
666
+            $actions = array();
667 667
 
668
-			foreach (clean($_REQUEST["rule"]) as $rule) {
669
-				$rule = json_decode($rule, true);
670
-				unset($rule["id"]);
668
+            foreach (clean($_REQUEST["rule"]) as $rule) {
669
+                $rule = json_decode($rule, true);
670
+                unset($rule["id"]);
671 671
 
672
-				if (array_search($rule, $rules) === false) {
673
-					array_push($rules, $rule);
674
-				}
675
-			}
672
+                if (array_search($rule, $rules) === false) {
673
+                    array_push($rules, $rule);
674
+                }
675
+            }
676 676
 
677
-			foreach (clean($_REQUEST["action"]) as $action) {
678
-				$action = json_decode($action, true);
679
-				unset($action["id"]);
677
+            foreach (clean($_REQUEST["action"]) as $action) {
678
+                $action = json_decode($action, true);
679
+                unset($action["id"]);
680 680
 
681
-				if (array_search($action, $actions) === false) {
682
-					array_push($actions, $action);
683
-				}
684
-			}
681
+                if (array_search($action, $actions) === false) {
682
+                    array_push($actions, $action);
683
+                }
684
+            }
685 685
 
686
-			$rsth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
686
+            $rsth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
687 687
 						(filter_id, reg_exp,filter_type,feed_id,cat_id,match_on,inverse) VALUES
688 688
 						(?, ?, ?, NULL, NULL, ?, ?)");
689 689
 
690
-			foreach ($rules as $rule) {
691
-				if ($rule) {
690
+            foreach ($rules as $rule) {
691
+                if ($rule) {
692 692
 
693
-					$reg_exp = trim($rule["reg_exp"]);
694
-					$inverse = isset($rule["inverse"]) ? 1 : 0;
693
+                    $reg_exp = trim($rule["reg_exp"]);
694
+                    $inverse = isset($rule["inverse"]) ? 1 : 0;
695 695
 
696
-					$filter_type = (int) trim($rule["filter_type"]);
697
-					$match_on = json_encode($rule["feed_id"]);
696
+                    $filter_type = (int) trim($rule["filter_type"]);
697
+                    $match_on = json_encode($rule["feed_id"]);
698 698
 
699
-					$rsth->execute([$filter_id, $reg_exp, $filter_type, $match_on, $inverse]);
700
-				}
701
-			}
699
+                    $rsth->execute([$filter_id, $reg_exp, $filter_type, $match_on, $inverse]);
700
+                }
701
+            }
702 702
 
703
-			$asth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
703
+            $asth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
704 704
 						(filter_id, action_id, action_param) VALUES
705 705
 						(?, ?, ?)");
706 706
 
707
-			foreach ($actions as $action) {
708
-				if ($action) {
707
+            foreach ($actions as $action) {
708
+                if ($action) {
709 709
 
710
-					$action_id = (int) $action["action_id"];
711
-					$action_param = $action["action_param"];
712
-					$action_param_label = $action["action_param_label"];
710
+                    $action_id = (int) $action["action_id"];
711
+                    $action_param = $action["action_param"];
712
+                    $action_param_label = $action["action_param_label"];
713 713
 
714
-					if ($action_id == 7) {
715
-						$action_param = $action_param_label;
716
-					}
714
+                    if ($action_id == 7) {
715
+                        $action_param = $action_param_label;
716
+                    }
717 717
 
718
-					if ($action_id == 6) {
719
-						$action_param = (int) str_replace("+", "", $action_param);
720
-					}
718
+                    if ($action_id == 6) {
719
+                        $action_param = (int) str_replace("+", "", $action_param);
720
+                    }
721 721
 
722
-					$asth->execute([$filter_id, $action_id, $action_param]);
723
-				}
724
-			}
725
-		}
726
-	}
722
+                    $asth->execute([$filter_id, $action_id, $action_param]);
723
+                }
724
+            }
725
+        }
726
+    }
727 727
 
728
-	public function add() {
729
-		if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") {
730
-			return $this->testFilter();
731
-		}
728
+    public function add() {
729
+        if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") {
730
+            return $this->testFilter();
731
+        }
732 732
 
733
-		$enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"]));
734
-		$match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
735
-		$title = clean($_REQUEST["title"]);
736
-		$inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
733
+        $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"]));
734
+        $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"]));
735
+        $title = clean($_REQUEST["title"]);
736
+        $inverse = checkbox_to_sql_bool(clean($_REQUEST["inverse"]));
737 737
 
738
-		$this->pdo->beginTransaction();
738
+        $this->pdo->beginTransaction();
739 739
 
740
-		/* create base filter */
740
+        /* create base filter */
741 741
 
742
-		$sth = $this->pdo->prepare("INSERT INTO ttrss_filters2
742
+        $sth = $this->pdo->prepare("INSERT INTO ttrss_filters2
743 743
 			(owner_uid, match_any_rule, enabled, title, inverse) VALUES
744 744
 			(?, ?, ?, ?, ?)");
745 745
 
746
-		$sth->execute([$_SESSION['uid'], $match_any_rule, $enabled, $title, $inverse]);
746
+        $sth->execute([$_SESSION['uid'], $match_any_rule, $enabled, $title, $inverse]);
747 747
 
748
-		$sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2
748
+        $sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2
749 749
 			WHERE owner_uid = ?");
750
-		$sth->execute([$_SESSION['uid']]);
750
+        $sth->execute([$_SESSION['uid']]);
751 751
 
752
-		if ($row = $sth->fetch()) {
753
-			$filter_id = $row['id'];
754
-			$this->saveRulesAndActions($filter_id);
755
-		}
752
+        if ($row = $sth->fetch()) {
753
+            $filter_id = $row['id'];
754
+            $this->saveRulesAndActions($filter_id);
755
+        }
756 756
 
757
-		$this->pdo->commit();
758
-	}
757
+        $this->pdo->commit();
758
+    }
759 759
 
760
-	public function index() {
760
+    public function index() {
761 761
 
762
-		$filter_search = clean($_REQUEST["search"]);
762
+        $filter_search = clean($_REQUEST["search"]);
763 763
 
764
-		if (array_key_exists("search", $_REQUEST)) {
765
-			$_SESSION["prefs_filter_search"] = $filter_search;
766
-		} else {
767
-			$filter_search = $_SESSION["prefs_filter_search"];
768
-		}
764
+        if (array_key_exists("search", $_REQUEST)) {
765
+            $_SESSION["prefs_filter_search"] = $filter_search;
766
+        } else {
767
+            $filter_search = $_SESSION["prefs_filter_search"];
768
+        }
769 769
 
770
-		print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
771
-		print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
772
-		print "<div dojoType='fox.Toolbar'>";
770
+        print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
771
+        print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
772
+        print "<div dojoType='fox.Toolbar'>";
773 773
 
774
-		if (array_key_exists("search", $_REQUEST)) {
775
-			$_SESSION["prefs_filter_search"] = $filter_search;
776
-		} else {
777
-			$filter_search = $_SESSION["prefs_filter_search"];
778
-		}
774
+        if (array_key_exists("search", $_REQUEST)) {
775
+            $_SESSION["prefs_filter_search"] = $filter_search;
776
+        } else {
777
+            $filter_search = $_SESSION["prefs_filter_search"];
778
+        }
779 779
 
780
-		print "<div style='float : right; padding-right : 4px;'>
780
+        print "<div style='float : right; padding-right : 4px;'>
781 781
 			<input dojoType=\"dijit.form.TextBox\" id=\"filter_search\" size=\"20\" type=\"search\"
782 782
 				value=\"$filter_search\">
783 783
 			<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('filterTree').reload()\">".
784
-				__('Search')."</button>
784
+                __('Search')."</button>
785 785
 			</div>";
786 786
 
787
-		print "<div dojoType=\"fox.form.DropDownButton\">".
788
-				"<span>".__('Select')."</span>";
789
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
790
-		print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"
787
+        print "<div dojoType=\"fox.form.DropDownButton\">".
788
+                "<span>".__('Select')."</span>";
789
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
790
+        print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(true)\"
791 791
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
792
-		print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"
792
+        print "<div onclick=\"dijit.byId('filterTree').model.setAllChecked(false)\"
793 793
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
794
-		print "</div></div>";
794
+        print "</div></div>";
795 795
 
796
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return Filters.quickAddFilter()\">".
797
-			__('Create filter')."</button> ";
796
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return Filters.quickAddFilter()\">".
797
+            __('Create filter')."</button> ";
798 798
 
799
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').joinSelectedFilters()\">".
800
-			__('Combine')."</button> ";
799
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').joinSelectedFilters()\">".
800
+            __('Combine')."</button> ";
801 801
 
802
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').editSelectedFilter()\">".
803
-			__('Edit')."</button> ";
802
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').editSelectedFilter()\">".
803
+            __('Edit')."</button> ";
804 804
 
805
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').resetFilterOrder()\">".
806
-			__('Reset sort order')."</button> ";
805
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').resetFilterOrder()\">".
806
+            __('Reset sort order')."</button> ";
807 807
 
808 808
 
809
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').removeSelectedFilters()\">".
810
-			__('Remove')."</button> ";
809
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterTree').removeSelectedFilters()\">".
810
+            __('Remove')."</button> ";
811 811
 
812
-		print "</div>"; # toolbar
813
-		print "</div>"; # toolbar-frame
814
-		print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
812
+        print "</div>"; # toolbar
813
+        print "</div>"; # toolbar-frame
814
+        print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='center'>";
815 815
 
816
-		print "<div id='filterlistLoading'>
816
+        print "<div id='filterlistLoading'>
817 817
 		<img src='images/indicator_tiny.gif'>".
818
-		 __("Loading, please wait...")."</div>";
818
+            __("Loading, please wait...")."</div>";
819 819
 
820
-		print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"
820
+        print "<div dojoType=\"fox.PrefFilterStore\" jsId=\"filterStore\"
821 821
 			url=\"backend.php?op=pref-filters&method=getfiltertree\">
822 822
 		</div>
823 823
 		<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"filterModel\" store=\"filterStore\"
@@ -842,152 +842,152 @@  discard block
 block discarded – undo
842 842
 
843 843
 		</div>";
844 844
 
845
-		print "</div>"; #pane
845
+        print "</div>"; #pane
846 846
 
847
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
848
-			"hook_prefs_tab", "prefFilters");
847
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
848
+            "hook_prefs_tab", "prefFilters");
849 849
 
850
-		print "</div>"; #container
850
+        print "</div>"; #container
851 851
 
852
-	}
852
+    }
853 853
 
854
-	public function newfilter() {
854
+    public function newfilter() {
855 855
 
856
-		print "<form name='filter_new_form' id='filter_new_form' onsubmit='return false'>";
856
+        print "<form name='filter_new_form' id='filter_new_form' onsubmit='return false'>";
857 857
 
858
-		print_hidden("op", "pref-filters");
859
-		print_hidden("method", "add");
860
-		print_hidden("csrf_token", $_SESSION['csrf_token']);
858
+        print_hidden("op", "pref-filters");
859
+        print_hidden("method", "add");
860
+        print_hidden("csrf_token", $_SESSION['csrf_token']);
861 861
 
862
-		print "<header>".__("Caption")."</header>";
862
+        print "<header>".__("Caption")."</header>";
863 863
 
864
-		print "<section>";
865
-		print "<input required='true' dojoType='dijit.form.ValidationTextBox' style='width : 20em;' name='title' value=''>";
866
-		print "</section>";
864
+        print "<section>";
865
+        print "<input required='true' dojoType='dijit.form.ValidationTextBox' style='width : 20em;' name='title' value=''>";
866
+        print "</section>";
867 867
 
868
-		print "<header class='horizontal'>".__("Match")."</header >";
869
-		print "<section>";
868
+        print "<header class='horizontal'>".__("Match")."</header >";
869
+        print "<section>";
870 870
 
871
-		print "<div dojoType='fox.Toolbar'>";
871
+        print "<div dojoType='fox.Toolbar'>";
872 872
 
873
-		print "<div dojoType='fox.form.DropDownButton'>".
874
-				"<span>".__('Select')."</span>";
875
-		print "<div dojoType='dijit.Menu' style='display: none'>";
876
-		print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
873
+        print "<div dojoType='fox.form.DropDownButton'>".
874
+                "<span>".__('Select')."</span>";
875
+        print "<div dojoType='dijit.Menu' style='display: none'>";
876
+        print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(true)\"
877 877
 			dojoType='dijit.MenuItem'>".__('All')."</div>";
878
-		print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
878
+        print "<div onclick=\"dijit.byId('filterEditDlg').selectRules(false)\"
879 879
 			dojoType='dijit.MenuItem'>".__('None')."</div>";
880
-		print "</div></div>";
880
+        print "</div></div>";
881 881
 
882
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
883
-			__('Add')."</button> ";
882
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addRule()\">".
883
+            __('Add')."</button> ";
884 884
 
885
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
886
-			__('Delete')."</button> ";
885
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteRule()\">".
886
+            __('Delete')."</button> ";
887 887
 
888
-		print "</div>";
888
+        print "</div>";
889 889
 
890
-		print "<ul id='filterDlg_Matches'>";
890
+        print "<ul id='filterDlg_Matches'>";
891 891
 #		print "<li>No rules</li>";
892
-		print "</ul>";
892
+        print "</ul>";
893 893
 
894
-		print "</section>";
894
+        print "</section>";
895 895
 
896
-		print "<header class='horizontal'>".__("Apply actions")."</header>";
896
+        print "<header class='horizontal'>".__("Apply actions")."</header>";
897 897
 
898
-		print "<section>";
898
+        print "<section>";
899 899
 
900
-		print "<div dojoType='fox.Toolbar'>";
900
+        print "<div dojoType='fox.Toolbar'>";
901 901
 
902
-		print "<div dojoType='fox.form.DropDownButton'>".
903
-				"<span>".__('Select')."</span>";
904
-		print "<div dojoType='dijit.Menu' style='display: none'>";
905
-		print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
902
+        print "<div dojoType='fox.form.DropDownButton'>".
903
+                "<span>".__('Select')."</span>";
904
+        print "<div dojoType='dijit.Menu' style='display: none'>";
905
+        print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(true)\"
906 906
 			dojoType='dijit.MenuItem'>".__('All')."</div>";
907
-		print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
907
+        print "<div onclick=\"dijit.byId('filterEditDlg').selectActions(false)\"
908 908
 			dojoType='dijit.MenuItem'>".__('None')."</div>";
909
-		print "</div></div>";
909
+        print "</div></div>";
910 910
 
911
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
912
-			__('Add')."</button> ";
911
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').addAction()\">".
912
+            __('Add')."</button> ";
913 913
 
914
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
915
-			__('Delete')."</button> ";
914
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').deleteAction()\">".
915
+            __('Delete')."</button> ";
916 916
 
917
-		print "</div>";
917
+        print "</div>";
918 918
 
919
-		print "<ul id='filterDlg_Actions'>";
919
+        print "<ul id='filterDlg_Actions'>";
920 920
 #		print "<li>No actions</li>";
921
-		print "</ul>";
921
+        print "</ul>";
922 922
 
923
-		print "</section>";
923
+        print "</section>";
924 924
 
925
-		print "<header>".__("Options")."</header>";
925
+        print "<header>".__("Options")."</header>";
926 926
 
927
-		print "<section>";
928
-		print "<fieldset class='narrow'>";
927
+        print "<section>";
928
+        print "<fieldset class='narrow'>";
929 929
 
930
-		print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='enabled' id='enabled' checked='1'>
930
+        print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='enabled' id='enabled' checked='1'>
931 931
 				".__('Enabled')."</label>";
932 932
 
933
-		print "</fieldset><fieldset class='narrow'>";
933
+        print "</fieldset><fieldset class='narrow'>";
934 934
 
935
-		print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='match_any_rule' id='match_any_rule'>
935
+        print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='match_any_rule' id='match_any_rule'>
936 936
 				".__('Match any rule')."</label>";
937 937
 
938
-		print "</fieldset><fieldset class='narrow'>";
938
+        print "</fieldset><fieldset class='narrow'>";
939 939
 
940
-		print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='inverse' id='inverse'>
940
+        print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' name='inverse' id='inverse'>
941 941
 				".__('Inverse matching')."</label>";
942 942
 
943
-		print "</fieldset>";
943
+        print "</fieldset>";
944 944
 
945
-		print "</section>";
945
+        print "</section>";
946 946
 
947
-		print "<footer>";
947
+        print "<footer>";
948 948
 
949
-		print "<button dojoType='dijit.form.Button' class='alt-info' onclick=\"return dijit.byId('filterEditDlg').test()\">".
950
-			__('Test')."</button> ";
951
-		print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"return dijit.byId('filterEditDlg').execute()\">".
952
-			__('Create')."</button> ";
953
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').hide()\">".
954
-			__('Cancel')."</button>";
949
+        print "<button dojoType='dijit.form.Button' class='alt-info' onclick=\"return dijit.byId('filterEditDlg').test()\">".
950
+            __('Test')."</button> ";
951
+        print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"return dijit.byId('filterEditDlg').execute()\">".
952
+            __('Create')."</button> ";
953
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterEditDlg').hide()\">".
954
+            __('Cancel')."</button>";
955 955
 
956
-		print "</footer>";
956
+        print "</footer>";
957 957
 
958
-	}
958
+    }
959 959
 
960
-	public function newrule() {
961
-		$rule = json_decode(clean($_REQUEST["rule"]), true);
960
+    public function newrule() {
961
+        $rule = json_decode(clean($_REQUEST["rule"]), true);
962 962
 
963
-		if ($rule) {
964
-			$reg_exp = htmlspecialchars($rule["reg_exp"]);
965
-			$filter_type = $rule["filter_type"];
966
-			$feed_id = $rule["feed_id"];
967
-			$inverse_checked = isset($rule["inverse"]) ? "checked" : "";
968
-		} else {
969
-			$reg_exp = "";
970
-			$filter_type = 1;
971
-			$feed_id = ["0"];
972
-			$inverse_checked = "";
973
-		}
963
+        if ($rule) {
964
+            $reg_exp = htmlspecialchars($rule["reg_exp"]);
965
+            $filter_type = $rule["filter_type"];
966
+            $feed_id = $rule["feed_id"];
967
+            $inverse_checked = isset($rule["inverse"]) ? "checked" : "";
968
+        } else {
969
+            $reg_exp = "";
970
+            $filter_type = 1;
971
+            $feed_id = ["0"];
972
+            $inverse_checked = "";
973
+        }
974 974
 
975
-		print "<form name='filter_new_rule_form' id='filter_new_rule_form' onsubmit='return false;'>";
975
+        print "<form name='filter_new_rule_form' id='filter_new_rule_form' onsubmit='return false;'>";
976 976
 
977
-		$res = $this->pdo->query("SELECT id,description
977
+        $res = $this->pdo->query("SELECT id,description
978 978
 			FROM ttrss_filter_types WHERE id != 5 ORDER BY description");
979 979
 
980
-		$filter_types = array();
980
+        $filter_types = array();
981 981
 
982
-		while ($line = $res->fetch()) {
983
-			$filter_types[$line["id"]] = __($line["description"]);
984
-		}
982
+        while ($line = $res->fetch()) {
983
+            $filter_types[$line["id"]] = __($line["description"]);
984
+        }
985 985
 
986
-		print "<header>".__("Match")."</header>";
986
+        print "<header>".__("Match")."</header>";
987 987
 
988
-		print "<section>";
988
+        print "<section>";
989 989
 
990
-		print "<input dojoType=\"dijit.form.ValidationTextBox\"
990
+        print "<input dojoType=\"dijit.form.ValidationTextBox\"
991 991
 			 required=\"true\" id=\"filterDlg_regExp\"
992 992
 			 onchange='Filters.filterDlgCheckRegExp(this)'
993 993
 			 onblur='Filters.filterDlgCheckRegExp(this)'
@@ -995,272 +995,272 @@  discard block
 block discarded – undo
995 995
 			 style=\"font-size : 16px; width : 500px\"
996 996
 			 name=\"reg_exp\" value=\"$reg_exp\"/>";
997 997
 
998
-		print "<div dojoType='dijit.Tooltip' id='filterDlg_regExp_tip' connectId='filterDlg_regExp' position='below'></div>";
998
+        print "<div dojoType='dijit.Tooltip' id='filterDlg_regExp_tip' connectId='filterDlg_regExp' position='below'></div>";
999 999
 
1000
-		print "<fieldset>";
1001
-		print "<label class='checkbox'><input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\"
1000
+        print "<fieldset>";
1001
+        print "<label class='checkbox'><input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\"
1002 1002
 			 name=\"inverse\" $inverse_checked/> ".
1003
-		 	__("Inverse regular expression matching")."</label>";
1004
-		print "</fieldset>";
1003
+                __("Inverse regular expression matching")."</label>";
1004
+        print "</fieldset>";
1005 1005
 
1006
-		print "<fieldset>";
1007
-		print "<label style='display : inline'>".__("on field")."</label> ";
1008
-		print_select_hash("filter_type", $filter_type, $filter_types,
1009
-			'dojoType="fox.form.Select"');
1010
-		print "<label style='padding-left : 10px; display : inline'>".__("in")."</label> ";
1006
+        print "<fieldset>";
1007
+        print "<label style='display : inline'>".__("on field")."</label> ";
1008
+        print_select_hash("filter_type", $filter_type, $filter_types,
1009
+            'dojoType="fox.form.Select"');
1010
+        print "<label style='padding-left : 10px; display : inline'>".__("in")."</label> ";
1011 1011
 
1012
-		print "</fieldset>";
1012
+        print "</fieldset>";
1013 1013
 
1014
-		print "<fieldset>";
1015
-		print "<span id='filterDlg_feeds'>";
1016
-		print_feed_multi_select("feed_id",
1017
-			$feed_id,
1018
-			'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"');
1019
-		print "</span>";
1014
+        print "<fieldset>";
1015
+        print "<span id='filterDlg_feeds'>";
1016
+        print_feed_multi_select("feed_id",
1017
+            $feed_id,
1018
+            'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"');
1019
+        print "</span>";
1020 1020
 
1021
-		print "</fieldset>";
1021
+        print "</fieldset>";
1022 1022
 
1023
-		print "</section>";
1023
+        print "</section>";
1024 1024
 
1025
-		print "<footer>";
1025
+        print "<footer>";
1026 1026
 
1027
-		print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'>
1027
+        print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'>
1028 1028
 			<i class='material-icons'>help</i> ".__("More info...")."</button>";
1029 1029
 
1030
-		print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">".
1031
-			($rule ? __("Save rule") : __('Add rule'))."</button> ";
1030
+        print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">".
1031
+            ($rule ? __("Save rule") : __('Add rule'))."</button> ";
1032 1032
 
1033
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">".
1034
-			__('Cancel')."</button>";
1033
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">".
1034
+            __('Cancel')."</button>";
1035 1035
 
1036
-		print "</footer>";
1036
+        print "</footer>";
1037 1037
 
1038
-		print "</form>";
1039
-	}
1038
+        print "</form>";
1039
+    }
1040 1040
 
1041
-	public function newaction() {
1042
-		$action = json_decode(clean($_REQUEST["action"]), true);
1041
+    public function newaction() {
1042
+        $action = json_decode(clean($_REQUEST["action"]), true);
1043 1043
 
1044
-		if ($action) {
1045
-			$action_param = $action["action_param"];
1046
-			$action_id = (int) $action["action_id"];
1047
-		} else {
1048
-			$action_param = "";
1049
-			$action_id = 0;
1050
-		}
1044
+        if ($action) {
1045
+            $action_param = $action["action_param"];
1046
+            $action_id = (int) $action["action_id"];
1047
+        } else {
1048
+            $action_param = "";
1049
+            $action_id = 0;
1050
+        }
1051 1051
 
1052
-		print "<form name='filter_new_action_form' id='filter_new_action_form' onsubmit='return false;'>";
1052
+        print "<form name='filter_new_action_form' id='filter_new_action_form' onsubmit='return false;'>";
1053 1053
 
1054
-		print "<header>".__("Perform Action")."</header>";
1054
+        print "<header>".__("Perform Action")."</header>";
1055 1055
 
1056
-		print "<section>";
1056
+        print "<section>";
1057 1057
 
1058
-		print "<select name='action_id' dojoType='fox.form.Select'
1058
+        print "<select name='action_id' dojoType='fox.form.Select'
1059 1059
 			onchange='Filters.filterDlgCheckAction(this)'>";
1060 1060
 
1061
-		$res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions
1061
+        $res = $this->pdo->query("SELECT id,description FROM ttrss_filter_actions
1062 1062
 			ORDER BY name");
1063 1063
 
1064
-		while ($line = $res->fetch()) {
1065
-			$is_selected = ($line["id"] == $action_id) ? "selected='1'" : "";
1066
-			printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"]));
1067
-		}
1064
+        while ($line = $res->fetch()) {
1065
+            $is_selected = ($line["id"] == $action_id) ? "selected='1'" : "";
1066
+            printf("<option $is_selected value='%d'>%s</option>", $line["id"], __($line["description"]));
1067
+        }
1068 1068
 
1069
-		print "</select>";
1069
+        print "</select>";
1070 1070
 
1071
-		$param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ?
1072
-			"" : "display : none";
1071
+        $param_box_hidden = ($action_id == 7 || $action_id == 4 || $action_id == 6 || $action_id == 9) ?
1072
+            "" : "display : none";
1073 1073
 
1074
-		$param_hidden = ($action_id == 4 || $action_id == 6) ?
1075
-			"" : "display : none";
1074
+        $param_hidden = ($action_id == 4 || $action_id == 6) ?
1075
+            "" : "display : none";
1076 1076
 
1077
-		$label_param_hidden = ($action_id == 7) ? "" : "display : none";
1078
-		$plugin_param_hidden = ($action_id == 9) ? "" : "display : none";
1077
+        $label_param_hidden = ($action_id == 7) ? "" : "display : none";
1078
+        $plugin_param_hidden = ($action_id == 9) ? "" : "display : none";
1079 1079
 
1080
-		print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">";
1081
-		print " ";
1082
-		//print " " . __("with parameters:") . " ";
1083
-		print "<input dojoType='dijit.form.TextBox'
1080
+        print "<span id='filterDlg_paramBox' style=\"$param_box_hidden\">";
1081
+        print " ";
1082
+        //print " " . __("with parameters:") . " ";
1083
+        print "<input dojoType='dijit.form.TextBox'
1084 1084
 			id='filterDlg_actionParam' style=\"$param_hidden\"
1085 1085
 			name='action_param' value=\"$action_param\">";
1086 1086
 
1087
-		print_label_select("action_param_label", $action_param,
1088
-			"id='filterDlg_actionParamLabel' style=\"$label_param_hidden\"
1087
+        print_label_select("action_param_label", $action_param,
1088
+            "id='filterDlg_actionParamLabel' style=\"$label_param_hidden\"
1089 1089
 			dojoType='fox.form.Select'");
1090 1090
 
1091
-		$filter_actions = PluginHost::getInstance()->get_filter_actions();
1092
-		$filter_action_hash = array();
1091
+        $filter_actions = PluginHost::getInstance()->get_filter_actions();
1092
+        $filter_action_hash = array();
1093 1093
 
1094
-		foreach ($filter_actions as $fclass => $factions) {
1095
-			foreach ($factions as $faction) {
1094
+        foreach ($filter_actions as $fclass => $factions) {
1095
+            foreach ($factions as $faction) {
1096 1096
 
1097
-				$filter_action_hash[$fclass.":".$faction["action"]] =
1098
-					$fclass.": ".$faction["description"];
1099
-			}
1100
-		}
1097
+                $filter_action_hash[$fclass.":".$faction["action"]] =
1098
+                    $fclass.": ".$faction["description"];
1099
+            }
1100
+        }
1101 1101
 
1102
-		if (count($filter_action_hash) == 0) {
1103
-			$filter_plugin_disabled = "disabled";
1102
+        if (count($filter_action_hash) == 0) {
1103
+            $filter_plugin_disabled = "disabled";
1104 1104
 
1105
-			$filter_action_hash["no-data"] = __("No actions available");
1105
+            $filter_action_hash["no-data"] = __("No actions available");
1106 1106
 
1107
-		} else {
1108
-			$filter_plugin_disabled = "";
1109
-		}
1107
+        } else {
1108
+            $filter_plugin_disabled = "";
1109
+        }
1110 1110
 
1111
-		print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash,
1112
-			"style=\"$plugin_param_hidden\" dojoType='fox.form.Select' $filter_plugin_disabled",
1113
-			"action_param_plugin");
1111
+        print_select_hash("filterDlg_actionParamPlugin", $action_param, $filter_action_hash,
1112
+            "style=\"$plugin_param_hidden\" dojoType='fox.form.Select' $filter_plugin_disabled",
1113
+            "action_param_plugin");
1114 1114
 
1115
-		print "</span>";
1115
+        print "</span>";
1116 1116
 
1117
-		print "&nbsp;"; // tiny layout hack
1117
+        print "&nbsp;"; // tiny layout hack
1118 1118
 
1119
-		print "</section>";
1119
+        print "</section>";
1120 1120
 
1121
-		print "<footer>";
1121
+        print "<footer>";
1122 1122
 
1123
-		print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewActionDlg').execute()\">".
1124
-			($action ? __("Save action") : __('Add action'))."</button> ";
1123
+        print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewActionDlg').execute()\">".
1124
+            ($action ? __("Save action") : __('Add action'))."</button> ";
1125 1125
 
1126
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewActionDlg').hide()\">".
1127
-			__('Cancel')."</button>";
1126
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewActionDlg').hide()\">".
1127
+            __('Cancel')."</button>";
1128 1128
 
1129
-		print "</footer>";
1129
+        print "</footer>";
1130 1130
 
1131
-		print "</form>";
1132
-	}
1131
+        print "</form>";
1132
+    }
1133 1133
 
1134
-	private function getFilterName($id) {
1134
+    private function getFilterName($id) {
1135 1135
 
1136
-		$sth = $this->pdo->prepare(
1137
-			"SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
1136
+        $sth = $this->pdo->prepare(
1137
+            "SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
1138 1138
 				FROM ttrss_filters2 AS f LEFT JOIN ttrss_filters2_rules AS r
1139 1139
 					ON (r.filter_id = f.id)
1140 1140
 						LEFT JOIN ttrss_filters2_actions AS a
1141 1141
 							ON (a.filter_id = f.id) WHERE f.id = ? GROUP BY f.title, f.match_any_rule, f.inverse");
1142
-		$sth->execute([$id]);
1142
+        $sth->execute([$id]);
1143 1143
 
1144
-		if ($row = $sth->fetch()) {
1144
+        if ($row = $sth->fetch()) {
1145 1145
 
1146
-			$title = $row["title"];
1147
-			$num_rules = $row["num_rules"];
1148
-			$num_actions = $row["num_actions"];
1149
-			$match_any_rule = $row["match_any_rule"];
1150
-			$inverse = $row["inverse"];
1146
+            $title = $row["title"];
1147
+            $num_rules = $row["num_rules"];
1148
+            $num_actions = $row["num_actions"];
1149
+            $match_any_rule = $row["match_any_rule"];
1150
+            $inverse = $row["inverse"];
1151 1151
 
1152
-			if (!$title) {
1153
-			    $title = __("[No caption]");
1154
-			}
1152
+            if (!$title) {
1153
+                $title = __("[No caption]");
1154
+            }
1155 1155
 
1156
-			$title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules);
1156
+            $title = sprintf(_ngettext("%s (%d rule)", "%s (%d rules)", (int) $num_rules), $title, $num_rules);
1157 1157
 
1158
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
1158
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
1159 1159
 				WHERE filter_id = ? ORDER BY id LIMIT 1");
1160
-			$sth->execute([$id]);
1160
+            $sth->execute([$id]);
1161 1161
 
1162
-			$actions = "";
1162
+            $actions = "";
1163 1163
 
1164
-			if ($line = $sth->fetch()) {
1165
-				$actions = $this->getActionName($line);
1164
+            if ($line = $sth->fetch()) {
1165
+                $actions = $this->getActionName($line);
1166 1166
 
1167
-				$num_actions -= 1;
1168
-			}
1167
+                $num_actions -= 1;
1168
+            }
1169 1169
 
1170
-			if ($match_any_rule) $title .= " (".__("matches any rule").")";
1171
-			if ($inverse) $title .= " (".__("inverse").")";
1170
+            if ($match_any_rule) $title .= " (".__("matches any rule").")";
1171
+            if ($inverse) $title .= " (".__("inverse").")";
1172 1172
 
1173
-			if ($num_actions > 0)
1174
-				$actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions);
1173
+            if ($num_actions > 0)
1174
+                $actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions);
1175 1175
 
1176
-			return [$title, $actions];
1177
-		}
1176
+            return [$title, $actions];
1177
+        }
1178 1178
 
1179
-		return [];
1180
-	}
1179
+        return [];
1180
+    }
1181 1181
 
1182
-	public function join() {
1183
-		$ids = explode(",", clean($_REQUEST["ids"]));
1182
+    public function join() {
1183
+        $ids = explode(",", clean($_REQUEST["ids"]));
1184 1184
 
1185
-		if (count($ids) > 1) {
1186
-			$base_id = array_shift($ids);
1187
-			$ids_qmarks = arr_qmarks($ids);
1185
+        if (count($ids) > 1) {
1186
+            $base_id = array_shift($ids);
1187
+            $ids_qmarks = arr_qmarks($ids);
1188 1188
 
1189
-			$this->pdo->beginTransaction();
1189
+            $this->pdo->beginTransaction();
1190 1190
 
1191
-			$sth = $this->pdo->prepare("UPDATE ttrss_filters2_rules
1191
+            $sth = $this->pdo->prepare("UPDATE ttrss_filters2_rules
1192 1192
 				SET filter_id = ? WHERE filter_id IN ($ids_qmarks)");
1193
-			$sth->execute(array_merge([$base_id], $ids));
1193
+            $sth->execute(array_merge([$base_id], $ids));
1194 1194
 
1195
-			$sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions
1195
+            $sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions
1196 1196
 				SET filter_id = ? WHERE filter_id IN ($ids_qmarks)");
1197
-			$sth->execute(array_merge([$base_id], $ids));
1197
+            $sth->execute(array_merge([$base_id], $ids));
1198 1198
 
1199
-			$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)");
1200
-			$sth->execute($ids);
1199
+            $sth = $this->pdo->prepare("DELETE FROM ttrss_filters2 WHERE id IN ($ids_qmarks)");
1200
+            $sth->execute($ids);
1201 1201
 
1202
-			$sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = ?");
1203
-			$sth->execute([$base_id]);
1202
+            $sth = $this->pdo->prepare("UPDATE ttrss_filters2 SET match_any_rule = true WHERE id = ?");
1203
+            $sth->execute([$base_id]);
1204 1204
 
1205
-			$this->pdo->commit();
1205
+            $this->pdo->commit();
1206 1206
 
1207
-			$this->optimizeFilter($base_id);
1207
+            $this->optimizeFilter($base_id);
1208 1208
 
1209
-		}
1210
-	}
1209
+        }
1210
+    }
1211 1211
 
1212
-	private function optimizeFilter($id) {
1212
+    private function optimizeFilter($id) {
1213 1213
 
1214
-		$this->pdo->beginTransaction();
1214
+        $this->pdo->beginTransaction();
1215 1215
 
1216
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
1216
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
1217 1217
 			WHERE filter_id = ?");
1218
-		$sth->execute([$id]);
1218
+        $sth->execute([$id]);
1219 1219
 
1220
-		$tmp = array();
1221
-		$dupe_ids = array();
1220
+        $tmp = array();
1221
+        $dupe_ids = array();
1222 1222
 
1223
-		while ($line = $sth->fetch()) {
1224
-			$id = $line["id"];
1225
-			unset($line["id"]);
1223
+        while ($line = $sth->fetch()) {
1224
+            $id = $line["id"];
1225
+            unset($line["id"]);
1226 1226
 
1227
-			if (array_search($line, $tmp) === false) {
1228
-				array_push($tmp, $line);
1229
-			} else {
1230
-				array_push($dupe_ids, $id);
1231
-			}
1232
-		}
1227
+            if (array_search($line, $tmp) === false) {
1228
+                array_push($tmp, $line);
1229
+            } else {
1230
+                array_push($dupe_ids, $id);
1231
+            }
1232
+        }
1233 1233
 
1234
-		if (count($dupe_ids) > 0) {
1235
-			$ids_str = join(",", $dupe_ids);
1234
+        if (count($dupe_ids) > 0) {
1235
+            $ids_str = join(",", $dupe_ids);
1236 1236
 
1237
-			$this->pdo->query("DELETE FROM ttrss_filters2_actions WHERE id IN ($ids_str)");
1238
-		}
1237
+            $this->pdo->query("DELETE FROM ttrss_filters2_actions WHERE id IN ($ids_str)");
1238
+        }
1239 1239
 
1240
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
1240
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
1241 1241
 			WHERE filter_id = ?");
1242
-		$sth->execute([$id]);
1242
+        $sth->execute([$id]);
1243 1243
 
1244
-		$tmp = array();
1245
-		$dupe_ids = array();
1244
+        $tmp = array();
1245
+        $dupe_ids = array();
1246 1246
 
1247
-		while ($line = $sth->fetch()) {
1248
-			$id = $line["id"];
1249
-			unset($line["id"]);
1247
+        while ($line = $sth->fetch()) {
1248
+            $id = $line["id"];
1249
+            unset($line["id"]);
1250 1250
 
1251
-			if (array_search($line, $tmp) === false) {
1252
-				array_push($tmp, $line);
1253
-			} else {
1254
-				array_push($dupe_ids, $id);
1255
-			}
1256
-		}
1251
+            if (array_search($line, $tmp) === false) {
1252
+                array_push($tmp, $line);
1253
+            } else {
1254
+                array_push($dupe_ids, $id);
1255
+            }
1256
+        }
1257 1257
 
1258
-		if (count($dupe_ids) > 0) {
1259
-			$ids_str = join(",", $dupe_ids);
1258
+        if (count($dupe_ids) > 0) {
1259
+            $ids_str = join(",", $dupe_ids);
1260 1260
 
1261
-			$this->pdo->query("DELETE FROM ttrss_filters2_rules WHERE id IN ($ids_str)");
1262
-		}
1261
+            $this->pdo->query("DELETE FROM ttrss_filters2_rules WHERE id IN ($ids_str)");
1262
+        }
1263 1263
 
1264
-		$this->pdo->commit();
1265
-	}
1264
+        $this->pdo->commit();
1265
+    }
1266 1266
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -16 removed lines patch added patch discarded remove patch
@@ -99,12 +99,16 @@  discard block
 block discarded – undo
99 99
 			}
100 100
 		}
101 101
 
102
-		if (count($scope_qparts) == 0) $scope_qparts = ["true"];
102
+		if (count($scope_qparts) == 0) {
103
+		    $scope_qparts = ["true"];
104
+		}
103 105
 
104 106
 		$glue = $filter['match_any_rule'] ? " OR " : " AND ";
105 107
 		$scope_qpart = join($glue, $scope_qparts);
106 108
 
107
-		if (!$scope_qpart) $scope_qpart = "true";
109
+		if (!$scope_qpart) {
110
+		    $scope_qpart = "true";
111
+		}
108 112
 
109 113
 		$rv = array();
110 114
 
@@ -209,10 +213,11 @@  discard block
 block discarded – undo
209 213
                         $feed_id = (int) substr($feed_id, 4);
210 214
                         array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id));
211 215
                     } else {
212
-                        if ($feed_id)
213
-                            array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id));
214
-                        else
215
-                            array_push($feeds_fmt, __("All feeds"));
216
+                        if ($feed_id) {
217
+                                                    array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id));
218
+                        } else {
219
+                                                    array_push($feeds_fmt, __("All feeds"));
220
+                        }
216 221
                     }
217 222
                 }
218 223
 
@@ -539,10 +544,11 @@  discard block
 block discarded – undo
539 544
                 $feed_id = (int) substr($feed_id, 4);
540 545
                 array_push($feeds_fmt, Feeds::getCategoryTitle($feed_id));
541 546
             } else {
542
-                if ($feed_id)
543
-                    array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id));
544
-                else
545
-                    array_push($feeds_fmt, __("All feeds"));
547
+                if ($feed_id) {
548
+                                    array_push($feeds_fmt, Feeds::getFeedTitle((int) $feed_id));
549
+                } else {
550
+                                    array_push($feeds_fmt, __("All feeds"));
551
+                }
546 552
             }
547 553
         }
548 554
 
@@ -581,8 +587,9 @@  discard block
 block discarded – undo
581 587
 			$title = __($row["description"]);
582 588
 
583 589
 			if ($action["action_id"] == 4 || $action["action_id"] == 6 ||
584
-				$action["action_id"] == 7)
585
-				$title .= ": ".$action["action_param"];
590
+				$action["action_id"] == 7) {
591
+							$title .= ": ".$action["action_param"];
592
+			}
586 593
 
587 594
 			if ($action["action_id"] == 9) {
588 595
 				list ($pfclass, $pfaction) = explode(":", $action["action_param"]);
@@ -1167,11 +1174,16 @@  discard block
 block discarded – undo
1167 1174
 				$num_actions -= 1;
1168 1175
 			}
1169 1176
 
1170
-			if ($match_any_rule) $title .= " (".__("matches any rule").")";
1171
-			if ($inverse) $title .= " (".__("inverse").")";
1177
+			if ($match_any_rule) {
1178
+			    $title .= " (".__("matches any rule").")";
1179
+			}
1180
+			if ($inverse) {
1181
+			    $title .= " (".__("inverse").")";
1182
+			}
1172 1183
 
1173
-			if ($num_actions > 0)
1174
-				$actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions);
1184
+			if ($num_actions > 0) {
1185
+							$actions = sprintf(_ngettext("%s (+%d action)", "%s (+%d actions)", (int) $num_actions), $actions, $num_actions);
1186
+			}
1175 1187
 
1176 1188
 			return [$title, $actions];
1177 1189
 		}
Please login to merge, or discard this patch.
classes/pref/prefs.php 2 patches
Indentation   +850 added lines, -850 removed lines patch added patch discarded remove patch
@@ -2,284 +2,284 @@  discard block
 block discarded – undo
2 2
 
3 3
 class Pref_Prefs extends Handler_Protected {
4 4
 
5
-	private $pref_help = [];
6
-	private $pref_item_map = [];
7
-	private $pref_blacklist = [];
8
-	private $profile_blacklist = [];
9
-
10
-	public function csrf_ignore($method) {
11
-		$csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles");
12
-
13
-		return array_search($method, $csrf_ignored) !== false;
14
-	}
15
-
16
-	public function __construct($args) {
17
-		parent::__construct($args);
18
-
19
-		$this->pref_item_map = [
20
-			__('General') => [
21
-				'USER_LANGUAGE',
22
-				'USER_TIMEZONE',
23
-				'BLOCK_SEPARATOR',
24
-				'USER_CSS_THEME',
25
-				'BLOCK_SEPARATOR',
26
-				'ENABLE_API_ACCESS',
27
-			],
28
-			__('Feeds') => [
29
-				'DEFAULT_UPDATE_INTERVAL',
30
-				'FRESH_ARTICLE_MAX_AGE',
31
-				'DEFAULT_SEARCH_LANGUAGE',
32
-				'BLOCK_SEPARATOR',
33
-				'ENABLE_FEED_CATS',
34
-				'BLOCK_SEPARATOR',
35
-				'CONFIRM_FEED_CATCHUP',
36
-				'ON_CATCHUP_SHOW_NEXT_FEED',
37
-				'BLOCK_SEPARATOR',
38
-				'HIDE_READ_FEEDS',
39
-				'HIDE_READ_SHOWS_SPECIAL',
40
-			],
41
-			__('Articles') => [
42
-				'PURGE_OLD_DAYS',
43
-				'PURGE_UNREAD_ARTICLES',
44
-				'BLOCK_SEPARATOR',
45
-				'COMBINED_DISPLAY_MODE',
46
-				'CDM_EXPANDED',
47
-				'BLOCK_SEPARATOR',
48
-				'CDM_AUTO_CATCHUP',
49
-				'VFEED_GROUP_BY_FEED',
50
-				'BLOCK_SEPARATOR',
51
-				'SHOW_CONTENT_PREVIEW',
52
-				'STRIP_IMAGES',
53
-			],
54
-			__('Digest') => [
55
-				'DIGEST_ENABLE',
56
-				'DIGEST_CATCHUP',
57
-				'DIGEST_PREFERRED_TIME',
58
-			],
59
-			__('Advanced') => [
60
-				'BLACKLISTED_TAGS',
61
-				'BLOCK_SEPARATOR',
62
-				'LONG_DATE_FORMAT',
63
-				'SHORT_DATE_FORMAT',
64
-				'BLOCK_SEPARATOR',
65
-				'SSL_CERT_SERIAL',
66
-			]
67
-		];
68
-
69
-		$this->pref_help = [
70
-			"ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""),
71
-			"BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("Never apply these tags automatically (comma-separated list).")),
72
-			"DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")),
73
-			"CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")),
74
-			"CDM_EXPANDED" => array(__("Always expand articles")),
75
-			"COMBINED_DISPLAY_MODE" => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")),
76
-			"CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feeds as read")),
77
-			"DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once")),
78
-			"DEFAULT_UPDATE_INTERVAL" => array(__("Default update interval")),
79
-			"DIGEST_CATCHUP" => array(__("Mark sent articles as read")),
80
-			"DIGEST_ENABLE" => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")),
81
-			"DIGEST_PREFERRED_TIME" => array(__("Try to send around this time"), __("Time in UTC")),
82
-			"ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")),
83
-			"ENABLE_FEED_CATS" => array(__("Enable categories")),
84
-			"FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""),
85
-			"FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>".__("hours")."</strong>"),
86
-			"HIDE_READ_FEEDS" => array(__("Hide read feeds")),
87
-			"HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")),
88
-			"LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")),
89
-			"ON_CATCHUP_SHOW_NEXT_FEED" => array(__("Automatically show next feed"), __("After marking one as read")),
90
-			"PURGE_OLD_DAYS" => array(__("Purge articles older than"), __("<strong>days</strong> (0 disables)")),
91
-			"PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles")),
92
-			"REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)")),
93
-			"SHORT_DATE_FORMAT" => array(__("Short date format")),
94
-			"SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines")),
95
-			"SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")),
96
-			"SSL_CERT_SERIAL" => array(__("SSL client certificate")),
97
-			"STRIP_IMAGES" => array(__("Do not embed media")),
98
-			"STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")),
99
-			"USER_STYLESHEET" => array(__("Customize stylesheet")),
100
-			"USER_TIMEZONE" => array(__("Time zone")),
101
-			"VFEED_GROUP_BY_FEED" => array(__("Group by feed"), __("Group multiple-feed output by originating feed")),
102
-			"USER_LANGUAGE" => array(__("Language")),
103
-			"USER_CSS_THEME" => array(__("Theme"))
104
-		];
105
-
106
-		$this->pref_blacklist = ["ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
107
-			"SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT",
108
-			"FEEDS_SORT_BY_UNREAD", "USER_STYLESHEET"];
109
-
110
-		/* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
111
-
112
-		$this->profile_blacklist = ["ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
113
-			"PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
114
-			"BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE",
115
-			"DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE",
116
-			"SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"];
117
-	}
118
-
119
-	public function changepassword() {
120
-
121
-		if (defined('_TTRSS_DEMO_INSTANCE')) {
122
-			print "ERROR: ".format_error("Disabled in demo version.");
123
-			return;
124
-		}
125
-
126
-		$old_pw = clean($_POST["old_password"]);
127
-		$new_pw = clean($_POST["new_password"]);
128
-		$con_pw = clean($_POST["confirm_password"]);
129
-
130
-		if ($old_pw == $new_pw) {
131
-			print "ERROR: ".format_error("New password must be different from the old one.");
132
-			return;
133
-		}
134
-
135
-		if ($old_pw == "") {
136
-			print "ERROR: ".format_error("Old password cannot be blank.");
137
-			return;
138
-		}
139
-
140
-		if ($new_pw == "") {
141
-			print "ERROR: ".format_error("New password cannot be blank.");
142
-			return;
143
-		}
144
-
145
-		if ($new_pw != $con_pw) {
146
-			print "ERROR: ".format_error("Entered passwords do not match.");
147
-			return;
148
-		}
149
-
150
-		$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
151
-
152
-		if (method_exists($authenticator, "change_password")) {
153
-			print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw));
154
-		} else {
155
-			print "ERROR: ".format_error("Function not supported by authentication module.");
156
-		}
157
-	}
158
-
159
-	public function saveconfig() {
160
-		$boolean_prefs = explode(",", clean($_POST["boolean_prefs"]));
161
-
162
-		foreach ($boolean_prefs as $pref) {
163
-			if (!isset($_POST[$pref])) {
164
-			    $_POST[$pref] = 'false';
165
-			}
166
-		}
167
-
168
-		$need_reload = false;
169
-
170
-		foreach (array_keys($_POST) as $pref_name) {
171
-
172
-			$value = $_POST[$pref_name];
173
-
174
-			switch ($pref_name) {
175
-				case 'DIGEST_PREFERRED_TIME':
176
-					if (get_pref('DIGEST_PREFERRED_TIME') != $value) {
177
-
178
-						$sth = $this->pdo->prepare("UPDATE ttrss_users SET
5
+    private $pref_help = [];
6
+    private $pref_item_map = [];
7
+    private $pref_blacklist = [];
8
+    private $profile_blacklist = [];
9
+
10
+    public function csrf_ignore($method) {
11
+        $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles");
12
+
13
+        return array_search($method, $csrf_ignored) !== false;
14
+    }
15
+
16
+    public function __construct($args) {
17
+        parent::__construct($args);
18
+
19
+        $this->pref_item_map = [
20
+            __('General') => [
21
+                'USER_LANGUAGE',
22
+                'USER_TIMEZONE',
23
+                'BLOCK_SEPARATOR',
24
+                'USER_CSS_THEME',
25
+                'BLOCK_SEPARATOR',
26
+                'ENABLE_API_ACCESS',
27
+            ],
28
+            __('Feeds') => [
29
+                'DEFAULT_UPDATE_INTERVAL',
30
+                'FRESH_ARTICLE_MAX_AGE',
31
+                'DEFAULT_SEARCH_LANGUAGE',
32
+                'BLOCK_SEPARATOR',
33
+                'ENABLE_FEED_CATS',
34
+                'BLOCK_SEPARATOR',
35
+                'CONFIRM_FEED_CATCHUP',
36
+                'ON_CATCHUP_SHOW_NEXT_FEED',
37
+                'BLOCK_SEPARATOR',
38
+                'HIDE_READ_FEEDS',
39
+                'HIDE_READ_SHOWS_SPECIAL',
40
+            ],
41
+            __('Articles') => [
42
+                'PURGE_OLD_DAYS',
43
+                'PURGE_UNREAD_ARTICLES',
44
+                'BLOCK_SEPARATOR',
45
+                'COMBINED_DISPLAY_MODE',
46
+                'CDM_EXPANDED',
47
+                'BLOCK_SEPARATOR',
48
+                'CDM_AUTO_CATCHUP',
49
+                'VFEED_GROUP_BY_FEED',
50
+                'BLOCK_SEPARATOR',
51
+                'SHOW_CONTENT_PREVIEW',
52
+                'STRIP_IMAGES',
53
+            ],
54
+            __('Digest') => [
55
+                'DIGEST_ENABLE',
56
+                'DIGEST_CATCHUP',
57
+                'DIGEST_PREFERRED_TIME',
58
+            ],
59
+            __('Advanced') => [
60
+                'BLACKLISTED_TAGS',
61
+                'BLOCK_SEPARATOR',
62
+                'LONG_DATE_FORMAT',
63
+                'SHORT_DATE_FORMAT',
64
+                'BLOCK_SEPARATOR',
65
+                'SSL_CERT_SERIAL',
66
+            ]
67
+        ];
68
+
69
+        $this->pref_help = [
70
+            "ALLOW_DUPLICATE_POSTS" => array(__("Allow duplicate articles"), ""),
71
+            "BLACKLISTED_TAGS" => array(__("Blacklisted tags"), __("Never apply these tags automatically (comma-separated list).")),
72
+            "DEFAULT_SEARCH_LANGUAGE" => array(__("Default language"), __("Used for full-text search")),
73
+            "CDM_AUTO_CATCHUP" => array(__("Mark read on scroll"), __("Mark articles as read as you scroll past them")),
74
+            "CDM_EXPANDED" => array(__("Always expand articles")),
75
+            "COMBINED_DISPLAY_MODE" => array(__("Combined mode"), __("Show flat list of articles instead of separate panels")),
76
+            "CONFIRM_FEED_CATCHUP" => array(__("Confirm marking feeds as read")),
77
+            "DEFAULT_ARTICLE_LIMIT" => array(__("Amount of articles to display at once")),
78
+            "DEFAULT_UPDATE_INTERVAL" => array(__("Default update interval")),
79
+            "DIGEST_CATCHUP" => array(__("Mark sent articles as read")),
80
+            "DIGEST_ENABLE" => array(__("Enable digest"), __("Send daily digest of new (and unread) headlines to your e-mail address")),
81
+            "DIGEST_PREFERRED_TIME" => array(__("Try to send around this time"), __("Time in UTC")),
82
+            "ENABLE_API_ACCESS" => array(__("Enable API"), __("Allows accessing this account through the API")),
83
+            "ENABLE_FEED_CATS" => array(__("Enable categories")),
84
+            "FEEDS_SORT_BY_UNREAD" => array(__("Sort feeds by unread articles count"), ""),
85
+            "FRESH_ARTICLE_MAX_AGE" => array(__("Maximum age of fresh articles"), "<strong>".__("hours")."</strong>"),
86
+            "HIDE_READ_FEEDS" => array(__("Hide read feeds")),
87
+            "HIDE_READ_SHOWS_SPECIAL" => array(__("Always show special feeds"), __("While hiding read feeds")),
88
+            "LONG_DATE_FORMAT" => array(__("Long date format"), __("Syntax is identical to PHP <a href='http://php.net/manual/function.date.php'>date()</a> function.")),
89
+            "ON_CATCHUP_SHOW_NEXT_FEED" => array(__("Automatically show next feed"), __("After marking one as read")),
90
+            "PURGE_OLD_DAYS" => array(__("Purge articles older than"), __("<strong>days</strong> (0 disables)")),
91
+            "PURGE_UNREAD_ARTICLES" => array(__("Purge unread articles")),
92
+            "REVERSE_HEADLINES" => array(__("Reverse headline order (oldest first)")),
93
+            "SHORT_DATE_FORMAT" => array(__("Short date format")),
94
+            "SHOW_CONTENT_PREVIEW" => array(__("Show content preview in headlines")),
95
+            "SORT_HEADLINES_BY_FEED_DATE" => array(__("Sort headlines by feed date"), __("Use feed-specified date to sort headlines instead of local import date.")),
96
+            "SSL_CERT_SERIAL" => array(__("SSL client certificate")),
97
+            "STRIP_IMAGES" => array(__("Do not embed media")),
98
+            "STRIP_UNSAFE_TAGS" => array(__("Strip unsafe tags from articles"), __("Strip all but most common HTML tags when reading articles.")),
99
+            "USER_STYLESHEET" => array(__("Customize stylesheet")),
100
+            "USER_TIMEZONE" => array(__("Time zone")),
101
+            "VFEED_GROUP_BY_FEED" => array(__("Group by feed"), __("Group multiple-feed output by originating feed")),
102
+            "USER_LANGUAGE" => array(__("Language")),
103
+            "USER_CSS_THEME" => array(__("Theme"))
104
+        ];
105
+
106
+        $this->pref_blacklist = ["ALLOW_DUPLICATE_POSTS", "STRIP_UNSAFE_TAGS", "REVERSE_HEADLINES",
107
+            "SORT_HEADLINES_BY_FEED_DATE", "DEFAULT_ARTICLE_LIMIT",
108
+            "FEEDS_SORT_BY_UNREAD", "USER_STYLESHEET"];
109
+
110
+        /* "FEEDS_SORT_BY_UNREAD", "HIDE_READ_FEEDS", "REVERSE_HEADLINES" */
111
+
112
+        $this->profile_blacklist = ["ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
113
+            "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",
114
+            "BLACKLISTED_TAGS", "ENABLE_API_ACCESS", "UPDATE_POST_ON_CHECKSUM_CHANGE",
115
+            "DEFAULT_UPDATE_INTERVAL", "USER_TIMEZONE", "SORT_HEADLINES_BY_FEED_DATE",
116
+            "SSL_CERT_SERIAL", "DIGEST_PREFERRED_TIME"];
117
+    }
118
+
119
+    public function changepassword() {
120
+
121
+        if (defined('_TTRSS_DEMO_INSTANCE')) {
122
+            print "ERROR: ".format_error("Disabled in demo version.");
123
+            return;
124
+        }
125
+
126
+        $old_pw = clean($_POST["old_password"]);
127
+        $new_pw = clean($_POST["new_password"]);
128
+        $con_pw = clean($_POST["confirm_password"]);
129
+
130
+        if ($old_pw == $new_pw) {
131
+            print "ERROR: ".format_error("New password must be different from the old one.");
132
+            return;
133
+        }
134
+
135
+        if ($old_pw == "") {
136
+            print "ERROR: ".format_error("Old password cannot be blank.");
137
+            return;
138
+        }
139
+
140
+        if ($new_pw == "") {
141
+            print "ERROR: ".format_error("New password cannot be blank.");
142
+            return;
143
+        }
144
+
145
+        if ($new_pw != $con_pw) {
146
+            print "ERROR: ".format_error("Entered passwords do not match.");
147
+            return;
148
+        }
149
+
150
+        $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
151
+
152
+        if (method_exists($authenticator, "change_password")) {
153
+            print format_notice($authenticator->change_password($_SESSION["uid"], $old_pw, $new_pw));
154
+        } else {
155
+            print "ERROR: ".format_error("Function not supported by authentication module.");
156
+        }
157
+    }
158
+
159
+    public function saveconfig() {
160
+        $boolean_prefs = explode(",", clean($_POST["boolean_prefs"]));
161
+
162
+        foreach ($boolean_prefs as $pref) {
163
+            if (!isset($_POST[$pref])) {
164
+                $_POST[$pref] = 'false';
165
+            }
166
+        }
167
+
168
+        $need_reload = false;
169
+
170
+        foreach (array_keys($_POST) as $pref_name) {
171
+
172
+            $value = $_POST[$pref_name];
173
+
174
+            switch ($pref_name) {
175
+                case 'DIGEST_PREFERRED_TIME':
176
+                    if (get_pref('DIGEST_PREFERRED_TIME') != $value) {
177
+
178
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users SET
179 179
 						last_digest_sent = NULL WHERE id = ?");
180
-						$sth->execute([$_SESSION['uid']]);
180
+                        $sth->execute([$_SESSION['uid']]);
181 181
 
182
-					}
183
-					break;
184
-				case 'USER_LANGUAGE':
185
-					if (!$need_reload) {
186
-					    $need_reload = $_SESSION["language"] != $value;
187
-					}
188
-					break;
182
+                    }
183
+                    break;
184
+                case 'USER_LANGUAGE':
185
+                    if (!$need_reload) {
186
+                        $need_reload = $_SESSION["language"] != $value;
187
+                    }
188
+                    break;
189 189
 
190
-				case 'USER_CSS_THEME':
191
-					if (!$need_reload) {
192
-					    $need_reload = get_pref($pref_name) != $value;
193
-					}
194
-					break;
195
-			}
190
+                case 'USER_CSS_THEME':
191
+                    if (!$need_reload) {
192
+                        $need_reload = get_pref($pref_name) != $value;
193
+                    }
194
+                    break;
195
+            }
196 196
 
197
-			set_pref($pref_name, $value);
198
-		}
197
+            set_pref($pref_name, $value);
198
+        }
199 199
 
200
-		if ($need_reload) {
201
-			print "PREFS_NEED_RELOAD";
202
-		} else {
203
-			print __("The configuration was saved.");
204
-		}
205
-	}
200
+        if ($need_reload) {
201
+            print "PREFS_NEED_RELOAD";
202
+        } else {
203
+            print __("The configuration was saved.");
204
+        }
205
+    }
206 206
 
207
-	public function changeemail() {
207
+    public function changeemail() {
208 208
 
209
-		$email = clean($_POST["email"]);
210
-		$full_name = clean($_POST["full_name"]);
211
-		$active_uid = $_SESSION["uid"];
209
+        $email = clean($_POST["email"]);
210
+        $full_name = clean($_POST["full_name"]);
211
+        $active_uid = $_SESSION["uid"];
212 212
 
213
-		$sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?");
214
-		$sth->execute([$active_uid]);
213
+        $sth = $this->pdo->prepare("SELECT email, login, full_name FROM ttrss_users WHERE id = ?");
214
+        $sth->execute([$active_uid]);
215 215
 
216
-		if ($row = $sth->fetch()) {
217
-			$old_email = $row["email"];
216
+        if ($row = $sth->fetch()) {
217
+            $old_email = $row["email"];
218 218
 
219
-			if ($old_email != $email) {
220
-				$mailer = new Mailer();
219
+            if ($old_email != $email) {
220
+                $mailer = new Mailer();
221 221
 
222
-				require_once "lib/MiniTemplator.class.php";
222
+                require_once "lib/MiniTemplator.class.php";
223 223
 
224
-				$tpl = new MiniTemplator;
224
+                $tpl = new MiniTemplator;
225 225
 
226
-				$tpl->readTemplateFromFile("templates/mail_change_template.txt");
226
+                $tpl->readTemplateFromFile("templates/mail_change_template.txt");
227 227
 
228
-				$tpl->setVariable('LOGIN', $row["login"]);
229
-				$tpl->setVariable('NEWMAIL', $email);
230
-				$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
228
+                $tpl->setVariable('LOGIN', $row["login"]);
229
+                $tpl->setVariable('NEWMAIL', $email);
230
+                $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
231 231
 
232
-				$tpl->addBlock('message');
232
+                $tpl->addBlock('message');
233 233
 
234
-				$tpl->generateOutputToString($message);
234
+                $tpl->generateOutputToString($message);
235 235
 
236
-				$mailer->mail(["to_name" => $row["login"],
237
-					"to_address" => $row["email"],
238
-					"subject" => "[tt-rss] Mail address change notification",
239
-					"message" => $message]);
236
+                $mailer->mail(["to_name" => $row["login"],
237
+                    "to_address" => $row["email"],
238
+                    "subject" => "[tt-rss] Mail address change notification",
239
+                    "message" => $message]);
240 240
 
241
-			}
242
-		}
241
+            }
242
+        }
243 243
 
244
-		$sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?,
244
+        $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ?,
245 245
 			full_name = ? WHERE id = ?");
246
-		$sth->execute([$email, $full_name, $active_uid]);
246
+        $sth->execute([$email, $full_name, $active_uid]);
247 247
 
248
-		print __("Your personal data has been saved.");
248
+        print __("Your personal data has been saved.");
249 249
 
250
-		return;
251
-	}
250
+        return;
251
+    }
252 252
 
253
-	public function resetconfig() {
253
+    public function resetconfig() {
254 254
 
255
-		$_SESSION["prefs_op_result"] = "reset-to-defaults";
255
+        $_SESSION["prefs_op_result"] = "reset-to-defaults";
256 256
 
257
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs
257
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_user_prefs
258 258
 			WHERE (profile = :profile OR (:profile IS NULL AND profile IS NULL))
259 259
 				AND owner_uid = :uid");
260
-		$sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]);
260
+        $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]);
261 261
 
262
-		initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
262
+        initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
263 263
 
264
-		echo __("Your preferences are now set to default values.");
265
-	}
264
+        echo __("Your preferences are now set to default values.");
265
+    }
266 266
 
267
-	public function index() {
267
+    public function index() {
268 268
 
269
-		global $access_level_names;
269
+        global $access_level_names;
270 270
 
271
-		$_SESSION["prefs_op_result"] = "";
271
+        $_SESSION["prefs_op_result"] = "";
272 272
 
273
-		print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
274
-		print "<div dojoType='dijit.layout.AccordionPane'
273
+        print "<div dojoType='dijit.layout.AccordionContainer' region='center'>";
274
+        print "<div dojoType='dijit.layout.AccordionPane'
275 275
 			title=\"<i class='material-icons'>person</i> ".__('Personal data / Authentication')."\">";
276 276
 
277
-		print "<div dojoType='dijit.layout.TabContainer'>";
278
-		print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Personal data')."\">";
277
+        print "<div dojoType='dijit.layout.TabContainer'>";
278
+        print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Personal data')."\">";
279 279
 
280
-		print "<form dojoType='dijit.form.Form' id='changeUserdataForm'>";
280
+        print "<form dojoType='dijit.form.Form' id='changeUserdataForm'>";
281 281
 
282
-		print "<script type='dojo/method' event='onSubmit' args='evt'>
282
+        print "<script type='dojo/method' event='onSubmit' args='evt'>
283 283
 		evt.preventDefault();
284 284
 		if (this.validate()) {
285 285
 			Notify.progress('Saving data...', true);
@@ -293,61 +293,61 @@  discard block
 block discarded – undo
293 293
 		}
294 294
 		</script>";
295 295
 
296
-		$sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled,
296
+        $sth = $this->pdo->prepare("SELECT email,full_name,otp_enabled,
297 297
 			access_level FROM ttrss_users
298 298
 			WHERE id = ?");
299
-		$sth->execute([$_SESSION["uid"]]);
300
-		$row = $sth->fetch();
301
-
302
-		$email = htmlspecialchars($row["email"]);
303
-		$full_name = htmlspecialchars($row["full_name"]);
304
-		$otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
305
-
306
-		print "<fieldset>";
307
-		print "<label>".__('Full name:')."</label>";
308
-		print "<input dojoType='dijit.form.ValidationTextBox' name='full_name' required='1' value='$full_name'>";
309
-		print "</fieldset>";
310
-
311
-		print "<fieldset>";
312
-		print "<label>".__('E-mail:')."</label>";
313
-		print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>";
314
-		print "</fieldset>";
315
-
316
-		if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
317
-
318
-			$access_level = $row["access_level"];
319
-			print "<fieldset>";
320
-			print "<label>".__('Access level:')."</label>";
321
-			print $access_level_names[$access_level];
322
-			print "</fieldset>";
323
-		}
299
+        $sth->execute([$_SESSION["uid"]]);
300
+        $row = $sth->fetch();
324 301
 
325
-		print_hidden("op", "pref-prefs");
326
-		print_hidden("method", "changeemail");
302
+        $email = htmlspecialchars($row["email"]);
303
+        $full_name = htmlspecialchars($row["full_name"]);
304
+        $otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
327 305
 
328
-		print "<hr/>";
306
+        print "<fieldset>";
307
+        print "<label>".__('Full name:')."</label>";
308
+        print "<input dojoType='dijit.form.ValidationTextBox' name='full_name' required='1' value='$full_name'>";
309
+        print "</fieldset>";
329 310
 
330
-		print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
331
-			__("Save data")."</button>";
311
+        print "<fieldset>";
312
+        print "<label>".__('E-mail:')."</label>";
313
+        print "<input dojoType='dijit.form.ValidationTextBox' name='email' required='1' value='$email'>";
314
+        print "</fieldset>";
332 315
 
333
-		print "</form>";
316
+        if (!SINGLE_USER_MODE && !$_SESSION["hide_hello"]) {
334 317
 
335
-		print "</div>"; # content pane
336
-		print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Password')."\">";
318
+            $access_level = $row["access_level"];
319
+            print "<fieldset>";
320
+            print "<label>".__('Access level:')."</label>";
321
+            print $access_level_names[$access_level];
322
+            print "</fieldset>";
323
+        }
337 324
 
338
-		if ($_SESSION["auth_module"]) {
339
-			$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
340
-		} else {
341
-			$authenticator = false;
342
-		}
325
+        print_hidden("op", "pref-prefs");
326
+        print_hidden("method", "changeemail");
327
+
328
+        print "<hr/>";
343 329
 
344
-		if ($authenticator && method_exists($authenticator, "change_password")) {
330
+        print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
331
+            __("Save data")."</button>";
345 332
 
346
-			print "<div style='display : none' id='pwd_change_infobox'></div>";
333
+        print "</form>";
347 334
 
348
-			print "<form dojoType='dijit.form.Form'>";
335
+        print "</div>"; # content pane
336
+        print "<div dojoType='dijit.layout.ContentPane' title=\"".__('Password')."\">";
349 337
 
350
-			print "<script type='dojo/method' event='onSubmit' args='evt'>
338
+        if ($_SESSION["auth_module"]) {
339
+            $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
340
+        } else {
341
+            $authenticator = false;
342
+        }
343
+
344
+        if ($authenticator && method_exists($authenticator, "change_password")) {
345
+
346
+            print "<div style='display : none' id='pwd_change_infobox'></div>";
347
+
348
+            print "<form dojoType='dijit.form.Form'>";
349
+
350
+            print "<script type='dojo/method' event='onSubmit' args='evt'>
351 351
 			evt.preventDefault();
352 352
 			if (this.validate()) {
353 353
 				Notify.progress('Changing password...', true);
@@ -376,71 +376,71 @@  discard block
 block discarded – undo
376 376
 			}
377 377
 			</script>";
378 378
 
379
-			if ($otp_enabled) {
380
-				print_notice(__("Changing your current password will disable OTP."));
381
-			}
379
+            if ($otp_enabled) {
380
+                print_notice(__("Changing your current password will disable OTP."));
381
+            }
382 382
 
383
-			print "<fieldset>";
384
-			print "<label>".__("Old password:")."</label>";
385
-			print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='old_password'>";
386
-			print "</fieldset>";
383
+            print "<fieldset>";
384
+            print "<label>".__("Old password:")."</label>";
385
+            print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='old_password'>";
386
+            print "</fieldset>";
387 387
 
388
-			print "<fieldset>";
389
-			print "<label>".__("New password:")."</label>";
390
-			print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='new_password'>";
391
-			print "</fieldset>";
388
+            print "<fieldset>";
389
+            print "<label>".__("New password:")."</label>";
390
+            print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='new_password'>";
391
+            print "</fieldset>";
392 392
 
393
-			print "<fieldset>";
394
-			print "<label>".__("Confirm password:")."</label>";
395
-			print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='confirm_password'>";
396
-			print "</fieldset>";
393
+            print "<fieldset>";
394
+            print "<label>".__("Confirm password:")."</label>";
395
+            print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='confirm_password'>";
396
+            print "</fieldset>";
397 397
 
398
-			print_hidden("op", "pref-prefs");
399
-			print_hidden("method", "changepassword");
398
+            print_hidden("op", "pref-prefs");
399
+            print_hidden("method", "changepassword");
400 400
 
401
-			print "<hr/>";
401
+            print "<hr/>";
402 402
 
403
-			print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
404
-				__("Change password")."</button>";
403
+            print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
404
+                __("Change password")."</button>";
405 405
 
406
-			print "</form>";
406
+            print "</form>";
407 407
 
408
-			print "</div>"; # content pane
408
+            print "</div>"; # content pane
409 409
 
410
-			if ($_SESSION["auth_module"] == "auth_internal") {
410
+            if ($_SESSION["auth_module"] == "auth_internal") {
411 411
 
412
-				print "<div dojoType='dijit.layout.ContentPane' title=\"".__('App passwords')."\">";
412
+                print "<div dojoType='dijit.layout.ContentPane' title=\"".__('App passwords')."\">";
413 413
 
414
-				print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP.");
414
+                print_notice("You can create separate passwords for API clients. Using one is required if you enable OTP.");
415 415
 
416
-				print "<div id='app_passwords_holder'>";
417
-				$this->appPasswordList();
418
-				print "</div>";
416
+                print "<div id='app_passwords_holder'>";
417
+                $this->appPasswordList();
418
+                print "</div>";
419 419
 
420
-				print "<hr>";
420
+                print "<hr>";
421 421
 
422
-				print "<button style='float : left' class='alt-primary' dojoType='dijit.form.Button'
422
+                print "<button style='float : left' class='alt-primary' dojoType='dijit.form.Button'
423 423
 					onclick=\"Helpers.AppPasswords.generate()\">" .
424
-					__('Generate new password')."</button> ";
424
+                    __('Generate new password')."</button> ";
425 425
 
426
-				print "<button style='float : left' class='alt-danger' dojoType='dijit.form.Button'
426
+                print "<button style='float : left' class='alt-danger' dojoType='dijit.form.Button'
427 427
 					onclick=\"Helpers.AppPasswords.removeSelected()\">" .
428
-					__('Remove selected passwords')."</button>";
428
+                    __('Remove selected passwords')."</button>";
429 429
 
430
-				print "</div>"; # content pane
431
-			}
430
+                print "</div>"; # content pane
431
+            }
432 432
 
433
-			print "<div dojoType='dijit.layout.ContentPane' title=\"".__('One time passwords / Authenticator')."\">";
433
+            print "<div dojoType='dijit.layout.ContentPane' title=\"".__('One time passwords / Authenticator')."\">";
434 434
 
435
-			if ($_SESSION["auth_module"] == "auth_internal") {
435
+            if ($_SESSION["auth_module"] == "auth_internal") {
436 436
 
437
-				if ($otp_enabled) {
437
+                if ($otp_enabled) {
438 438
 
439
-					print_warning("One time passwords are currently enabled. Enter your current password below to disable.");
439
+                    print_warning("One time passwords are currently enabled. Enter your current password below to disable.");
440 440
 
441
-					print "<form dojoType='dijit.form.Form'>";
441
+                    print "<form dojoType='dijit.form.Form'>";
442 442
 
443
-					print "<script type='dojo/method' event='onSubmit' args='evt'>
443
+                    print "<script type='dojo/method' event='onSubmit' args='evt'>
444 444
 					evt.preventDefault();
445 445
 					if (this.validate()) {
446 446
 						Notify.progress('Disabling OTP', true);
@@ -459,49 +459,49 @@  discard block
 block discarded – undo
459 459
 					}
460 460
 					</script>";
461 461
 
462
-					print "<fieldset>";
463
-					print "<label>".__("Your password:")."</label>";
464
-					print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='password'>";
465
-					print "</fieldset>";
462
+                    print "<fieldset>";
463
+                    print "<label>".__("Your password:")."</label>";
464
+                    print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='password'>";
465
+                    print "</fieldset>";
466 466
 
467
-					print_hidden("op", "pref-prefs");
468
-					print_hidden("method", "otpdisable");
467
+                    print_hidden("op", "pref-prefs");
468
+                    print_hidden("method", "otpdisable");
469 469
 
470
-					print "<hr/>";
470
+                    print "<hr/>";
471 471
 
472
-					print "<button dojoType='dijit.form.Button' type='submit'>".
473
-						__("Disable OTP")."</button>";
472
+                    print "<button dojoType='dijit.form.Button' type='submit'>".
473
+                        __("Disable OTP")."</button>";
474 474
 
475
-					print "</form>";
475
+                    print "</form>";
476 476
 
477
-				} else {
477
+                } else {
478 478
 
479
-					print_warning("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.");
480
-					print_notice("You will need to generate app passwords for the API clients if you enable OTP.");
479
+                    print_warning("You will need a compatible Authenticator to use this. Changing your password would automatically disable OTP.");
480
+                    print_notice("You will need to generate app passwords for the API clients if you enable OTP.");
481 481
 
482
-					if (function_exists("imagecreatefromstring")) {
483
-						print "<h3>".__("Scan the following code by the Authenticator application or copy the key manually")."</h3>";
482
+                    if (function_exists("imagecreatefromstring")) {
483
+                        print "<h3>".__("Scan the following code by the Authenticator application or copy the key manually")."</h3>";
484 484
 
485
-						$csrf_token = $_SESSION["csrf_token"];
486
-						print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>";
487
-					} else {
488
-						print_error("PHP GD functions are required to generate QR codes.");
489
-						print "<h3>".__("Use the following OTP key with a compatible Authenticator application")."</h3>";
490
-					}
485
+                        $csrf_token = $_SESSION["csrf_token"];
486
+                        print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>";
487
+                    } else {
488
+                        print_error("PHP GD functions are required to generate QR codes.");
489
+                        print "<h3>".__("Use the following OTP key with a compatible Authenticator application")."</h3>";
490
+                    }
491 491
 
492
-					print "<form dojoType='dijit.form.Form' id='changeOtpForm'>";
492
+                    print "<form dojoType='dijit.form.Form' id='changeOtpForm'>";
493 493
 
494
-					$otp_secret = $this->otpsecret();
494
+                    $otp_secret = $this->otpsecret();
495 495
 
496
-					print "<fieldset>";
497
-					print "<label>".__("OTP Key:")."</label>";
498
-					print "<input dojoType='dijit.form.ValidationTextBox' disabled='disabled' value='$otp_secret' size='32'>";
499
-					print "</fieldset>";
496
+                    print "<fieldset>";
497
+                    print "<label>".__("OTP Key:")."</label>";
498
+                    print "<input dojoType='dijit.form.ValidationTextBox' disabled='disabled' value='$otp_secret' size='32'>";
499
+                    print "</fieldset>";
500 500
 
501
-					print_hidden("op", "pref-prefs");
502
-					print_hidden("method", "otpenable");
501
+                    print_hidden("op", "pref-prefs");
502
+                    print_hidden("method", "otpenable");
503 503
 
504
-					print "<script type='dojo/method' event='onSubmit' args='evt'>
504
+                    print "<script type='dojo/method' event='onSubmit' args='evt'>
505 505
 					evt.preventDefault();
506 506
 					if (this.validate()) {
507 507
 						Notify.progress('Saving data...', true);
@@ -520,43 +520,43 @@  discard block
 block discarded – undo
520 520
 					}
521 521
 					</script>";
522 522
 
523
-					print "<fieldset>";
524
-					print "<label>".__("Your password:")."</label>";
525
-					print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1'
523
+                    print "<fieldset>";
524
+                    print "<label>".__("Your password:")."</label>";
525
+                    print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1'
526 526
 						name='password'>";
527
-					print "</fieldset>";
527
+                    print "</fieldset>";
528 528
 
529
-					print "<fieldset>";
530
-					print "<label>".__("One time password:")."</label>";
531
-					print "<input dojoType='dijit.form.ValidationTextBox' autocomplete='off'
529
+                    print "<fieldset>";
530
+                    print "<label>".__("One time password:")."</label>";
531
+                    print "<input dojoType='dijit.form.ValidationTextBox' autocomplete='off'
532 532
 						required='1' name='otp'>";
533
-					print "</fieldset>";
533
+                    print "</fieldset>";
534 534
 
535
-					print "<hr/>";
536
-					print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
537
-						__("Enable OTP")."</button>";
535
+                    print "<hr/>";
536
+                    print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".
537
+                        __("Enable OTP")."</button>";
538 538
 
539
-					print "</form>";
539
+                    print "</form>";
540 540
 
541
-				}
542
-			}
541
+                }
542
+            }
543 543
 
544
-			print "</div>"; # content pane
545
-			print "</div>"; # tab container
544
+            print "</div>"; # content pane
545
+            print "</div>"; # tab container
546 546
 
547
-		}
547
+        }
548 548
 
549
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
550
-			"hook_prefs_tab_section", "prefPrefsAuth");
549
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
550
+            "hook_prefs_tab_section", "prefPrefsAuth");
551 551
 
552
-		print "</div>"; #pane
552
+        print "</div>"; #pane
553 553
 
554
-		print "<div dojoType='dijit.layout.AccordionPane' selected='true'
554
+        print "<div dojoType='dijit.layout.AccordionPane' selected='true'
555 555
 			title=\"<i class='material-icons'>settings</i> ".__('Preferences')."\">";
556 556
 
557
-		print "<form dojoType='dijit.form.Form' id='changeSettingsForm'>";
557
+        print "<form dojoType='dijit.form.Form' id='changeSettingsForm'>";
558 558
 
559
-		print "<script type='dojo/method' event='onSubmit' args='evt, quit'>
559
+        print "<script type='dojo/method' event='onSubmit' args='evt, quit'>
560 560
 		if (evt) evt.preventDefault();
561 561
 		if (this.validate()) {
562 562
 			console.log(dojo.objectToQuery(this.getValues()));
@@ -578,23 +578,23 @@  discard block
 block discarded – undo
578 578
 		}
579 579
 		</script>";
580 580
 
581
-		print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
581
+        print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
582 582
 
583
-		print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
583
+        print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
584 584
 
585
-		$profile = $_SESSION["profile"];
585
+        $profile = $_SESSION["profile"];
586 586
 
587
-		if ($profile) {
588
-			print_notice(__("Some preferences are only available in default profile."));
587
+        if ($profile) {
588
+            print_notice(__("Some preferences are only available in default profile."));
589 589
 
590
-			initialize_user_prefs($_SESSION["uid"], $profile);
591
-		} else {
592
-			initialize_user_prefs($_SESSION["uid"]);
593
-		}
590
+            initialize_user_prefs($_SESSION["uid"], $profile);
591
+        } else {
592
+            initialize_user_prefs($_SESSION["uid"]);
593
+        }
594 594
 
595
-		$prefs_available = [];
595
+        $prefs_available = [];
596 596
 
597
-		$sth = $this->pdo->prepare("SELECT DISTINCT
597
+        $sth = $this->pdo->prepare("SELECT DISTINCT
598 598
 			ttrss_user_prefs.pref_name,value,type_name,
599 599
 			ttrss_prefs_sections.order_id,
600 600
 			def_value,section_id
@@ -605,235 +605,235 @@  discard block
 block discarded – undo
605 605
 				ttrss_user_prefs.pref_name = ttrss_prefs.pref_name AND
606 606
 				owner_uid = :uid
607 607
 			ORDER BY ttrss_prefs_sections.order_id,pref_name");
608
-		$sth->execute([":uid" => $_SESSION['uid'], ":profile" => $profile]);
608
+        $sth->execute([":uid" => $_SESSION['uid'], ":profile" => $profile]);
609 609
 
610
-		$listed_boolean_prefs = [];
610
+        $listed_boolean_prefs = [];
611 611
 
612
-		while ($line = $sth->fetch()) {
612
+        while ($line = $sth->fetch()) {
613 613
 
614
-			if (in_array($line["pref_name"], $this->pref_blacklist)) {
615
-				continue;
616
-			}
614
+            if (in_array($line["pref_name"], $this->pref_blacklist)) {
615
+                continue;
616
+            }
617 617
 
618
-			if ($profile && in_array($line["pref_name"], $this->profile_blacklist)) {
619
-				continue;
620
-			}
618
+            if ($profile && in_array($line["pref_name"], $this->profile_blacklist)) {
619
+                continue;
620
+            }
621 621
 
622
-			$pref_name = $line["pref_name"];
623
-			$short_desc = $this->getShortDesc($pref_name);
622
+            $pref_name = $line["pref_name"];
623
+            $short_desc = $this->getShortDesc($pref_name);
624 624
 
625
-			if (!$short_desc) {
626
-							continue;
627
-			}
625
+            if (!$short_desc) {
626
+                            continue;
627
+            }
628 628
 
629
-			$prefs_available[$pref_name] = [
630
-				'type_name' => $line["type_name"],
631
-				'value' => $line['value'],
632
-				'help_text' => $this->getHelpText($pref_name),
633
-				'short_desc' => $short_desc
634
-			];
635
-		}
629
+            $prefs_available[$pref_name] = [
630
+                'type_name' => $line["type_name"],
631
+                'value' => $line['value'],
632
+                'help_text' => $this->getHelpText($pref_name),
633
+                'short_desc' => $short_desc
634
+            ];
635
+        }
636 636
 
637
-		foreach (array_keys($this->pref_item_map) as $section) {
637
+        foreach (array_keys($this->pref_item_map) as $section) {
638 638
 
639
-			print "<h2>$section</h2>";
639
+            print "<h2>$section</h2>";
640 640
 
641
-			foreach ($this->pref_item_map[$section] as $pref_name) {
641
+            foreach ($this->pref_item_map[$section] as $pref_name) {
642 642
 
643
-				if ($pref_name == 'BLOCK_SEPARATOR' && !$profile) {
644
-					print "<hr/>";
645
-					continue;
646
-				}
643
+                if ($pref_name == 'BLOCK_SEPARATOR' && !$profile) {
644
+                    print "<hr/>";
645
+                    continue;
646
+                }
647 647
 
648
-				if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && DB_TYPE != "pgsql") {
649
-					continue;
650
-				}
648
+                if ($pref_name == "DEFAULT_SEARCH_LANGUAGE" && DB_TYPE != "pgsql") {
649
+                    continue;
650
+                }
651 651
 
652
-				if ($item = $prefs_available[$pref_name]) {
652
+                if ($item = $prefs_available[$pref_name]) {
653 653
 
654
-					print "<fieldset class='prefs'>";
654
+                    print "<fieldset class='prefs'>";
655 655
 
656
-					print "<label for='CB_$pref_name'>";
657
-					print $item['short_desc'].":";
658
-					print "</label>";
656
+                    print "<label for='CB_$pref_name'>";
657
+                    print $item['short_desc'].":";
658
+                    print "</label>";
659 659
 
660
-					$value = $item['value'];
661
-					$type_name = $item['type_name'];
660
+                    $value = $item['value'];
661
+                    $type_name = $item['type_name'];
662 662
 
663
-					if ($pref_name == "USER_LANGUAGE") {
664
-						print_select_hash($pref_name, $value, get_translations(),
665
-							"style='width : 220px; margin : 0px' dojoType='fox.form.Select'");
663
+                    if ($pref_name == "USER_LANGUAGE") {
664
+                        print_select_hash($pref_name, $value, get_translations(),
665
+                            "style='width : 220px; margin : 0px' dojoType='fox.form.Select'");
666 666
 
667
-					} else if ($pref_name == "USER_TIMEZONE") {
667
+                    } else if ($pref_name == "USER_TIMEZONE") {
668 668
 
669
-						$timezones = explode("\n", file_get_contents("lib/timezones.txt"));
669
+                        $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
670 670
 
671
-						print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
672
-					} else if ($pref_name == "USER_CSS_THEME") {
671
+                        print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
672
+                    } else if ($pref_name == "USER_CSS_THEME") {
673 673
 
674
-						$themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css"));
675
-						$themes = array_map("basename", $themes);
676
-						$themes = array_filter($themes, "theme_exists");
677
-						asort($themes);
674
+                        $themes = array_merge(glob("themes/*.php"), glob("themes/*.css"), glob("themes.local/*.css"));
675
+                        $themes = array_map("basename", $themes);
676
+                        $themes = array_filter($themes, "theme_exists");
677
+                        asort($themes);
678 678
 
679
-						if (!theme_exists($value)) {
680
-						    $value = "default.php";
681
-						}
679
+                        if (!theme_exists($value)) {
680
+                            $value = "default.php";
681
+                        }
682 682
 
683
-						print "<select name='$pref_name' id='$pref_name' dojoType='fox.form.Select'>";
683
+                        print "<select name='$pref_name' id='$pref_name' dojoType='fox.form.Select'>";
684 684
 
685
-						$issel = $value == "default.php" ? "selected='selected'" : "";
686
-						print "<option $issel value='default.php'>".__("default")."</option>";
685
+                        $issel = $value == "default.php" ? "selected='selected'" : "";
686
+                        print "<option $issel value='default.php'>".__("default")."</option>";
687 687
 
688
-						foreach ($themes as $theme) {
689
-							$issel = $value == $theme ? "selected='selected'" : "";
690
-							print "<option $issel value='$theme'>$theme</option>";
691
-						}
688
+                        foreach ($themes as $theme) {
689
+                            $issel = $value == $theme ? "selected='selected'" : "";
690
+                            print "<option $issel value='$theme'>$theme</option>";
691
+                        }
692 692
 
693
-						print "</select>";
693
+                        print "</select>";
694 694
 
695
-						print " <button dojoType=\"dijit.form.Button\" class='alt-info'
695
+                        print " <button dojoType=\"dijit.form.Button\" class='alt-info'
696 696
 							onclick=\"Helpers.customizeCSS()\">" . __('Customize')."</button>";
697 697
 
698
-						print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'>
698
+                        print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'>
699 699
 							<i class='material-icons'>open_in_new</i> ".__("More themes...")."</button>";
700 700
 
701
-					} else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
701
+                    } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
702 702
 
703
-						global $update_intervals_nodefault;
703
+                        global $update_intervals_nodefault;
704 704
 
705
-						print_select_hash($pref_name, $value, $update_intervals_nodefault,
706
-							'dojoType="fox.form.Select"');
707
-					} else if ($pref_name == "DEFAULT_SEARCH_LANGUAGE") {
705
+                        print_select_hash($pref_name, $value, $update_intervals_nodefault,
706
+                            'dojoType="fox.form.Select"');
707
+                    } else if ($pref_name == "DEFAULT_SEARCH_LANGUAGE") {
708 708
 
709
-						print_select($pref_name, $value, Pref_Feeds::get_ts_languages(),
710
-							'dojoType="fox.form.Select"');
709
+                        print_select($pref_name, $value, Pref_Feeds::get_ts_languages(),
710
+                            'dojoType="fox.form.Select"');
711 711
 
712
-					} else if ($type_name == "bool") {
712
+                    } else if ($type_name == "bool") {
713 713
 
714
-						array_push($listed_boolean_prefs, $pref_name);
714
+                        array_push($listed_boolean_prefs, $pref_name);
715 715
 
716
-						$checked = ($value == "true") ? "checked=\"checked\"" : "";
716
+                        $checked = ($value == "true") ? "checked=\"checked\"" : "";
717 717
 
718
-						if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
719
-							$disabled = "disabled=\"1\"";
720
-							$checked = "checked=\"checked\"";
721
-						} else {
722
-							$disabled = "";
723
-						}
718
+                        if ($pref_name == "PURGE_UNREAD_ARTICLES" && FORCE_ARTICLE_PURGE != 0) {
719
+                            $disabled = "disabled=\"1\"";
720
+                            $checked = "checked=\"checked\"";
721
+                        } else {
722
+                            $disabled = "";
723
+                        }
724 724
 
725
-						print "<input type='checkbox' name='$pref_name' $checked $disabled
725
+                        print "<input type='checkbox' name='$pref_name' $checked $disabled
726 726
 							dojoType='dijit.form.CheckBox' id='CB_$pref_name' value='1'>";
727 727
 
728
-					} else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE',
729
-							'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
728
+                    } else if (array_search($pref_name, array('FRESH_ARTICLE_MAX_AGE',
729
+                            'PURGE_OLD_DAYS', 'LONG_DATE_FORMAT', 'SHORT_DATE_FORMAT')) !== false) {
730 730
 
731
-						$regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
731
+                        $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
732 732
 
733
-						if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
734
-							$disabled = "disabled='1'";
735
-							$value = FORCE_ARTICLE_PURGE;
736
-						} else {
737
-							$disabled = "";
738
-						}
733
+                        if ($pref_name == "PURGE_OLD_DAYS" && FORCE_ARTICLE_PURGE != 0) {
734
+                            $disabled = "disabled='1'";
735
+                            $value = FORCE_ARTICLE_PURGE;
736
+                        } else {
737
+                            $disabled = "";
738
+                        }
739 739
 
740
-						if ($type_name == 'integer') {
741
-													print "<input dojoType=\"dijit.form.NumberSpinner\"
740
+                        if ($type_name == 'integer') {
741
+                                                    print "<input dojoType=\"dijit.form.NumberSpinner\"
742 742
 								required='1' $disabled
743 743
 								name=\"$pref_name\" value=\"$value\">";
744
-						} else {
745
-													print "<input dojoType=\"dijit.form.TextBox\"
744
+                        } else {
745
+                                                    print "<input dojoType=\"dijit.form.TextBox\"
746 746
 								required='1' $regexp $disabled
747 747
 								name=\"$pref_name\" value=\"$value\">";
748
-						}
748
+                        }
749 749
 
750
-					} else if ($pref_name == "SSL_CERT_SERIAL") {
750
+                    } else if ($pref_name == "SSL_CERT_SERIAL") {
751 751
 
752
-						print "<input dojoType='dijit.form.ValidationTextBox'
752
+                        print "<input dojoType='dijit.form.ValidationTextBox'
753 753
 							id='SSL_CERT_SERIAL' readonly='1'
754 754
 							name=\"$pref_name\" value=\"$value\">";
755 755
 
756
-						$cert_serial = htmlspecialchars(get_ssl_certificate_id());
757
-						$has_serial = ($cert_serial) ? "false" : "true";
756
+                        $cert_serial = htmlspecialchars(get_ssl_certificate_id());
757
+                        $has_serial = ($cert_serial) ? "false" : "true";
758 758
 
759
-						print "<button dojoType='dijit.form.Button' disabled='$has_serial'
759
+                        print "<button dojoType='dijit.form.Button' disabled='$has_serial'
760 760
 							onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '$cert_serial')\">".
761
-							__('Register')."</button>";
761
+                            __('Register')."</button>";
762 762
 
763
-						print "<button dojoType='dijit.form.Button' class='alt-danger'
763
+                        print "<button dojoType='dijit.form.Button' class='alt-danger'
764 764
 							onclick=\"dijit.byId('SSL_CERT_SERIAL').attr('value', '')\">" .
765
-							__('Clear')."</button>";
765
+                            __('Clear')."</button>";
766 766
 
767
-						print "<button dojoType='dijit.form.Button' class='alt-info'
767
+                        print "<button dojoType='dijit.form.Button' class='alt-info'
768 768
 							onclick='window.open(\"https://tt-rss.org/wiki/SSL%20Certificate%20Authentication\")'>
769 769
 							<i class='material-icons'>help</i> ".__("More info...")."</button>";
770 770
 
771
-					} else if ($pref_name == 'DIGEST_PREFERRED_TIME') {
772
-						print "<input dojoType=\"dijit.form.ValidationTextBox\"
771
+                    } else if ($pref_name == 'DIGEST_PREFERRED_TIME') {
772
+                        print "<input dojoType=\"dijit.form.ValidationTextBox\"
773 773
 							id=\"$pref_name\" regexp=\"[012]?\d:\d\d\" placeHolder=\"12:00\"
774 774
 							name=\"$pref_name\" value=\"$value\">";
775 775
 
776
-						$item['help_text'] .= ". ".T_sprintf("Current server time: %s", date("H:i"));
777
-					} else {
778
-						$regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
776
+                        $item['help_text'] .= ". ".T_sprintf("Current server time: %s", date("H:i"));
777
+                    } else {
778
+                        $regexp = ($type_name == 'integer') ? 'regexp="^\d*$"' : '';
779 779
 
780
-						print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">";
781
-					}
780
+                        print "<input dojoType=\"dijit.form.ValidationTextBox\" $regexp name=\"$pref_name\" value=\"$value\">";
781
+                    }
782 782
 
783
-					if ($item['help_text']) {
784
-											print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>";
785
-					}
783
+                    if ($item['help_text']) {
784
+                                            print "<div class='help-text text-muted'><label for='CB_$pref_name'>".$item['help_text']."</label></div>";
785
+                    }
786 786
 
787
-					print "</fieldset>";
788
-				}
789
-			}
790
-		}
787
+                    print "</fieldset>";
788
+                }
789
+            }
790
+        }
791 791
 
792
-		$listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs));
792
+        $listed_boolean_prefs = htmlspecialchars(join(",", $listed_boolean_prefs));
793 793
 
794
-		print_hidden("boolean_prefs", "$listed_boolean_prefs");
794
+        print_hidden("boolean_prefs", "$listed_boolean_prefs");
795 795
 
796
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
797
-			"hook_prefs_tab_section", "prefPrefsPrefsInside");
796
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
797
+            "hook_prefs_tab_section", "prefPrefsPrefsInside");
798 798
 
799
-		print '</div>'; # inside pane
800
-		print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
799
+        print '</div>'; # inside pane
800
+        print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
801 801
 
802
-		print_hidden("op", "pref-prefs");
803
-		print_hidden("method", "saveconfig");
802
+        print_hidden("op", "pref-prefs");
803
+        print_hidden("method", "saveconfig");
804 804
 
805
-		print "<div dojoType=\"fox.form.ComboButton\" type=\"submit\" class=\"alt-primary\">
805
+        print "<div dojoType=\"fox.form.ComboButton\" type=\"submit\" class=\"alt-primary\">
806 806
 			<span>".__('Save configuration')."</span>
807 807
 			<div dojoType=\"dijit.DropDownMenu\">
808 808
 				<div dojoType=\"dijit.MenuItem\"
809 809
 					onclick=\"dijit.byId('changeSettingsForm').onSubmit(null, true)\">".
810
-				__("Save and exit preferences")."</div>
810
+                __("Save and exit preferences")."</div>
811 811
 			</div>
812 812
 			</div>";
813 813
 
814
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.editProfiles()\">".
815
-			__('Manage profiles')."</button> ";
814
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.editProfiles()\">".
815
+            __('Manage profiles')."</button> ";
816 816
 
817
-		print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.confirmReset()\">".
818
-			__('Reset to defaults')."</button>";
817
+        print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.confirmReset()\">".
818
+            __('Reset to defaults')."</button>";
819 819
 
820
-		print "&nbsp;";
820
+        print "&nbsp;";
821 821
 
822
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
823
-			"hook_prefs_tab_section", "prefPrefsPrefsOutside");
822
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
823
+            "hook_prefs_tab_section", "prefPrefsPrefsOutside");
824 824
 
825
-		print "</form>";
826
-		print '</div>'; # inner pane
827
-		print '</div>'; # border container
825
+        print "</form>";
826
+        print '</div>'; # inner pane
827
+        print '</div>'; # border container
828 828
 
829
-		print "</div>"; #pane
829
+        print "</div>"; #pane
830 830
 
831
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
831
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
832 832
 			title=\"<i class='material-icons'>extension</i> ".__('Plugins')."\">";
833 833
 
834
-		print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
834
+        print "<form dojoType=\"dijit.form.Form\" id=\"changePluginsForm\">";
835 835
 
836
-		print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
836
+        print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
837 837
 		evt.preventDefault();
838 838
 		if (this.validate()) {
839 839
 			Notify.progress('Saving data...', true);
@@ -850,384 +850,384 @@  discard block
 block discarded – undo
850 850
 		}
851 851
 		</script>";
852 852
 
853
-		print_hidden("op", "pref-prefs");
854
-		print_hidden("method", "setplugins");
853
+        print_hidden("op", "pref-prefs");
854
+        print_hidden("method", "setplugins");
855 855
 
856
-		print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
857
-		print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
856
+        print '<div dojoType="dijit.layout.BorderContainer" gutters="false">';
857
+        print '<div dojoType="dijit.layout.ContentPane" region="center" style="overflow-y : auto">';
858 858
 
859
-		if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) {
860
-			print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly.");
861
-		}
859
+        if (ini_get("open_basedir") && function_exists("curl_init") && !defined("NO_CURL")) {
860
+            print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly.");
861
+        }
862 862
 
863
-		$feed_handler_whitelist = ["Af_Comics"];
863
+        $feed_handler_whitelist = ["Af_Comics"];
864 864
 
865
-		$feed_handlers = array_merge(
866
-			PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED),
867
-			PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED),
868
-			PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED));
865
+        $feed_handlers = array_merge(
866
+            PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_FETCHED),
867
+            PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_PARSED),
868
+            PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED));
869 869
 
870
-		$feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) {
871
-			return in_array(get_class($plugin), $feed_handler_whitelist) === false; });
870
+        $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) {
871
+            return in_array(get_class($plugin), $feed_handler_whitelist) === false; });
872 872
 
873
-		if (count($feed_handlers) > 0) {
874
-			print_error(
875
-				T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>",
876
-					implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers))
877
-				)." (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)"
878
-			);
879
-		}
873
+        if (count($feed_handlers) > 0) {
874
+            print_error(
875
+                T_sprintf("The following plugins use per-feed content hooks. This may cause excessive data usage and origin server load resulting in a ban of your instance: <b>%s</b>",
876
+                    implode(", ", array_map(function($plugin) { return get_class($plugin); }, $feed_handlers))
877
+                )." (<a href='https://tt-rss.org/wiki/FeedHandlerPlugins' target='_blank'>".__("More info...")."</a>)"
878
+            );
879
+        }
880 880
 
881
-		print "<h2>".__("System plugins")."</h2>";
882
-		print_notice("System plugins are enabled in <strong>config.php</strong> for all users.");
881
+        print "<h2>".__("System plugins")."</h2>";
882
+        print_notice("System plugins are enabled in <strong>config.php</strong> for all users.");
883 883
 
884
-		$system_enabled = array_map("trim", explode(",", PLUGINS));
885
-		$user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
884
+        $system_enabled = array_map("trim", explode(",", PLUGINS));
885
+        $user_enabled = array_map("trim", explode(",", get_pref("_ENABLED_PLUGINS")));
886 886
 
887
-		$tmppluginhost = new PluginHost();
888
-		$tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
889
-		$tmppluginhost->load_data();
887
+        $tmppluginhost = new PluginHost();
888
+        $tmppluginhost->load_all($tmppluginhost::KIND_ALL, $_SESSION["uid"], true);
889
+        $tmppluginhost->load_data();
890 890
 
891
-		foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
892
-			$about = $plugin->about();
891
+        foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
892
+            $about = $plugin->about();
893 893
 
894
-			if ($about[3]) {
895
-				if (in_array($name, $system_enabled)) {
896
-					$checked = "checked='1'";
897
-				} else {
898
-					$checked = "";
899
-				}
894
+            if ($about[3]) {
895
+                if (in_array($name, $system_enabled)) {
896
+                    $checked = "checked='1'";
897
+                } else {
898
+                    $checked = "";
899
+                }
900 900
 
901
-				print "<fieldset class='prefs plugin'>
901
+                print "<fieldset class='prefs plugin'>
902 902
 					<label>$name:</label>
903 903
 					<label class='checkbox description text-muted' id='PLABEL-$name'>
904 904
 						<input disabled='1'
905 905
 							dojoType='dijit.form.CheckBox' $checked type='checkbox'>
906 906
 						".htmlspecialchars($about[1])."</label>";
907 907
 
908
-					if (@$about[4]) {
909
-						print "<button dojoType='dijit.form.Button' class='alt-info'
908
+                    if (@$about[4]) {
909
+                        print "<button dojoType='dijit.form.Button' class='alt-info'
910 910
 							onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
911 911
 								<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";
912
-					}
912
+                    }
913 913
 
914
-					print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>".
915
-						htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])).
916
-						"</div>";
914
+                    print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>".
915
+                        htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])).
916
+                        "</div>";
917 917
 
918
-				print "</fieldset>";
918
+                print "</fieldset>";
919 919
 
920
-			}
921
-		}
920
+            }
921
+        }
922 922
 
923
-		print "<h2>".__("User plugins")."</h2>";
923
+        print "<h2>".__("User plugins")."</h2>";
924 924
 
925
-		foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
926
-			$about = $plugin->about();
925
+        foreach ($tmppluginhost->get_plugins() as $name => $plugin) {
926
+            $about = $plugin->about();
927 927
 
928
-			if (!$about[3]) {
928
+            if (!$about[3]) {
929 929
 
930
-				$checked = "";
931
-				$disabled = "";
930
+                $checked = "";
931
+                $disabled = "";
932 932
 
933
-				if (in_array($name, $system_enabled)) {
934
-					$checked = "checked='1'";
935
-					$disabled = "disabled='1'";
936
-				} else if (in_array($name, $user_enabled)) {
937
-					$checked = "checked='1'";
938
-				}
933
+                if (in_array($name, $system_enabled)) {
934
+                    $checked = "checked='1'";
935
+                    $disabled = "disabled='1'";
936
+                } else if (in_array($name, $user_enabled)) {
937
+                    $checked = "checked='1'";
938
+                }
939 939
 
940
-				print "<fieldset class='prefs plugin'>
940
+                print "<fieldset class='prefs plugin'>
941 941
 					<label>$name:</label>
942 942
 					<label class='checkbox description text-muted' id='PLABEL-$name'>
943 943
 						<input name='plugins[]' value='$name' dojoType='dijit.form.CheckBox' $checked $disabled type='checkbox'>
944 944
 						".htmlspecialchars($about[1])."</label>";
945 945
 
946
-				if (count($tmppluginhost->get_all($plugin)) > 0) {
947
-					if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
948
-						print " <button dojoType='dijit.form.Button'
946
+                if (count($tmppluginhost->get_all($plugin)) > 0) {
947
+                    if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
948
+                        print " <button dojoType='dijit.form.Button'
949 949
 							onclick=\"Helpers.clearPluginData('$name')\">
950 950
 								<i class='material-icons'>clear</i> ".__("Clear data")."</button>";
951
-					}
952
-				}
951
+                    }
952
+                }
953 953
 
954
-				if (@$about[4]) {
955
-					print " <button dojoType='dijit.form.Button' class='alt-info'
954
+                if (@$about[4]) {
955
+                    print " <button dojoType='dijit.form.Button' class='alt-info'
956 956
 							onclick='window.open(\"".htmlspecialchars($about[4])."\")'>
957 957
 								<i class='material-icons'>open_in_new</i> ".__("More info...")."</button>";
958
-				}
958
+                }
959 959
 
960
-				print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>".
961
-					htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])).
962
-					"</div>";
960
+                print "<div dojoType='dijit.Tooltip' connectId='PLABEL-$name' position='after'>".
961
+                    htmlspecialchars(T_sprintf("v%.2f, by %s", $about[0], $about[2])).
962
+                    "</div>";
963 963
 
964
-				print "</fieldset>";
965
-			}
966
-		}
964
+                print "</fieldset>";
965
+            }
966
+        }
967 967
 
968
-		print "</div>"; #content-pane
969
-		print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
968
+        print "</div>"; #content-pane
969
+        print '<div dojoType="dijit.layout.ContentPane" region="bottom">';
970 970
 
971
-		print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/Plugins\")'>
971
+        print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/Plugins\")'>
972 972
 			<i class='material-icons'>help</i> ".__("More info...")."</button>";
973 973
 
974
-		print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>".
975
-			__("Enable selected plugins")."</button>";
976
-		print "</div>"; #pane
974
+        print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>".
975
+            __("Enable selected plugins")."</button>";
976
+        print "</div>"; #pane
977 977
 
978
-		print "</div>"; #pane
979
-		print "</div>"; #border-container
978
+        print "</div>"; #pane
979
+        print "</div>"; #border-container
980 980
 
981
-		print "</form>";
981
+        print "</form>";
982 982
 
983
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
984
-			"hook_prefs_tab", "prefPrefs");
983
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
984
+            "hook_prefs_tab", "prefPrefs");
985 985
 
986
-		print "</div>"; #container
986
+        print "</div>"; #container
987 987
 
988
-	}
988
+    }
989 989
 
990
-	public function toggleAdvanced() {
991
-		$_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"];
992
-	}
990
+    public function toggleAdvanced() {
991
+        $_SESSION["prefs_show_advanced"] = !$_SESSION["prefs_show_advanced"];
992
+    }
993 993
 
994
-	public function otpsecret() {
995
-		$sth = $this->pdo->prepare("SELECT salt, otp_enabled
994
+    public function otpsecret() {
995
+        $sth = $this->pdo->prepare("SELECT salt, otp_enabled
996 996
 			FROM ttrss_users
997 997
 			WHERE id = ?");
998
-		$sth->execute([$_SESSION['uid']]);
998
+        $sth->execute([$_SESSION['uid']]);
999 999
 
1000
-		if ($row = $sth->fetch()) {
1001
-			$otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
1000
+        if ($row = $sth->fetch()) {
1001
+            $otp_enabled = sql_bool_to_bool($row["otp_enabled"]);
1002 1002
 
1003
-			if (!$otp_enabled) {
1004
-				$base32 = new \OTPHP\Base32();
1005
-				$secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false);
1003
+            if (!$otp_enabled) {
1004
+                $base32 = new \OTPHP\Base32();
1005
+                $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false);
1006 1006
 
1007
-				return $secret;
1008
-			}
1009
-		}
1007
+                return $secret;
1008
+            }
1009
+        }
1010 1010
 
1011
-		return false;
1012
-	}
1011
+        return false;
1012
+    }
1013 1013
 
1014
-	public function otpqrcode() {
1015
-		require_once "lib/phpqrcode/phpqrcode.php";
1014
+    public function otpqrcode() {
1015
+        require_once "lib/phpqrcode/phpqrcode.php";
1016 1016
 
1017
-		$sth = $this->pdo->prepare("SELECT login
1017
+        $sth = $this->pdo->prepare("SELECT login
1018 1018
 			FROM ttrss_users
1019 1019
 			WHERE id = ?");
1020
-		$sth->execute([$_SESSION['uid']]);
1020
+        $sth->execute([$_SESSION['uid']]);
1021 1021
 
1022
-		if ($row = $sth->fetch()) {
1023
-			$secret = $this->otpsecret();
1024
-			$login = $row['login'];
1022
+        if ($row = $sth->fetch()) {
1023
+            $secret = $this->otpsecret();
1024
+            $login = $row['login'];
1025 1025
 
1026
-			if ($secret) {
1027
-				QRcode::png("otpauth://totp/".urlencode($login).
1028
-					"?secret=$secret&issuer=".urlencode("Tiny Tiny RSS"));
1029
-			}
1030
-		}
1031
-	}
1026
+            if ($secret) {
1027
+                QRcode::png("otpauth://totp/".urlencode($login).
1028
+                    "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS"));
1029
+            }
1030
+        }
1031
+    }
1032 1032
 
1033
-	public function otpenable() {
1033
+    public function otpenable() {
1034 1034
 
1035
-		$password = clean($_REQUEST["password"]);
1036
-		$otp = clean($_REQUEST["otp"]);
1035
+        $password = clean($_REQUEST["password"]);
1036
+        $otp = clean($_REQUEST["otp"]);
1037 1037
 
1038
-		$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1038
+        $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1039 1039
 
1040
-		if ($authenticator->check_password($_SESSION["uid"], $password)) {
1040
+        if ($authenticator->check_password($_SESSION["uid"], $password)) {
1041 1041
 
1042
-			$secret = $this->otpsecret();
1042
+            $secret = $this->otpsecret();
1043 1043
 
1044
-			if ($secret) {
1045
-				$topt = new \OTPHP\TOTP($secret);
1046
-				$otp_check = $topt->now();
1044
+            if ($secret) {
1045
+                $topt = new \OTPHP\TOTP($secret);
1046
+                $otp_check = $topt->now();
1047 1047
 
1048
-				if ($otp == $otp_check) {
1049
-					$sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = true WHERE id = ?");
1048
+                if ($otp == $otp_check) {
1049
+                    $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = true WHERE id = ?");
1050 1050
 
1051
-					$sth->execute([$_SESSION['uid']]);
1051
+                    $sth->execute([$_SESSION['uid']]);
1052 1052
 
1053
-					print "OK";
1054
-				} else {
1055
-					print "ERROR:".__("Incorrect one time password");
1056
-				}
1057
-			}
1053
+                    print "OK";
1054
+                } else {
1055
+                    print "ERROR:".__("Incorrect one time password");
1056
+                }
1057
+            }
1058 1058
 
1059
-		} else {
1060
-			print "ERROR:".__("Incorrect password");
1061
-		}
1059
+        } else {
1060
+            print "ERROR:".__("Incorrect password");
1061
+        }
1062 1062
 
1063
-	}
1063
+    }
1064 1064
 
1065
-	public static function isdefaultpassword() {
1066
-		$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1065
+    public static function isdefaultpassword() {
1066
+        $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1067 1067
 
1068
-		if ($authenticator &&
1068
+        if ($authenticator &&
1069 1069
                 method_exists($authenticator, "check_password") &&
1070 1070
                 $authenticator->check_password($_SESSION["uid"], "password")) {
1071 1071
 
1072
-			return true;
1073
-		}
1072
+            return true;
1073
+        }
1074 1074
 
1075
-		return false;
1076
-	}
1075
+        return false;
1076
+    }
1077 1077
 
1078
-	public function otpdisable() {
1079
-		$password = clean($_REQUEST["password"]);
1078
+    public function otpdisable() {
1079
+        $password = clean($_REQUEST["password"]);
1080 1080
 
1081
-		$authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1081
+        $authenticator = PluginHost::getInstance()->get_plugin($_SESSION["auth_module"]);
1082 1082
 
1083
-		if ($authenticator->check_password($_SESSION["uid"], $password)) {
1083
+        if ($authenticator->check_password($_SESSION["uid"], $password)) {
1084 1084
 
1085
-			$sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?");
1086
-			$sth->execute([$_SESSION['uid']]);
1085
+            $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?");
1086
+            $sth->execute([$_SESSION['uid']]);
1087 1087
 
1088
-			if ($row = $sth->fetch()) {
1089
-				$mailer = new Mailer();
1088
+            if ($row = $sth->fetch()) {
1089
+                $mailer = new Mailer();
1090 1090
 
1091
-				require_once "lib/MiniTemplator.class.php";
1091
+                require_once "lib/MiniTemplator.class.php";
1092 1092
 
1093
-				$tpl = new MiniTemplator;
1093
+                $tpl = new MiniTemplator;
1094 1094
 
1095
-				$tpl->readTemplateFromFile("templates/otp_disabled_template.txt");
1095
+                $tpl->readTemplateFromFile("templates/otp_disabled_template.txt");
1096 1096
 
1097
-				$tpl->setVariable('LOGIN', $row["login"]);
1098
-				$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
1097
+                $tpl->setVariable('LOGIN', $row["login"]);
1098
+                $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
1099 1099
 
1100
-				$tpl->addBlock('message');
1100
+                $tpl->addBlock('message');
1101 1101
 
1102
-				$tpl->generateOutputToString($message);
1102
+                $tpl->generateOutputToString($message);
1103 1103
 
1104
-				$mailer->mail(["to_name" => $row["login"],
1105
-					"to_address" => $row["email"],
1106
-					"subject" => "[tt-rss] OTP change notification",
1107
-					"message" => $message]);
1108
-			}
1104
+                $mailer->mail(["to_name" => $row["login"],
1105
+                    "to_address" => $row["email"],
1106
+                    "subject" => "[tt-rss] OTP change notification",
1107
+                    "message" => $message]);
1108
+            }
1109 1109
 
1110
-			$sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE
1110
+            $sth = $this->pdo->prepare("UPDATE ttrss_users SET otp_enabled = false WHERE
1111 1111
 				id = ?");
1112
-			$sth->execute([$_SESSION['uid']]);
1112
+            $sth->execute([$_SESSION['uid']]);
1113 1113
 
1114
-			print "OK";
1115
-		} else {
1116
-			print "ERROR: ".__("Incorrect password");
1117
-		}
1114
+            print "OK";
1115
+        } else {
1116
+            print "ERROR: ".__("Incorrect password");
1117
+        }
1118 1118
 
1119
-	}
1119
+    }
1120 1120
 
1121
-	public function setplugins() {
1122
-		if (is_array(clean($_REQUEST["plugins"]))) {
1123
-					$plugins = join(",", clean($_REQUEST["plugins"]));
1124
-		} else {
1125
-					$plugins = "";
1126
-		}
1121
+    public function setplugins() {
1122
+        if (is_array(clean($_REQUEST["plugins"]))) {
1123
+                    $plugins = join(",", clean($_REQUEST["plugins"]));
1124
+        } else {
1125
+                    $plugins = "";
1126
+        }
1127 1127
 
1128
-		set_pref("_ENABLED_PLUGINS", $plugins);
1129
-	}
1128
+        set_pref("_ENABLED_PLUGINS", $plugins);
1129
+    }
1130 1130
 
1131
-	public function clearplugindata() {
1132
-		$name = clean($_REQUEST["name"]);
1131
+    public function clearplugindata() {
1132
+        $name = clean($_REQUEST["name"]);
1133 1133
 
1134
-		PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name));
1135
-	}
1134
+        PluginHost::getInstance()->clear_data(PluginHost::getInstance()->get_plugin($name));
1135
+    }
1136 1136
 
1137
-	public function customizeCSS() {
1138
-		$value = get_pref("USER_STYLESHEET");
1139
-		$value = str_replace("<br/>", "\n", $value);
1137
+    public function customizeCSS() {
1138
+        $value = get_pref("USER_STYLESHEET");
1139
+        $value = str_replace("<br/>", "\n", $value);
1140 1140
 
1141
-		print_notice(__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here."));
1141
+        print_notice(__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here."));
1142 1142
 
1143
-		print_hidden("op", "rpc");
1144
-		print_hidden("method", "setpref");
1145
-		print_hidden("key", "USER_STYLESHEET");
1143
+        print_hidden("op", "rpc");
1144
+        print_hidden("method", "setpref");
1145
+        print_hidden("key", "USER_STYLESHEET");
1146 1146
 
1147
-		print "<div id='css_edit_apply_msg' style='display : none'>";
1148
-		print_warning(__("User CSS has been applied, you might need to reload the page to see all changes."));
1149
-		print "</div>";
1147
+        print "<div id='css_edit_apply_msg' style='display : none'>";
1148
+        print_warning(__("User CSS has been applied, you might need to reload the page to see all changes."));
1149
+        print "</div>";
1150 1150
 
1151
-		print "<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea'
1151
+        print "<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea'
1152 1152
 			style='font-size : 12px;' name='value'>$value</textarea>";
1153 1153
 
1154
-		print "<footer>";
1155
-		print "<button dojoType='dijit.form.Button' class='alt-success'
1154
+        print "<footer>";
1155
+        print "<button dojoType='dijit.form.Button' class='alt-success'
1156 1156
 			onclick=\"dijit.byId('cssEditDlg').apply()\">".__('Apply')."</button> ";
1157
-		print "<button dojoType='dijit.form.Button' class='alt-primary'
1157
+        print "<button dojoType='dijit.form.Button' class='alt-primary'
1158 1158
 			onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save and reload')."</button> ";
1159
-		print "<button dojoType='dijit.form.Button'
1159
+        print "<button dojoType='dijit.form.Button'
1160 1160
 			onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
1161
-		print "</footer>";
1161
+        print "</footer>";
1162 1162
 
1163
-	}
1163
+    }
1164 1164
 
1165
-	public function editPrefProfiles() {
1166
-		print "<div dojoType='fox.Toolbar'>";
1165
+    public function editPrefProfiles() {
1166
+        print "<div dojoType='fox.Toolbar'>";
1167 1167
 
1168
-		print "<div dojoType='fox.form.DropDownButton'>".
1169
-				"<span>".__('Select')."</span>";
1170
-		print "<div dojoType='dijit.Menu' style='display: none'>";
1171
-		print "<div onclick=\"Tables.select('pref-profiles-list', true)\"
1168
+        print "<div dojoType='fox.form.DropDownButton'>".
1169
+                "<span>".__('Select')."</span>";
1170
+        print "<div dojoType='dijit.Menu' style='display: none'>";
1171
+        print "<div onclick=\"Tables.select('pref-profiles-list', true)\"
1172 1172
 			dojoType='dijit.MenuItem'>".__('All')."</div>";
1173
-		print "<div onclick=\"Tables.select('pref-profiles-list', false)\"
1173
+        print "<div onclick=\"Tables.select('pref-profiles-list', false)\"
1174 1174
 			dojoType='dijit.MenuItem'>".__('None')."</div>";
1175
-		print "</div></div>";
1175
+        print "</div></div>";
1176 1176
 
1177
-		print "<div style='float : right'>";
1177
+        print "<div style='float : right'>";
1178 1178
 
1179
-		print "<input name='newprofile' dojoType='dijit.form.ValidationTextBox'
1179
+        print "<input name='newprofile' dojoType='dijit.form.ValidationTextBox'
1180 1180
 				required='1'>
1181 1181
 			<button dojoType='dijit.form.Button'
1182 1182
 			onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
1183
-				__('Create profile')."</button></div>";
1183
+                __('Create profile')."</button></div>";
1184 1184
 
1185
-		print "</div>";
1185
+        print "</div>";
1186 1186
 
1187
-		$sth = $this->pdo->prepare("SELECT title,id FROM ttrss_settings_profiles
1187
+        $sth = $this->pdo->prepare("SELECT title,id FROM ttrss_settings_profiles
1188 1188
 			WHERE owner_uid = ? ORDER BY title");
1189
-		$sth->execute([$_SESSION['uid']]);
1189
+        $sth->execute([$_SESSION['uid']]);
1190 1190
 
1191
-		print "<div class='panel panel-scrollable'>";
1191
+        print "<div class='panel panel-scrollable'>";
1192 1192
 
1193
-		print "<form id='profile_edit_form' onsubmit='return false'>";
1193
+        print "<form id='profile_edit_form' onsubmit='return false'>";
1194 1194
 
1195
-		print "<table width='100%' id='pref-profiles-list'>";
1195
+        print "<table width='100%' id='pref-profiles-list'>";
1196 1196
 
1197
-		print "<tr>"; # data-row-id='0' <-- no point, shouldn't be removed
1197
+        print "<tr>"; # data-row-id='0' <-- no point, shouldn't be removed
1198 1198
 
1199
-		print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>";
1199
+        print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>";
1200 1200
 
1201
-		if (!$_SESSION["profile"]) {
1202
-			$is_active = __("(active)");
1203
-		} else {
1204
-			$is_active = "";
1205
-		}
1201
+        if (!$_SESSION["profile"]) {
1202
+            $is_active = __("(active)");
1203
+        } else {
1204
+            $is_active = "";
1205
+        }
1206 1206
 
1207
-		print "<td width='100%'><span>".__("Default profile")." $is_active</span></td>";
1207
+        print "<td width='100%'><span>".__("Default profile")." $is_active</span></td>";
1208 1208
 
1209
-		print "</tr>";
1209
+        print "</tr>";
1210 1210
 
1211
-		while ($line = $sth->fetch()) {
1211
+        while ($line = $sth->fetch()) {
1212 1212
 
1213
-			$profile_id = $line["id"];
1213
+            $profile_id = $line["id"];
1214 1214
 
1215
-			print "<tr data-row-id='$profile_id'>";
1215
+            print "<tr data-row-id='$profile_id'>";
1216 1216
 
1217
-			$edit_title = htmlspecialchars($line["title"]);
1217
+            $edit_title = htmlspecialchars($line["title"]);
1218 1218
 
1219
-			print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>";
1219
+            print "<td><input onclick='Tables.onRowChecked(this);' dojoType='dijit.form.CheckBox' type='checkbox'></td>";
1220 1220
 
1221
-			if ($_SESSION["profile"] == $line["id"]) {
1222
-				$is_active = __("(active)");
1223
-			} else {
1224
-				$is_active = "";
1225
-			}
1221
+            if ($_SESSION["profile"] == $line["id"]) {
1222
+                $is_active = __("(active)");
1223
+            } else {
1224
+                $is_active = "";
1225
+            }
1226 1226
 
1227
-			print "<td><span dojoType='dijit.InlineEditBox'
1227
+            print "<td><span dojoType='dijit.InlineEditBox'
1228 1228
 				width='300px' autoSave='false'
1229 1229
 				profile-id='$profile_id'>".$edit_title.
1230
-				"<script type='dojo/method' event='onChange' args='item'>
1230
+                "<script type='dojo/method' event='onChange' args='item'>
1231 1231
 					var elem = this;
1232 1232
 					dojo.xhrPost({
1233 1233
 						url: 'backend.php',
@@ -1241,118 +1241,118 @@  discard block
 block discarded – undo
1241 1241
 				</script>
1242 1242
 			</span> $is_active</td>";
1243 1243
 
1244
-			print "</tr>";
1245
-		}
1244
+            print "</tr>";
1245
+        }
1246 1246
 
1247
-		print "</table>";
1248
-		print "</form>";
1249
-		print "</div>";
1247
+        print "</table>";
1248
+        print "</form>";
1249
+        print "</div>";
1250 1250
 
1251
-		print "<footer>
1251
+        print "<footer>
1252 1252
 			<button style='float : left' class='alt-danger' dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('profileEditDlg').removeSelected()\">".
1253
-			__('Remove selected profiles')."</button>
1253
+            __('Remove selected profiles')."</button>
1254 1254
 			<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"dijit.byId('profileEditDlg').activateProfile()\">".
1255
-			__('Activate profile')."</button>
1255
+            __('Activate profile')."</button>
1256 1256
 			<button dojoType='dijit.form.Button' onclick=\"dijit.byId('profileEditDlg').hide()\">".
1257
-			__('Cancel')."</button>";
1258
-		print "</footer>";
1259
-
1260
-	}
1261
-
1262
-	private function getShortDesc($pref_name) {
1263
-		if (isset($this->pref_help[$pref_name])) {
1264
-			return $this->pref_help[$pref_name][0];
1265
-		}
1266
-		return "";
1267
-	}
1268
-
1269
-	private function getHelpText($pref_name) {
1270
-		if (isset($this->pref_help[$pref_name])) {
1271
-			return $this->pref_help[$pref_name][1];
1272
-		}
1273
-		return "";
1274
-	}
1275
-
1276
-	private function appPasswordList() {
1277
-		print "<div dojoType='fox.Toolbar'>";
1278
-		print "<div dojoType='fox.form.DropDownButton'>".
1279
-			"<span>".__('Select')."</span>";
1280
-		print "<div dojoType='dijit.Menu' style='display: none'>";
1281
-		print "<div onclick=\"Tables.select('app-password-list', true)\"
1257
+            __('Cancel')."</button>";
1258
+        print "</footer>";
1259
+
1260
+    }
1261
+
1262
+    private function getShortDesc($pref_name) {
1263
+        if (isset($this->pref_help[$pref_name])) {
1264
+            return $this->pref_help[$pref_name][0];
1265
+        }
1266
+        return "";
1267
+    }
1268
+
1269
+    private function getHelpText($pref_name) {
1270
+        if (isset($this->pref_help[$pref_name])) {
1271
+            return $this->pref_help[$pref_name][1];
1272
+        }
1273
+        return "";
1274
+    }
1275
+
1276
+    private function appPasswordList() {
1277
+        print "<div dojoType='fox.Toolbar'>";
1278
+        print "<div dojoType='fox.form.DropDownButton'>".
1279
+            "<span>".__('Select')."</span>";
1280
+        print "<div dojoType='dijit.Menu' style='display: none'>";
1281
+        print "<div onclick=\"Tables.select('app-password-list', true)\"
1282 1282
 				dojoType=\"dijit.MenuItem\">" . __('All')."</div>";
1283
-		print "<div onclick=\"Tables.select('app-password-list', false)\"
1283
+        print "<div onclick=\"Tables.select('app-password-list', false)\"
1284 1284
 				dojoType=\"dijit.MenuItem\">" . __('None')."</div>";
1285
-		print "</div></div>";
1286
-		print "</div>"; #toolbar
1287
-
1288
-		print "<div class='panel panel-scrollable'>";
1289
-		print "<table width='100%' id='app-password-list'>";
1290
-		print "<tr>";
1291
-		print "<th width='2%'></th>";
1292
-		print "<th align='left'>".__("Description")."</th>";
1293
-		print "<th align='right'>".__("Created")."</th>";
1294
-		print "<th align='right'>".__("Last used")."</th>";
1295
-		print "</tr>";
1296
-
1297
-		$sth = $this->pdo->prepare("SELECT id, title, created, last_used
1285
+        print "</div></div>";
1286
+        print "</div>"; #toolbar
1287
+
1288
+        print "<div class='panel panel-scrollable'>";
1289
+        print "<table width='100%' id='app-password-list'>";
1290
+        print "<tr>";
1291
+        print "<th width='2%'></th>";
1292
+        print "<th align='left'>".__("Description")."</th>";
1293
+        print "<th align='right'>".__("Created")."</th>";
1294
+        print "<th align='right'>".__("Last used")."</th>";
1295
+        print "</tr>";
1296
+
1297
+        $sth = $this->pdo->prepare("SELECT id, title, created, last_used
1298 1298
 			FROM ttrss_app_passwords WHERE owner_uid = ?");
1299
-		$sth->execute([$_SESSION['uid']]);
1299
+        $sth->execute([$_SESSION['uid']]);
1300 1300
 
1301
-		while ($row = $sth->fetch()) {
1301
+        while ($row = $sth->fetch()) {
1302 1302
 
1303
-			$row_id = $row["id"];
1303
+            $row_id = $row["id"];
1304 1304
 
1305
-			print "<tr data-row-id='$row_id'>";
1305
+            print "<tr data-row-id='$row_id'>";
1306 1306
 
1307
-			print "<td align='center'>
1307
+            print "<td align='center'>
1308 1308
 						<input onclick='Tables.onRowChecked(this)' dojoType='dijit.form.CheckBox' type='checkbox'></td>";
1309
-			print "<td>".htmlspecialchars($row["title"])."</td>";
1309
+            print "<td>".htmlspecialchars($row["title"])."</td>";
1310 1310
 
1311
-			print "<td align='right' class='text-muted'>";
1312
-			print make_local_datetime($row['created'], false);
1313
-			print "</td>";
1311
+            print "<td align='right' class='text-muted'>";
1312
+            print make_local_datetime($row['created'], false);
1313
+            print "</td>";
1314 1314
 
1315
-			print "<td align='right' class='text-muted'>";
1316
-			print make_local_datetime($row['last_used'], false);
1317
-			print "</td>";
1315
+            print "<td align='right' class='text-muted'>";
1316
+            print make_local_datetime($row['last_used'], false);
1317
+            print "</td>";
1318 1318
 
1319
-			print "</tr>";
1320
-		}
1319
+            print "</tr>";
1320
+        }
1321 1321
 
1322
-		print "</table>";
1323
-		print "</div>";
1324
-	}
1322
+        print "</table>";
1323
+        print "</div>";
1324
+    }
1325 1325
 
1326
-	private function encryptAppPassword($password) {
1327
-		$salt = substr(bin2hex(get_random_bytes(24)), 0, 24);
1326
+    private function encryptAppPassword($password) {
1327
+        $salt = substr(bin2hex(get_random_bytes(24)), 0, 24);
1328 1328
 
1329
-		return "SSHA-512:".hash('sha512', $salt.$password).":$salt";
1330
-	}
1329
+        return "SSHA-512:".hash('sha512', $salt.$password).":$salt";
1330
+    }
1331 1331
 
1332
-	public function deleteAppPassword() {
1333
-		$ids = explode(",", clean($_REQUEST['ids']));
1334
-		$ids_qmarks = arr_qmarks($ids);
1332
+    public function deleteAppPassword() {
1333
+        $ids = explode(",", clean($_REQUEST['ids']));
1334
+        $ids_qmarks = arr_qmarks($ids);
1335 1335
 
1336
-		$sth = $this->pdo->prepare("DELETE FROM ttrss_app_passwords WHERE id IN ($ids_qmarks) AND owner_uid = ?");
1337
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
1336
+        $sth = $this->pdo->prepare("DELETE FROM ttrss_app_passwords WHERE id IN ($ids_qmarks) AND owner_uid = ?");
1337
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
1338 1338
 
1339
-		$this->appPasswordList();
1340
-	}
1339
+        $this->appPasswordList();
1340
+    }
1341 1341
 
1342
-	public function generateAppPassword() {
1343
-		$title = clean($_REQUEST['title']);
1344
-		$new_password = make_password(16);
1345
-		$new_password_hash = $this->encryptAppPassword($new_password);
1342
+    public function generateAppPassword() {
1343
+        $title = clean($_REQUEST['title']);
1344
+        $new_password = make_password(16);
1345
+        $new_password_hash = $this->encryptAppPassword($new_password);
1346 1346
 
1347
-		print_warning(T_sprintf("Generated password <strong>%s</strong> for %s. Please remember it for future reference.", $new_password, $title));
1347
+        print_warning(T_sprintf("Generated password <strong>%s</strong> for %s. Please remember it for future reference.", $new_password, $title));
1348 1348
 
1349
-		$sth = $this->pdo->prepare("INSERT INTO ttrss_app_passwords
1349
+        $sth = $this->pdo->prepare("INSERT INTO ttrss_app_passwords
1350 1350
     			(title, pwd_hash, service, created, owner_uid)
1351 1351
     		 VALUES
1352 1352
     		    (?, ?, ?, NOW(), ?)");
1353 1353
 
1354
-		$sth->execute([$title, $new_password_hash, Auth_Base::AUTH_SERVICE_API, $_SESSION['uid']]);
1354
+        $sth->execute([$title, $new_password_hash, Auth_Base::AUTH_SERVICE_API, $_SESSION['uid']]);
1355 1355
 
1356
-		$this->appPasswordList();
1357
-	}
1356
+        $this->appPasswordList();
1357
+    }
1358 1358
 }
Please login to merge, or discard this patch.
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -172,26 +172,26 @@
 block discarded – undo
172 172
 			$value = $_POST[$pref_name];
173 173
 
174 174
 			switch ($pref_name) {
175
-				case 'DIGEST_PREFERRED_TIME':
176
-					if (get_pref('DIGEST_PREFERRED_TIME') != $value) {
175
+			case 'DIGEST_PREFERRED_TIME':
176
+				if (get_pref('DIGEST_PREFERRED_TIME') != $value) {
177 177
 
178
-						$sth = $this->pdo->prepare("UPDATE ttrss_users SET
178
+					$sth = $this->pdo->prepare("UPDATE ttrss_users SET
179 179
 						last_digest_sent = NULL WHERE id = ?");
180
-						$sth->execute([$_SESSION['uid']]);
180
+					$sth->execute([$_SESSION['uid']]);
181 181
 
182
-					}
183
-					break;
184
-				case 'USER_LANGUAGE':
185
-					if (!$need_reload) {
186
-					    $need_reload = $_SESSION["language"] != $value;
187
-					}
188
-					break;
182
+				}
183
+				break;
184
+			case 'USER_LANGUAGE':
185
+				if (!$need_reload) {
186
+				    $need_reload = $_SESSION["language"] != $value;
187
+				}
188
+				break;
189 189
 
190
-				case 'USER_CSS_THEME':
191
-					if (!$need_reload) {
192
-					    $need_reload = get_pref($pref_name) != $value;
193
-					}
194
-					break;
190
+			case 'USER_CSS_THEME':
191
+				if (!$need_reload) {
192
+				    $need_reload = get_pref($pref_name) != $value;
193
+				}
194
+				break;
195 195
 			}
196 196
 
197 197
 			set_pref($pref_name, $value);
Please login to merge, or discard this patch.
classes/pref/labels.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -1,286 +1,286 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Pref_Labels extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("index", "getlabeltree", "edit");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("index", "getlabeltree", "edit");
6 6
 
7
-		return array_search($method, $csrf_ignored) !== false;
8
-	}
7
+        return array_search($method, $csrf_ignored) !== false;
8
+    }
9 9
 
10
-	public function edit() {
11
-		$label_id = clean($_REQUEST['id']);
10
+    public function edit() {
11
+        $label_id = clean($_REQUEST['id']);
12 12
 
13
-		$sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
13
+        $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
14 14
 			id = ? AND owner_uid = ?");
15
-		$sth->execute([$label_id, $_SESSION['uid']]);
15
+        $sth->execute([$label_id, $_SESSION['uid']]);
16 16
 
17
-		if ($line = $sth->fetch()) {
17
+        if ($line = $sth->fetch()) {
18 18
 
19
-			print_hidden("id", "$label_id");
20
-			print_hidden("op", "pref-labels");
21
-			print_hidden("method", "save");
19
+            print_hidden("id", "$label_id");
20
+            print_hidden("op", "pref-labels");
21
+            print_hidden("method", "save");
22 22
 
23
-			print "<form onsubmit='return false;'>";
23
+            print "<form onsubmit='return false;'>";
24 24
 
25
-			print "<header>".__("Caption")."</header>";
25
+            print "<header>".__("Caption")."</header>";
26 26
 
27
-			print "<section>";
27
+            print "<section>";
28 28
 
29
-			$fg_color = $line['fg_color'];
30
-			$bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5';
29
+            $fg_color = $line['fg_color'];
30
+            $bg_color = $line['bg_color'] ? $line['bg_color'] : '#fff7d5';
31 31
 
32
-			print "<input style='font-size : 16px; color : $fg_color; background : $bg_color; transition : background 0.1s linear'
32
+            print "<input style='font-size : 16px; color : $fg_color; background : $bg_color; transition : background 0.1s linear'
33 33
 				id='labelEdit_caption' name='caption' dojoType='dijit.form.ValidationTextBox'
34 34
 				required='true' value=\"".htmlspecialchars($line['caption'])."\">";
35 35
 
36
-			print "</section>";
36
+            print "</section>";
37 37
 
38
-			print "<header>".__("Colors")."</header>";
39
-			print "<section>";
38
+            print "<header>".__("Colors")."</header>";
39
+            print "<section>";
40 40
 
41
-			print "<table>";
42
-			print "<tr><th style='text-align : left'>".__("Foreground:")."</th><th style='text-align : left'>".__("Background:")."</th></tr>";
43
-			print "<tr><td style='padding-right : 10px'>";
41
+            print "<table>";
42
+            print "<tr><th style='text-align : left'>".__("Foreground:")."</th><th style='text-align : left'>".__("Background:")."</th></tr>";
43
+            print "<tr><td style='padding-right : 10px'>";
44 44
 
45
-			print "<input dojoType='dijit.form.TextBox'
45
+            print "<input dojoType='dijit.form.TextBox'
46 46
 				style='display : none' id='labelEdit_fgColor'
47 47
 				name='fg_color' value='$fg_color'>";
48
-			print "<input dojoType='dijit.form.TextBox'
48
+            print "<input dojoType='dijit.form.TextBox'
49 49
 				style='display : none' id='labelEdit_bgColor'
50 50
 				name='bg_color' value='$bg_color'>";
51 51
 
52
-			print "<div dojoType='dijit.ColorPalette'>
52
+            print "<div dojoType='dijit.ColorPalette'>
53 53
 			<script type='dojo/method' event='onChange' args='fg_color'>
54 54
 				dijit.byId('labelEdit_fgColor').attr('value', fg_color);
55 55
 				dijit.byId('labelEdit_caption').domNode.setStyle({color: fg_color});
56 56
 			</script>
57 57
 			</div>";
58 58
 
59
-			print "</td><td>";
59
+            print "</td><td>";
60 60
 
61
-			print "<div dojoType='dijit.ColorPalette'>
61
+            print "<div dojoType='dijit.ColorPalette'>
62 62
 			<script type='dojo/method' event='onChange' args='bg_color'>
63 63
 				dijit.byId('labelEdit_bgColor').attr('value', bg_color);
64 64
 				dijit.byId('labelEdit_caption').domNode.setStyle({backgroundColor: bg_color});
65 65
 			</script>
66 66
 			</div>";
67 67
 
68
-			print "</td></tr></table>";
69
-			print "</section>";
68
+            print "</td></tr></table>";
69
+            print "</section>";
70 70
 
71
-			print "<footer>";
72
-			print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('labelEditDlg').execute()\">".
73
-				__('Save')."</button>";
74
-			print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('labelEditDlg').hide()\">".
75
-				__('Cancel')."</button>";
76
-			print "</footer>";
71
+            print "<footer>";
72
+            print "<button dojoType='dijit.form.Button' type='submit' class='alt-primary' onclick=\"dijit.byId('labelEditDlg').execute()\">".
73
+                __('Save')."</button>";
74
+            print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('labelEditDlg').hide()\">".
75
+                __('Cancel')."</button>";
76
+            print "</footer>";
77 77
 
78
-			print "</form>";
79
-		}
80
-	}
78
+            print "</form>";
79
+        }
80
+    }
81 81
 
82
-	public function getlabeltree() {
83
-		$root = array();
84
-		$root['id'] = 'root';
85
-		$root['name'] = __('Labels');
86
-		$root['items'] = array();
82
+    public function getlabeltree() {
83
+        $root = array();
84
+        $root['id'] = 'root';
85
+        $root['name'] = __('Labels');
86
+        $root['items'] = array();
87 87
 
88
-		$sth = $this->pdo->prepare("SELECT *
88
+        $sth = $this->pdo->prepare("SELECT *
89 89
 			FROM ttrss_labels2
90 90
 			WHERE owner_uid = ?
91 91
 			ORDER BY caption");
92
-		$sth->execute([$_SESSION['uid']]);
93
-
94
-		while ($line = $sth->fetch()) {
95
-			$label = array();
96
-			$label['id'] = 'LABEL:'.$line['id'];
97
-			$label['bare_id'] = $line['id'];
98
-			$label['name'] = $line['caption'];
99
-			$label['fg_color'] = $line['fg_color'];
100
-			$label['bg_color'] = $line['bg_color'];
101
-			$label['type'] = 'label';
102
-			$label['checkbox'] = false;
103
-
104
-			array_push($root['items'], $label);
105
-		}
106
-
107
-		$fl = array();
108
-		$fl['identifier'] = 'id';
109
-		$fl['label'] = 'name';
110
-		$fl['items'] = array($root);
111
-
112
-		print json_encode($fl);
113
-		return;
114
-	}
115
-
116
-	public function colorset() {
117
-		$kind = clean($_REQUEST["kind"]);
118
-		$ids = explode(',', clean($_REQUEST["ids"]));
119
-		$color = clean($_REQUEST["color"]);
120
-		$fg = clean($_REQUEST["fg"]);
121
-		$bg = clean($_REQUEST["bg"]);
122
-
123
-		foreach ($ids as $id) {
124
-
125
-			if ($kind == "fg" || $kind == "bg") {
126
-				$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
92
+        $sth->execute([$_SESSION['uid']]);
93
+
94
+        while ($line = $sth->fetch()) {
95
+            $label = array();
96
+            $label['id'] = 'LABEL:'.$line['id'];
97
+            $label['bare_id'] = $line['id'];
98
+            $label['name'] = $line['caption'];
99
+            $label['fg_color'] = $line['fg_color'];
100
+            $label['bg_color'] = $line['bg_color'];
101
+            $label['type'] = 'label';
102
+            $label['checkbox'] = false;
103
+
104
+            array_push($root['items'], $label);
105
+        }
106
+
107
+        $fl = array();
108
+        $fl['identifier'] = 'id';
109
+        $fl['label'] = 'name';
110
+        $fl['items'] = array($root);
111
+
112
+        print json_encode($fl);
113
+        return;
114
+    }
115
+
116
+    public function colorset() {
117
+        $kind = clean($_REQUEST["kind"]);
118
+        $ids = explode(',', clean($_REQUEST["ids"]));
119
+        $color = clean($_REQUEST["color"]);
120
+        $fg = clean($_REQUEST["fg"]);
121
+        $bg = clean($_REQUEST["bg"]);
122
+
123
+        foreach ($ids as $id) {
124
+
125
+            if ($kind == "fg" || $kind == "bg") {
126
+                $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
127 127
 					${kind}_color = ? WHERE id = ?
128 128
 					AND owner_uid = ?");
129 129
 
130
-				$sth->execute([$color, $id, $_SESSION['uid']]);
130
+                $sth->execute([$color, $id, $_SESSION['uid']]);
131 131
 
132
-			} else {
132
+            } else {
133 133
 
134
-				$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
134
+                $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
135 135
 					fg_color = ?, bg_color = ? WHERE id = ?
136 136
 					AND owner_uid = ?");
137 137
 
138
-				$sth->execute([$fg, $bg, $id, $_SESSION['uid']]);
139
-			}
138
+                $sth->execute([$fg, $bg, $id, $_SESSION['uid']]);
139
+            }
140 140
 
141
-			/* Remove cached data */
141
+            /* Remove cached data */
142 142
 
143
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
143
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
144 144
 				WHERE owner_uid = ?");
145
-			$sth->execute([$_SESSION['uid']]);
146
-		}
147
-	}
145
+            $sth->execute([$_SESSION['uid']]);
146
+        }
147
+    }
148 148
 
149
-	public function colorreset() {
150
-		$ids = explode(',', clean($_REQUEST["ids"]));
149
+    public function colorreset() {
150
+        $ids = explode(',', clean($_REQUEST["ids"]));
151 151
 
152
-		foreach ($ids as $id) {
153
-			$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
152
+        foreach ($ids as $id) {
153
+            $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
154 154
 				fg_color = '', bg_color = '' WHERE id = ?
155 155
 				AND owner_uid = ?");
156
-			$sth->execute([$id, $_SESSION['uid']]);
156
+            $sth->execute([$id, $_SESSION['uid']]);
157 157
 
158
-			/* Remove cached data */
158
+            /* Remove cached data */
159 159
 
160
-			$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
160
+            $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET label_cache = ''
161 161
 				WHERE owner_uid = ?");
162
-			$sth->execute([$_SESSION['uid']]);
163
-		}
164
-	}
162
+            $sth->execute([$_SESSION['uid']]);
163
+        }
164
+    }
165 165
 
166
-	public function save() {
166
+    public function save() {
167 167
 
168
-		$id = clean($_REQUEST["id"]);
169
-		$caption = trim(clean($_REQUEST["caption"]));
168
+        $id = clean($_REQUEST["id"]);
169
+        $caption = trim(clean($_REQUEST["caption"]));
170 170
 
171
-		$this->pdo->beginTransaction();
171
+        $this->pdo->beginTransaction();
172 172
 
173
-		$sth = $this->pdo->prepare("SELECT caption FROM ttrss_labels2
173
+        $sth = $this->pdo->prepare("SELECT caption FROM ttrss_labels2
174 174
 			WHERE id = ? AND owner_uid = ?");
175
-		$sth->execute([$id, $_SESSION['uid']]);
175
+        $sth->execute([$id, $_SESSION['uid']]);
176 176
 
177
-		if ($row = $sth->fetch()) {
178
-			$old_caption = $row["caption"];
177
+        if ($row = $sth->fetch()) {
178
+            $old_caption = $row["caption"];
179 179
 
180
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2
180
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_labels2
181 181
 				WHERE caption = ? AND owner_uid = ?");
182
-			$sth->execute([$caption, $_SESSION['uid']]);
182
+            $sth->execute([$caption, $_SESSION['uid']]);
183 183
 
184
-			if (!$sth->fetch()) {
185
-				if ($caption) {
186
-					$sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
184
+            if (!$sth->fetch()) {
185
+                if ($caption) {
186
+                    $sth = $this->pdo->prepare("UPDATE ttrss_labels2 SET
187 187
 						caption = ? WHERE id = ? AND
188 188
 						owner_uid = ?");
189
-					$sth->execute([$caption, $id, $_SESSION['uid']]);
189
+                    $sth->execute([$caption, $id, $_SESSION['uid']]);
190 190
 
191
-					/* Update filters that reference label being renamed */
191
+                    /* Update filters that reference label being renamed */
192 192
 
193
-					$sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions SET
193
+                    $sth = $this->pdo->prepare("UPDATE ttrss_filters2_actions SET
194 194
 						action_param = ? WHERE action_param = ?
195 195
 						AND action_id = 7
196 196
 						AND filter_id IN (SELECT id FROM ttrss_filters2 WHERE owner_uid = ?)");
197 197
 
198
-					$sth->execute([$caption, $old_caption, $_SESSION['uid']]);
198
+                    $sth->execute([$caption, $old_caption, $_SESSION['uid']]);
199 199
 
200
-					print clean($_REQUEST["value"]);
201
-				} else {
202
-					print $old_caption;
203
-				}
204
-			} else {
205
-				print $old_caption;
206
-			}
207
-		}
200
+                    print clean($_REQUEST["value"]);
201
+                } else {
202
+                    print $old_caption;
203
+                }
204
+            } else {
205
+                print $old_caption;
206
+            }
207
+        }
208 208
 
209
-		$this->pdo->commit();
209
+        $this->pdo->commit();
210 210
 
211
-	}
211
+    }
212 212
 
213
-	public function remove() {
213
+    public function remove() {
214 214
 
215
-		$ids = explode(",", clean($_REQUEST["ids"]));
215
+        $ids = explode(",", clean($_REQUEST["ids"]));
216 216
 
217
-		foreach ($ids as $id) {
218
-			Labels::remove($id, $_SESSION["uid"]);
219
-		}
217
+        foreach ($ids as $id) {
218
+            Labels::remove($id, $_SESSION["uid"]);
219
+        }
220 220
 
221
-	}
221
+    }
222 222
 
223
-	public function add() {
224
-		$caption = clean($_REQUEST["caption"]);
225
-		$output = clean($_REQUEST["output"]);
223
+    public function add() {
224
+        $caption = clean($_REQUEST["caption"]);
225
+        $output = clean($_REQUEST["output"]);
226 226
 
227
-		if ($caption) {
227
+        if ($caption) {
228 228
 
229
-			if (Labels::create($caption)) {
230
-				if (!$output) {
231
-					print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
232
-				}
233
-			}
229
+            if (Labels::create($caption)) {
230
+                if (!$output) {
231
+                    print T_sprintf("Created label <b>%s</b>", htmlspecialchars($caption));
232
+                }
233
+            }
234 234
 
235
-			if ($output == "select") {
236
-				header("Content-Type: text/xml");
235
+            if ($output == "select") {
236
+                header("Content-Type: text/xml");
237 237
 
238
-				print "<rpc-reply><payload>";
238
+                print "<rpc-reply><payload>";
239 239
 
240
-				print_label_select("select_label",
241
-					$caption, "");
240
+                print_label_select("select_label",
241
+                    $caption, "");
242 242
 
243
-				print "</payload></rpc-reply>";
244
-			}
245
-		}
243
+                print "</payload></rpc-reply>";
244
+            }
245
+        }
246 246
 
247
-		return;
248
-	}
247
+        return;
248
+    }
249 249
 
250
-	public function index() {
250
+    public function index() {
251 251
 
252
-		print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
253
-		print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
254
-		print "<div dojoType='fox.Toolbar'>";
252
+        print "<div dojoType='dijit.layout.BorderContainer' gutters='false'>";
253
+        print "<div style='padding : 0px' dojoType='dijit.layout.ContentPane' region='top'>";
254
+        print "<div dojoType='fox.Toolbar'>";
255 255
 
256
-		print "<div dojoType='fox.form.DropDownButton'>".
257
-				"<span>".__('Select')."</span>";
258
-		print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
259
-		print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(true)\"
256
+        print "<div dojoType='fox.form.DropDownButton'>".
257
+                "<span>".__('Select')."</span>";
258
+        print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
259
+        print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(true)\"
260 260
 			dojoType=\"dijit.MenuItem\">".__('All')."</div>";
261
-		print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(false)\"
261
+        print "<div onclick=\"dijit.byId('labelTree').model.setAllChecked(false)\"
262 262
 			dojoType=\"dijit.MenuItem\">".__('None')."</div>";
263
-		print "</div></div>";
263
+        print "</div></div>";
264 264
 
265
-		print"<button dojoType=\"dijit.form.Button\" onclick=\"CommonDialogs.addLabel()\">".
266
-			__('Create label')."</button dojoType=\"dijit.form.Button\"> ";
265
+        print"<button dojoType=\"dijit.form.Button\" onclick=\"CommonDialogs.addLabel()\">".
266
+            __('Create label')."</button dojoType=\"dijit.form.Button\"> ";
267 267
 
268
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').removeSelected()\">".
269
-			__('Remove')."</button dojoType=\"dijit.form.Button\"> ";
268
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').removeSelected()\">".
269
+            __('Remove')."</button dojoType=\"dijit.form.Button\"> ";
270 270
 
271
-		print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').resetColors()\">".
272
-			__('Clear colors')."</button dojoType=\"dijit.form.Button\">";
271
+        print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('labelTree').resetColors()\">".
272
+            __('Clear colors')."</button dojoType=\"dijit.form.Button\">";
273 273
 
274 274
 
275
-		print "</div>"; #toolbar
276
-		print "</div>"; #pane
277
-		print "<div style='padding : 0px' dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
275
+        print "</div>"; #toolbar
276
+        print "</div>"; #pane
277
+        print "<div style='padding : 0px' dojoType=\"dijit.layout.ContentPane\" region=\"center\">";
278 278
 
279
-		print "<div id=\"labellistLoading\">
279
+        print "<div id=\"labellistLoading\">
280 280
 		<img src='images/indicator_tiny.gif'>".
281
-		 __("Loading, please wait...")."</div>";
281
+            __("Loading, please wait...")."</div>";
282 282
 
283
-		print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"labelStore\"
283
+        print "<div dojoType=\"dojo.data.ItemFileWriteStore\" jsId=\"labelStore\"
284 284
 			url=\"backend.php?op=pref-labels&method=getlabeltree\">
285 285
 		</div>
286 286
 		<div dojoType=\"lib.CheckBoxStoreModel\" jsId=\"labelModel\" store=\"labelStore\"
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
 		</script>
303 303
 		</div>";
304 304
 
305
-		print "</div>"; #pane
305
+        print "</div>"; #pane
306 306
 
307
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
308
-			"hook_prefs_tab", "prefLabels");
307
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB,
308
+            "hook_prefs_tab", "prefLabels");
309 309
 
310
-		print "</div>"; #container
310
+        print "</div>"; #container
311 311
 
312
-	}
312
+    }
313 313
 }
Please login to merge, or discard this patch.
classes/db.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -2,118 +2,118 @@
 block discarded – undo
2 2
 class Db
3 3
 {
4 4
 
5
-	/* @var Db $instance */
6
-	private static $instance;
5
+    /* @var Db $instance */
6
+    private static $instance;
7 7
 
8
-	/* @var IDb $adapter */
9
-	private $adapter;
8
+    /* @var IDb $adapter */
9
+    private $adapter;
10 10
 
11
-	private $link;
11
+    private $link;
12 12
 
13
-	/* @var PDO $pdo */
14
-	private $pdo;
13
+    /* @var PDO $pdo */
14
+    private $pdo;
15 15
 
16
-	private function __clone() {
17
-		//
18
-	}
16
+    private function __clone() {
17
+        //
18
+    }
19 19
 
20
-	private function legacy_connect() {
20
+    private function legacy_connect() {
21 21
 
22
-		user_error("Legacy connect requested to ".DB_TYPE, E_USER_NOTICE);
22
+        user_error("Legacy connect requested to ".DB_TYPE, E_USER_NOTICE);
23 23
 
24
-		$er = error_reporting(E_ALL);
24
+        $er = error_reporting(E_ALL);
25 25
 
26
-		switch (DB_TYPE) {
27
-			case "mysql":
28
-				$this->adapter = new Db_Mysqli();
29
-				break;
30
-			case "pgsql":
31
-				$this->adapter = new Db_Pgsql();
32
-				break;
33
-			default:
34
-				die("Unknown DB_TYPE: ".DB_TYPE);
35
-		}
26
+        switch (DB_TYPE) {
27
+            case "mysql":
28
+                $this->adapter = new Db_Mysqli();
29
+                break;
30
+            case "pgsql":
31
+                $this->adapter = new Db_Pgsql();
32
+                break;
33
+            default:
34
+                die("Unknown DB_TYPE: ".DB_TYPE);
35
+        }
36 36
 
37
-		if (!$this->adapter) {
38
-			print("Error initializing database adapter for ".DB_TYPE);
39
-			exit(100);
40
-		}
37
+        if (!$this->adapter) {
38
+            print("Error initializing database adapter for ".DB_TYPE);
39
+            exit(100);
40
+        }
41 41
 
42
-		$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
42
+        $this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
43 43
 
44
-		if (!$this->link) {
45
-			print("Error connecting through adapter: ".$this->adapter->last_error());
46
-			exit(101);
47
-		}
44
+        if (!$this->link) {
45
+            print("Error connecting through adapter: ".$this->adapter->last_error());
46
+            exit(101);
47
+        }
48 48
 
49
-		error_reporting($er);
50
-	}
49
+        error_reporting($er);
50
+    }
51 51
 
52
-	// this really shouldn't be used unless a separate PDO connection is needed
53
-	// normal usage is Db::pdo()->prepare(...) etc
54
-	public function pdo_connect() {
52
+    // this really shouldn't be used unless a separate PDO connection is needed
53
+    // normal usage is Db::pdo()->prepare(...) etc
54
+    public function pdo_connect() {
55 55
 
56
-		$db_port = defined('DB_PORT') && DB_PORT ? ';port='.DB_PORT : '';
57
-		$db_host = defined('DB_HOST') && DB_HOST ? ';host='.DB_HOST : '';
56
+        $db_port = defined('DB_PORT') && DB_PORT ? ';port='.DB_PORT : '';
57
+        $db_host = defined('DB_HOST') && DB_HOST ? ';host='.DB_HOST : '';
58 58
 
59
-		try {
60
-			$pdo = new PDO(DB_TYPE.':dbname='.DB_NAME.$db_host.$db_port,
61
-				DB_USER,
62
-				DB_PASS);
63
-		} catch (Exception $e) {
64
-			print "<pre>Exception while creating PDO object:".$e->getMessage()."</pre>";
65
-			exit(101);
66
-		}
59
+        try {
60
+            $pdo = new PDO(DB_TYPE.':dbname='.DB_NAME.$db_host.$db_port,
61
+                DB_USER,
62
+                DB_PASS);
63
+        } catch (Exception $e) {
64
+            print "<pre>Exception while creating PDO object:".$e->getMessage()."</pre>";
65
+            exit(101);
66
+        }
67 67
 
68
-		$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
68
+        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
69 69
 
70
-		if (DB_TYPE == "pgsql") {
70
+        if (DB_TYPE == "pgsql") {
71 71
 
72
-			$pdo->query("set client_encoding = 'UTF-8'");
73
-			$pdo->query("set datestyle = 'ISO, european'");
74
-			$pdo->query("set TIME ZONE 0");
75
-			$pdo->query("set cpu_tuple_cost = 0.5");
72
+            $pdo->query("set client_encoding = 'UTF-8'");
73
+            $pdo->query("set datestyle = 'ISO, european'");
74
+            $pdo->query("set TIME ZONE 0");
75
+            $pdo->query("set cpu_tuple_cost = 0.5");
76 76
 
77
-		} else if (DB_TYPE == "mysql") {
78
-			$pdo->query("SET time_zone = '+0:0'");
77
+        } else if (DB_TYPE == "mysql") {
78
+            $pdo->query("SET time_zone = '+0:0'");
79 79
 
80
-			if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
81
-				$pdo->query("SET NAMES ".MYSQL_CHARSET);
82
-			}
83
-		}
80
+            if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
81
+                $pdo->query("SET NAMES ".MYSQL_CHARSET);
82
+            }
83
+        }
84 84
 
85
-		return $pdo;
86
-	}
85
+        return $pdo;
86
+    }
87 87
 
88
-	public static function instance() {
89
-		if (self::$instance == null) {
90
-					self::$instance = new self();
91
-		}
88
+    public static function instance() {
89
+        if (self::$instance == null) {
90
+                    self::$instance = new self();
91
+        }
92 92
 
93
-		return self::$instance;
94
-	}
93
+        return self::$instance;
94
+    }
95 95
 
96
-	public static function get() {
97
-		if (self::$instance == null) {
98
-					self::$instance = new self();
99
-		}
96
+    public static function get() {
97
+        if (self::$instance == null) {
98
+                    self::$instance = new self();
99
+        }
100 100
 
101
-		if (!self::$instance->adapter) {
102
-			self::$instance->legacy_connect();
103
-		}
101
+        if (!self::$instance->adapter) {
102
+            self::$instance->legacy_connect();
103
+        }
104 104
 
105
-		return self::$instance->adapter;
106
-	}
105
+        return self::$instance->adapter;
106
+    }
107 107
 
108
-	public static function pdo() {
109
-		if (self::$instance == null) {
110
-					self::$instance = new self();
111
-		}
108
+    public static function pdo() {
109
+        if (self::$instance == null) {
110
+                    self::$instance = new self();
111
+        }
112 112
 
113
-		if (!self::$instance->pdo) {
114
-			self::$instance->pdo = self::$instance->pdo_connect();
115
-		}
113
+        if (!self::$instance->pdo) {
114
+            self::$instance->pdo = self::$instance->pdo_connect();
115
+        }
116 116
 
117
-		return self::$instance->pdo;
118
-	}
117
+        return self::$instance->pdo;
118
+    }
119 119
 }
Please login to merge, or discard this patch.
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
 		$er = error_reporting(E_ALL);
25 25
 
26 26
 		switch (DB_TYPE) {
27
-			case "mysql":
28
-				$this->adapter = new Db_Mysqli();
29
-				break;
30
-			case "pgsql":
31
-				$this->adapter = new Db_Pgsql();
32
-				break;
33
-			default:
34
-				die("Unknown DB_TYPE: ".DB_TYPE);
27
+		case "mysql":
28
+			$this->adapter = new Db_Mysqli();
29
+			break;
30
+		case "pgsql":
31
+			$this->adapter = new Db_Pgsql();
32
+			break;
33
+		default:
34
+			die("Unknown DB_TYPE: ".DB_TYPE);
35 35
 		}
36 36
 
37 37
 		if (!$this->adapter) {
Please login to merge, or discard this patch.