Passed
Push — master ( a3c0d0...678db7 )
by Cody
06:27 queued 03:12
created
classes/handler/protected.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 class Handler_Protected extends Handler {
3 3
 
4
-	public function before($method) {
5
-		return parent::before($method) && $_SESSION['uid'];
6
-	}
4
+    public function before($method) {
5
+        return parent::before($method) && $_SESSION['uid'];
6
+    }
7 7
 }
Please login to merge, or discard this patch.
classes/handler/public.php 1 patch
Indentation   +716 added lines, -716 removed lines patch added patch discarded remove patch
@@ -1,329 +1,329 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Handler_Public extends Handler {
3 3
 
4
-	private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
5
-		$limit, $offset, $search,
6
-		$view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) {
4
+    private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
5
+        $limit, $offset, $search,
6
+        $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) {
7 7
 
8
-		require_once "lib/MiniTemplator.class.php";
8
+        require_once "lib/MiniTemplator.class.php";
9 9
 
10
-		$note_style = 	"background-color : #fff7d5;
10
+        $note_style = 	"background-color : #fff7d5;
11 11
 			border-width : 1px; ".
12
-			"padding : 5px; border-style : dashed; border-color : #e7d796;".
13
-			"margin-bottom : 1em; color : #9a8c59;";
14
-
15
-		if (!$limit) $limit = 60;
16
-
17
-		$date_sort_field = "date_entered DESC, updated DESC";
18
-
19
-		if ($feed == -2 && !$is_cat) {
20
-			$date_sort_field = "last_published DESC";
21
-		} else if ($feed == -1 && !$is_cat) {
22
-			$date_sort_field = "last_marked DESC";
23
-		}
24
-
25
-		switch ($order) {
26
-		case "title":
27
-			$date_sort_field = "ttrss_entries.title, date_entered, updated";
28
-			break;
29
-		case "date_reverse":
30
-			$date_sort_field = "date_entered, updated";
31
-			break;
32
-		case "feed_dates":
33
-			$date_sort_field = "updated DESC";
34
-			break;
35
-		}
36
-
37
-		$params = array(
38
-			"owner_uid" => $owner_uid,
39
-			"feed" => $feed,
40
-			"limit" => $limit,
41
-			"view_mode" => $view_mode,
42
-			"cat_view" => $is_cat,
43
-			"search" => $search,
44
-			"override_order" => $date_sort_field,
45
-			"include_children" => true,
46
-			"ignore_vfeed_group" => true,
47
-			"offset" => $offset,
48
-			"start_ts" => $start_ts
49
-		);
50
-
51
-		if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
52
-
53
-			$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
54
-
55
-			$tmppluginhost = new PluginHost();
56
-			$tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL);
57
-			$tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
58
-			$tmppluginhost->load_data();
59
-
60
-			$handler = $tmppluginhost->get_feed_handler(
61
-				PluginHost::feed_to_pfeed_id($feed));
62
-
63
-			if ($handler) {
64
-				$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $params);
65
-			}
66
-
67
-		} else {
68
-			$qfh_ret = Feeds::queryFeedHeadlines($params);
69
-		}
70
-
71
-		$result = $qfh_ret[0];
72
-		$feed_title = htmlspecialchars($qfh_ret[1]);
73
-		$feed_site_url = $qfh_ret[2];
74
-		/* $last_error = $qfh_ret[3]; */
75
-
76
-		$feed_self_url = get_self_url_prefix() .
77
-			"/public.php?op=rss&id=$feed&key=" .
78
-			Feeds::get_feed_access_key($feed, false, $owner_uid);
79
-
80
-		if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
81
-
82
-		if ($format == 'atom') {
83
-			$tpl = new MiniTemplator;
84
-
85
-			$tpl->readTemplateFromFile("templates/generated_feed.txt");
86
-
87
-			$tpl->setVariable('FEED_TITLE', $feed_title, true);
88
-			$tpl->setVariable('VERSION', get_version(), true);
89
-			$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
90
-
91
-			$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
92
-			while ($line = $result->fetch()) {
93
-
94
-				$line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
95
-
96
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
97
-					$line = $p->hook_query_headlines($line);
98
-				}
12
+            "padding : 5px; border-style : dashed; border-color : #e7d796;".
13
+            "margin-bottom : 1em; color : #9a8c59;";
14
+
15
+        if (!$limit) $limit = 60;
16
+
17
+        $date_sort_field = "date_entered DESC, updated DESC";
18
+
19
+        if ($feed == -2 && !$is_cat) {
20
+            $date_sort_field = "last_published DESC";
21
+        } else if ($feed == -1 && !$is_cat) {
22
+            $date_sort_field = "last_marked DESC";
23
+        }
24
+
25
+        switch ($order) {
26
+        case "title":
27
+            $date_sort_field = "ttrss_entries.title, date_entered, updated";
28
+            break;
29
+        case "date_reverse":
30
+            $date_sort_field = "date_entered, updated";
31
+            break;
32
+        case "feed_dates":
33
+            $date_sort_field = "updated DESC";
34
+            break;
35
+        }
36
+
37
+        $params = array(
38
+            "owner_uid" => $owner_uid,
39
+            "feed" => $feed,
40
+            "limit" => $limit,
41
+            "view_mode" => $view_mode,
42
+            "cat_view" => $is_cat,
43
+            "search" => $search,
44
+            "override_order" => $date_sort_field,
45
+            "include_children" => true,
46
+            "ignore_vfeed_group" => true,
47
+            "offset" => $offset,
48
+            "start_ts" => $start_ts
49
+        );
50
+
51
+        if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
52
+
53
+            $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
54
+
55
+            $tmppluginhost = new PluginHost();
56
+            $tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL);
57
+            $tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
58
+            $tmppluginhost->load_data();
59
+
60
+            $handler = $tmppluginhost->get_feed_handler(
61
+                PluginHost::feed_to_pfeed_id($feed));
62
+
63
+            if ($handler) {
64
+                $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $params);
65
+            }
99 66
 
100
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
101
-					$line = $p->hook_article_export_feed($line, $feed, $is_cat);
102
-				}
67
+        } else {
68
+            $qfh_ret = Feeds::queryFeedHeadlines($params);
69
+        }
103 70
 
104
-				$tpl->setVariable('ARTICLE_ID',
105
-					htmlspecialchars($orig_guid ? $line['link'] :
106
-							$this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
107
-				$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
108
-				$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
109
-				$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
71
+        $result = $qfh_ret[0];
72
+        $feed_title = htmlspecialchars($qfh_ret[1]);
73
+        $feed_site_url = $qfh_ret[2];
74
+        /* $last_error = $qfh_ret[3]; */
110 75
 
111
-				$content = sanitize($line["content"], false, $owner_uid,
112
-					$feed_site_url, false, $line["id"]);
76
+        $feed_self_url = get_self_url_prefix() .
77
+            "/public.php?op=rss&id=$feed&key=" .
78
+            Feeds::get_feed_access_key($feed, false, $owner_uid);
113 79
 
114
-				if ($line['note']) {
115
-					$content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
116
-						$content;
117
-					$tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
118
-				}
80
+        if (!$feed_site_url) $feed_site_url = get_self_url_prefix();
119 81
 
120
-				$tpl->setVariable('ARTICLE_CONTENT', $content, true);
82
+        if ($format == 'atom') {
83
+            $tpl = new MiniTemplator;
121 84
 
122
-				$tpl->setVariable('ARTICLE_UPDATED_ATOM',
123
-					date('c', strtotime($line["updated"])), true);
124
-				$tpl->setVariable('ARTICLE_UPDATED_RFC822',
125
-					date(DATE_RFC822, strtotime($line["updated"])), true);
85
+            $tpl->readTemplateFromFile("templates/generated_feed.txt");
126 86
 
127
-				$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
87
+            $tpl->setVariable('FEED_TITLE', $feed_title, true);
88
+            $tpl->setVariable('VERSION', get_version(), true);
89
+            $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
128 90
 
129
-				$tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
130
-				$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
91
+            $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
92
+            while ($line = $result->fetch()) {
131 93
 
132
-				$tags = Article::get_article_tags($line["id"], $owner_uid);
94
+                $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
133 95
 
134
-				foreach ($tags as $tag) {
135
-					$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
136
-					$tpl->addBlock('category');
137
-				}
96
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
97
+                    $line = $p->hook_query_headlines($line);
98
+                }
138 99
 
139
-				$enclosures = Article::get_article_enclosures($line["id"]);
100
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
101
+                    $line = $p->hook_article_export_feed($line, $feed, $is_cat);
102
+                }
140 103
 
141
-				if (count($enclosures) > 0) {
142
-					foreach ($enclosures as $e) {
143
-						$type = htmlspecialchars($e['content_type']);
144
-						$url = htmlspecialchars($e['content_url']);
145
-						$length = $e['duration'] ? $e['duration'] : 1;
104
+                $tpl->setVariable('ARTICLE_ID',
105
+                    htmlspecialchars($orig_guid ? $line['link'] :
106
+                            $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
107
+                $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
108
+                $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
109
+                $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
146 110
 
147
-						$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
148
-						$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
149
-						$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
111
+                $content = sanitize($line["content"], false, $owner_uid,
112
+                    $feed_site_url, false, $line["id"]);
150 113
 
151
-						$tpl->addBlock('enclosure');
152
-					}
153
-				} else {
154
-					$tpl->setVariable('ARTICLE_ENCLOSURE_URL', null, true);
155
-					$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', null, true);
156
-					$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true);
157
-				}
114
+                if ($line['note']) {
115
+                    $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
116
+                        $content;
117
+                    $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
118
+                }
158 119
 
159
-				list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $feed_site_url);
120
+                $tpl->setVariable('ARTICLE_CONTENT', $content, true);
160 121
 
161
-				$tpl->setVariable('ARTICLE_OG_IMAGE', $og_image, true);
122
+                $tpl->setVariable('ARTICLE_UPDATED_ATOM',
123
+                    date('c', strtotime($line["updated"])), true);
124
+                $tpl->setVariable('ARTICLE_UPDATED_RFC822',
125
+                    date(DATE_RFC822, strtotime($line["updated"])), true);
162 126
 
163
-				$tpl->addBlock('entry');
164
-			}
127
+                $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
165 128
 
166
-			$tmp = "";
129
+                $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
130
+                $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
167 131
 
168
-			$tpl->addBlock('feed');
169
-			$tpl->generateOutputToString($tmp);
132
+                $tags = Article::get_article_tags($line["id"], $owner_uid);
170 133
 
171
-			if (@!clean($_REQUEST["noxml"])) {
172
-				header("Content-Type: text/xml; charset=utf-8");
173
-			} else {
174
-				header("Content-Type: text/plain; charset=utf-8");
175
-			}
134
+                foreach ($tags as $tag) {
135
+                    $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
136
+                    $tpl->addBlock('category');
137
+                }
176 138
 
177
-			print $tmp;
178
-		} else if ($format == 'json') {
139
+                $enclosures = Article::get_article_enclosures($line["id"]);
179 140
 
180
-			$feed = array();
141
+                if (count($enclosures) > 0) {
142
+                    foreach ($enclosures as $e) {
143
+                        $type = htmlspecialchars($e['content_type']);
144
+                        $url = htmlspecialchars($e['content_url']);
145
+                        $length = $e['duration'] ? $e['duration'] : 1;
181 146
 
182
-			$feed['title'] = $feed_title;
183
-			$feed['feed_url'] = $feed_self_url;
147
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
148
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
149
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
184 150
 
185
-			$feed['self_url'] = get_self_url_prefix();
151
+                        $tpl->addBlock('enclosure');
152
+                    }
153
+                } else {
154
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_URL', null, true);
155
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', null, true);
156
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true);
157
+                }
186 158
 
187
-			$feed['articles'] = array();
159
+                list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $feed_site_url);
188 160
 
189
-			while ($line = $result->fetch()) {
161
+                $tpl->setVariable('ARTICLE_OG_IMAGE', $og_image, true);
190 162
 
191
-				$line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
163
+                $tpl->addBlock('entry');
164
+            }
192 165
 
193
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
194
-					$line = $p->hook_query_headlines($line, 100);
195
-				}
166
+            $tmp = "";
196 167
 
197
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
198
-					$line = $p->hook_article_export_feed($line, $feed, $is_cat);
199
-				}
168
+            $tpl->addBlock('feed');
169
+            $tpl->generateOutputToString($tmp);
200 170
 
201
-				$article = array();
171
+            if (@!clean($_REQUEST["noxml"])) {
172
+                header("Content-Type: text/xml; charset=utf-8");
173
+            } else {
174
+                header("Content-Type: text/plain; charset=utf-8");
175
+            }
202 176
 
203
-				$article['id'] = $line['link'];
204
-				$article['link']	= $line['link'];
205
-				$article['title'] = $line['title'];
206
-				$article['excerpt'] = $line["content_preview"];
207
-				$article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
208
-				$article['updated'] = date('c', strtotime($line["updated"]));
177
+            print $tmp;
178
+        } else if ($format == 'json') {
209 179
 
210
-				if ($line['note']) $article['note'] = $line['note'];
211
-				if ($article['author']) $article['author'] = $line['author'];
180
+            $feed = array();
212 181
 
213
-				$tags = Article::get_article_tags($line["id"], $owner_uid);
182
+            $feed['title'] = $feed_title;
183
+            $feed['feed_url'] = $feed_self_url;
214 184
 
215
-				if (count($tags) > 0) {
216
-					$article['tags'] = array();
185
+            $feed['self_url'] = get_self_url_prefix();
217 186
 
218
-					foreach ($tags as $tag) {
219
-						array_push($article['tags'], $tag);
220
-					}
221
-				}
187
+            $feed['articles'] = array();
222 188
 
223
-				$enclosures = Article::get_article_enclosures($line["id"]);
189
+            while ($line = $result->fetch()) {
224 190
 
225
-				if (count($enclosures) > 0) {
226
-					$article['enclosures'] = array();
191
+                $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
227 192
 
228
-					foreach ($enclosures as $e) {
229
-						$type = $e['content_type'];
230
-						$url = $e['content_url'];
231
-						$length = $e['duration'];
193
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
194
+                    $line = $p->hook_query_headlines($line, 100);
195
+                }
232 196
 
233
-						array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
234
-					}
235
-				}
197
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
198
+                    $line = $p->hook_article_export_feed($line, $feed, $is_cat);
199
+                }
200
+
201
+                $article = array();
202
+
203
+                $article['id'] = $line['link'];
204
+                $article['link']	= $line['link'];
205
+                $article['title'] = $line['title'];
206
+                $article['excerpt'] = $line["content_preview"];
207
+                $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
208
+                $article['updated'] = date('c', strtotime($line["updated"]));
209
+
210
+                if ($line['note']) $article['note'] = $line['note'];
211
+                if ($article['author']) $article['author'] = $line['author'];
212
+
213
+                $tags = Article::get_article_tags($line["id"], $owner_uid);
214
+
215
+                if (count($tags) > 0) {
216
+                    $article['tags'] = array();
236 217
 
237
-				array_push($feed['articles'], $article);
238
-			}
218
+                    foreach ($tags as $tag) {
219
+                        array_push($article['tags'], $tag);
220
+                    }
221
+                }
222
+
223
+                $enclosures = Article::get_article_enclosures($line["id"]);
239 224
 
240
-			header("Content-Type: text/json; charset=utf-8");
241
-			print json_encode($feed);
225
+                if (count($enclosures) > 0) {
226
+                    $article['enclosures'] = array();
242 227
 
243
-		} else {
244
-			header("Content-Type: text/plain; charset=utf-8");
245
-			print json_encode(array("error" => array("message" => "Unknown format")));
246
-		}
247
-	}
228
+                    foreach ($enclosures as $e) {
229
+                        $type = $e['content_type'];
230
+                        $url = $e['content_url'];
231
+                        $length = $e['duration'];
248 232
 
249
-	public function getUnread() {
250
-		$login = clean($_REQUEST["login"]);
251
-		$fresh = clean($_REQUEST["fresh"]) == "1";
233
+                        array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
234
+                    }
235
+                }
236
+
237
+                array_push($feed['articles'], $article);
238
+            }
252 239
 
253
-		$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
254
-		$sth->execute([$login]);
240
+            header("Content-Type: text/json; charset=utf-8");
241
+            print json_encode($feed);
255 242
 
256
-		if ($row = $sth->fetch()) {
257
-			$uid = $row["id"];
243
+        } else {
244
+            header("Content-Type: text/plain; charset=utf-8");
245
+            print json_encode(array("error" => array("message" => "Unknown format")));
246
+        }
247
+    }
258 248
 
259
-			print Feeds::getGlobalUnread($uid);
249
+    public function getUnread() {
250
+        $login = clean($_REQUEST["login"]);
251
+        $fresh = clean($_REQUEST["fresh"]) == "1";
260 252
 
261
-			if ($fresh) {
262
-				print ";";
263
-				print Feeds::getFeedArticles(-3, false, true, $uid);
264
-			}
253
+        $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
254
+        $sth->execute([$login]);
255
+
256
+        if ($row = $sth->fetch()) {
257
+            $uid = $row["id"];
258
+
259
+            print Feeds::getGlobalUnread($uid);
260
+
261
+            if ($fresh) {
262
+                print ";";
263
+                print Feeds::getFeedArticles(-3, false, true, $uid);
264
+            }
265 265
 
266
-		} else {
267
-			print "-1;User not found";
268
-		}
269
-	}
266
+        } else {
267
+            print "-1;User not found";
268
+        }
269
+    }
270 270
 
271
-	public function getProfiles() {
272
-		$login = clean($_REQUEST["login"]);
273
-		$rv = [];
271
+    public function getProfiles() {
272
+        $login = clean($_REQUEST["login"]);
273
+        $rv = [];
274 274
 
275
-		if ($login) {
276
-			$sth = $this->pdo->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
275
+        if ($login) {
276
+            $sth = $this->pdo->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
277 277
 			WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title");
278
-			$sth->execute([$login]);
278
+            $sth->execute([$login]);
279 279
 
280
-			$rv = [ [ "value" => 0, "label" => __("Default profile") ] ];
280
+            $rv = [ [ "value" => 0, "label" => __("Default profile") ] ];
281 281
 
282
-			while ($line = $sth->fetch()) {
283
-				$id = $line["id"];
284
-				$title = $line["title"];
282
+            while ($line = $sth->fetch()) {
283
+                $id = $line["id"];
284
+                $title = $line["title"];
285 285
 
286
-				array_push($rv, [ "label" => $title, "value" => $id ]);
287
-			}
288
-	    }
286
+                array_push($rv, [ "label" => $title, "value" => $id ]);
287
+            }
288
+        }
289 289
 
290
-		print json_encode($rv);
291
-	}
290
+        print json_encode($rv);
291
+    }
292 292
 
293
-	public function logout() {
294
-		logout_user();
295
-		header("Location: index.php");
296
-	}
293
+    public function logout() {
294
+        logout_user();
295
+        header("Location: index.php");
296
+    }
297 297
 
298
-	public function share() {
299
-		$uuid = clean($_REQUEST["key"]);
298
+    public function share() {
299
+        $uuid = clean($_REQUEST["key"]);
300 300
 
301
-		if ($uuid) {
302
-			$sth = $this->pdo->prepare("SELECT ref_id, owner_uid
301
+        if ($uuid) {
302
+            $sth = $this->pdo->prepare("SELECT ref_id, owner_uid
303 303
 						FROM ttrss_user_entries WHERE uuid = ?");
304
-			$sth->execute([$uuid]);
304
+            $sth->execute([$uuid]);
305 305
 
306
-			if ($row = $sth->fetch()) {
307
-				header("Content-Type: text/html");
306
+            if ($row = $sth->fetch()) {
307
+                header("Content-Type: text/html");
308 308
 
309
-				$id = $row["ref_id"];
310
-				$owner_uid = $row["owner_uid"];
309
+                $id = $row["ref_id"];
310
+                $owner_uid = $row["owner_uid"];
311 311
 
312
-				print $this->format_article($id, $owner_uid);
312
+                print $this->format_article($id, $owner_uid);
313 313
 
314
-				return;
315
-			}
316
-		}
314
+                return;
315
+            }
316
+        }
317 317
 
318
-		header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
319
-		print "Article not found.";
320
-	}
318
+        header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
319
+        print "Article not found.";
320
+    }
321 321
 
322
-	private function format_article($id, $owner_uid) {
322
+    private function format_article($id, $owner_uid) {
323 323
 
324
-		$pdo = Db::pdo();
324
+        $pdo = Db::pdo();
325 325
 
326
-		$sth = $pdo->prepare("SELECT id,title,link,content,feed_id,comments,int_id,lang,
326
+        $sth = $pdo->prepare("SELECT id,title,link,content,feed_id,comments,int_id,lang,
327 327
 			".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
328 328
 			(SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
329 329
 			(SELECT title FROM ttrss_feeds WHERE id = feed_id) as feed_title,
@@ -337,26 +337,26 @@  discard block
 block discarded – undo
337 337
 			note
338 338
 			FROM ttrss_entries,ttrss_user_entries
339 339
 			WHERE	id = ? AND ref_id = id AND owner_uid = ?");
340
-		$sth->execute([$id, $owner_uid]);
340
+        $sth->execute([$id, $owner_uid]);
341 341
 
342
-		$rv = '';
342
+        $rv = '';
343 343
 
344
-		if ($line = $sth->fetch()) {
344
+        if ($line = $sth->fetch()) {
345 345
 
346
-			$line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]);
347
-			unset($line["tag_cache"]);
346
+            $line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]);
347
+            unset($line["tag_cache"]);
348 348
 
349
-			$line["content"] = sanitize($line["content"],
350
-				$line['hide_images'],
351
-				$owner_uid, $line["site_url"], false, $line["id"]);
349
+            $line["content"] = sanitize($line["content"],
350
+                $line['hide_images'],
351
+                $owner_uid, $line["site_url"], false, $line["id"]);
352 352
 
353
-			foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
354
-				$line = $p->hook_render_article($line);
355
-			}
353
+            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
354
+                $line = $p->hook_render_article($line);
355
+            }
356 356
 
357
-			$line['content'] = DiskCache::rewriteUrls($line['content']);
357
+            $line['content'] = DiskCache::rewriteUrls($line['content']);
358 358
 
359
-			$enclosures = Article::get_article_enclosures($line["id"]);
359
+            $enclosures = Article::get_article_enclosures($line["id"]);
360 360
 
361 361
             header("Content-Type: text/html");
362 362
 
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
             $rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n";
372 372
             $rv .= "<meta property='og:description' content=\"".
373 373
                 htmlspecialchars(
374
-                	truncate_string(
375
-                		preg_replace("/[\r\n\t]/", "",
376
-							preg_replace("/ {1,}/", " ",
377
-								strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401))
378
-							)
379
-					), 500, "...")
380
-				)."\"/>\n";
374
+                    truncate_string(
375
+                        preg_replace("/[\r\n\t]/", "",
376
+                            preg_replace("/ {1,}/", " ",
377
+                                strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401))
378
+                            )
379
+                    ), 500, "...")
380
+                )."\"/>\n";
381 381
 
382 382
             $rv .= "</head>";
383 383
 
@@ -390,132 +390,132 @@  discard block
 block discarded – undo
390 390
             $rv .= "<body class='flat ttrss_utility ttrss_zoom'>";
391 391
             $rv .= "<div class='container'>";
392 392
 
393
-			if ($line["link"]) {
394
-				$rv .= "<h1><a target='_blank' rel='noopener noreferrer'
393
+            if ($line["link"]) {
394
+                $rv .= "<h1><a target='_blank' rel='noopener noreferrer'
395 395
 					title=\"".htmlspecialchars($line['title'])."\"
396 396
 					href=\"" .htmlspecialchars($line["link"]) . "\">" .	$line["title"] . "</a></h1>";
397
-			} else {
398
-				$rv .= "<h1>" . $line["title"] . "</h1>";
399
-			}
397
+            } else {
398
+                $rv .= "<h1>" . $line["title"] . "</h1>";
399
+            }
400 400
 
401
-			$rv .= "<div class='content post'>";
401
+            $rv .= "<div class='content post'>";
402 402
 
403
-			/* header */
403
+            /* header */
404 404
 
405
-			$rv .= "<div class='header'>";
406
-			$rv .= "<div class='row'>"; # row
405
+            $rv .= "<div class='header'>";
406
+            $rv .= "<div class='row'>"; # row
407 407
 
408
-			//$entry_author = $line["author"] ? " - " . $line["author"] : "";
409
-			$parsed_updated = make_local_datetime($line["updated"], true,
410
-				$owner_uid, true);
408
+            //$entry_author = $line["author"] ? " - " . $line["author"] : "";
409
+            $parsed_updated = make_local_datetime($line["updated"], true,
410
+                $owner_uid, true);
411 411
 
412
-			$rv .= "<div>".$line['author']."</div>";
412
+            $rv .= "<div>".$line['author']."</div>";
413 413
             $rv .= "<div>$parsed_updated</div>";
414 414
 
415
-			$rv .= "</div>"; # row
415
+            $rv .= "</div>"; # row
416 416
 
417
-			$rv .= "</div>"; # header
417
+            $rv .= "</div>"; # header
418 418
 
419
-			/* content */
419
+            /* content */
420 420
 
421
-			$lang = $line['lang'] ? $line['lang'] : "en";
422
-			$rv .= "<div class='content' lang='$lang'>";
421
+            $lang = $line['lang'] ? $line['lang'] : "en";
422
+            $rv .= "<div class='content' lang='$lang'>";
423 423
 
424
-			/* content body */
424
+            /* content body */
425 425
 
426
-			$rv .= $line["content"];
426
+            $rv .= $line["content"];
427 427
 
428 428
             $rv .= Article::format_article_enclosures($id,
429 429
                 $line["always_display_enclosures"],
430 430
                 $line["content"],
431 431
                 $line["hide_images"]);
432 432
 
433
-			$rv .= "</div>"; # content
433
+            $rv .= "</div>"; # content
434 434
 
435
-			$rv .= "</div>"; # post
435
+            $rv .= "</div>"; # post
436 436
 
437
-		}
437
+        }
438 438
 
439
-		foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE) as $p) {
440
-			$rv = $p->hook_format_article($rv, $line, true);
441
-		}
439
+        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE) as $p) {
440
+            $rv = $p->hook_format_article($rv, $line, true);
441
+        }
442 442
 
443
-		return $rv;
443
+        return $rv;
444 444
 
445
-	}
445
+    }
446 446
 
447
-	public function rss() {
448
-		$feed = clean($_REQUEST["id"]);
449
-		$key = clean($_REQUEST["key"]);
450
-		$is_cat = clean($_REQUEST["is_cat"]);
451
-		$limit = (int)clean($_REQUEST["limit"]);
452
-		$offset = (int)clean($_REQUEST["offset"]);
447
+    public function rss() {
448
+        $feed = clean($_REQUEST["id"]);
449
+        $key = clean($_REQUEST["key"]);
450
+        $is_cat = clean($_REQUEST["is_cat"]);
451
+        $limit = (int)clean($_REQUEST["limit"]);
452
+        $offset = (int)clean($_REQUEST["offset"]);
453 453
 
454
-		$search = clean($_REQUEST["q"]);
455
-		$view_mode = clean($_REQUEST["view-mode"]);
456
-		$order = clean($_REQUEST["order"]);
457
-		$start_ts = clean($_REQUEST["ts"]);
454
+        $search = clean($_REQUEST["q"]);
455
+        $view_mode = clean($_REQUEST["view-mode"]);
456
+        $order = clean($_REQUEST["order"]);
457
+        $start_ts = clean($_REQUEST["ts"]);
458 458
 
459
-		$format = clean($_REQUEST['format']);
460
-		$orig_guid = clean($_REQUEST["orig_guid"]);
459
+        $format = clean($_REQUEST['format']);
460
+        $orig_guid = clean($_REQUEST["orig_guid"]);
461 461
 
462
-		if (!$format) $format = 'atom';
462
+        if (!$format) $format = 'atom';
463 463
 
464
-		if (SINGLE_USER_MODE) {
465
-			authenticate_user("admin", null);
466
-		}
464
+        if (SINGLE_USER_MODE) {
465
+            authenticate_user("admin", null);
466
+        }
467 467
 
468
-		$owner_id = false;
468
+        $owner_id = false;
469 469
 
470
-		if ($key) {
471
-			$sth = $this->pdo->prepare("SELECT owner_uid FROM
470
+        if ($key) {
471
+            $sth = $this->pdo->prepare("SELECT owner_uid FROM
472 472
 				ttrss_access_keys WHERE access_key = ? AND feed_id = ?");
473
-			$sth->execute([$key, $feed]);
473
+            $sth->execute([$key, $feed]);
474 474
 
475
-			if ($row = $sth->fetch())
476
-				$owner_id = $row["owner_uid"];
477
-		}
475
+            if ($row = $sth->fetch())
476
+                $owner_id = $row["owner_uid"];
477
+        }
478 478
 
479
-		if ($owner_id) {
480
-			$this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
481
-				$offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
482
-		} else {
483
-			header('HTTP/1.1 403 Forbidden');
484
-		}
485
-	}
479
+        if ($owner_id) {
480
+            $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
481
+                $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
482
+        } else {
483
+            header('HTTP/1.1 403 Forbidden');
484
+        }
485
+    }
486 486
 
487
-	public function updateTask() {
488
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
489
-	}
487
+    public function updateTask() {
488
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
489
+    }
490 490
 
491
-	public function housekeepingTask() {
492
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", false);
493
-	}
491
+    public function housekeepingTask() {
492
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", false);
493
+    }
494 494
 
495
-	public function globalUpdateFeeds() {
496
-		RPC::updaterandomfeed_real();
495
+    public function globalUpdateFeeds() {
496
+        RPC::updaterandomfeed_real();
497 497
 
498
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
499
-	}
498
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
499
+    }
500 500
 
501
-	public function sharepopup() {
502
-		if (SINGLE_USER_MODE) {
503
-			login_sequence();
504
-		}
501
+    public function sharepopup() {
502
+        if (SINGLE_USER_MODE) {
503
+            login_sequence();
504
+        }
505 505
 
506
-		header('Content-Type: text/html; charset=utf-8');
507
-		?>
506
+        header('Content-Type: text/html; charset=utf-8');
507
+        ?>
508 508
 		<!DOCTYPE html>
509 509
 		<html>
510 510
 		<head>
511 511
 			<title><?php echo __("Share with Tiny Tiny RSS") ?></title>
512 512
 			<?php
513
-			echo stylesheet_tag("css/default.css");
514
-			echo javascript_tag("lib/prototype.js");
515
-			echo javascript_tag("lib/dojo/dojo.js");
516
-			echo javascript_tag("lib/dojo/tt-rss-layer.js");
517
-			echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls")
518
-			?>
513
+            echo stylesheet_tag("css/default.css");
514
+            echo javascript_tag("lib/prototype.js");
515
+            echo javascript_tag("lib/dojo/dojo.js");
516
+            echo javascript_tag("lib/dojo/tt-rss-layer.js");
517
+            echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls")
518
+            ?>
519 519
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
520 520
 			<link rel="shortcut icon" type="image/png" href="images/favicon.png">
521 521
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
@@ -537,29 +537,29 @@  discard block
 block discarded – undo
537 537
 
538 538
 		<?php
539 539
 
540
-		$action = clean($_REQUEST["action"]);
540
+        $action = clean($_REQUEST["action"]);
541 541
 
542
-		if ($_SESSION["uid"]) {
542
+        if ($_SESSION["uid"]) {
543 543
 
544
-			if ($action == 'share') {
544
+            if ($action == 'share') {
545 545
 
546
-				$title = strip_tags(clean($_REQUEST["title"]));
547
-				$url = strip_tags(clean($_REQUEST["url"]));
548
-				$content = strip_tags(clean($_REQUEST["content"]));
549
-				$labels = strip_tags(clean($_REQUEST["labels"]));
546
+                $title = strip_tags(clean($_REQUEST["title"]));
547
+                $url = strip_tags(clean($_REQUEST["url"]));
548
+                $content = strip_tags(clean($_REQUEST["content"]));
549
+                $labels = strip_tags(clean($_REQUEST["labels"]));
550 550
 
551
-				Article::create_published_article($title, $url, $content, $labels,
552
-					$_SESSION["uid"]);
551
+                Article::create_published_article($title, $url, $content, $labels,
552
+                    $_SESSION["uid"]);
553 553
 
554
-				print "<script type='text/javascript'>";
555
-				print "window.close();";
556
-				print "</script>";
554
+                print "<script type='text/javascript'>";
555
+                print "window.close();";
556
+                print "</script>";
557 557
 
558
-			} else {
559
-				$title = htmlspecialchars(clean($_REQUEST["title"]));
560
-				$url = htmlspecialchars(clean($_REQUEST["url"]));
558
+            } else {
559
+                $title = htmlspecialchars(clean($_REQUEST["title"]));
560
+                $url = htmlspecialchars(clean($_REQUEST["url"]));
561 561
 
562
-				?>
562
+                ?>
563 563
 				<form id='share_form' name='share_form'>
564 564
 
565 565
 					<input type="hidden" name="op" value="sharepopup">
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 				</form>
600 600
 				<?php
601 601
 
602
-			}
602
+            }
603 603
 
604
-		} else {
604
+        } else {
605 605
 
606
-			$return = urlencode(make_self_url());
607
-			print_error("Not logged in"); ?>
606
+            $return = urlencode(make_self_url());
607
+            print_error("Not logged in"); ?>
608 608
 
609 609
 			<form action="public.php?return=<?php echo $return ?>" method="post">
610 610
 
@@ -636,90 +636,90 @@  discard block
 block discarded – undo
636 636
 
637 637
 			</form>
638 638
 			<?php
639
-		}
639
+        }
640 640
 
641
-		print "</div></body></html>";
642
-	}
641
+        print "</div></body></html>";
642
+    }
643 643
 
644
-	public function login() {
645
-		if (!SINGLE_USER_MODE) {
644
+    public function login() {
645
+        if (!SINGLE_USER_MODE) {
646 646
 
647
-			$login = clean($_POST["login"]);
648
-			$password = clean($_POST["password"]);
649
-			$remember_me = clean($_POST["remember_me"]);
647
+            $login = clean($_POST["login"]);
648
+            $password = clean($_POST["password"]);
649
+            $remember_me = clean($_POST["remember_me"]);
650 650
 
651
-			if ($remember_me) {
652
-				session_set_cookie_params(SESSION_COOKIE_LIFETIME);
653
-			} else {
654
-				session_set_cookie_params(0);
655
-			}
651
+            if ($remember_me) {
652
+                session_set_cookie_params(SESSION_COOKIE_LIFETIME);
653
+            } else {
654
+                session_set_cookie_params(0);
655
+            }
656 656
 
657
-			if (authenticate_user($login, $password)) {
658
-				$_POST["password"] = "";
657
+            if (authenticate_user($login, $password)) {
658
+                $_POST["password"] = "";
659 659
 
660
-				if (get_schema_version() >= 120) {
661
-					$_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
662
-				}
660
+                if (get_schema_version() >= 120) {
661
+                    $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
662
+                }
663 663
 
664
-				$_SESSION["ref_schema_version"] = get_schema_version(true);
665
-				$_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
664
+                $_SESSION["ref_schema_version"] = get_schema_version(true);
665
+                $_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
666 666
 
667
-				if (clean($_POST["profile"])) {
667
+                if (clean($_POST["profile"])) {
668 668
 
669
-					$profile = (int) clean($_POST["profile"]);
669
+                    $profile = (int) clean($_POST["profile"]);
670 670
 
671
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
671
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
672 672
 						WHERE id = ? AND owner_uid = ?");
673
-					$sth->execute([$profile, $_SESSION['uid']]);
673
+                    $sth->execute([$profile, $_SESSION['uid']]);
674 674
 
675
-					if ($sth->fetch()) {
676
-						$_SESSION["profile"] = $profile;
677
- 					} else {
678
-					    $_SESSION["profile"] = null;
675
+                    if ($sth->fetch()) {
676
+                        $_SESSION["profile"] = $profile;
677
+                        } else {
678
+                        $_SESSION["profile"] = null;
679 679
                     }
680
-				}
681
-			} else {
680
+                }
681
+            } else {
682 682
 
683
-				// start an empty session to deliver login error message
684
-				@session_start();
683
+                // start an empty session to deliver login error message
684
+                @session_start();
685 685
 
686
-				if (!isset($_SESSION["login_error_msg"]))
687
-					$_SESSION["login_error_msg"] = __("Incorrect username or password");
686
+                if (!isset($_SESSION["login_error_msg"]))
687
+                    $_SESSION["login_error_msg"] = __("Incorrect username or password");
688 688
 
689
-				user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
690
-			}
689
+                user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
690
+            }
691 691
 
692
-			$return = clean($_REQUEST['return']);
692
+            $return = clean($_REQUEST['return']);
693 693
 
694
-			if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
695
-				header("Location: " . clean($_REQUEST['return']));
696
-			} else {
697
-				header("Location: " . get_self_url_prefix());
698
-			}
699
-		}
700
-	}
694
+            if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
695
+                header("Location: " . clean($_REQUEST['return']));
696
+            } else {
697
+                header("Location: " . get_self_url_prefix());
698
+            }
699
+        }
700
+    }
701 701
 
702
-	public function subscribe() {
703
-		if (SINGLE_USER_MODE) {
704
-			login_sequence();
705
-		}
702
+    public function subscribe() {
703
+        if (SINGLE_USER_MODE) {
704
+            login_sequence();
705
+        }
706 706
 
707
-		if ($_SESSION["uid"]) {
707
+        if ($_SESSION["uid"]) {
708 708
 
709
-			$feed_url = trim(clean($_REQUEST["feed_url"]));
709
+            $feed_url = trim(clean($_REQUEST["feed_url"]));
710 710
 
711
-			header('Content-Type: text/html; charset=utf-8');
712
-			?>
711
+            header('Content-Type: text/html; charset=utf-8');
712
+            ?>
713 713
 			<!DOCTYPE html>
714 714
 			<html>
715 715
 			<head>
716 716
 				<title>Tiny Tiny RSS</title>
717 717
 				<?php
718
-					echo stylesheet_tag("css/default.css");
719
-					echo javascript_tag("lib/prototype.js");
720
-					echo javascript_tag("lib/dojo/dojo.js");
721
-					echo javascript_tag("lib/dojo/tt-rss-layer.js");
722
-				?>
718
+                    echo stylesheet_tag("css/default.css");
719
+                    echo javascript_tag("lib/prototype.js");
720
+                    echo javascript_tag("lib/dojo/dojo.js");
721
+                    echo javascript_tag("lib/dojo/tt-rss-layer.js");
722
+                ?>
723 723
 				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
724 724
 				<link rel="shortcut icon" type="image/png" href="images/favicon.png">
725 725
 				<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
@@ -738,8 +738,8 @@  discard block
 block discarded – undo
738 738
 			<div class='content'>
739 739
 			<?php
740 740
 
741
-			if (!$feed_url) {
742
-				?>
741
+            if (!$feed_url) {
742
+                ?>
743 743
 				<form method="post">
744 744
 					<input type="hidden" name="op" value="subscribe">
745 745
 					<fieldset>
@@ -754,101 +754,101 @@  discard block
 block discarded – undo
754 754
 					<a href="index.php"><?php echo __("Return to Tiny Tiny RSS") ?></a>
755 755
 				</form>
756 756
 				<?php
757
-			} else {
758
-
759
-				$rc = Feeds::subscribe_to_feed($feed_url);
760
-				$feed_urls = false;
761
-
762
-				switch ($rc['code']) {
763
-					case 0:
764
-						print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
765
-						break;
766
-					case 1:
767
-						print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
768
-						break;
769
-					case 2:
770
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
771
-						break;
772
-					case 3:
773
-						print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
774
-						break;
775
-					case 4:
776
-						$feed_urls = $rc["feeds"];
777
-						break;
778
-					case 5:
779
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
780
-						break;
781
-				}
782
-
783
-				if ($feed_urls) {
784
-
785
-					print "<form action='public.php'>";
786
-					print "<input type='hidden' name='op' value='subscribe'>";
787
-
788
-					print "<fieldset>";
789
-					print "<label style='display : inline'>" . __("Multiple feed URLs found:") . "</label>";
790
-					print "<select name='feed_url' dojoType='dijit.form.Select'>";
791
-
792
-					foreach ($feed_urls as $url => $name) {
793
-						$url = htmlspecialchars($url);
794
-						$name = htmlspecialchars($name);
795
-
796
-						print "<option value=\"$url\">$name</option>";
797
-					}
757
+            } else {
758
+
759
+                $rc = Feeds::subscribe_to_feed($feed_url);
760
+                $feed_urls = false;
761
+
762
+                switch ($rc['code']) {
763
+                    case 0:
764
+                        print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
765
+                        break;
766
+                    case 1:
767
+                        print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
768
+                        break;
769
+                    case 2:
770
+                        print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
771
+                        break;
772
+                    case 3:
773
+                        print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
774
+                        break;
775
+                    case 4:
776
+                        $feed_urls = $rc["feeds"];
777
+                        break;
778
+                    case 5:
779
+                        print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
780
+                        break;
781
+                }
782
+
783
+                if ($feed_urls) {
784
+
785
+                    print "<form action='public.php'>";
786
+                    print "<input type='hidden' name='op' value='subscribe'>";
787
+
788
+                    print "<fieldset>";
789
+                    print "<label style='display : inline'>" . __("Multiple feed URLs found:") . "</label>";
790
+                    print "<select name='feed_url' dojoType='dijit.form.Select'>";
791
+
792
+                    foreach ($feed_urls as $url => $name) {
793
+                        $url = htmlspecialchars($url);
794
+                        $name = htmlspecialchars($name);
795
+
796
+                        print "<option value=\"$url\">$name</option>";
797
+                    }
798 798
 
799
-					print "</select>";
800
-					print "</fieldset>";
799
+                    print "</select>";
800
+                    print "</fieldset>";
801 801
 
802
-					print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>";
803
-					print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
802
+                    print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>";
803
+                    print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
804 804
 
805
-					print "</form>";
806
-				}
805
+                    print "</form>";
806
+                }
807 807
 
808
-				$tp_uri = get_self_url_prefix() . "/prefs.php";
808
+                $tp_uri = get_self_url_prefix() . "/prefs.php";
809 809
 
810
-				if ($rc['code'] <= 2){
811
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
810
+                if ($rc['code'] <= 2){
811
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
812 812
 					feed_url = ? AND owner_uid = ?");
813
-					$sth->execute([$feed_url, $_SESSION['uid']]);
814
-					$row = $sth->fetch();
813
+                    $sth->execute([$feed_url, $_SESSION['uid']]);
814
+                    $row = $sth->fetch();
815 815
 
816
-					$feed_id = $row["id"];
817
-				} else {
818
-					$feed_id = 0;
819
-				}
816
+                    $feed_id = $row["id"];
817
+                } else {
818
+                    $feed_id = 0;
819
+                }
820 820
 
821
-				if ($feed_id) {
822
-					print "<form method='GET' action=\"$tp_uri\">
821
+                if ($feed_id) {
822
+                    print "<form method='GET' action=\"$tp_uri\">
823 823
 					<input type='hidden' name='tab' value='feedConfig'>
824 824
 					<input type='hidden' name='method' value='editfeed'>
825 825
 					<input type='hidden' name='methodparam' value='$feed_id'>
826 826
 					<button dojoType='dijit.form.Button' class='alt-info' type='submit'>".__("Edit subscription options")."</button>
827 827
 					<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>
828 828
 					</form>";
829
-				}
830
-			}
829
+                }
830
+            }
831 831
 
832
-			print "</div></div></body></html>";
832
+            print "</div></div></body></html>";
833 833
 
834
-		} else {
835
-			render_login_form();
836
-		}
837
-	}
834
+        } else {
835
+            render_login_form();
836
+        }
837
+    }
838 838
 
839
-	public function index() {
840
-		header("Content-Type: text/plain");
841
-		print error_json(13);
842
-	}
839
+    public function index() {
840
+        header("Content-Type: text/plain");
841
+        print error_json(13);
842
+    }
843 843
 
844
-	public function forgotpass() {
845
-		startup_gettext();
846
-		session_start();
844
+    public function forgotpass() {
845
+        startup_gettext();
846
+        session_start();
847 847
 
848
-		@$hash = clean($_REQUEST["hash"]);
848
+        @$hash = clean($_REQUEST["hash"]);
849 849
 
850
-		header('Content-Type: text/html; charset=utf-8');
851
-		?>
850
+        header('Content-Type: text/html; charset=utf-8');
851
+        ?>
852 852
 		<!DOCTYPE html>
853 853
 		<html>
854 854
 		<head>
@@ -857,11 +857,11 @@  discard block
 block discarded – undo
857 857
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
858 858
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
859 859
 			<?php
860
-				echo stylesheet_tag("css/default.css");
861
-				echo javascript_tag("lib/prototype.js");
862
-				echo javascript_tag("lib/dojo/dojo.js");
863
-				echo javascript_tag("lib/dojo/tt-rss-layer.js");
864
-			?>
860
+                echo stylesheet_tag("css/default.css");
861
+                echo javascript_tag("lib/prototype.js");
862
+                echo javascript_tag("lib/dojo/dojo.js");
863
+                echo javascript_tag("lib/dojo/tt-rss-layer.js");
864
+            ?>
865 865
 		</head>
866 866
 		<body class='flat ttrss_utility'>
867 867
 		<div class='container'>
@@ -876,52 +876,52 @@  discard block
 block discarded – undo
876 876
 		</script>
877 877
 		<?php
878 878
 
879
-		print "<h1>".__("Password recovery")."</h1>";
880
-		print "<div class='content'>";
879
+        print "<h1>".__("Password recovery")."</h1>";
880
+        print "<div class='content'>";
881 881
 
882
-		@$method = clean($_POST['method']);
882
+        @$method = clean($_POST['method']);
883 883
 
884
-		if ($hash) {
885
-			$login = clean($_REQUEST["login"]);
884
+        if ($hash) {
885
+            $login = clean($_REQUEST["login"]);
886 886
 
887
-			if ($login) {
888
-				$sth = $this->pdo->prepare("SELECT id, resetpass_token FROM ttrss_users
887
+            if ($login) {
888
+                $sth = $this->pdo->prepare("SELECT id, resetpass_token FROM ttrss_users
889 889
 					WHERE login = ?");
890
-				$sth->execute([$login]);
890
+                $sth->execute([$login]);
891 891
 
892
-				if ($row = $sth->fetch()) {
893
-					$id = $row["id"];
894
-					$resetpass_token_full = $row["resetpass_token"];
895
-					list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
892
+                if ($row = $sth->fetch()) {
893
+                    $id = $row["id"];
894
+                    $resetpass_token_full = $row["resetpass_token"];
895
+                    list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
896 896
 
897
-					if ($timestamp && $resetpass_token &&
898
-						$timestamp >= time() - 15*60*60 &&
899
-						$resetpass_token == $hash) {
897
+                    if ($timestamp && $resetpass_token &&
898
+                        $timestamp >= time() - 15*60*60 &&
899
+                        $resetpass_token == $hash) {
900 900
 
901
-							$sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL
901
+                            $sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL
902 902
 								WHERE id = ?");
903
-							$sth->execute([$id]);
903
+                            $sth->execute([$id]);
904 904
 
905
-							Pref_Users::resetUserPassword($id, true);
905
+                            Pref_Users::resetUserPassword($id, true);
906 906
 
907
-							print "<p>"."Completed."."</p>";
907
+                            print "<p>"."Completed."."</p>";
908 908
 
909
-					} else {
910
-						print_error("Some of the information provided is missing or incorrect.");
911
-					}
912
-				} else {
913
-					print_error("Some of the information provided is missing or incorrect.");
914
-				}
915
-			} else {
916
-				print_error("Some of the information provided is missing or incorrect.");
917
-			}
909
+                    } else {
910
+                        print_error("Some of the information provided is missing or incorrect.");
911
+                    }
912
+                } else {
913
+                    print_error("Some of the information provided is missing or incorrect.");
914
+                }
915
+            } else {
916
+                print_error("Some of the information provided is missing or incorrect.");
917
+            }
918 918
 
919
-			print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
919
+            print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
920 920
 
921
-		} else if (!$method) {
922
-			print_notice(__("You will need to provide valid account name and email. Password reset link will be sent to your email address."));
921
+        } else if (!$method) {
922
+            print_notice(__("You will need to provide valid account name and email. Password reset link will be sent to your email address."));
923 923
 
924
-			print "<form method='POST' action='public.php'>
924
+            print "<form method='POST' action='public.php'>
925 925
 				<input type='hidden' name='method' value='do'>
926 926
 				<input type='hidden' name='op' value='forgotpass'>
927 927
 
@@ -935,10 +935,10 @@  discard block
 block discarded – undo
935 935
 				<input dojoType='dijit.form.TextBox' type='email' name='email' value='' required>
936 936
 				</fieldset>";
937 937
 
938
-			$_SESSION["pwdreset:testvalue1"] = rand(1,10);
939
-			$_SESSION["pwdreset:testvalue2"] = rand(1,10);
938
+            $_SESSION["pwdreset:testvalue1"] = rand(1,10);
939
+            $_SESSION["pwdreset:testvalue2"] = rand(1,10);
940 940
 
941
-			print "<fieldset>
941
+            print "<fieldset>
942 942
 				<label>".T_sprintf("How much is %d + %d:", $_SESSION["pwdreset:testvalue1"], $_SESSION["pwdreset:testvalue2"])."</label>
943 943
 				<input dojoType='dijit.form.TextBox' type='text' name='test' value='' required>
944 944
 				</fieldset>
@@ -950,109 +950,109 @@  discard block
 block discarded – undo
950 950
 				</fieldset>
951 951
 
952 952
 				</form>";
953
-		} else if ($method == 'do') {
953
+        } else if ($method == 'do') {
954 954
 
955
-			$login = clean($_POST["login"]);
956
-			$email = clean($_POST["email"]);
957
-			$test = clean($_POST["test"]);
955
+            $login = clean($_POST["login"]);
956
+            $email = clean($_POST["email"]);
957
+            $test = clean($_POST["test"]);
958 958
 
959
-			if ($test != ($_SESSION["pwdreset:testvalue1"] + $_SESSION["pwdreset:testvalue2"]) || !$email || !$login) {
960
-				print_error(__('Some of the required form parameters are missing or incorrect.'));
959
+            if ($test != ($_SESSION["pwdreset:testvalue1"] + $_SESSION["pwdreset:testvalue2"]) || !$email || !$login) {
960
+                print_error(__('Some of the required form parameters are missing or incorrect.'));
961 961
 
962
-				print "<form method='GET' action='public.php'>
962
+                print "<form method='GET' action='public.php'>
963 963
 					<input type='hidden' name='op' value='forgotpass'>
964 964
 					<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".__("Go back")."</button>
965 965
 					</form>";
966 966
 
967
-			} else {
967
+            } else {
968 968
 
969
-				// prevent submitting this form multiple times
970
-				$_SESSION["pwdreset:testvalue1"] = rand(1, 1000);
971
-				$_SESSION["pwdreset:testvalue2"] = rand(1, 1000);
969
+                // prevent submitting this form multiple times
970
+                $_SESSION["pwdreset:testvalue1"] = rand(1, 1000);
971
+                $_SESSION["pwdreset:testvalue2"] = rand(1, 1000);
972 972
 
973
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users
973
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users
974 974
 					WHERE login = ? AND email = ?");
975
-				$sth->execute([$login, $email]);
975
+                $sth->execute([$login, $email]);
976 976
 
977
-				if ($row = $sth->fetch()) {
978
-					print_notice("Password reset instructions are being sent to your email address.");
977
+                if ($row = $sth->fetch()) {
978
+                    print_notice("Password reset instructions are being sent to your email address.");
979 979
 
980
-					$id = $row["id"];
980
+                    $id = $row["id"];
981 981
 
982
-					if ($id) {
983
-						$resetpass_token = sha1(get_random_bytes(128));
984
-						$resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
985
-							"&login=" . urlencode($login);
982
+                    if ($id) {
983
+                        $resetpass_token = sha1(get_random_bytes(128));
984
+                        $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token .
985
+                            "&login=" . urlencode($login);
986 986
 
987
-						require_once "lib/MiniTemplator.class.php";
987
+                        require_once "lib/MiniTemplator.class.php";
988 988
 
989
-						$tpl = new MiniTemplator;
989
+                        $tpl = new MiniTemplator;
990 990
 
991
-						$tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
991
+                        $tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
992 992
 
993
-						$tpl->setVariable('LOGIN', $login);
994
-						$tpl->setVariable('RESETPASS_LINK', $resetpass_link);
995
-						$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
993
+                        $tpl->setVariable('LOGIN', $login);
994
+                        $tpl->setVariable('RESETPASS_LINK', $resetpass_link);
995
+                        $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
996 996
 
997
-						$tpl->addBlock('message');
997
+                        $tpl->addBlock('message');
998 998
 
999
-						$message = "";
999
+                        $message = "";
1000 1000
 
1001
-						$tpl->generateOutputToString($message);
1001
+                        $tpl->generateOutputToString($message);
1002 1002
 
1003
-						$mailer = new Mailer();
1003
+                        $mailer = new Mailer();
1004 1004
 
1005
-						$rc = $mailer->mail(["to_name" => $login,
1006
-							"to_address" => $email,
1007
-							"subject" => __("[tt-rss] Password reset request"),
1008
-							"message" => $message]);
1005
+                        $rc = $mailer->mail(["to_name" => $login,
1006
+                            "to_address" => $email,
1007
+                            "subject" => __("[tt-rss] Password reset request"),
1008
+                            "message" => $message]);
1009 1009
 
1010
-						if (!$rc) print_error($mailer->error());
1010
+                        if (!$rc) print_error($mailer->error());
1011 1011
 
1012
-						$resetpass_token_full = time() . ":" . $resetpass_token;
1012
+                        $resetpass_token_full = time() . ":" . $resetpass_token;
1013 1013
 
1014
-						$sth = $this->pdo->prepare("UPDATE ttrss_users
1014
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users
1015 1015
 							SET resetpass_token = ?
1016 1016
 							WHERE login = ? AND email = ?");
1017 1017
 
1018
-						$sth->execute([$resetpass_token_full, $login, $email]);
1018
+                        $sth->execute([$resetpass_token_full, $login, $email]);
1019 1019
 
1020
-					} else {
1021
-						print_error("User ID not found.");
1022
-					}
1020
+                    } else {
1021
+                        print_error("User ID not found.");
1022
+                    }
1023 1023
 
1024
-					print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1024
+                    print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1025 1025
 
1026
-				} else {
1027
-					print_error(__("Sorry, login and email combination not found."));
1026
+                } else {
1027
+                    print_error(__("Sorry, login and email combination not found."));
1028 1028
 
1029
-					print "<form method='GET' action='public.php'>
1029
+                    print "<form method='GET' action='public.php'>
1030 1030
 						<input type='hidden' name='op' value='forgotpass'>
1031 1031
 						<button dojoType='dijit.form.Button' type='submit'>".__("Go back")."</button>
1032 1032
 						</form>";
1033 1033
 
1034
-				}
1035
-			}
1034
+                }
1035
+            }
1036 1036
 
1037
-		}
1037
+        }
1038 1038
 
1039
-		print "</div>";
1040
-		print "</div>";
1041
-		print "</body>";
1042
-		print "</html>";
1039
+        print "</div>";
1040
+        print "</div>";
1041
+        print "</body>";
1042
+        print "</html>";
1043 1043
 
1044
-	}
1044
+    }
1045 1045
 
1046
-	public function dbupdate() {
1047
-		startup_gettext();
1046
+    public function dbupdate() {
1047
+        startup_gettext();
1048 1048
 
1049
-		if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
1050
-			$_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
1051
-			render_login_form();
1052
-			exit;
1053
-		}
1049
+        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
1050
+            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
1051
+            render_login_form();
1052
+            exit;
1053
+        }
1054 1054
 
1055
-		?>
1055
+        ?>
1056 1056
 		<!DOCTYPE html>
1057 1057
 		<html>
1058 1058
 			<head>
@@ -1062,11 +1062,11 @@  discard block
 block discarded – undo
1062 1062
 			<link rel="shortcut icon" type="image/png" href="images/favicon.png">
1063 1063
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
1064 1064
 			<?php
1065
-				echo stylesheet_tag("css/default.css");
1066
-				echo javascript_tag("lib/prototype.js");
1067
-				echo javascript_tag("lib/dojo/dojo.js");
1068
-				echo javascript_tag("lib/dojo/tt-rss-layer.js");
1069
-			?>
1065
+                echo stylesheet_tag("css/default.css");
1066
+                echo javascript_tag("lib/prototype.js");
1067
+                echo javascript_tag("lib/dojo/dojo.js");
1068
+                echo javascript_tag("lib/dojo/tt-rss-layer.js");
1069
+            ?>
1070 1070
 			<style type="text/css">
1071 1071
 				span.ok { color : #009000; font-weight : bold; }
1072 1072
 				span.err { color : #ff0000; font-weight : bold; }
@@ -1093,139 +1093,139 @@  discard block
 block discarded – undo
1093 1093
 			<div class="content">
1094 1094
 
1095 1095
 			<?php
1096
-				@$op = clean($_REQUEST["subop"]);
1097
-				$updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
1096
+                @$op = clean($_REQUEST["subop"]);
1097
+                $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
1098 1098
 
1099
-				if ($op == "performupdate") {
1100
-					if ($updater->isUpdateRequired()) {
1099
+                if ($op == "performupdate") {
1100
+                    if ($updater->isUpdateRequired()) {
1101 1101
 
1102
-						print "<h2>" . T_sprintf("Performing updates to version %d", SCHEMA_VERSION) . "</h2>";
1102
+                        print "<h2>" . T_sprintf("Performing updates to version %d", SCHEMA_VERSION) . "</h2>";
1103 1103
 
1104
-						for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
1105
-							print "<ul>";
1104
+                        for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
1105
+                            print "<ul>";
1106 1106
 
1107
-							print "<li class='text-info'>" . T_sprintf("Updating to version %d", $i) . "</li>";
1107
+                            print "<li class='text-info'>" . T_sprintf("Updating to version %d", $i) . "</li>";
1108 1108
 
1109
-							print "<li>";
1110
-							$result = $updater->performUpdateTo($i, true);
1111
-							print "</li>";
1109
+                            print "<li>";
1110
+                            $result = $updater->performUpdateTo($i, true);
1111
+                            print "</li>";
1112 1112
 
1113
-							if (!$result) {
1114
-								print "</ul>";
1113
+                            if (!$result) {
1114
+                                print "</ul>";
1115 1115
 
1116
-								print_error("One of the updates failed. Either retry the process or perform updates manually.");
1116
+                                print_error("One of the updates failed. Either retry the process or perform updates manually.");
1117 1117
 
1118
-								print "<form method='POST'>
1118
+                                print "<form method='POST'>
1119 1119
 									<input type='hidden' name='subop' value='performupdate'>
1120 1120
 									<button type='submit' dojoType='dijit.form.Button' class='alt-danger' onclick='return confirmOP()'>".__("Try again")."</button>
1121 1121
 									<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>
1122 1122
 								</form>";
1123 1123
 
1124
-								return;
1125
-							} else {
1126
-								print "<li class='text-success'>" . __("Completed.") . "</li>";
1127
-								print "</ul>";
1128
-							}
1129
-						}
1124
+                                return;
1125
+                            } else {
1126
+                                print "<li class='text-success'>" . __("Completed.") . "</li>";
1127
+                                print "</ul>";
1128
+                            }
1129
+                        }
1130 1130
 
1131
-						print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
1131
+                        print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
1132 1132
 
1133
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1133
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1134 1134
 
1135
-					} else {
1136
-						print_notice("Tiny Tiny RSS database is up to date.");
1135
+                    } else {
1136
+                        print_notice("Tiny Tiny RSS database is up to date.");
1137 1137
 
1138
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1139
-					}
1140
-				} else {
1141
-					if ($updater->isUpdateRequired()) {
1138
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1139
+                    }
1140
+                } else {
1141
+                    if ($updater->isUpdateRequired()) {
1142 1142
 
1143
-						print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
1144
-							$updater->getSchemaVersion(), SCHEMA_VERSION)."</h2>";
1143
+                        print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
1144
+                            $updater->getSchemaVersion(), SCHEMA_VERSION)."</h2>";
1145 1145
 
1146
-						if (DB_TYPE == "mysql") {
1147
-							print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
1148
-								"Errors may put it in an inconsistent state requiring manual rollback. <strong>BACKUP YOUR DATABASE BEFORE CONTINUING.</strong>");
1149
-						} else {
1150
-							print_warning("Please backup your database before proceeding.");
1151
-						}
1146
+                        if (DB_TYPE == "mysql") {
1147
+                            print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
1148
+                                "Errors may put it in an inconsistent state requiring manual rollback. <strong>BACKUP YOUR DATABASE BEFORE CONTINUING.</strong>");
1149
+                        } else {
1150
+                            print_warning("Please backup your database before proceeding.");
1151
+                        }
1152 1152
 
1153
-						print "<form method='POST'>
1153
+                        print "<form method='POST'>
1154 1154
 							<input type='hidden' name='subop' value='performupdate'>
1155 1155
 							<button type='submit' dojoType='dijit.form.Button' class='alt-danger' onclick='return confirmOP()'>".__("Perform updates")."</button>
1156 1156
 						</form>";
1157 1157
 
1158
-					} else {
1158
+                    } else {
1159 1159
 
1160
-						print_notice("Tiny Tiny RSS database is up to date.");
1160
+                        print_notice("Tiny Tiny RSS database is up to date.");
1161 1161
 
1162
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1163
-					}
1164
-				}
1165
-			?>
1162
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1163
+                    }
1164
+                }
1165
+            ?>
1166 1166
 
1167 1167
 			</div>
1168 1168
 			</div>
1169 1169
 			</body>
1170 1170
 			</html>
1171 1171
 		<?php
1172
-	}
1173
-
1174
-	public function cached_url() {
1175
-		list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
1176
-
1177
-		// we do not allow files with extensions at the moment
1178
-		$filename = str_replace(".", "", $filename);
1179
-
1180
-		$cache = new DiskCache($cache_dir);
1181
-
1182
-		if ($cache->exists($filename)) {
1183
-			$cache->send($filename);
1184
-		} else {
1185
-			header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
1186
-			echo "File not found.";
1187
-		}
1188
-	}
1189
-
1190
-	private function make_article_tag_uri($id, $timestamp) {
1191
-
1192
-		$timestamp = date("Y-m-d", strtotime($timestamp));
1193
-
1194
-		return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id";
1195
-	}
1196
-
1197
-	// this should be used very carefully because this endpoint is exposed to unauthenticated users
1198
-	// plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
1199
-	// in general, don't do anything user-related in here and do not modify $_SESSION
1200
-	public function pluginhandler() {
1201
-		$host = new PluginHost();
1202
-
1203
-		$plugin_name = clean_filename($_REQUEST["plugin"]);
1204
-		$method = clean($_REQUEST["pmethod"]);
1205
-
1206
-		$host->load($plugin_name, PluginHost::KIND_USER, 0);
1207
-		$host->load_data();
1208
-
1209
-		$plugin = $host->get_plugin($plugin_name);
1210
-
1211
-		if ($plugin) {
1212
-			if (method_exists($plugin, $method)) {
1213
-				if ($plugin->is_public_method($method)) {
1214
-					$plugin->$method();
1215
-				} else {
1216
-					user_error("PluginHandler[PUBLIC]: Requested private method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1217
-					header("Content-Type: text/json");
1218
-					print error_json(6);
1219
-				}
1220
-			} else {
1221
-				user_error("PluginHandler[PUBLIC]: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1222
-				header("Content-Type: text/json");
1223
-				print error_json(13);
1224
-			}
1225
-		} else {
1226
-			user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
1227
-			header("Content-Type: text/json");
1228
-			print error_json(14);
1229
-		}
1230
-	}
1172
+    }
1173
+
1174
+    public function cached_url() {
1175
+        list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
1176
+
1177
+        // we do not allow files with extensions at the moment
1178
+        $filename = str_replace(".", "", $filename);
1179
+
1180
+        $cache = new DiskCache($cache_dir);
1181
+
1182
+        if ($cache->exists($filename)) {
1183
+            $cache->send($filename);
1184
+        } else {
1185
+            header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
1186
+            echo "File not found.";
1187
+        }
1188
+    }
1189
+
1190
+    private function make_article_tag_uri($id, $timestamp) {
1191
+
1192
+        $timestamp = date("Y-m-d", strtotime($timestamp));
1193
+
1194
+        return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id";
1195
+    }
1196
+
1197
+    // this should be used very carefully because this endpoint is exposed to unauthenticated users
1198
+    // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
1199
+    // in general, don't do anything user-related in here and do not modify $_SESSION
1200
+    public function pluginhandler() {
1201
+        $host = new PluginHost();
1202
+
1203
+        $plugin_name = clean_filename($_REQUEST["plugin"]);
1204
+        $method = clean($_REQUEST["pmethod"]);
1205
+
1206
+        $host->load($plugin_name, PluginHost::KIND_USER, 0);
1207
+        $host->load_data();
1208
+
1209
+        $plugin = $host->get_plugin($plugin_name);
1210
+
1211
+        if ($plugin) {
1212
+            if (method_exists($plugin, $method)) {
1213
+                if ($plugin->is_public_method($method)) {
1214
+                    $plugin->$method();
1215
+                } else {
1216
+                    user_error("PluginHandler[PUBLIC]: Requested private method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1217
+                    header("Content-Type: text/json");
1218
+                    print error_json(6);
1219
+                }
1220
+            } else {
1221
+                user_error("PluginHandler[PUBLIC]: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1222
+                header("Content-Type: text/json");
1223
+                print error_json(13);
1224
+            }
1225
+        } else {
1226
+            user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
1227
+            header("Content-Type: text/json");
1228
+            print error_json(14);
1229
+        }
1230
+    }
1231 1231
 }
Please login to merge, or discard this patch.
classes/feedenclosure.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 class FeedEnclosure {
3
-	public $link;
4
-	public $type;
5
-	public $length;
6
-	public $title;
7
-	public $height;
8
-	public $width;
3
+    public $link;
4
+    public $type;
5
+    public $length;
6
+    public $title;
7
+    public $height;
8
+    public $width;
9 9
 }
10 10
 
Please login to merge, or discard this patch.
classes/feedparser.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -1,233 +1,233 @@
 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
-				if ($title) {
88
-					$this->title = $title->nodeValue;
89
-				}
90
-
91
-				$link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
92
-
93
-				if (!$link)
94
-					$link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
95
-
96
-				if (!$link)
97
-					$link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
98
-
99
-				if (!$link)
100
-					$link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
101
-
102
-				if ($link && $link->hasAttributes()) {
103
-					$this->link = $link->getAttribute("href");
104
-				}
105
-
106
-				$articles = $xpath->query("//atom:entry");
107
-
108
-				if (!$articles || $articles->length == 0)
109
-					$articles = $xpath->query("//atom03:entry");
110
-
111
-				foreach ($articles as $article) {
112
-					array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
113
-				}
114
-
115
-				break;
116
-			case $this::FEED_RSS:
117
-				$title = $xpath->query("//channel/title")->item(0);
118
-
119
-				if ($title) {
120
-					$this->title = $title->nodeValue;
121
-				}
122
-
123
-				$link = $xpath->query("//channel/link")->item(0);
124
-
125
-				if ($link) {
126
-					if ($link->getAttribute("href"))
127
-						$this->link = $link->getAttribute("href");
128
-					else if ($link->nodeValue)
129
-						$this->link = $link->nodeValue;
130
-				}
131
-
132
-				$articles = $xpath->query("//channel/item");
133
-
134
-				foreach ($articles as $article) {
135
-					array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
136
-				}
137
-
138
-				break;
139
-			case $this::FEED_RDF:
140
-				$xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
141
-
142
-				$title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
143
-
144
-				if ($title) {
145
-					$this->title = $title->nodeValue;
146
-				}
147
-
148
-				$link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
149
-
150
-				if ($link) {
151
-					$this->link = $link->nodeValue;
152
-				}
153
-
154
-				$articles = $xpath->query("//rssfake:item");
155
-
156
-				foreach ($articles as $article) {
157
-					array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
158
-				}
159
-
160
-				break;
161
-
162
-			}
163
-
164
-			if ($this->title) $this->title = trim($this->title);
165
-			if ($this->link) $this->link = trim($this->link);
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
+                if ($title) {
88
+                    $this->title = $title->nodeValue;
89
+                }
90
+
91
+                $link = $xpath->query("//atom:feed/atom:link[not(@rel)]")->item(0);
92
+
93
+                if (!$link)
94
+                    $link = $xpath->query("//atom:feed/atom:link[@rel='alternate']")->item(0);
95
+
96
+                if (!$link)
97
+                    $link = $xpath->query("//atom03:feed/atom03:link[not(@rel)]")->item(0);
98
+
99
+                if (!$link)
100
+                    $link = $xpath->query("//atom03:feed/atom03:link[@rel='alternate']")->item(0);
101
+
102
+                if ($link && $link->hasAttributes()) {
103
+                    $this->link = $link->getAttribute("href");
104
+                }
105
+
106
+                $articles = $xpath->query("//atom:entry");
107
+
108
+                if (!$articles || $articles->length == 0)
109
+                    $articles = $xpath->query("//atom03:entry");
110
+
111
+                foreach ($articles as $article) {
112
+                    array_push($this->items, new FeedItem_Atom($article, $this->doc, $this->xpath));
113
+                }
114
+
115
+                break;
116
+            case $this::FEED_RSS:
117
+                $title = $xpath->query("//channel/title")->item(0);
118
+
119
+                if ($title) {
120
+                    $this->title = $title->nodeValue;
121
+                }
122
+
123
+                $link = $xpath->query("//channel/link")->item(0);
124
+
125
+                if ($link) {
126
+                    if ($link->getAttribute("href"))
127
+                        $this->link = $link->getAttribute("href");
128
+                    else if ($link->nodeValue)
129
+                        $this->link = $link->nodeValue;
130
+                }
131
+
132
+                $articles = $xpath->query("//channel/item");
133
+
134
+                foreach ($articles as $article) {
135
+                    array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
136
+                }
137
+
138
+                break;
139
+            case $this::FEED_RDF:
140
+                $xpath->registerNamespace('rssfake', 'http://purl.org/rss/1.0/');
141
+
142
+                $title = $xpath->query("//rssfake:channel/rssfake:title")->item(0);
143
+
144
+                if ($title) {
145
+                    $this->title = $title->nodeValue;
146
+                }
147
+
148
+                $link = $xpath->query("//rssfake:channel/rssfake:link")->item(0);
149
+
150
+                if ($link) {
151
+                    $this->link = $link->nodeValue;
152
+                }
153
+
154
+                $articles = $xpath->query("//rssfake:item");
155
+
156
+                foreach ($articles as $article) {
157
+                    array_push($this->items, new FeedItem_RSS($article, $this->doc, $this->xpath));
158
+                }
159
+
160
+                break;
161
+
162
+            }
163
+
164
+            if ($this->title) $this->title = trim($this->title);
165
+            if ($this->link) $this->link = trim($this->link);
166 166
 
167
-		} else {
168
-			if( !isset($this->error) ){
169
-				$this->error = "Unknown/unsupported feed type";
170
-			}
171
-			return;
172
-		}
173
-	}
167
+        } else {
168
+            if( !isset($this->error) ){
169
+                $this->error = "Unknown/unsupported feed type";
170
+            }
171
+            return;
172
+        }
173
+    }
174 174
 
175
-	public function format_error($error) {
176
-		if ($error) {
177
-			return sprintf("LibXML error %s at line %d (column %d): %s",
178
-				$error->code, $error->line, $error->column,
179
-				$error->message);
180
-		} else {
181
-			return "";
182
-		}
183
-	}
175
+    public function format_error($error) {
176
+        if ($error) {
177
+            return sprintf("LibXML error %s at line %d (column %d): %s",
178
+                $error->code, $error->line, $error->column,
179
+                $error->message);
180
+        } else {
181
+            return "";
182
+        }
183
+    }
184 184
 
185
-	// libxml may have invalid unicode data in error messages
186
-	public function error() {
187
-		return UConverter::transcode($this->error, 'UTF-8', 'UTF-8');
188
-	}
185
+    // libxml may have invalid unicode data in error messages
186
+    public function error() {
187
+        return UConverter::transcode($this->error, 'UTF-8', 'UTF-8');
188
+    }
189 189
 
190
-	// WARNING: may return invalid unicode data
191
-	public function errors() {
192
-		return $this->libxml_errors;
193
-	}
190
+    // WARNING: may return invalid unicode data
191
+    public function errors() {
192
+        return $this->libxml_errors;
193
+    }
194 194
 
195
-	public function get_link() {
196
-		return clean($this->link);
197
-	}
195
+    public function get_link() {
196
+        return clean($this->link);
197
+    }
198 198
 
199
-	public function get_title() {
200
-		return clean($this->title);
201
-	}
202
-
203
-	public function get_items() {
204
-		return $this->items;
205
-	}
206
-
207
-	public function get_links($rel) {
208
-		$rv = array();
209
-
210
-		switch ($this->type) {
211
-		case $this::FEED_ATOM:
212
-			$links = $this->xpath->query("//atom:feed/atom:link");
213
-
214
-			foreach ($links as $link) {
215
-				if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
216
-					array_push($rv, clean(trim($link->getAttribute('href'))));
217
-				}
218
-			}
219
-			break;
220
-		case $this::FEED_RSS:
221
-			$links = $this->xpath->query("//atom:link");
222
-
223
-			foreach ($links as $link) {
224
-				if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
225
-					array_push($rv, clean(trim($link->getAttribute('href'))));
226
-				}
227
-			}
228
-			break;
229
-		}
230
-
231
-		return $rv;
232
-	}
199
+    public function get_title() {
200
+        return clean($this->title);
201
+    }
202
+
203
+    public function get_items() {
204
+        return $this->items;
205
+    }
206
+
207
+    public function get_links($rel) {
208
+        $rv = array();
209
+
210
+        switch ($this->type) {
211
+        case $this::FEED_ATOM:
212
+            $links = $this->xpath->query("//atom:feed/atom:link");
213
+
214
+            foreach ($links as $link) {
215
+                if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
216
+                    array_push($rv, clean(trim($link->getAttribute('href'))));
217
+                }
218
+            }
219
+            break;
220
+        case $this::FEED_RSS:
221
+            $links = $this->xpath->query("//atom:link");
222
+
223
+            foreach ($links as $link) {
224
+                if (!$rel || $link->hasAttribute('rel') && $link->getAttribute('rel') == $rel) {
225
+                    array_push($rv, clean(trim($link->getAttribute('href'))));
226
+                }
227
+            }
228
+            break;
229
+        }
230
+
231
+        return $rv;
232
+    }
233 233
 }
Please login to merge, or discard this patch.
classes/iauthmodule.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1 1
 <?php
2 2
 interface IAuthModule {
3
-	public function authenticate($login, $password); // + optional third parameter: $service
3
+    public function authenticate($login, $password); // + optional third parameter: $service
4 4
 }
Please login to merge, or discard this patch.
classes/dbupdater.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -2,83 +2,83 @@
 block discarded – undo
2 2
 
3 3
 class DbUpdater {
4 4
 
5
-	private $pdo;
6
-	private $db_type;
7
-	private $need_version;
8
-
9
-	public function __construct($db_type, $need_version) {
10
-		$this->pdo = Db::pdo();
11
-		$this->db_type = $db_type;
12
-		$this->need_version = (int) $need_version;
13
-	}
14
-
15
-	public function getSchemaVersion() {
16
-		$row = $this->pdo->query("SELECT schema_version FROM ttrss_version")->fetch();
17
-		return (int) $row['schema_version'];
18
-	}
19
-
20
-	public function isUpdateRequired() {
21
-		return $this->getSchemaVersion() < $this->need_version;
22
-	}
23
-
24
-	public function getSchemaLines($version) {
25
-		$filename = "schema/versions/".$this->db_type."/$version.sql";
26
-
27
-		if (file_exists($filename)) {
28
-			return explode(";", preg_replace("/[\r\n]/", "", file_get_contents($filename)));
29
-		} else {
30
-			user_error("DB Updater: schema file for version $version is not found.");
31
-			return false;
32
-		}
33
-	}
34
-
35
-	public function performUpdateTo($version, $html_output = true) {
36
-		if ($this->getSchemaVersion() == $version - 1) {
37
-
38
-			$lines = $this->getSchemaLines($version);
39
-
40
-			if (is_array($lines)) {
41
-
42
-				$this->pdo->beginTransaction();
43
-
44
-				foreach ($lines as $line) {
45
-					if (strpos($line, "--") !== 0 && $line) {
46
-
47
-						if ($html_output)
48
-							print "<pre>$line</pre>";
49
-						else
50
-							Debug::log("> $line");
51
-
52
-						try {
53
-							$this->pdo->query($line); // PDO returns errors as exceptions now
54
-						} catch (PDOException $e) {
55
-							if ($html_output) {
56
-								print "<div class='text-error'>Error: " . $e->getMessage() . "</div>";
57
-							} else {
58
-								Debug::log("Error: " . $e->getMessage());
59
-							}
60
-
61
-							$this->pdo->rollBack();
62
-							return false;
63
-						}
64
-					}
65
-				}
66
-
67
-				$db_version = $this->getSchemaVersion();
68
-
69
-				if ($db_version == $version) {
70
-					$this->pdo->commit();
71
-					return true;
72
-				} else {
73
-					$this->pdo->rollBack();
74
-					return false;
75
-				}
76
-			} else {
77
-				return false;
78
-			}
79
-		} else {
80
-			return false;
81
-		}
82
-	}
5
+    private $pdo;
6
+    private $db_type;
7
+    private $need_version;
8
+
9
+    public function __construct($db_type, $need_version) {
10
+        $this->pdo = Db::pdo();
11
+        $this->db_type = $db_type;
12
+        $this->need_version = (int) $need_version;
13
+    }
14
+
15
+    public function getSchemaVersion() {
16
+        $row = $this->pdo->query("SELECT schema_version FROM ttrss_version")->fetch();
17
+        return (int) $row['schema_version'];
18
+    }
19
+
20
+    public function isUpdateRequired() {
21
+        return $this->getSchemaVersion() < $this->need_version;
22
+    }
23
+
24
+    public function getSchemaLines($version) {
25
+        $filename = "schema/versions/".$this->db_type."/$version.sql";
26
+
27
+        if (file_exists($filename)) {
28
+            return explode(";", preg_replace("/[\r\n]/", "", file_get_contents($filename)));
29
+        } else {
30
+            user_error("DB Updater: schema file for version $version is not found.");
31
+            return false;
32
+        }
33
+    }
34
+
35
+    public function performUpdateTo($version, $html_output = true) {
36
+        if ($this->getSchemaVersion() == $version - 1) {
37
+
38
+            $lines = $this->getSchemaLines($version);
39
+
40
+            if (is_array($lines)) {
41
+
42
+                $this->pdo->beginTransaction();
43
+
44
+                foreach ($lines as $line) {
45
+                    if (strpos($line, "--") !== 0 && $line) {
46
+
47
+                        if ($html_output)
48
+                            print "<pre>$line</pre>";
49
+                        else
50
+                            Debug::log("> $line");
51
+
52
+                        try {
53
+                            $this->pdo->query($line); // PDO returns errors as exceptions now
54
+                        } catch (PDOException $e) {
55
+                            if ($html_output) {
56
+                                print "<div class='text-error'>Error: " . $e->getMessage() . "</div>";
57
+                            } else {
58
+                                Debug::log("Error: " . $e->getMessage());
59
+                            }
60
+
61
+                            $this->pdo->rollBack();
62
+                            return false;
63
+                        }
64
+                    }
65
+                }
66
+
67
+                $db_version = $this->getSchemaVersion();
68
+
69
+                if ($db_version == $version) {
70
+                    $this->pdo->commit();
71
+                    return true;
72
+                } else {
73
+                    $this->pdo->rollBack();
74
+                    return false;
75
+                }
76
+            } else {
77
+                return false;
78
+            }
79
+        } else {
80
+            return false;
81
+        }
82
+    }
83 83
 
84 84
 }
Please login to merge, or discard this patch.
classes/pluginhandler.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 class PluginHandler extends Handler_Protected {
3
-	public function csrf_ignore($method) {
4
-		return true;
5
-	}
3
+    public function csrf_ignore($method) {
4
+        return true;
5
+    }
6 6
 
7
-	public function catchall($method) {
8
-		$plugin_name = clean($_REQUEST["plugin"]);
9
-		$plugin = PluginHost::getInstance()->get_plugin($plugin_name);
7
+    public function catchall($method) {
8
+        $plugin_name = clean($_REQUEST["plugin"]);
9
+        $plugin = PluginHost::getInstance()->get_plugin($plugin_name);
10 10
 
11
-		if ($plugin) {
12
-			if (method_exists($plugin, $method)) {
13
-				$plugin->$method();
14
-			} else {
15
-				user_error("PluginHandler: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
16
-				print error_json(13);
17
-			}
18
-		} else {
19
-			user_error("PluginHandler: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
20
-			print error_json(14);
21
-		}
22
-	}
11
+        if ($plugin) {
12
+            if (method_exists($plugin, $method)) {
13
+                $plugin->$method();
14
+            } else {
15
+                user_error("PluginHandler: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
16
+                print error_json(13);
17
+            }
18
+        } else {
19
+            user_error("PluginHandler: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
20
+            print error_json(14);
21
+        }
22
+    }
23 23
 }
Please login to merge, or discard this patch.
classes/db.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -2,115 +2,115 @@
 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();
88
+    public static function instance() {
89
+        if (self::$instance == null)
90
+            self::$instance = new self();
91 91
 
92
-		return self::$instance;
93
-	}
92
+        return self::$instance;
93
+    }
94 94
 
95
-	public static function get() {
96
-		if (self::$instance == null)
97
-			self::$instance = new self();
95
+    public static function get() {
96
+        if (self::$instance == null)
97
+            self::$instance = new self();
98 98
 
99
-		if (!self::$instance->adapter) {
100
-			self::$instance->legacy_connect();
101
-		}
99
+        if (!self::$instance->adapter) {
100
+            self::$instance->legacy_connect();
101
+        }
102 102
 
103
-		return self::$instance->adapter;
104
-	}
103
+        return self::$instance->adapter;
104
+    }
105 105
 
106
-	public static function pdo() {
107
-		if (self::$instance == null)
108
-			self::$instance = new self();
106
+    public static function pdo() {
107
+        if (self::$instance == null)
108
+            self::$instance = new self();
109 109
 
110
-		if (!self::$instance->pdo) {
111
-			self::$instance->pdo = self::$instance->pdo_connect();
112
-		}
110
+        if (!self::$instance->pdo) {
111
+            self::$instance->pdo = self::$instance->pdo_connect();
112
+        }
113 113
 
114
-		return self::$instance->pdo;
115
-	}
114
+        return self::$instance->pdo;
115
+    }
116 116
 }
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.