Passed
Push — master ( 678db7...164b32 )
by Cody
06:12 queued 03:06
created
af_readability/vendor/andreskrey/Readability/Nodes/DOM/DOMNodeList.php 1 patch
Switch Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
     public function __get($name)
33 33
     {
34 34
         switch ($name) {
35
-            case 'length':
36
-                return $this->length;
37
-            default:
38
-                trigger_error(sprintf('Undefined property: %s::%s', static::class, $name));
35
+        case 'length':
36
+            return $this->length;
37
+        default:
38
+            trigger_error(sprintf('Undefined property: %s::%s', static::class, $name));
39 39
         }
40 40
     }
41 41
 
Please login to merge, or discard this patch.
plugins/af_readability/vendor/andreskrey/Readability/Nodes/NodeTrait.php 1 patch
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -121,36 +121,36 @@
 block discarded – undo
121 121
             $contentScore = 0;
122 122
 
123 123
             switch ($this->nodeName) {
124
-                case 'div':
125
-                    $contentScore += 5;
126
-                    break;
127
-
128
-                case 'pre':
129
-                case 'td':
130
-                case 'blockquote':
131
-                    $contentScore += 3;
132
-                    break;
133
-
134
-                case 'address':
135
-                case 'ol':
136
-                case 'ul':
137
-                case 'dl':
138
-                case 'dd':
139
-                case 'dt':
140
-                case 'li':
141
-                case 'form':
142
-                    $contentScore -= 3;
143
-                    break;
144
-
145
-                case 'h1':
146
-                case 'h2':
147
-                case 'h3':
148
-                case 'h4':
149
-                case 'h5':
150
-                case 'h6':
151
-                case 'th':
152
-                    $contentScore -= 5;
153
-                    break;
124
+            case 'div':
125
+                $contentScore += 5;
126
+                break;
127
+
128
+            case 'pre':
129
+            case 'td':
130
+            case 'blockquote':
131
+                $contentScore += 3;
132
+                break;
133
+
134
+            case 'address':
135
+            case 'ol':
136
+            case 'ul':
137
+            case 'dl':
138
+            case 'dd':
139
+            case 'dt':
140
+            case 'li':
141
+            case 'form':
142
+                $contentScore -= 3;
143
+                break;
144
+
145
+            case 'h1':
146
+            case 'h2':
147
+            case 'h3':
148
+            case 'h4':
149
+            case 'h5':
150
+            case 'h6':
151
+            case 'th':
152
+                $contentScore -= 5;
153
+                break;
154 154
             }
155 155
 
156 156
             $this->contentScore = $contentScore + ($weightClasses ? $this->getClassWeight() : 0);
Please login to merge, or discard this patch.
classes/handler/public.php 2 patches
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -760,24 +760,24 @@
 block discarded – undo
760 760
 				$feed_urls = false;
761 761
 
762 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;
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 781
 				}
782 782
 
783 783
 				if ($feed_urls) {
Please login to merge, or discard this patch.
Indentation   +737 added lines, -737 removed lines patch added patch discarded remove patch
@@ -1,336 +1,336 @@  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) {
16
-		    $limit = 60;
17
-		}
18
-
19
-		$date_sort_field = "date_entered DESC, updated DESC";
20
-
21
-		if ($feed == -2 && !$is_cat) {
22
-			$date_sort_field = "last_published DESC";
23
-		} else if ($feed == -1 && !$is_cat) {
24
-			$date_sort_field = "last_marked DESC";
25
-		}
26
-
27
-		switch ($order) {
28
-		case "title":
29
-			$date_sort_field = "ttrss_entries.title, date_entered, updated";
30
-			break;
31
-		case "date_reverse":
32
-			$date_sort_field = "date_entered, updated";
33
-			break;
34
-		case "feed_dates":
35
-			$date_sort_field = "updated DESC";
36
-			break;
37
-		}
38
-
39
-		$params = array(
40
-			"owner_uid" => $owner_uid,
41
-			"feed" => $feed,
42
-			"limit" => $limit,
43
-			"view_mode" => $view_mode,
44
-			"cat_view" => $is_cat,
45
-			"search" => $search,
46
-			"override_order" => $date_sort_field,
47
-			"include_children" => true,
48
-			"ignore_vfeed_group" => true,
49
-			"offset" => $offset,
50
-			"start_ts" => $start_ts
51
-		);
52
-
53
-		if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
54
-
55
-			$user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
56
-
57
-			$tmppluginhost = new PluginHost();
58
-			$tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL);
59
-			$tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
60
-			$tmppluginhost->load_data();
61
-
62
-			$handler = $tmppluginhost->get_feed_handler(
63
-				PluginHost::feed_to_pfeed_id($feed));
64
-
65
-			if ($handler) {
66
-				$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $params);
67
-			}
68
-
69
-		} else {
70
-			$qfh_ret = Feeds::queryFeedHeadlines($params);
71
-		}
72
-
73
-		$result = $qfh_ret[0];
74
-		$feed_title = htmlspecialchars($qfh_ret[1]);
75
-		$feed_site_url = $qfh_ret[2];
76
-		/* $last_error = $qfh_ret[3]; */
77
-
78
-		$feed_self_url = get_self_url_prefix().
79
-			"/public.php?op=rss&id=$feed&key=".
80
-			Feeds::get_feed_access_key($feed, false, $owner_uid);
81
-
82
-		if (!$feed_site_url) {
83
-		    $feed_site_url = get_self_url_prefix();
84
-		}
85
-
86
-		if ($format == 'atom') {
87
-			$tpl = new MiniTemplator;
88
-
89
-			$tpl->readTemplateFromFile("templates/generated_feed.txt");
90
-
91
-			$tpl->setVariable('FEED_TITLE', $feed_title, true);
92
-			$tpl->setVariable('VERSION', get_version(), true);
93
-			$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
94
-
95
-			$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
96
-			while ($line = $result->fetch()) {
97
-
98
-				$line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
99
-
100
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
101
-					$line = $p->hook_query_headlines($line);
102
-				}
12
+            "padding : 5px; border-style : dashed; border-color : #e7d796;".
13
+            "margin-bottom : 1em; color : #9a8c59;";
14
+
15
+        if (!$limit) {
16
+            $limit = 60;
17
+        }
18
+
19
+        $date_sort_field = "date_entered DESC, updated DESC";
20
+
21
+        if ($feed == -2 && !$is_cat) {
22
+            $date_sort_field = "last_published DESC";
23
+        } else if ($feed == -1 && !$is_cat) {
24
+            $date_sort_field = "last_marked DESC";
25
+        }
26
+
27
+        switch ($order) {
28
+        case "title":
29
+            $date_sort_field = "ttrss_entries.title, date_entered, updated";
30
+            break;
31
+        case "date_reverse":
32
+            $date_sort_field = "date_entered, updated";
33
+            break;
34
+        case "feed_dates":
35
+            $date_sort_field = "updated DESC";
36
+            break;
37
+        }
38
+
39
+        $params = array(
40
+            "owner_uid" => $owner_uid,
41
+            "feed" => $feed,
42
+            "limit" => $limit,
43
+            "view_mode" => $view_mode,
44
+            "cat_view" => $is_cat,
45
+            "search" => $search,
46
+            "override_order" => $date_sort_field,
47
+            "include_children" => true,
48
+            "ignore_vfeed_group" => true,
49
+            "offset" => $offset,
50
+            "start_ts" => $start_ts
51
+        );
52
+
53
+        if (!$is_cat && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) {
54
+
55
+            $user_plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
56
+
57
+            $tmppluginhost = new PluginHost();
58
+            $tmppluginhost->load(PLUGINS, PluginHost::KIND_ALL);
59
+            $tmppluginhost->load($user_plugins, PluginHost::KIND_USER, $owner_uid);
60
+            $tmppluginhost->load_data();
61
+
62
+            $handler = $tmppluginhost->get_feed_handler(
63
+                PluginHost::feed_to_pfeed_id($feed));
64
+
65
+            if ($handler) {
66
+                $qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id($feed), $params);
67
+            }
103 68
 
104
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
105
-					$line = $p->hook_article_export_feed($line, $feed, $is_cat);
106
-				}
69
+        } else {
70
+            $qfh_ret = Feeds::queryFeedHeadlines($params);
71
+        }
107 72
 
108
-				$tpl->setVariable('ARTICLE_ID',
109
-					htmlspecialchars($orig_guid ? $line['link'] : $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
110
-				$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
111
-				$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
112
-				$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
73
+        $result = $qfh_ret[0];
74
+        $feed_title = htmlspecialchars($qfh_ret[1]);
75
+        $feed_site_url = $qfh_ret[2];
76
+        /* $last_error = $qfh_ret[3]; */
113 77
 
114
-				$content = sanitize($line["content"], false, $owner_uid,
115
-					$feed_site_url, false, $line["id"]);
78
+        $feed_self_url = get_self_url_prefix().
79
+            "/public.php?op=rss&id=$feed&key=".
80
+            Feeds::get_feed_access_key($feed, false, $owner_uid);
116 81
 
117
-				if ($line['note']) {
118
-					$content = "<div style=\"$note_style\">Article note: ".$line['note']."</div>".
119
-						$content;
120
-					$tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
121
-				}
82
+        if (!$feed_site_url) {
83
+            $feed_site_url = get_self_url_prefix();
84
+        }
122 85
 
123
-				$tpl->setVariable('ARTICLE_CONTENT', $content, true);
86
+        if ($format == 'atom') {
87
+            $tpl = new MiniTemplator;
124 88
 
125
-				$tpl->setVariable('ARTICLE_UPDATED_ATOM',
126
-					date('c', strtotime($line["updated"])), true);
127
-				$tpl->setVariable('ARTICLE_UPDATED_RFC822',
128
-					date(DATE_RFC822, strtotime($line["updated"])), true);
89
+            $tpl->readTemplateFromFile("templates/generated_feed.txt");
129 90
 
130
-				$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
91
+            $tpl->setVariable('FEED_TITLE', $feed_title, true);
92
+            $tpl->setVariable('VERSION', get_version(), true);
93
+            $tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);
131 94
 
132
-				$tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
133
-				$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
95
+            $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
96
+            while ($line = $result->fetch()) {
134 97
 
135
-				$tags = Article::get_article_tags($line["id"], $owner_uid);
98
+                $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...'));
136 99
 
137
-				foreach ($tags as $tag) {
138
-					$tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
139
-					$tpl->addBlock('category');
140
-				}
100
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
101
+                    $line = $p->hook_query_headlines($line);
102
+                }
141 103
 
142
-				$enclosures = Article::get_article_enclosures($line["id"]);
104
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
105
+                    $line = $p->hook_article_export_feed($line, $feed, $is_cat);
106
+                }
143 107
 
144
-				if (count($enclosures) > 0) {
145
-					foreach ($enclosures as $e) {
146
-						$type = htmlspecialchars($e['content_type']);
147
-						$url = htmlspecialchars($e['content_url']);
148
-						$length = $e['duration'] ? $e['duration'] : 1;
108
+                $tpl->setVariable('ARTICLE_ID',
109
+                    htmlspecialchars($orig_guid ? $line['link'] : $this->make_article_tag_uri($line['id'], $line['date_entered'])), true);
110
+                $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
111
+                $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
112
+                $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
149 113
 
150
-						$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
151
-						$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
152
-						$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
114
+                $content = sanitize($line["content"], false, $owner_uid,
115
+                    $feed_site_url, false, $line["id"]);
153 116
 
154
-						$tpl->addBlock('enclosure');
155
-					}
156
-				} else {
157
-					$tpl->setVariable('ARTICLE_ENCLOSURE_URL', null, true);
158
-					$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', null, true);
159
-					$tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true);
160
-				}
117
+                if ($line['note']) {
118
+                    $content = "<div style=\"$note_style\">Article note: ".$line['note']."</div>".
119
+                        $content;
120
+                    $tpl->setVariable('ARTICLE_NOTE', htmlspecialchars($line['note']), true);
121
+                }
161 122
 
162
-				list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $feed_site_url);
123
+                $tpl->setVariable('ARTICLE_CONTENT', $content, true);
163 124
 
164
-				$tpl->setVariable('ARTICLE_OG_IMAGE', $og_image, true);
125
+                $tpl->setVariable('ARTICLE_UPDATED_ATOM',
126
+                    date('c', strtotime($line["updated"])), true);
127
+                $tpl->setVariable('ARTICLE_UPDATED_RFC822',
128
+                    date(DATE_RFC822, strtotime($line["updated"])), true);
165 129
 
166
-				$tpl->addBlock('entry');
167
-			}
130
+                $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
168 131
 
169
-			$tmp = "";
132
+                $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
133
+                $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
170 134
 
171
-			$tpl->addBlock('feed');
172
-			$tpl->generateOutputToString($tmp);
135
+                $tags = Article::get_article_tags($line["id"], $owner_uid);
173 136
 
174
-			if (@!clean($_REQUEST["noxml"])) {
175
-				header("Content-Type: text/xml; charset=utf-8");
176
-			} else {
177
-				header("Content-Type: text/plain; charset=utf-8");
178
-			}
137
+                foreach ($tags as $tag) {
138
+                    $tpl->setVariable('ARTICLE_CATEGORY', htmlspecialchars($tag), true);
139
+                    $tpl->addBlock('category');
140
+                }
179 141
 
180
-			print $tmp;
181
-		} else if ($format == 'json') {
142
+                $enclosures = Article::get_article_enclosures($line["id"]);
182 143
 
183
-			$feed = array();
144
+                if (count($enclosures) > 0) {
145
+                    foreach ($enclosures as $e) {
146
+                        $type = htmlspecialchars($e['content_type']);
147
+                        $url = htmlspecialchars($e['content_url']);
148
+                        $length = $e['duration'] ? $e['duration'] : 1;
184 149
 
185
-			$feed['title'] = $feed_title;
186
-			$feed['feed_url'] = $feed_self_url;
150
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
151
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
152
+                        $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', $length, true);
187 153
 
188
-			$feed['self_url'] = get_self_url_prefix();
154
+                        $tpl->addBlock('enclosure');
155
+                    }
156
+                } else {
157
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_URL', null, true);
158
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', null, true);
159
+                    $tpl->setVariable('ARTICLE_ENCLOSURE_LENGTH', null, true);
160
+                }
189 161
 
190
-			$feed['articles'] = array();
162
+                list ($og_image, $og_stream) = Article::get_article_image($enclosures, $line['content'], $feed_site_url);
191 163
 
192
-			while ($line = $result->fetch()) {
164
+                $tpl->setVariable('ARTICLE_OG_IMAGE', $og_image, true);
193 165
 
194
-				$line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
166
+                $tpl->addBlock('entry');
167
+            }
195 168
 
196
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
197
-					$line = $p->hook_query_headlines($line, 100);
198
-				}
169
+            $tmp = "";
199 170
 
200
-				foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
201
-					$line = $p->hook_article_export_feed($line, $feed, $is_cat);
202
-				}
171
+            $tpl->addBlock('feed');
172
+            $tpl->generateOutputToString($tmp);
203 173
 
204
-				$article = array();
174
+            if (@!clean($_REQUEST["noxml"])) {
175
+                header("Content-Type: text/xml; charset=utf-8");
176
+            } else {
177
+                header("Content-Type: text/plain; charset=utf-8");
178
+            }
205 179
 
206
-				$article['id'] = $line['link'];
207
-				$article['link'] = $line['link'];
208
-				$article['title'] = $line['title'];
209
-				$article['excerpt'] = $line["content_preview"];
210
-				$article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
211
-				$article['updated'] = date('c', strtotime($line["updated"]));
180
+            print $tmp;
181
+        } else if ($format == 'json') {
212 182
 
213
-				if ($line['note']) {
214
-				    $article['note'] = $line['note'];
215
-				}
216
-				if ($article['author']) {
217
-				    $article['author'] = $line['author'];
218
-				}
183
+            $feed = array();
219 184
 
220
-				$tags = Article::get_article_tags($line["id"], $owner_uid);
185
+            $feed['title'] = $feed_title;
186
+            $feed['feed_url'] = $feed_self_url;
221 187
 
222
-				if (count($tags) > 0) {
223
-					$article['tags'] = array();
188
+            $feed['self_url'] = get_self_url_prefix();
224 189
 
225
-					foreach ($tags as $tag) {
226
-						array_push($article['tags'], $tag);
227
-					}
228
-				}
190
+            $feed['articles'] = array();
229 191
 
230
-				$enclosures = Article::get_article_enclosures($line["id"]);
192
+            while ($line = $result->fetch()) {
231 193
 
232
-				if (count($enclosures) > 0) {
233
-					$article['enclosures'] = array();
194
+                $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...'));
234 195
 
235
-					foreach ($enclosures as $e) {
236
-						$type = $e['content_type'];
237
-						$url = $e['content_url'];
238
-						$length = $e['duration'];
196
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
197
+                    $line = $p->hook_query_headlines($line, 100);
198
+                }
239 199
 
240
-						array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
241
-					}
242
-				}
200
+                foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_EXPORT_FEED) as $p) {
201
+                    $line = $p->hook_article_export_feed($line, $feed, $is_cat);
202
+                }
203
+
204
+                $article = array();
205
+
206
+                $article['id'] = $line['link'];
207
+                $article['link'] = $line['link'];
208
+                $article['title'] = $line['title'];
209
+                $article['excerpt'] = $line["content_preview"];
210
+                $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]);
211
+                $article['updated'] = date('c', strtotime($line["updated"]));
212
+
213
+                if ($line['note']) {
214
+                    $article['note'] = $line['note'];
215
+                }
216
+                if ($article['author']) {
217
+                    $article['author'] = $line['author'];
218
+                }
219
+
220
+                $tags = Article::get_article_tags($line["id"], $owner_uid);
221
+
222
+                if (count($tags) > 0) {
223
+                    $article['tags'] = array();
224
+
225
+                    foreach ($tags as $tag) {
226
+                        array_push($article['tags'], $tag);
227
+                    }
228
+                }
229
+
230
+                $enclosures = Article::get_article_enclosures($line["id"]);
231
+
232
+                if (count($enclosures) > 0) {
233
+                    $article['enclosures'] = array();
243 234
 
244
-				array_push($feed['articles'], $article);
245
-			}
235
+                    foreach ($enclosures as $e) {
236
+                        $type = $e['content_type'];
237
+                        $url = $e['content_url'];
238
+                        $length = $e['duration'];
246 239
 
247
-			header("Content-Type: text/json; charset=utf-8");
248
-			print json_encode($feed);
240
+                        array_push($article['enclosures'], array("url" => $url, "type" => $type, "length" => $length));
241
+                    }
242
+                }
249 243
 
250
-		} else {
251
-			header("Content-Type: text/plain; charset=utf-8");
252
-			print json_encode(array("error" => array("message" => "Unknown format")));
253
-		}
254
-	}
244
+                array_push($feed['articles'], $article);
245
+            }
255 246
 
256
-	public function getUnread() {
257
-		$login = clean($_REQUEST["login"]);
258
-		$fresh = clean($_REQUEST["fresh"]) == "1";
247
+            header("Content-Type: text/json; charset=utf-8");
248
+            print json_encode($feed);
259 249
 
260
-		$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
261
-		$sth->execute([$login]);
250
+        } else {
251
+            header("Content-Type: text/plain; charset=utf-8");
252
+            print json_encode(array("error" => array("message" => "Unknown format")));
253
+        }
254
+    }
262 255
 
263
-		if ($row = $sth->fetch()) {
264
-			$uid = $row["id"];
256
+    public function getUnread() {
257
+        $login = clean($_REQUEST["login"]);
258
+        $fresh = clean($_REQUEST["fresh"]) == "1";
265 259
 
266
-			print Feeds::getGlobalUnread($uid);
260
+        $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
261
+        $sth->execute([$login]);
267 262
 
268
-			if ($fresh) {
269
-				print ";";
270
-				print Feeds::getFeedArticles(-3, false, true, $uid);
271
-			}
263
+        if ($row = $sth->fetch()) {
264
+            $uid = $row["id"];
272 265
 
273
-		} else {
274
-			print "-1;User not found";
275
-		}
276
-	}
266
+            print Feeds::getGlobalUnread($uid);
277 267
 
278
-	public function getProfiles() {
279
-		$login = clean($_REQUEST["login"]);
280
-		$rv = [];
268
+            if ($fresh) {
269
+                print ";";
270
+                print Feeds::getFeedArticles(-3, false, true, $uid);
271
+            }
281 272
 
282
-		if ($login) {
283
-			$sth = $this->pdo->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
273
+        } else {
274
+            print "-1;User not found";
275
+        }
276
+    }
277
+
278
+    public function getProfiles() {
279
+        $login = clean($_REQUEST["login"]);
280
+        $rv = [];
281
+
282
+        if ($login) {
283
+            $sth = $this->pdo->prepare("SELECT ttrss_settings_profiles.* FROM ttrss_settings_profiles,ttrss_users
284 284
 			WHERE ttrss_users.id = ttrss_settings_profiles.owner_uid AND login = ? ORDER BY title");
285
-			$sth->execute([$login]);
285
+            $sth->execute([$login]);
286 286
 
287
-			$rv = [["value" => 0, "label" => __("Default profile")]];
287
+            $rv = [["value" => 0, "label" => __("Default profile")]];
288 288
 
289
-			while ($line = $sth->fetch()) {
290
-				$id = $line["id"];
291
-				$title = $line["title"];
289
+            while ($line = $sth->fetch()) {
290
+                $id = $line["id"];
291
+                $title = $line["title"];
292 292
 
293
-				array_push($rv, ["label" => $title, "value" => $id]);
294
-			}
295
-	    }
293
+                array_push($rv, ["label" => $title, "value" => $id]);
294
+            }
295
+        }
296 296
 
297
-		print json_encode($rv);
298
-	}
297
+        print json_encode($rv);
298
+    }
299 299
 
300
-	public function logout() {
301
-		logout_user();
302
-		header("Location: index.php");
303
-	}
300
+    public function logout() {
301
+        logout_user();
302
+        header("Location: index.php");
303
+    }
304 304
 
305
-	public function share() {
306
-		$uuid = clean($_REQUEST["key"]);
305
+    public function share() {
306
+        $uuid = clean($_REQUEST["key"]);
307 307
 
308
-		if ($uuid) {
309
-			$sth = $this->pdo->prepare("SELECT ref_id, owner_uid
308
+        if ($uuid) {
309
+            $sth = $this->pdo->prepare("SELECT ref_id, owner_uid
310 310
 						FROM ttrss_user_entries WHERE uuid = ?");
311
-			$sth->execute([$uuid]);
311
+            $sth->execute([$uuid]);
312 312
 
313
-			if ($row = $sth->fetch()) {
314
-				header("Content-Type: text/html");
313
+            if ($row = $sth->fetch()) {
314
+                header("Content-Type: text/html");
315 315
 
316
-				$id = $row["ref_id"];
317
-				$owner_uid = $row["owner_uid"];
316
+                $id = $row["ref_id"];
317
+                $owner_uid = $row["owner_uid"];
318 318
 
319
-				print $this->format_article($id, $owner_uid);
319
+                print $this->format_article($id, $owner_uid);
320 320
 
321
-				return;
322
-			}
323
-		}
321
+                return;
322
+            }
323
+        }
324 324
 
325
-		header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
326
-		print "Article not found.";
327
-	}
325
+        header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
326
+        print "Article not found.";
327
+    }
328 328
 
329
-	private function format_article($id, $owner_uid) {
329
+    private function format_article($id, $owner_uid) {
330 330
 
331
-		$pdo = Db::pdo();
331
+        $pdo = Db::pdo();
332 332
 
333
-		$sth = $pdo->prepare("SELECT id,title,link,content,feed_id,comments,int_id,lang,
333
+        $sth = $pdo->prepare("SELECT id,title,link,content,feed_id,comments,int_id,lang,
334 334
 			".SUBSTRING_FOR_DATE."(updated,1,16) as updated,
335 335
 			(SELECT site_url FROM ttrss_feeds WHERE id = feed_id) as site_url,
336 336
 			(SELECT title FROM ttrss_feeds WHERE id = feed_id) as feed_title,
@@ -344,26 +344,26 @@  discard block
 block discarded – undo
344 344
 			note
345 345
 			FROM ttrss_entries,ttrss_user_entries
346 346
 			WHERE	id = ? AND ref_id = id AND owner_uid = ?");
347
-		$sth->execute([$id, $owner_uid]);
347
+        $sth->execute([$id, $owner_uid]);
348 348
 
349
-		$rv = '';
349
+        $rv = '';
350 350
 
351
-		if ($line = $sth->fetch()) {
351
+        if ($line = $sth->fetch()) {
352 352
 
353
-			$line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]);
354
-			unset($line["tag_cache"]);
353
+            $line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]);
354
+            unset($line["tag_cache"]);
355 355
 
356
-			$line["content"] = sanitize($line["content"],
357
-				$line['hide_images'],
358
-				$owner_uid, $line["site_url"], false, $line["id"]);
356
+            $line["content"] = sanitize($line["content"],
357
+                $line['hide_images'],
358
+                $owner_uid, $line["site_url"], false, $line["id"]);
359 359
 
360
-			foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
361
-				$line = $p->hook_render_article($line);
362
-			}
360
+            foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE) as $p) {
361
+                $line = $p->hook_render_article($line);
362
+            }
363 363
 
364
-			$line['content'] = DiskCache::rewriteUrls($line['content']);
364
+            $line['content'] = DiskCache::rewriteUrls($line['content']);
365 365
 
366
-			$enclosures = Article::get_article_enclosures($line["id"]);
366
+            $enclosures = Article::get_article_enclosures($line["id"]);
367 367
 
368 368
             header("Content-Type: text/html");
369 369
 
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
             $rv .= "<meta property='og:title' content=\"".htmlspecialchars(html_entity_decode($line["title"], ENT_NOQUOTES | ENT_HTML401))."\"/>\n";
379 379
             $rv .= "<meta property='og:description' content=\"".
380 380
                 htmlspecialchars(
381
-                	truncate_string(
382
-                		preg_replace("/[\r\n\t]/", "",
383
-							preg_replace("/ {1,}/", " ",
384
-								strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401))
385
-							)
386
-					), 500, "...")
387
-				)."\"/>\n";
381
+                    truncate_string(
382
+                        preg_replace("/[\r\n\t]/", "",
383
+                            preg_replace("/ {1,}/", " ",
384
+                                strip_tags(html_entity_decode($line["content"], ENT_NOQUOTES | ENT_HTML401))
385
+                            )
386
+                    ), 500, "...")
387
+                )."\"/>\n";
388 388
 
389 389
             $rv .= "</head>";
390 390
 
@@ -397,135 +397,135 @@  discard block
 block discarded – undo
397 397
             $rv .= "<body class='flat ttrss_utility ttrss_zoom'>";
398 398
             $rv .= "<div class='container'>";
399 399
 
400
-			if ($line["link"]) {
401
-				$rv .= "<h1><a target='_blank' rel='noopener noreferrer'
400
+            if ($line["link"]) {
401
+                $rv .= "<h1><a target='_blank' rel='noopener noreferrer'
402 402
 					title=\"".htmlspecialchars($line['title'])."\"
403 403
 					href=\"" .htmlspecialchars($line["link"])."\">".$line["title"]."</a></h1>";
404
-			} else {
405
-				$rv .= "<h1>".$line["title"]."</h1>";
406
-			}
404
+            } else {
405
+                $rv .= "<h1>".$line["title"]."</h1>";
406
+            }
407 407
 
408
-			$rv .= "<div class='content post'>";
408
+            $rv .= "<div class='content post'>";
409 409
 
410
-			/* header */
410
+            /* header */
411 411
 
412
-			$rv .= "<div class='header'>";
413
-			$rv .= "<div class='row'>"; # row
412
+            $rv .= "<div class='header'>";
413
+            $rv .= "<div class='row'>"; # row
414 414
 
415
-			//$entry_author = $line["author"] ? " - " . $line["author"] : "";
416
-			$parsed_updated = make_local_datetime($line["updated"], true,
417
-				$owner_uid, true);
415
+            //$entry_author = $line["author"] ? " - " . $line["author"] : "";
416
+            $parsed_updated = make_local_datetime($line["updated"], true,
417
+                $owner_uid, true);
418 418
 
419
-			$rv .= "<div>".$line['author']."</div>";
419
+            $rv .= "<div>".$line['author']."</div>";
420 420
             $rv .= "<div>$parsed_updated</div>";
421 421
 
422
-			$rv .= "</div>"; # row
422
+            $rv .= "</div>"; # row
423 423
 
424
-			$rv .= "</div>"; # header
424
+            $rv .= "</div>"; # header
425 425
 
426
-			/* content */
426
+            /* content */
427 427
 
428
-			$lang = $line['lang'] ? $line['lang'] : "en";
429
-			$rv .= "<div class='content' lang='$lang'>";
428
+            $lang = $line['lang'] ? $line['lang'] : "en";
429
+            $rv .= "<div class='content' lang='$lang'>";
430 430
 
431
-			/* content body */
431
+            /* content body */
432 432
 
433
-			$rv .= $line["content"];
433
+            $rv .= $line["content"];
434 434
 
435 435
             $rv .= Article::format_article_enclosures($id,
436 436
                 $line["always_display_enclosures"],
437 437
                 $line["content"],
438 438
                 $line["hide_images"]);
439 439
 
440
-			$rv .= "</div>"; # content
440
+            $rv .= "</div>"; # content
441 441
 
442
-			$rv .= "</div>"; # post
442
+            $rv .= "</div>"; # post
443 443
 
444
-		}
444
+        }
445 445
 
446
-		foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE) as $p) {
447
-			$rv = $p->hook_format_article($rv, $line, true);
448
-		}
446
+        foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ARTICLE) as $p) {
447
+            $rv = $p->hook_format_article($rv, $line, true);
448
+        }
449 449
 
450
-		return $rv;
450
+        return $rv;
451 451
 
452
-	}
452
+    }
453 453
 
454
-	public function rss() {
455
-		$feed = clean($_REQUEST["id"]);
456
-		$key = clean($_REQUEST["key"]);
457
-		$is_cat = clean($_REQUEST["is_cat"]);
458
-		$limit = (int) clean($_REQUEST["limit"]);
459
-		$offset = (int) clean($_REQUEST["offset"]);
454
+    public function rss() {
455
+        $feed = clean($_REQUEST["id"]);
456
+        $key = clean($_REQUEST["key"]);
457
+        $is_cat = clean($_REQUEST["is_cat"]);
458
+        $limit = (int) clean($_REQUEST["limit"]);
459
+        $offset = (int) clean($_REQUEST["offset"]);
460 460
 
461
-		$search = clean($_REQUEST["q"]);
462
-		$view_mode = clean($_REQUEST["view-mode"]);
463
-		$order = clean($_REQUEST["order"]);
464
-		$start_ts = clean($_REQUEST["ts"]);
461
+        $search = clean($_REQUEST["q"]);
462
+        $view_mode = clean($_REQUEST["view-mode"]);
463
+        $order = clean($_REQUEST["order"]);
464
+        $start_ts = clean($_REQUEST["ts"]);
465 465
 
466
-		$format = clean($_REQUEST['format']);
467
-		$orig_guid = clean($_REQUEST["orig_guid"]);
466
+        $format = clean($_REQUEST['format']);
467
+        $orig_guid = clean($_REQUEST["orig_guid"]);
468 468
 
469
-		if (!$format) {
470
-		    $format = 'atom';
471
-		}
469
+        if (!$format) {
470
+            $format = 'atom';
471
+        }
472 472
 
473
-		if (SINGLE_USER_MODE) {
474
-			authenticate_user("admin", null);
475
-		}
473
+        if (SINGLE_USER_MODE) {
474
+            authenticate_user("admin", null);
475
+        }
476 476
 
477
-		$owner_id = false;
477
+        $owner_id = false;
478 478
 
479
-		if ($key) {
480
-			$sth = $this->pdo->prepare("SELECT owner_uid FROM
479
+        if ($key) {
480
+            $sth = $this->pdo->prepare("SELECT owner_uid FROM
481 481
 				ttrss_access_keys WHERE access_key = ? AND feed_id = ?");
482
-			$sth->execute([$key, $feed]);
483
-
484
-			if ($row = $sth->fetch()) {
485
-							$owner_id = $row["owner_uid"];
486
-			}
487
-		}
488
-
489
-		if ($owner_id) {
490
-			$this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
491
-				$offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
492
-		} else {
493
-			header('HTTP/1.1 403 Forbidden');
494
-		}
495
-	}
496
-
497
-	public function updateTask() {
498
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
499
-	}
500
-
501
-	public function housekeepingTask() {
502
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", false);
503
-	}
504
-
505
-	public function globalUpdateFeeds() {
506
-		RPC::updaterandomfeed_real();
507
-
508
-		PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
509
-	}
510
-
511
-	public function sharepopup() {
512
-		if (SINGLE_USER_MODE) {
513
-			login_sequence();
514
-		}
515
-
516
-		header('Content-Type: text/html; charset=utf-8');
517
-		?>
482
+            $sth->execute([$key, $feed]);
483
+
484
+            if ($row = $sth->fetch()) {
485
+                            $owner_id = $row["owner_uid"];
486
+            }
487
+        }
488
+
489
+        if ($owner_id) {
490
+            $this->generate_syndicated_feed($owner_id, $feed, $is_cat, $limit,
491
+                $offset, $search, $view_mode, $format, $order, $orig_guid, $start_ts);
492
+        } else {
493
+            header('HTTP/1.1 403 Forbidden');
494
+        }
495
+    }
496
+
497
+    public function updateTask() {
498
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
499
+    }
500
+
501
+    public function housekeepingTask() {
502
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", false);
503
+    }
504
+
505
+    public function globalUpdateFeeds() {
506
+        RPC::updaterandomfeed_real();
507
+
508
+        PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", false);
509
+    }
510
+
511
+    public function sharepopup() {
512
+        if (SINGLE_USER_MODE) {
513
+            login_sequence();
514
+        }
515
+
516
+        header('Content-Type: text/html; charset=utf-8');
517
+        ?>
518 518
 		<!DOCTYPE html>
519 519
 		<html>
520 520
 		<head>
521 521
 			<title><?php echo __("Share with Tiny Tiny RSS") ?></title>
522 522
 			<?php
523
-			echo stylesheet_tag("css/default.css");
524
-			echo javascript_tag("lib/prototype.js");
525
-			echo javascript_tag("lib/dojo/dojo.js");
526
-			echo javascript_tag("lib/dojo/tt-rss-layer.js");
527
-			echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls")
528
-			?>
523
+            echo stylesheet_tag("css/default.css");
524
+            echo javascript_tag("lib/prototype.js");
525
+            echo javascript_tag("lib/dojo/dojo.js");
526
+            echo javascript_tag("lib/dojo/tt-rss-layer.js");
527
+            echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls")
528
+            ?>
529 529
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
530 530
 			<link rel="shortcut icon" type="image/png" href="images/favicon.png">
531 531
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
@@ -547,29 +547,29 @@  discard block
 block discarded – undo
547 547
 
548 548
 		<?php
549 549
 
550
-		$action = clean($_REQUEST["action"]);
550
+        $action = clean($_REQUEST["action"]);
551 551
 
552
-		if ($_SESSION["uid"]) {
552
+        if ($_SESSION["uid"]) {
553 553
 
554
-			if ($action == 'share') {
554
+            if ($action == 'share') {
555 555
 
556
-				$title = strip_tags(clean($_REQUEST["title"]));
557
-				$url = strip_tags(clean($_REQUEST["url"]));
558
-				$content = strip_tags(clean($_REQUEST["content"]));
559
-				$labels = strip_tags(clean($_REQUEST["labels"]));
556
+                $title = strip_tags(clean($_REQUEST["title"]));
557
+                $url = strip_tags(clean($_REQUEST["url"]));
558
+                $content = strip_tags(clean($_REQUEST["content"]));
559
+                $labels = strip_tags(clean($_REQUEST["labels"]));
560 560
 
561
-				Article::create_published_article($title, $url, $content, $labels,
562
-					$_SESSION["uid"]);
561
+                Article::create_published_article($title, $url, $content, $labels,
562
+                    $_SESSION["uid"]);
563 563
 
564
-				print "<script type='text/javascript'>";
565
-				print "window.close();";
566
-				print "</script>";
564
+                print "<script type='text/javascript'>";
565
+                print "window.close();";
566
+                print "</script>";
567 567
 
568
-			} else {
569
-				$title = htmlspecialchars(clean($_REQUEST["title"]));
570
-				$url = htmlspecialchars(clean($_REQUEST["url"]));
568
+            } else {
569
+                $title = htmlspecialchars(clean($_REQUEST["title"]));
570
+                $url = htmlspecialchars(clean($_REQUEST["url"]));
571 571
 
572
-				?>
572
+                ?>
573 573
 				<form id='share_form' name='share_form'>
574 574
 
575 575
 					<input type="hidden" name="op" value="sharepopup">
@@ -609,12 +609,12 @@  discard block
 block discarded – undo
609 609
 				</form>
610 610
 				<?php
611 611
 
612
-			}
612
+            }
613 613
 
614
-		} else {
614
+        } else {
615 615
 
616
-			$return = urlencode(make_self_url());
617
-			print_error("Not logged in"); ?>
616
+            $return = urlencode(make_self_url());
617
+            print_error("Not logged in"); ?>
618 618
 
619 619
 			<form action="public.php?return=<?php echo $return ?>" method="post">
620 620
 
@@ -646,91 +646,91 @@  discard block
 block discarded – undo
646 646
 
647 647
 			</form>
648 648
 			<?php
649
-		}
649
+        }
650 650
 
651
-		print "</div></body></html>";
652
-	}
651
+        print "</div></body></html>";
652
+    }
653 653
 
654
-	public function login() {
655
-		if (!SINGLE_USER_MODE) {
654
+    public function login() {
655
+        if (!SINGLE_USER_MODE) {
656 656
 
657
-			$login = clean($_POST["login"]);
658
-			$password = clean($_POST["password"]);
659
-			$remember_me = clean($_POST["remember_me"]);
657
+            $login = clean($_POST["login"]);
658
+            $password = clean($_POST["password"]);
659
+            $remember_me = clean($_POST["remember_me"]);
660 660
 
661
-			if ($remember_me) {
662
-				session_set_cookie_params(SESSION_COOKIE_LIFETIME);
663
-			} else {
664
-				session_set_cookie_params(0);
665
-			}
661
+            if ($remember_me) {
662
+                session_set_cookie_params(SESSION_COOKIE_LIFETIME);
663
+            } else {
664
+                session_set_cookie_params(0);
665
+            }
666 666
 
667
-			if (authenticate_user($login, $password)) {
668
-				$_POST["password"] = "";
667
+            if (authenticate_user($login, $password)) {
668
+                $_POST["password"] = "";
669 669
 
670
-				if (get_schema_version() >= 120) {
671
-					$_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
672
-				}
670
+                if (get_schema_version() >= 120) {
671
+                    $_SESSION["language"] = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
672
+                }
673 673
 
674
-				$_SESSION["ref_schema_version"] = get_schema_version(true);
675
-				$_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
674
+                $_SESSION["ref_schema_version"] = get_schema_version(true);
675
+                $_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]);
676 676
 
677
-				if (clean($_POST["profile"])) {
677
+                if (clean($_POST["profile"])) {
678 678
 
679
-					$profile = (int) clean($_POST["profile"]);
679
+                    $profile = (int) clean($_POST["profile"]);
680 680
 
681
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
681
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles
682 682
 						WHERE id = ? AND owner_uid = ?");
683
-					$sth->execute([$profile, $_SESSION['uid']]);
683
+                    $sth->execute([$profile, $_SESSION['uid']]);
684 684
 
685
-					if ($sth->fetch()) {
686
-						$_SESSION["profile"] = $profile;
687
- 					} else {
688
-					    $_SESSION["profile"] = null;
685
+                    if ($sth->fetch()) {
686
+                        $_SESSION["profile"] = $profile;
687
+                        } else {
688
+                        $_SESSION["profile"] = null;
689 689
                     }
690
-				}
691
-			} else {
690
+                }
691
+            } else {
692 692
 
693
-				// start an empty session to deliver login error message
694
-				@session_start();
693
+                // start an empty session to deliver login error message
694
+                @session_start();
695 695
 
696
-				if (!isset($_SESSION["login_error_msg"])) {
697
-									$_SESSION["login_error_msg"] = __("Incorrect username or password");
698
-				}
696
+                if (!isset($_SESSION["login_error_msg"])) {
697
+                                    $_SESSION["login_error_msg"] = __("Incorrect username or password");
698
+                }
699 699
 
700
-				user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
701
-			}
700
+                user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING);
701
+            }
702 702
 
703
-			$return = clean($_REQUEST['return']);
703
+            $return = clean($_REQUEST['return']);
704 704
 
705
-			if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
706
-				header("Location: ".clean($_REQUEST['return']));
707
-			} else {
708
-				header("Location: ".get_self_url_prefix());
709
-			}
710
-		}
711
-	}
705
+            if ($_REQUEST['return'] && mb_strpos($return, SELF_URL_PATH) === 0) {
706
+                header("Location: ".clean($_REQUEST['return']));
707
+            } else {
708
+                header("Location: ".get_self_url_prefix());
709
+            }
710
+        }
711
+    }
712 712
 
713
-	public function subscribe() {
714
-		if (SINGLE_USER_MODE) {
715
-			login_sequence();
716
-		}
713
+    public function subscribe() {
714
+        if (SINGLE_USER_MODE) {
715
+            login_sequence();
716
+        }
717 717
 
718
-		if ($_SESSION["uid"]) {
718
+        if ($_SESSION["uid"]) {
719 719
 
720
-			$feed_url = trim(clean($_REQUEST["feed_url"]));
720
+            $feed_url = trim(clean($_REQUEST["feed_url"]));
721 721
 
722
-			header('Content-Type: text/html; charset=utf-8');
723
-			?>
722
+            header('Content-Type: text/html; charset=utf-8');
723
+            ?>
724 724
 			<!DOCTYPE html>
725 725
 			<html>
726 726
 			<head>
727 727
 				<title>Tiny Tiny RSS</title>
728 728
 				<?php
729
-					echo stylesheet_tag("css/default.css");
730
-					echo javascript_tag("lib/prototype.js");
731
-					echo javascript_tag("lib/dojo/dojo.js");
732
-					echo javascript_tag("lib/dojo/tt-rss-layer.js");
733
-				?>
729
+                    echo stylesheet_tag("css/default.css");
730
+                    echo javascript_tag("lib/prototype.js");
731
+                    echo javascript_tag("lib/dojo/dojo.js");
732
+                    echo javascript_tag("lib/dojo/tt-rss-layer.js");
733
+                ?>
734 734
 				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
735 735
 				<link rel="shortcut icon" type="image/png" href="images/favicon.png">
736 736
 				<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
@@ -749,8 +749,8 @@  discard block
 block discarded – undo
749 749
 			<div class='content'>
750 750
 			<?php
751 751
 
752
-			if (!$feed_url) {
753
-				?>
752
+            if (!$feed_url) {
753
+                ?>
754 754
 				<form method="post">
755 755
 					<input type="hidden" name="op" value="subscribe">
756 756
 					<fieldset>
@@ -765,101 +765,101 @@  discard block
 block discarded – undo
765 765
 					<a href="index.php"><?php echo __("Return to Tiny Tiny RSS") ?></a>
766 766
 				</form>
767 767
 				<?php
768
-			} else {
769
-
770
-				$rc = Feeds::subscribe_to_feed($feed_url);
771
-				$feed_urls = false;
772
-
773
-				switch ($rc['code']) {
774
-					case 0:
775
-						print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
776
-						break;
777
-					case 1:
778
-						print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
779
-						break;
780
-					case 2:
781
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
782
-						break;
783
-					case 3:
784
-						print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
785
-						break;
786
-					case 4:
787
-						$feed_urls = $rc["feeds"];
788
-						break;
789
-					case 5:
790
-						print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
791
-						break;
792
-				}
793
-
794
-				if ($feed_urls) {
795
-
796
-					print "<form action='public.php'>";
797
-					print "<input type='hidden' name='op' value='subscribe'>";
798
-
799
-					print "<fieldset>";
800
-					print "<label style='display : inline'>".__("Multiple feed URLs found:")."</label>";
801
-					print "<select name='feed_url' dojoType='dijit.form.Select'>";
802
-
803
-					foreach ($feed_urls as $url => $name) {
804
-						$url = htmlspecialchars($url);
805
-						$name = htmlspecialchars($name);
768
+            } else {
769
+
770
+                $rc = Feeds::subscribe_to_feed($feed_url);
771
+                $feed_urls = false;
772
+
773
+                switch ($rc['code']) {
774
+                    case 0:
775
+                        print_warning(T_sprintf("Already subscribed to <b>%s</b>.", $feed_url));
776
+                        break;
777
+                    case 1:
778
+                        print_notice(T_sprintf("Subscribed to <b>%s</b>.", $feed_url));
779
+                        break;
780
+                    case 2:
781
+                        print_error(T_sprintf("Could not subscribe to <b>%s</b>.", $feed_url));
782
+                        break;
783
+                    case 3:
784
+                        print_error(T_sprintf("No feeds found in <b>%s</b>.", $feed_url));
785
+                        break;
786
+                    case 4:
787
+                        $feed_urls = $rc["feeds"];
788
+                        break;
789
+                    case 5:
790
+                        print_error(T_sprintf("Could not subscribe to <b>%s</b>.<br>Can't download the Feed URL.", $feed_url));
791
+                        break;
792
+                }
793
+
794
+                if ($feed_urls) {
795
+
796
+                    print "<form action='public.php'>";
797
+                    print "<input type='hidden' name='op' value='subscribe'>";
798
+
799
+                    print "<fieldset>";
800
+                    print "<label style='display : inline'>".__("Multiple feed URLs found:")."</label>";
801
+                    print "<select name='feed_url' dojoType='dijit.form.Select'>";
802
+
803
+                    foreach ($feed_urls as $url => $name) {
804
+                        $url = htmlspecialchars($url);
805
+                        $name = htmlspecialchars($name);
806
+
807
+                        print "<option value=\"$url\">$name</option>";
808
+                    }
806 809
 
807
-						print "<option value=\"$url\">$name</option>";
808
-					}
810
+                    print "</select>";
811
+                    print "</fieldset>";
809 812
 
810
-					print "</select>";
811
-					print "</fieldset>";
813
+                    print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>";
814
+                    print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
812 815
 
813
-					print "<button class='alt-primary' dojoType='dijit.form.Button' type='submit'>".__("Subscribe to selected feed")."</button>";
814
-					print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
816
+                    print "</form>";
817
+                }
815 818
 
816
-					print "</form>";
817
-				}
819
+                $tp_uri = get_self_url_prefix()."/prefs.php";
818 820
 
819
-				$tp_uri = get_self_url_prefix()."/prefs.php";
820
-
821
-				if ($rc['code'] <= 2) {
822
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
821
+                if ($rc['code'] <= 2) {
822
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
823 823
 					feed_url = ? AND owner_uid = ?");
824
-					$sth->execute([$feed_url, $_SESSION['uid']]);
825
-					$row = $sth->fetch();
824
+                    $sth->execute([$feed_url, $_SESSION['uid']]);
825
+                    $row = $sth->fetch();
826 826
 
827
-					$feed_id = $row["id"];
828
-				} else {
829
-					$feed_id = 0;
830
-				}
827
+                    $feed_id = $row["id"];
828
+                } else {
829
+                    $feed_id = 0;
830
+                }
831 831
 
832
-				if ($feed_id) {
833
-					print "<form method='GET' action=\"$tp_uri\">
832
+                if ($feed_id) {
833
+                    print "<form method='GET' action=\"$tp_uri\">
834 834
 					<input type='hidden' name='tab' value='feedConfig'>
835 835
 					<input type='hidden' name='method' value='editfeed'>
836 836
 					<input type='hidden' name='methodparam' value='$feed_id'>
837 837
 					<button dojoType='dijit.form.Button' class='alt-info' type='submit'>".__("Edit subscription options")."</button>
838 838
 					<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>
839 839
 					</form>";
840
-				}
841
-			}
840
+                }
841
+            }
842 842
 
843
-			print "</div></div></body></html>";
843
+            print "</div></div></body></html>";
844 844
 
845
-		} else {
846
-			render_login_form();
847
-		}
848
-	}
845
+        } else {
846
+            render_login_form();
847
+        }
848
+    }
849 849
 
850
-	public function index() {
851
-		header("Content-Type: text/plain");
852
-		print error_json(13);
853
-	}
850
+    public function index() {
851
+        header("Content-Type: text/plain");
852
+        print error_json(13);
853
+    }
854 854
 
855
-	public function forgotpass() {
856
-		startup_gettext();
857
-		session_start();
855
+    public function forgotpass() {
856
+        startup_gettext();
857
+        session_start();
858 858
 
859
-		@$hash = clean($_REQUEST["hash"]);
859
+        @$hash = clean($_REQUEST["hash"]);
860 860
 
861
-		header('Content-Type: text/html; charset=utf-8');
862
-		?>
861
+        header('Content-Type: text/html; charset=utf-8');
862
+        ?>
863 863
 		<!DOCTYPE html>
864 864
 		<html>
865 865
 		<head>
@@ -868,11 +868,11 @@  discard block
 block discarded – undo
868 868
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
869 869
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
870 870
 			<?php
871
-				echo stylesheet_tag("css/default.css");
872
-				echo javascript_tag("lib/prototype.js");
873
-				echo javascript_tag("lib/dojo/dojo.js");
874
-				echo javascript_tag("lib/dojo/tt-rss-layer.js");
875
-			?>
871
+                echo stylesheet_tag("css/default.css");
872
+                echo javascript_tag("lib/prototype.js");
873
+                echo javascript_tag("lib/dojo/dojo.js");
874
+                echo javascript_tag("lib/dojo/tt-rss-layer.js");
875
+            ?>
876 876
 		</head>
877 877
 		<body class='flat ttrss_utility'>
878 878
 		<div class='container'>
@@ -887,52 +887,52 @@  discard block
 block discarded – undo
887 887
 		</script>
888 888
 		<?php
889 889
 
890
-		print "<h1>".__("Password recovery")."</h1>";
891
-		print "<div class='content'>";
890
+        print "<h1>".__("Password recovery")."</h1>";
891
+        print "<div class='content'>";
892 892
 
893
-		@$method = clean($_POST['method']);
893
+        @$method = clean($_POST['method']);
894 894
 
895
-		if ($hash) {
896
-			$login = clean($_REQUEST["login"]);
895
+        if ($hash) {
896
+            $login = clean($_REQUEST["login"]);
897 897
 
898
-			if ($login) {
899
-				$sth = $this->pdo->prepare("SELECT id, resetpass_token FROM ttrss_users
898
+            if ($login) {
899
+                $sth = $this->pdo->prepare("SELECT id, resetpass_token FROM ttrss_users
900 900
 					WHERE login = ?");
901
-				$sth->execute([$login]);
901
+                $sth->execute([$login]);
902 902
 
903
-				if ($row = $sth->fetch()) {
904
-					$id = $row["id"];
905
-					$resetpass_token_full = $row["resetpass_token"];
906
-					list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
903
+                if ($row = $sth->fetch()) {
904
+                    $id = $row["id"];
905
+                    $resetpass_token_full = $row["resetpass_token"];
906
+                    list($timestamp, $resetpass_token) = explode(":", $resetpass_token_full);
907 907
 
908
-					if ($timestamp && $resetpass_token &&
909
-						$timestamp >= time() - 15 * 60 * 60 &&
910
-						$resetpass_token == $hash) {
908
+                    if ($timestamp && $resetpass_token &&
909
+                        $timestamp >= time() - 15 * 60 * 60 &&
910
+                        $resetpass_token == $hash) {
911 911
 
912
-							$sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL
912
+                            $sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL
913 913
 								WHERE id = ?");
914
-							$sth->execute([$id]);
914
+                            $sth->execute([$id]);
915 915
 
916
-							Pref_Users::resetUserPassword($id, true);
916
+                            Pref_Users::resetUserPassword($id, true);
917 917
 
918
-							print "<p>"."Completed."."</p>";
918
+                            print "<p>"."Completed."."</p>";
919 919
 
920
-					} else {
921
-						print_error("Some of the information provided is missing or incorrect.");
922
-					}
923
-				} else {
924
-					print_error("Some of the information provided is missing or incorrect.");
925
-				}
926
-			} else {
927
-				print_error("Some of the information provided is missing or incorrect.");
928
-			}
920
+                    } else {
921
+                        print_error("Some of the information provided is missing or incorrect.");
922
+                    }
923
+                } else {
924
+                    print_error("Some of the information provided is missing or incorrect.");
925
+                }
926
+            } else {
927
+                print_error("Some of the information provided is missing or incorrect.");
928
+            }
929 929
 
930
-			print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
930
+            print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
931 931
 
932
-		} else if (!$method) {
933
-			print_notice(__("You will need to provide valid account name and email. Password reset link will be sent to your email address."));
932
+        } else if (!$method) {
933
+            print_notice(__("You will need to provide valid account name and email. Password reset link will be sent to your email address."));
934 934
 
935
-			print "<form method='POST' action='public.php'>
935
+            print "<form method='POST' action='public.php'>
936 936
 				<input type='hidden' name='method' value='do'>
937 937
 				<input type='hidden' name='op' value='forgotpass'>
938 938
 
@@ -946,10 +946,10 @@  discard block
 block discarded – undo
946 946
 				<input dojoType='dijit.form.TextBox' type='email' name='email' value='' required>
947 947
 				</fieldset>";
948 948
 
949
-			$_SESSION["pwdreset:testvalue1"] = rand(1, 10);
950
-			$_SESSION["pwdreset:testvalue2"] = rand(1, 10);
949
+            $_SESSION["pwdreset:testvalue1"] = rand(1, 10);
950
+            $_SESSION["pwdreset:testvalue2"] = rand(1, 10);
951 951
 
952
-			print "<fieldset>
952
+            print "<fieldset>
953 953
 				<label>".T_sprintf("How much is %d + %d:", $_SESSION["pwdreset:testvalue1"], $_SESSION["pwdreset:testvalue2"])."</label>
954 954
 				<input dojoType='dijit.form.TextBox' type='text' name='test' value='' required>
955 955
 				</fieldset>
@@ -961,111 +961,111 @@  discard block
 block discarded – undo
961 961
 				</fieldset>
962 962
 
963 963
 				</form>";
964
-		} else if ($method == 'do') {
964
+        } else if ($method == 'do') {
965 965
 
966
-			$login = clean($_POST["login"]);
967
-			$email = clean($_POST["email"]);
968
-			$test = clean($_POST["test"]);
966
+            $login = clean($_POST["login"]);
967
+            $email = clean($_POST["email"]);
968
+            $test = clean($_POST["test"]);
969 969
 
970
-			if ($test != ($_SESSION["pwdreset:testvalue1"] + $_SESSION["pwdreset:testvalue2"]) || !$email || !$login) {
971
-				print_error(__('Some of the required form parameters are missing or incorrect.'));
970
+            if ($test != ($_SESSION["pwdreset:testvalue1"] + $_SESSION["pwdreset:testvalue2"]) || !$email || !$login) {
971
+                print_error(__('Some of the required form parameters are missing or incorrect.'));
972 972
 
973
-				print "<form method='GET' action='public.php'>
973
+                print "<form method='GET' action='public.php'>
974 974
 					<input type='hidden' name='op' value='forgotpass'>
975 975
 					<button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".__("Go back")."</button>
976 976
 					</form>";
977 977
 
978
-			} else {
978
+            } else {
979 979
 
980
-				// prevent submitting this form multiple times
981
-				$_SESSION["pwdreset:testvalue1"] = rand(1, 1000);
982
-				$_SESSION["pwdreset:testvalue2"] = rand(1, 1000);
980
+                // prevent submitting this form multiple times
981
+                $_SESSION["pwdreset:testvalue1"] = rand(1, 1000);
982
+                $_SESSION["pwdreset:testvalue2"] = rand(1, 1000);
983 983
 
984
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users
984
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users
985 985
 					WHERE login = ? AND email = ?");
986
-				$sth->execute([$login, $email]);
986
+                $sth->execute([$login, $email]);
987 987
 
988
-				if ($row = $sth->fetch()) {
989
-					print_notice("Password reset instructions are being sent to your email address.");
988
+                if ($row = $sth->fetch()) {
989
+                    print_notice("Password reset instructions are being sent to your email address.");
990 990
 
991
-					$id = $row["id"];
991
+                    $id = $row["id"];
992 992
 
993
-					if ($id) {
994
-						$resetpass_token = sha1(get_random_bytes(128));
995
-						$resetpass_link = get_self_url_prefix()."/public.php?op=forgotpass&hash=".$resetpass_token.
996
-							"&login=".urlencode($login);
993
+                    if ($id) {
994
+                        $resetpass_token = sha1(get_random_bytes(128));
995
+                        $resetpass_link = get_self_url_prefix()."/public.php?op=forgotpass&hash=".$resetpass_token.
996
+                            "&login=".urlencode($login);
997 997
 
998
-						require_once "lib/MiniTemplator.class.php";
998
+                        require_once "lib/MiniTemplator.class.php";
999 999
 
1000
-						$tpl = new MiniTemplator;
1000
+                        $tpl = new MiniTemplator;
1001 1001
 
1002
-						$tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
1002
+                        $tpl->readTemplateFromFile("templates/resetpass_link_template.txt");
1003 1003
 
1004
-						$tpl->setVariable('LOGIN', $login);
1005
-						$tpl->setVariable('RESETPASS_LINK', $resetpass_link);
1006
-						$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
1004
+                        $tpl->setVariable('LOGIN', $login);
1005
+                        $tpl->setVariable('RESETPASS_LINK', $resetpass_link);
1006
+                        $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
1007 1007
 
1008
-						$tpl->addBlock('message');
1008
+                        $tpl->addBlock('message');
1009 1009
 
1010
-						$message = "";
1010
+                        $message = "";
1011 1011
 
1012
-						$tpl->generateOutputToString($message);
1012
+                        $tpl->generateOutputToString($message);
1013 1013
 
1014
-						$mailer = new Mailer();
1014
+                        $mailer = new Mailer();
1015 1015
 
1016
-						$rc = $mailer->mail(["to_name" => $login,
1017
-							"to_address" => $email,
1018
-							"subject" => __("[tt-rss] Password reset request"),
1019
-							"message" => $message]);
1016
+                        $rc = $mailer->mail(["to_name" => $login,
1017
+                            "to_address" => $email,
1018
+                            "subject" => __("[tt-rss] Password reset request"),
1019
+                            "message" => $message]);
1020 1020
 
1021
-						if (!$rc) {
1022
-						    print_error($mailer->error());
1023
-						}
1021
+                        if (!$rc) {
1022
+                            print_error($mailer->error());
1023
+                        }
1024 1024
 
1025
-						$resetpass_token_full = time().":".$resetpass_token;
1025
+                        $resetpass_token_full = time().":".$resetpass_token;
1026 1026
 
1027
-						$sth = $this->pdo->prepare("UPDATE ttrss_users
1027
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users
1028 1028
 							SET resetpass_token = ?
1029 1029
 							WHERE login = ? AND email = ?");
1030 1030
 
1031
-						$sth->execute([$resetpass_token_full, $login, $email]);
1031
+                        $sth->execute([$resetpass_token_full, $login, $email]);
1032 1032
 
1033
-					} else {
1034
-						print_error("User ID not found.");
1035
-					}
1033
+                    } else {
1034
+                        print_error("User ID not found.");
1035
+                    }
1036 1036
 
1037
-					print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1037
+                    print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1038 1038
 
1039
-				} else {
1040
-					print_error(__("Sorry, login and email combination not found."));
1039
+                } else {
1040
+                    print_error(__("Sorry, login and email combination not found."));
1041 1041
 
1042
-					print "<form method='GET' action='public.php'>
1042
+                    print "<form method='GET' action='public.php'>
1043 1043
 						<input type='hidden' name='op' value='forgotpass'>
1044 1044
 						<button dojoType='dijit.form.Button' type='submit'>".__("Go back")."</button>
1045 1045
 						</form>";
1046 1046
 
1047
-				}
1048
-			}
1047
+                }
1048
+            }
1049 1049
 
1050
-		}
1050
+        }
1051 1051
 
1052
-		print "</div>";
1053
-		print "</div>";
1054
-		print "</body>";
1055
-		print "</html>";
1052
+        print "</div>";
1053
+        print "</div>";
1054
+        print "</body>";
1055
+        print "</html>";
1056 1056
 
1057
-	}
1057
+    }
1058 1058
 
1059
-	public function dbupdate() {
1060
-		startup_gettext();
1059
+    public function dbupdate() {
1060
+        startup_gettext();
1061 1061
 
1062
-		if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
1063
-			$_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
1064
-			render_login_form();
1065
-			exit;
1066
-		}
1062
+        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
1063
+            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
1064
+            render_login_form();
1065
+            exit;
1066
+        }
1067 1067
 
1068
-		?>
1068
+        ?>
1069 1069
 		<!DOCTYPE html>
1070 1070
 		<html>
1071 1071
 			<head>
@@ -1075,11 +1075,11 @@  discard block
 block discarded – undo
1075 1075
 			<link rel="shortcut icon" type="image/png" href="images/favicon.png">
1076 1076
 			<link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png">
1077 1077
 			<?php
1078
-				echo stylesheet_tag("css/default.css");
1079
-				echo javascript_tag("lib/prototype.js");
1080
-				echo javascript_tag("lib/dojo/dojo.js");
1081
-				echo javascript_tag("lib/dojo/tt-rss-layer.js");
1082
-			?>
1078
+                echo stylesheet_tag("css/default.css");
1079
+                echo javascript_tag("lib/prototype.js");
1080
+                echo javascript_tag("lib/dojo/dojo.js");
1081
+                echo javascript_tag("lib/dojo/tt-rss-layer.js");
1082
+            ?>
1083 1083
 			<style type="text/css">
1084 1084
 				span.ok { color : #009000; font-weight : bold; }
1085 1085
 				span.err { color : #ff0000; font-weight : bold; }
@@ -1106,139 +1106,139 @@  discard block
 block discarded – undo
1106 1106
 			<div class="content">
1107 1107
 
1108 1108
 			<?php
1109
-				@$op = clean($_REQUEST["subop"]);
1110
-				$updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
1109
+                @$op = clean($_REQUEST["subop"]);
1110
+                $updater = new DbUpdater(DB_TYPE, SCHEMA_VERSION);
1111 1111
 
1112
-				if ($op == "performupdate") {
1113
-					if ($updater->isUpdateRequired()) {
1112
+                if ($op == "performupdate") {
1113
+                    if ($updater->isUpdateRequired()) {
1114 1114
 
1115
-						print "<h2>".T_sprintf("Performing updates to version %d", SCHEMA_VERSION)."</h2>";
1115
+                        print "<h2>".T_sprintf("Performing updates to version %d", SCHEMA_VERSION)."</h2>";
1116 1116
 
1117
-						for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
1118
-							print "<ul>";
1117
+                        for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
1118
+                            print "<ul>";
1119 1119
 
1120
-							print "<li class='text-info'>".T_sprintf("Updating to version %d", $i)."</li>";
1120
+                            print "<li class='text-info'>".T_sprintf("Updating to version %d", $i)."</li>";
1121 1121
 
1122
-							print "<li>";
1123
-							$result = $updater->performUpdateTo($i, true);
1124
-							print "</li>";
1122
+                            print "<li>";
1123
+                            $result = $updater->performUpdateTo($i, true);
1124
+                            print "</li>";
1125 1125
 
1126
-							if (!$result) {
1127
-								print "</ul>";
1126
+                            if (!$result) {
1127
+                                print "</ul>";
1128 1128
 
1129
-								print_error("One of the updates failed. Either retry the process or perform updates manually.");
1129
+                                print_error("One of the updates failed. Either retry the process or perform updates manually.");
1130 1130
 
1131
-								print "<form method='POST'>
1131
+                                print "<form method='POST'>
1132 1132
 									<input type='hidden' name='subop' value='performupdate'>
1133 1133
 									<button type='submit' dojoType='dijit.form.Button' class='alt-danger' onclick='return confirmOP()'>".__("Try again")."</button>
1134 1134
 									<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>
1135 1135
 								</form>";
1136 1136
 
1137
-								return;
1138
-							} else {
1139
-								print "<li class='text-success'>".__("Completed.")."</li>";
1140
-								print "</ul>";
1141
-							}
1142
-						}
1137
+                                return;
1138
+                            } else {
1139
+                                print "<li class='text-success'>".__("Completed.")."</li>";
1140
+                                print "</ul>";
1141
+                            }
1142
+                        }
1143 1143
 
1144
-						print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
1144
+                        print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
1145 1145
 
1146
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1146
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1147 1147
 
1148
-					} else {
1149
-						print_notice("Tiny Tiny RSS database is up to date.");
1148
+                    } else {
1149
+                        print_notice("Tiny Tiny RSS database is up to date.");
1150 1150
 
1151
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1152
-					}
1153
-				} else {
1154
-					if ($updater->isUpdateRequired()) {
1151
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1152
+                    }
1153
+                } else {
1154
+                    if ($updater->isUpdateRequired()) {
1155 1155
 
1156
-						print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
1157
-							$updater->getSchemaVersion(), SCHEMA_VERSION)."</h2>";
1156
+                        print "<h2>".T_sprintf("Tiny Tiny RSS database needs update to the latest version (%d to %d).",
1157
+                            $updater->getSchemaVersion(), SCHEMA_VERSION)."</h2>";
1158 1158
 
1159
-						if (DB_TYPE == "mysql") {
1160
-							print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
1161
-								"Errors may put it in an inconsistent state requiring manual rollback. <strong>BACKUP YOUR DATABASE BEFORE CONTINUING.</strong>");
1162
-						} else {
1163
-							print_warning("Please backup your database before proceeding.");
1164
-						}
1159
+                        if (DB_TYPE == "mysql") {
1160
+                            print_error("<strong>READ THIS:</strong> Due to MySQL limitations, your database is not completely protected while updating. ".
1161
+                                "Errors may put it in an inconsistent state requiring manual rollback. <strong>BACKUP YOUR DATABASE BEFORE CONTINUING.</strong>");
1162
+                        } else {
1163
+                            print_warning("Please backup your database before proceeding.");
1164
+                        }
1165 1165
 
1166
-						print "<form method='POST'>
1166
+                        print "<form method='POST'>
1167 1167
 							<input type='hidden' name='subop' value='performupdate'>
1168 1168
 							<button type='submit' dojoType='dijit.form.Button' class='alt-danger' onclick='return confirmOP()'>".__("Perform updates")."</button>
1169 1169
 						</form>";
1170 1170
 
1171
-					} else {
1171
+                    } else {
1172 1172
 
1173
-						print_notice("Tiny Tiny RSS database is up to date.");
1173
+                        print_notice("Tiny Tiny RSS database is up to date.");
1174 1174
 
1175
-						print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1176
-					}
1177
-				}
1178
-			?>
1175
+                        print "<a href='index.php'>".__("Return to Tiny Tiny RSS")."</a>";
1176
+                    }
1177
+                }
1178
+            ?>
1179 1179
 
1180 1180
 			</div>
1181 1181
 			</div>
1182 1182
 			</body>
1183 1183
 			</html>
1184 1184
 		<?php
1185
-	}
1186
-
1187
-	public function cached_url() {
1188
-		list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
1189
-
1190
-		// we do not allow files with extensions at the moment
1191
-		$filename = str_replace(".", "", $filename);
1192
-
1193
-		$cache = new DiskCache($cache_dir);
1194
-
1195
-		if ($cache->exists($filename)) {
1196
-			$cache->send($filename);
1197
-		} else {
1198
-			header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
1199
-			echo "File not found.";
1200
-		}
1201
-	}
1202
-
1203
-	private function make_article_tag_uri($id, $timestamp) {
1204
-
1205
-		$timestamp = date("Y-m-d", strtotime($timestamp));
1206
-
1207
-		return "tag:".parse_url(get_self_url_prefix(), PHP_URL_HOST).",$timestamp:/$id";
1208
-	}
1209
-
1210
-	// this should be used very carefully because this endpoint is exposed to unauthenticated users
1211
-	// plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
1212
-	// in general, don't do anything user-related in here and do not modify $_SESSION
1213
-	public function pluginhandler() {
1214
-		$host = new PluginHost();
1215
-
1216
-		$plugin_name = clean_filename($_REQUEST["plugin"]);
1217
-		$method = clean($_REQUEST["pmethod"]);
1218
-
1219
-		$host->load($plugin_name, PluginHost::KIND_USER, 0);
1220
-		$host->load_data();
1221
-
1222
-		$plugin = $host->get_plugin($plugin_name);
1223
-
1224
-		if ($plugin) {
1225
-			if (method_exists($plugin, $method)) {
1226
-				if ($plugin->is_public_method($method)) {
1227
-					$plugin->$method();
1228
-				} else {
1229
-					user_error("PluginHandler[PUBLIC]: Requested private method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1230
-					header("Content-Type: text/json");
1231
-					print error_json(6);
1232
-				}
1233
-			} else {
1234
-				user_error("PluginHandler[PUBLIC]: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1235
-				header("Content-Type: text/json");
1236
-				print error_json(13);
1237
-			}
1238
-		} else {
1239
-			user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
1240
-			header("Content-Type: text/json");
1241
-			print error_json(14);
1242
-		}
1243
-	}
1185
+    }
1186
+
1187
+    public function cached_url() {
1188
+        list ($cache_dir, $filename) = explode("/", $_GET["file"], 2);
1189
+
1190
+        // we do not allow files with extensions at the moment
1191
+        $filename = str_replace(".", "", $filename);
1192
+
1193
+        $cache = new DiskCache($cache_dir);
1194
+
1195
+        if ($cache->exists($filename)) {
1196
+            $cache->send($filename);
1197
+        } else {
1198
+            header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
1199
+            echo "File not found.";
1200
+        }
1201
+    }
1202
+
1203
+    private function make_article_tag_uri($id, $timestamp) {
1204
+
1205
+        $timestamp = date("Y-m-d", strtotime($timestamp));
1206
+
1207
+        return "tag:".parse_url(get_self_url_prefix(), PHP_URL_HOST).",$timestamp:/$id";
1208
+    }
1209
+
1210
+    // this should be used very carefully because this endpoint is exposed to unauthenticated users
1211
+    // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
1212
+    // in general, don't do anything user-related in here and do not modify $_SESSION
1213
+    public function pluginhandler() {
1214
+        $host = new PluginHost();
1215
+
1216
+        $plugin_name = clean_filename($_REQUEST["plugin"]);
1217
+        $method = clean($_REQUEST["pmethod"]);
1218
+
1219
+        $host->load($plugin_name, PluginHost::KIND_USER, 0);
1220
+        $host->load_data();
1221
+
1222
+        $plugin = $host->get_plugin($plugin_name);
1223
+
1224
+        if ($plugin) {
1225
+            if (method_exists($plugin, $method)) {
1226
+                if ($plugin->is_public_method($method)) {
1227
+                    $plugin->$method();
1228
+                } else {
1229
+                    user_error("PluginHandler[PUBLIC]: Requested private method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1230
+                    header("Content-Type: text/json");
1231
+                    print error_json(6);
1232
+                }
1233
+            } else {
1234
+                user_error("PluginHandler[PUBLIC]: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
1235
+                header("Content-Type: text/json");
1236
+                print error_json(13);
1237
+            }
1238
+        } else {
1239
+            user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
1240
+            header("Content-Type: text/json");
1241
+            print error_json(14);
1242
+        }
1243
+    }
1244 1244
 }
Please login to merge, or discard this patch.
lib/phpqrcode/qrsplit.php 2 patches
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -255,14 +255,14 @@
 block discarded – undo
255 255
                 $mode = $this->identifyMode(0);
256 256
                 
257 257
                 switch ($mode) {
258
-                    case QR_MODE_NUM: $length = $this->eatNum(); break;
259
-                    case QR_MODE_AN:  $length = $this->eatAn(); break;
260
-                    case QR_MODE_KANJI:
261
-                        if ($this->modeHint == QR_MODE_KANJI)
262
-                                $length = $this->eatKanji();
263
-                        else    $length = $this->eat8();
264
-                        break;
265
-                    default: $length = $this->eat8(); break;
258
+                case QR_MODE_NUM: $length = $this->eatNum(); break;
259
+                case QR_MODE_AN:  $length = $this->eatAn(); break;
260
+                case QR_MODE_KANJI:
261
+                    if ($this->modeHint == QR_MODE_KANJI)
262
+                            $length = $this->eatKanji();
263
+                    else    $length = $this->eat8();
264
+                    break;
265
+                default: $length = $this->eat8(); break;
266 266
                 
267 267
                 }
268 268
 
Please login to merge, or discard this patch.
Braces   +29 added lines, -17 removed lines patch added patch discarded remove patch
@@ -123,8 +123,9 @@  discard block
 block discarded – undo
123 123
             }
124 124
             
125 125
             $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr));
126
-            if ($ret < 0)
127
-                return -1;
126
+            if ($ret < 0) {
127
+                            return -1;
128
+            }
128 129
 
129 130
             return $run;
130 131
         }
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
             }
171 172
 
172 173
             $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr));
173
-            if ($ret < 0)
174
-                return -1;
174
+            if ($ret < 0) {
175
+                            return -1;
176
+            }
175 177
 
176 178
             return $run;
177 179
         }
@@ -186,8 +188,9 @@  discard block
 block discarded – undo
186 188
             }
187 189
             
188 190
             $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr));
189
-            if ($ret < 0)
190
-                return -1;
191
+            if ($ret < 0) {
192
+                            return -1;
193
+            }
191 194
 
192 195
             return $ret;
193 196
         }
@@ -241,8 +244,9 @@  discard block
 block discarded – undo
241 244
             $run = $p;
242 245
             $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr));
243 246
             
244
-            if ($ret < 0)
245
-                return -1;
247
+            if ($ret < 0) {
248
+                            return -1;
249
+            }
246 250
 
247 251
             return $run;
248 252
         }
@@ -252,8 +256,9 @@  discard block
 block discarded – undo
252 256
         {
253 257
             while (strlen($this->dataStr) > 0)
254 258
             {
255
-                if ($this->dataStr == '')
256
-                    return 0;
259
+                if ($this->dataStr == '') {
260
+                                    return 0;
261
+                }
257 262
 
258 263
                 $mode = $this->identifyMode(0);
259 264
                 
@@ -261,16 +266,22 @@  discard block
 block discarded – undo
261 266
                     case QR_MODE_NUM: $length = $this->eatNum(); break;
262 267
                     case QR_MODE_AN:  $length = $this->eatAn(); break;
263 268
                     case QR_MODE_KANJI:
264
-                        if ($this->modeHint == QR_MODE_KANJI)
265
-                                $length = $this->eatKanji();
266
-                        else    $length = $this->eat8();
269
+                        if ($this->modeHint == QR_MODE_KANJI) {
270
+                                                        $length = $this->eatKanji();
271
+                        } else {
272
+                            $length = $this->eat8();
273
+                        }
267 274
                         break;
268 275
                     default: $length = $this->eat8(); break;
269 276
                 
270 277
                 }
271 278
 
272
-                if ($length == 0) return 0;
273
-                if ($length < 0)  return -1;
279
+                if ($length == 0) {
280
+                    return 0;
281
+                }
282
+                if ($length < 0) {
283
+                    return -1;
284
+                }
274 285
                 
275 286
                 $this->dataStr = substr($this->dataStr, $length);
276 287
             }
@@ -306,8 +317,9 @@  discard block
 block discarded – undo
306 317
 
307 318
             $split = new QRsplit($string, $input, $modeHint);
308 319
             
309
-            if (!$casesensitive)
310
-                $split->toUpper();
320
+            if (!$casesensitive) {
321
+                            $split->toUpper();
322
+            }
311 323
                 
312 324
             return $split->splitString();
313 325
         }
Please login to merge, or discard this patch.
lib/phpqrcode/qrencode.php 2 patches
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -415,28 +415,28 @@
 block discarded – undo
415 415
             $enc->margin = $margin;
416 416
             
417 417
             switch ($level.'') {
418
-                case '0':
419
-                case '1':
420
-                case '2':
421
-                case '3':
422
-                        $enc->level = $level;
423
-                    break;
424
-                case 'l':
425
-                case 'L':
426
-                        $enc->level = QR_ECLEVEL_L;
427
-                    break;
428
-                case 'm':
429
-                case 'M':
430
-                        $enc->level = QR_ECLEVEL_M;
431
-                    break;
432
-                case 'q':
433
-                case 'Q':
434
-                        $enc->level = QR_ECLEVEL_Q;
435
-                    break;
436
-                case 'h':
437
-                case 'H':
438
-                        $enc->level = QR_ECLEVEL_H;
439
-                    break;
418
+            case '0':
419
+            case '1':
420
+            case '2':
421
+            case '3':
422
+                    $enc->level = $level;
423
+                break;
424
+            case 'l':
425
+            case 'L':
426
+                    $enc->level = QR_ECLEVEL_L;
427
+                break;
428
+            case 'm':
429
+            case 'M':
430
+                    $enc->level = QR_ECLEVEL_M;
431
+                break;
432
+            case 'q':
433
+            case 'Q':
434
+                    $enc->level = QR_ECLEVEL_Q;
435
+                break;
436
+            case 'h':
437
+            case 'H':
438
+                    $enc->level = QR_ECLEVEL_H;
439
+                break;
440 440
             }
441 441
             
442 442
             return $enc;
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -104,14 +104,17 @@  discard block
 block discarded – undo
104 104
                 $blockNo++;
105 105
             }
106 106
 
107
-            if (QRspec::rsBlockNum2($spec) == 0)
108
-                return 0;
107
+            if (QRspec::rsBlockNum2($spec) == 0) {
108
+                            return 0;
109
+            }
109 110
 
110 111
             $dl = QRspec::rsDataCodes2($spec);
111 112
             $el = QRspec::rsEccCodes2($spec);
112 113
             $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el);
113 114
             
114
-            if ($rs == null) return -1;
115
+            if ($rs == null) {
116
+                return -1;
117
+            }
115 118
             
116 119
             for ($i = 0; $i < QRspec::rsBlockNum2($spec); $i++) {
117 120
                 $ecc = array_slice($this->ecccode, $eccPos);
@@ -249,7 +252,9 @@  discard block
 block discarded – undo
249 252
             }
250 253
 
251 254
             $input = new QRinput($version, $level);
252
-            if ($input == null) return null;
255
+            if ($input == null) {
256
+                return null;
257
+            }
253 258
 
254 259
             $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string));
255 260
             if ($ret < 0) {
@@ -269,7 +274,9 @@  discard block
 block discarded – undo
269 274
             }
270 275
 
271 276
             $input = new QRinput($version, $level);
272
-            if ($input == null) return null;
277
+            if ($input == null) {
278
+                return null;
279
+            }
273 280
 
274 281
             $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive);
275 282
             if ($ret < 0) {
@@ -379,7 +386,9 @@  discard block
 block discarded – undo
379 386
                         }
380 387
                     }
381 388
                 }
382
-                if ($x < 0 || $y < 0) return null;
389
+                if ($x < 0 || $y < 0) {
390
+                    return null;
391
+                }
383 392
 
384 393
                 $this->x = $x;
385 394
                 $this->y = $y;
Please login to merge, or discard this patch.
classes/logger.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@
 block discarded – undo
52 52
 
53 53
     public function __construct() {
54 54
         switch (LOG_DESTINATION) {
55
-            case "sql":
56
-                $this->adapter = new Logger_SQL();
57
-                break;
58
-            case "syslog":
59
-                $this->adapter = new Logger_Syslog();
60
-                break;
61
-            default:
62
-                $this->adapter = false;
55
+        case "sql":
56
+            $this->adapter = new Logger_SQL();
57
+            break;
58
+        case "syslog":
59
+            $this->adapter = new Logger_Syslog();
60
+            break;
61
+        default:
62
+            $this->adapter = false;
63 63
         }
64 64
     }
65 65
 
Please login to merge, or discard this patch.
classes/logger/sql.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,9 @@
 block discarded – undo
24 24
 			];
25 25
 
26 26
 			foreach ($server_params as $n => $p) {
27
-				if (isset($_SERVER[$p]))
28
-					$context .= "\n$n: ".$_SERVER[$p];
27
+				if (isset($_SERVER[$p])) {
28
+									$context .= "\n$n: ".$_SERVER[$p];
29
+				}
29 30
 			}
30 31
 
31 32
 			// passed error message may contain invalid unicode characters, failing to insert an error here
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@
 block discarded – undo
1 1
 <?php
2 2
 class Logger_SQL {
3 3
 
4
-	private $pdo;
4
+    private $pdo;
5 5
 
6
-	public function log_error($errno, $errstr, $file, $line, $context) {
6
+    public function log_error($errno, $errstr, $file, $line, $context) {
7 7
 
8
-		// separate PDO connection object is used for logging
9
-		if (!$this->pdo) {
10
-		    $this->pdo = Db::instance()->pdo_connect();
11
-		}
8
+        // separate PDO connection object is used for logging
9
+        if (!$this->pdo) {
10
+            $this->pdo = Db::instance()->pdo_connect();
11
+        }
12 12
 
13
-		if ($this->pdo && get_schema_version() > 117) {
13
+        if ($this->pdo && get_schema_version() > 117) {
14 14
 
15
-			$owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null;
15
+            $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : null;
16 16
 
17
-			// limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge
18
-			$context = mb_substr($context, 0, 8192);
17
+            // limit context length, DOMDocument dumps entire XML in here sometimes, which may be huge
18
+            $context = mb_substr($context, 0, 8192);
19 19
 
20
-			$server_params = [
21
-				"IP" => "REMOTE_ADDR",
22
-				"Request URI" => "REQUEST_URI",
23
-				"User agent" => "HTTP_USER_AGENT",
24
-			];
20
+            $server_params = [
21
+                "IP" => "REMOTE_ADDR",
22
+                "Request URI" => "REQUEST_URI",
23
+                "User agent" => "HTTP_USER_AGENT",
24
+            ];
25 25
 
26
-			foreach ($server_params as $n => $p) {
27
-				if (isset($_SERVER[$p]))
28
-					$context .= "\n$n: ".$_SERVER[$p];
29
-			}
26
+            foreach ($server_params as $n => $p) {
27
+                if (isset($_SERVER[$p]))
28
+                    $context .= "\n$n: ".$_SERVER[$p];
29
+            }
30 30
 
31
-			// passed error message may contain invalid unicode characters, failing to insert an error here
32
-			// would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc
33
-			$errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8');
34
-			$context = UConverter::transcode($context, 'UTF-8', 'UTF-8');
31
+            // passed error message may contain invalid unicode characters, failing to insert an error here
32
+            // would break the execution entirely by generating an actual fatal error instead of a E_WARNING etc
33
+            $errstr = UConverter::transcode($errstr, 'UTF-8', 'UTF-8');
34
+            $context = UConverter::transcode($context, 'UTF-8', 'UTF-8');
35 35
 
36
-			$sth = $this->pdo->prepare("INSERT INTO ttrss_error_log
36
+            $sth = $this->pdo->prepare("INSERT INTO ttrss_error_log
37 37
 				(errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
38 38
 				(?, ?, ?, ?, ?, ?, NOW())");
39
-			$sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]);
39
+            $sth->execute([$errno, $errstr, $file, $line, $context, $owner_uid]);
40 40
 
41
-			return $sth->rowCount();
42
-		}
41
+            return $sth->rowCount();
42
+        }
43 43
 
44
-		return false;
45
-	}
44
+        return false;
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
classes/feeditem/common.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -186,8 +186,9 @@
 block discarded – undo
186 186
 			$cat = clean(trim(mb_strtolower($srccat)));
187 187
 
188 188
 			// we don't support numeric tags
189
-			if (is_numeric($cat))
190
-				$cat = 't:'.$cat;
189
+			if (is_numeric($cat)) {
190
+							$cat = 't:'.$cat;
191
+			}
191 192
 
192 193
 			$cat = preg_replace('/[,\'\"]/', "", $cat);
193 194
 
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -1,209 +1,209 @@
 block discarded – undo
1 1
 <?php
2 2
 abstract class FeedItem_Common extends FeedItem {
3
-	protected $elem;
4
-	protected $xpath;
5
-	protected $doc;
6
-
7
-	public function __construct($elem, $doc, $xpath) {
8
-		$this->elem = $elem;
9
-		$this->xpath = $xpath;
10
-		$this->doc = $doc;
11
-
12
-		try {
3
+    protected $elem;
4
+    protected $xpath;
5
+    protected $doc;
6
+
7
+    public function __construct($elem, $doc, $xpath) {
8
+        $this->elem = $elem;
9
+        $this->xpath = $xpath;
10
+        $this->doc = $doc;
11
+
12
+        try {
13 13
 
14
-			$source = $elem->getElementsByTagName("source")->item(0);
14
+            $source = $elem->getElementsByTagName("source")->item(0);
15 15
 
16
-			// we don't need <source> element
17
-			if ($source) {
18
-							$elem->removeChild($source);
19
-			}
20
-		} catch (DOMException $e) {
21
-			//
22
-		}
23
-	}
16
+            // we don't need <source> element
17
+            if ($source) {
18
+                            $elem->removeChild($source);
19
+            }
20
+        } catch (DOMException $e) {
21
+            //
22
+        }
23
+    }
24 24
 
25
-	public function get_element() {
26
-		return $this->elem;
27
-	}
25
+    public function get_element() {
26
+        return $this->elem;
27
+    }
28 28
 
29
-	public function get_author() {
30
-		$author = $this->elem->getElementsByTagName("author")->item(0);
29
+    public function get_author() {
30
+        $author = $this->elem->getElementsByTagName("author")->item(0);
31 31
 
32
-		if ($author) {
33
-			$name = $author->getElementsByTagName("name")->item(0);
32
+        if ($author) {
33
+            $name = $author->getElementsByTagName("name")->item(0);
34 34
 
35
-			if ($name) {
36
-			    return clean($name->nodeValue);
37
-			}
38
-
39
-			$email = $author->getElementsByTagName("email")->item(0);
40
-
41
-			if ($email) {
42
-			    return clean($email->nodeValue);
43
-			}
44
-
45
-			if ($author->nodeValue) {
46
-							return clean($author->nodeValue);
47
-			}
48
-		}
49
-
50
-		$author_elems = $this->xpath->query("dc:creator", $this->elem);
51
-		$authors = [];
52
-
53
-		foreach ($author_elems as $author) {
54
-			array_push($authors, clean($author->nodeValue));
55
-		}
56
-
57
-		return implode(", ", $authors);
58
-	}
59
-
60
-	public function get_comments_url() {
61
-		//RSS only. Use a query here to avoid namespace clashes (e.g. with slash).
62
-		//might give a wrong result if a default namespace was declared (possible with XPath 2.0)
63
-		$com_url = $this->xpath->query("comments", $this->elem)->item(0);
35
+            if ($name) {
36
+                return clean($name->nodeValue);
37
+            }
38
+
39
+            $email = $author->getElementsByTagName("email")->item(0);
40
+
41
+            if ($email) {
42
+                return clean($email->nodeValue);
43
+            }
44
+
45
+            if ($author->nodeValue) {
46
+                            return clean($author->nodeValue);
47
+            }
48
+        }
49
+
50
+        $author_elems = $this->xpath->query("dc:creator", $this->elem);
51
+        $authors = [];
52
+
53
+        foreach ($author_elems as $author) {
54
+            array_push($authors, clean($author->nodeValue));
55
+        }
56
+
57
+        return implode(", ", $authors);
58
+    }
59
+
60
+    public function get_comments_url() {
61
+        //RSS only. Use a query here to avoid namespace clashes (e.g. with slash).
62
+        //might give a wrong result if a default namespace was declared (possible with XPath 2.0)
63
+        $com_url = $this->xpath->query("comments", $this->elem)->item(0);
64 64
 
65
-		if ($com_url) {
66
-					return clean($com_url->nodeValue);
67
-		}
65
+        if ($com_url) {
66
+                    return clean($com_url->nodeValue);
67
+        }
68 68
 
69
-		//Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common.
70
-		//'text/html' for type is too restrictive?
71
-		$com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0);
72
-
73
-		if ($com_url) {
74
-					return clean($com_url->nodeValue);
75
-		}
76
-	}
77
-
78
-	public function get_comments_count() {
79
-		//also query for ATE stuff here
80
-		$query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count";
81
-		$comments = $this->xpath->query($query, $this->elem)->item(0);
82
-
83
-		if ($comments) {
84
-			return clean($comments->nodeValue);
85
-		}
86
-	}
69
+        //Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common.
70
+        //'text/html' for type is too restrictive?
71
+        $com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0);
72
+
73
+        if ($com_url) {
74
+                    return clean($com_url->nodeValue);
75
+        }
76
+    }
77
+
78
+    public function get_comments_count() {
79
+        //also query for ATE stuff here
80
+        $query = "slash:comments|thread:total|atom:link[@rel='replies']/@thread:count";
81
+        $comments = $this->xpath->query($query, $this->elem)->item(0);
82
+
83
+        if ($comments) {
84
+            return clean($comments->nodeValue);
85
+        }
86
+    }
87 87
 
88
-	// this is common for both Atom and RSS types and deals with various media: elements
89
-	public function get_enclosures() {
90
-		$encs = [];
88
+    // this is common for both Atom and RSS types and deals with various media: elements
89
+    public function get_enclosures() {
90
+        $encs = [];
91 91
 
92
-		$enclosures = $this->xpath->query("media:content", $this->elem);
92
+        $enclosures = $this->xpath->query("media:content", $this->elem);
93 93
 
94
-		foreach ($enclosures as $enclosure) {
95
-			$enc = new FeedEnclosure();
94
+        foreach ($enclosures as $enclosure) {
95
+            $enc = new FeedEnclosure();
96 96
 
97
-			$enc->type = clean($enclosure->getAttribute("type"));
98
-			$enc->link = clean($enclosure->getAttribute("url"));
99
-			$enc->length = clean($enclosure->getAttribute("length"));
100
-			$enc->height = clean($enclosure->getAttribute("height"));
101
-			$enc->width = clean($enclosure->getAttribute("width"));
97
+            $enc->type = clean($enclosure->getAttribute("type"));
98
+            $enc->link = clean($enclosure->getAttribute("url"));
99
+            $enc->length = clean($enclosure->getAttribute("length"));
100
+            $enc->height = clean($enclosure->getAttribute("height"));
101
+            $enc->width = clean($enclosure->getAttribute("width"));
102 102
 
103
-			$medium = clean($enclosure->getAttribute("medium"));
104
-			if (!$enc->type && $medium) {
105
-				$enc->type = strtolower("$medium/generic");
106
-			}
103
+            $medium = clean($enclosure->getAttribute("medium"));
104
+            if (!$enc->type && $medium) {
105
+                $enc->type = strtolower("$medium/generic");
106
+            }
107 107
 
108
-			$desc = $this->xpath->query("media:description", $enclosure)->item(0);
109
-			if ($desc) {
110
-			    $enc->title = clean($desc->nodeValue);
111
-			}
108
+            $desc = $this->xpath->query("media:description", $enclosure)->item(0);
109
+            if ($desc) {
110
+                $enc->title = clean($desc->nodeValue);
111
+            }
112 112
 
113
-			array_push($encs, $enc);
114
-		}
113
+            array_push($encs, $enc);
114
+        }
115 115
 
116
-		$enclosures = $this->xpath->query("media:group", $this->elem);
116
+        $enclosures = $this->xpath->query("media:group", $this->elem);
117 117
 
118
-		foreach ($enclosures as $enclosure) {
119
-			$enc = new FeedEnclosure();
118
+        foreach ($enclosures as $enclosure) {
119
+            $enc = new FeedEnclosure();
120 120
 
121
-			$content = $this->xpath->query("media:content", $enclosure)->item(0);
121
+            $content = $this->xpath->query("media:content", $enclosure)->item(0);
122 122
 
123
-			if ($content) {
124
-				$enc->type = clean($content->getAttribute("type"));
125
-				$enc->link = clean($content->getAttribute("url"));
126
-				$enc->length = clean($content->getAttribute("length"));
127
-				$enc->height = clean($content->getAttribute("height"));
128
-				$enc->width = clean($content->getAttribute("width"));
123
+            if ($content) {
124
+                $enc->type = clean($content->getAttribute("type"));
125
+                $enc->link = clean($content->getAttribute("url"));
126
+                $enc->length = clean($content->getAttribute("length"));
127
+                $enc->height = clean($content->getAttribute("height"));
128
+                $enc->width = clean($content->getAttribute("width"));
129 129
 
130
-				$medium = clean($content->getAttribute("medium"));
131
-				if (!$enc->type && $medium) {
132
-					$enc->type = strtolower("$medium/generic");
133
-				}
130
+                $medium = clean($content->getAttribute("medium"));
131
+                if (!$enc->type && $medium) {
132
+                    $enc->type = strtolower("$medium/generic");
133
+                }
134 134
 
135
-				$desc = $this->xpath->query("media:description", $content)->item(0);
136
-				if ($desc) {
137
-					$enc->title = clean($desc->nodeValue);
138
-				} else {
139
-					$desc = $this->xpath->query("media:description", $enclosure)->item(0);
140
-					if ($desc) {
141
-					    $enc->title = clean($desc->nodeValue);
142
-					}
143
-				}
135
+                $desc = $this->xpath->query("media:description", $content)->item(0);
136
+                if ($desc) {
137
+                    $enc->title = clean($desc->nodeValue);
138
+                } else {
139
+                    $desc = $this->xpath->query("media:description", $enclosure)->item(0);
140
+                    if ($desc) {
141
+                        $enc->title = clean($desc->nodeValue);
142
+                    }
143
+                }
144 144
 
145
-				array_push($encs, $enc);
146
-			}
147
-		}
145
+                array_push($encs, $enc);
146
+            }
147
+        }
148 148
 
149
-		$enclosures = $this->xpath->query("media:thumbnail", $this->elem);
149
+        $enclosures = $this->xpath->query("media:thumbnail", $this->elem);
150 150
 
151
-		foreach ($enclosures as $enclosure) {
152
-			$enc = new FeedEnclosure();
151
+        foreach ($enclosures as $enclosure) {
152
+            $enc = new FeedEnclosure();
153 153
 
154
-			$enc->type = "image/generic";
155
-			$enc->link = clean($enclosure->getAttribute("url"));
156
-			$enc->height = clean($enclosure->getAttribute("height"));
157
-			$enc->width = clean($enclosure->getAttribute("width"));
154
+            $enc->type = "image/generic";
155
+            $enc->link = clean($enclosure->getAttribute("url"));
156
+            $enc->height = clean($enclosure->getAttribute("height"));
157
+            $enc->width = clean($enclosure->getAttribute("width"));
158 158
 
159
-			array_push($encs, $enc);
160
-		}
159
+            array_push($encs, $enc);
160
+        }
161 161
 
162
-		return $encs;
163
-	}
162
+        return $encs;
163
+    }
164 164
 
165
-	public function count_children($node) {
166
-		return $node->getElementsByTagName("*")->length;
167
-	}
165
+    public function count_children($node) {
166
+        return $node->getElementsByTagName("*")->length;
167
+    }
168 168
 
169
-	public function subtree_or_text($node) {
170
-		if ($this->count_children($node) == 0) {
171
-			return $node->nodeValue;
172
-		} else {
173
-			return $node->c14n();
174
-		}
175
-	}
169
+    public function subtree_or_text($node) {
170
+        if ($this->count_children($node) == 0) {
171
+            return $node->nodeValue;
172
+        } else {
173
+            return $node->c14n();
174
+        }
175
+    }
176 176
 
177
-	public static function normalize_categories($cats) {
177
+    public static function normalize_categories($cats) {
178 178
 
179
-		$tmp = [];
179
+        $tmp = [];
180 180
 
181
-		foreach ($cats as $rawcat) {
182
-			$tmp = array_merge($tmp, explode(",", $rawcat));
183
-		}
181
+        foreach ($cats as $rawcat) {
182
+            $tmp = array_merge($tmp, explode(",", $rawcat));
183
+        }
184 184
 
185
-		$tmp = array_map(function($srccat) {
186
-			$cat = clean(trim(mb_strtolower($srccat)));
185
+        $tmp = array_map(function($srccat) {
186
+            $cat = clean(trim(mb_strtolower($srccat)));
187 187
 
188
-			// we don't support numeric tags
189
-			if (is_numeric($cat))
190
-				$cat = 't:'.$cat;
188
+            // we don't support numeric tags
189
+            if (is_numeric($cat))
190
+                $cat = 't:'.$cat;
191 191
 
192
-			$cat = preg_replace('/[,\'\"]/', "", $cat);
192
+            $cat = preg_replace('/[,\'\"]/', "", $cat);
193 193
 
194
-			if (DB_TYPE == "mysql") {
195
-				$cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat);
196
-			}
194
+            if (DB_TYPE == "mysql") {
195
+                $cat = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $cat);
196
+            }
197 197
 
198
-			if (mb_strlen($cat) > 250) {
199
-							$cat = mb_substr($cat, 0, 250);
200
-			}
198
+            if (mb_strlen($cat) > 250) {
199
+                            $cat = mb_substr($cat, 0, 250);
200
+            }
201 201
 
202
-			return $cat;
203
-		}, $tmp);
202
+            return $cat;
203
+        }, $tmp);
204 204
 
205
-		asort($tmp);
205
+        asort($tmp);
206 206
 
207
-		return array_unique($tmp);
208
-	}
207
+        return array_unique($tmp);
208
+    }
209 209
 }
Please login to merge, or discard this patch.
plugins/mailto/init.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		while ($line = $sth->fetch()) {
55 55
 
56 56
 			if (!$subject) {
57
-							$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
57
+							$subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]);
58 58
 			}
59 59
 
60 60
 			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,96 +1,96 @@
 block discarded – undo
1 1
 <?php
2 2
 class MailTo extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Share article via email (using mailto: links, invoking your mail client)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Share article via email (using mailto: links, invoking your mail client)",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
11
+    public function init($host) {
12
+        $this->host = $host;
13 13
 
14
-		$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
15
-	}
14
+        $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
15
+    }
16 16
 
17
-	public function get_js() {
18
-		return file_get_contents(dirname(__FILE__)."/init.js");
19
-	}
17
+    public function get_js() {
18
+        return file_get_contents(dirname(__FILE__)."/init.js");
19
+    }
20 20
 
21
-	public function hook_article_button($line) {
22
-		return "<i class='material-icons' style=\"cursor : pointer\"
21
+    public function hook_article_button($line) {
22
+        return "<i class='material-icons' style=\"cursor : pointer\"
23 23
 					onclick=\"Plugins.Mailto.send(".$line["id"].")\"
24 24
 					title='".__('Forward by email')."'>mail_outline</i>";
25
-	}
25
+    }
26 26
 
27
-	public function emailArticle() {
27
+    public function emailArticle() {
28 28
 
29
-		$ids = explode(",", $_REQUEST['param']);
30
-		$ids_qmarks = arr_qmarks($ids);
29
+        $ids = explode(",", $_REQUEST['param']);
30
+        $ids_qmarks = arr_qmarks($ids);
31 31
 
32
-		require_once "lib/MiniTemplator.class.php";
32
+        require_once "lib/MiniTemplator.class.php";
33 33
 
34
-		$tpl = new MiniTemplator;
34
+        $tpl = new MiniTemplator;
35 35
 
36
-		$tpl->readTemplateFromFile("templates/email_article_template.txt");
36
+        $tpl->readTemplateFromFile("templates/email_article_template.txt");
37 37
 
38
-		$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
39
-		//$tpl->setVariable('USER_EMAIL', $user_email, true);
40
-		$tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
38
+        $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
39
+        //$tpl->setVariable('USER_EMAIL', $user_email, true);
40
+        $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
41 41
 
42 42
 
43
-		$sth = $this->pdo->prepare("SELECT DISTINCT link, content, title
43
+        $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title
44 44
 			FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
45 45
 			id IN ($ids_qmarks) AND owner_uid = ?");
46
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
46
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
47 47
 
48
-		if (count($ids) > 1) {
49
-			$subject = __("[Forwarded]")." ".__("Multiple articles");
50
-		} else {
51
-			$subject = "";
52
-		}
48
+        if (count($ids) > 1) {
49
+            $subject = __("[Forwarded]")." ".__("Multiple articles");
50
+        } else {
51
+            $subject = "";
52
+        }
53 53
 
54
-		while ($line = $sth->fetch()) {
54
+        while ($line = $sth->fetch()) {
55 55
 
56
-			if (!$subject) {
57
-							$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
58
-			}
56
+            if (!$subject) {
57
+                            $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
58
+            }
59 59
 
60
-			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
61
-			$tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
60
+            $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
61
+            $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
62 62
 
63
-			$tpl->addBlock('article');
64
-		}
63
+            $tpl->addBlock('article');
64
+        }
65 65
 
66
-		$tpl->addBlock('email');
66
+        $tpl->addBlock('email');
67 67
 
68
-		$content = "";
69
-		$tpl->generateOutputToString($content);
68
+        $content = "";
69
+        $tpl->generateOutputToString($content);
70 70
 
71
-		$mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject).
72
-			"&body=".rawurlencode($content));
71
+        $mailto_link = htmlspecialchars("mailto:?subject=".rawurlencode($subject).
72
+            "&body=".rawurlencode($content));
73 73
 
74
-		print __("Clicking the following link to invoke your mail client:");
74
+        print __("Clicking the following link to invoke your mail client:");
75 75
 
76
-		print "<div class='panel text-center'>";
77
-		print "<a target=\"_blank\" href=\"$mailto_link\">".
78
-			__("Forward selected article(s) by email.")."</a>";
79
-		print "</div>";
76
+        print "<div class='panel text-center'>";
77
+        print "<a target=\"_blank\" href=\"$mailto_link\">".
78
+            __("Forward selected article(s) by email.")."</a>";
79
+        print "</div>";
80 80
 
81
-		print __("You should be able to edit the message before sending in your mail client.");
81
+        print __("You should be able to edit the message before sending in your mail client.");
82 82
 
83
-		print "<p>";
83
+        print "<p>";
84 84
 
85
-		print "<footer class='text-center'>";
86
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
87
-		print "</footer>";
85
+        print "<footer class='text-center'>";
86
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Close this dialog')."</button>";
87
+        print "</footer>";
88 88
 
89
-		//return;
90
-	}
89
+        //return;
90
+    }
91 91
 
92
-	public function api_version() {
93
-		return 2;
94
-	}
92
+    public function api_version() {
93
+        return 2;
94
+    }
95 95
 
96 96
 }
Please login to merge, or discard this patch.