Passed
Branch master (a3c0d0)
by Cody
02:54
created
classes/opml.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			$cat_title = htmlspecialchars($row['title']);
71 71
 
72 72
 			if ($include_settings) {
73
-				$order_id = (int)$row["order_id"];
73
+				$order_id = (int) $row["order_id"];
74 74
 				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
75 75
 			}
76 76
 		} else {
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 			$site_url = htmlspecialchars($fline["site_url"]);
104 104
 
105 105
 			if ($include_settings) {
106
-				$update_interval = (int)$fline["update_interval"];
107
-				$order_id = (int)$fline["order_id"];
106
+				$update_interval = (int) $fline["update_interval"];
107
+				$order_id = (int) $fline["order_id"];
108 108
 
109 109
 				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
110 110
 			} else {
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 		if (!isset($_REQUEST["debug"])) {
132 132
 			header("Content-type: application/xml+opml");
133
-			header("Content-Disposition: attachment; filename=" . $name );
133
+			header("Content-Disposition: attachment; filename=".$name);
134 134
 		} else {
135 135
 			header("Content-type: text/xml");
136 136
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$out .= "<opml version=\"1.0\">";
141 141
 		$out .= "<head>
142
-			<dateCreated>" . date("r", time()) . "</dateCreated>
142
+			<dateCreated>" . date("r", time())."</dateCreated>
143 143
 			<title>Tiny Tiny RSS Feed Export</title>
144 144
 		</head>";
145 145
 		$out .= "<body>";
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 					    foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
215 215
 
216 216
                             if (strpos($feed_id, "CAT:") === 0) {
217
-                                $feed_id = (int)substr($feed_id, 4);
217
+                                $feed_id = (int) substr($feed_id, 4);
218 218
                                 if ($feed_id) {
219 219
                                     array_push($match, [Feeds::getCategoryTitle($feed_id), true, false]);
220 220
                                 } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                                 }
223 223
                             } else {
224 224
                                 if ($feed_id) {
225
-                                    array_push($match, [Feeds::getFeedTitle((int)$feed_id), false, false]);
225
+                                    array_push($match, [Feeds::getFeedTitle((int) $feed_id), false, false]);
226 226
                                 } else {
227 227
                                     array_push($match, [0, false, true]);
228 228
                                 }
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 						        list ($name, $is_cat, $is_id) = $match;
410 410
 
411 411
 						        if ($is_id) {
412
-						            array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
412
+						            array_push($match_on, ($is_cat ? "CAT:" : "").$name);
413 413
                                 } else {
414 414
 
415 415
                                     if (!$is_cat) {
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
                             }
439 439
 
440 440
                             $reg_exp = $rule["reg_exp"];
441
-                            $filter_type = (int)$rule["filter_type"];
441
+                            $filter_type = (int) $rule["filter_type"];
442 442
                             $inverse = bool_to_sql_bool($rule["inverse"]);
443 443
                             $match_on = json_encode($match_on);
444 444
 
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 
473 473
                             $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
474 474
                             $reg_exp = $rule["reg_exp"];
475
-                            $filter_type = (int)$rule["filter_type"];
475
+                            $filter_type = (int) $rule["filter_type"];
476 476
                             $inverse = bool_to_sql_bool($rule["inverse"]);
477 477
 
478 478
                             $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_rules
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
 					foreach ($filter["actions"] as $action) {
487 487
 
488
-						$action_id = (int)$action["action_id"];
488
+						$action_id = (int) $action["action_id"];
489 489
 						$action_param = $action["action_param"];
490 490
 
491 491
 						$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 		}
586 586
 
587 587
 		if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
588
-			$tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
588
+			$tmp_file = tempnam(CACHE_DIR.'/upload', 'opml');
589 589
 
590 590
 			$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
591 591
 				$tmp_file);
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 		print "$msg<br/>";
624 624
 	}
625 625
 
626
-	public static function opml_publish_url(){
626
+	public static function opml_publish_url() {
627 627
 
628 628
 		$url_path = get_self_url_prefix();
629
-		$url_path .= "/opml.php?op=publish&key=" .
629
+		$url_path .= "/opml.php?op=publish&key=".
630 630
 			Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
631 631
 
632 632
 		return $url_path;
Please login to merge, or discard this patch.
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Opml extends Handler_Protected {
3 3
 
4
-	public function csrf_ignore($method) {
5
-		$csrf_ignored = array("export", "import");
4
+    public function csrf_ignore($method) {
5
+        $csrf_ignored = array("export", "import");
6 6
 
7
-		return array_search($method, $csrf_ignored) !== false;
8
-	}
7
+        return array_search($method, $csrf_ignored) !== false;
8
+    }
9 9
 
10
-	public function export() {
11
-		$output_name = "tt-rss_".date("Y-m-d").".opml";
12
-		$include_settings = $_REQUEST["include_settings"] == "1";
13
-		$owner_uid = $_SESSION["uid"];
10
+    public function export() {
11
+        $output_name = "tt-rss_".date("Y-m-d").".opml";
12
+        $include_settings = $_REQUEST["include_settings"] == "1";
13
+        $owner_uid = $_SESSION["uid"];
14 14
 
15
-		$rc = $this->opml_export($output_name, $owner_uid, false, $include_settings);
15
+        $rc = $this->opml_export($output_name, $owner_uid, false, $include_settings);
16 16
 
17
-		return $rc;
18
-	}
17
+        return $rc;
18
+    }
19 19
 
20
-	public function import() {
21
-		$owner_uid = $_SESSION["uid"];
20
+    public function import() {
21
+        $owner_uid = $_SESSION["uid"];
22 22
 
23
-		header('Content-Type: text/html; charset=utf-8');
23
+        header('Content-Type: text/html; charset=utf-8');
24 24
 
25
-		print "<html>
25
+        print "<html>
26 26
 			<head>
27 27
 				".stylesheet_tag("css/default.css")."
28 28
 				<title>".__("OPML Utility")."</title>
@@ -31,177 +31,177 @@  discard block
 block discarded – undo
31 31
 			<body class='claro ttrss_utility'>
32 32
 			<h1>".__('OPML Utility')."</h1><div class='content'>";
33 33
 
34
-		Feeds::add_feed_category("Imported feeds");
34
+        Feeds::add_feed_category("Imported feeds");
35 35
 
36
-		$this->opml_notice(__("Importing OPML..."));
36
+        $this->opml_notice(__("Importing OPML..."));
37 37
 
38
-		$this->opml_import($owner_uid);
38
+        $this->opml_import($owner_uid);
39 39
 
40
-		print "<br><form method=\"GET\" action=\"prefs.php\">
40
+        print "<br><form method=\"GET\" action=\"prefs.php\">
41 41
 			<input type=\"submit\" value=\"".__("Return to preferences")."\">
42 42
 			</form>";
43 43
 
44
-		print "</div></body></html>";
44
+        print "</div></body></html>";
45 45
 
46 46
 
47
-	}
47
+    }
48 48
 
49
-	// Export
49
+    // Export
50 50
 
51
-	private function opml_export_category($owner_uid, $cat_id, $hide_private_feeds = false, $include_settings = true) {
51
+    private function opml_export_category($owner_uid, $cat_id, $hide_private_feeds = false, $include_settings = true) {
52 52
 
53
-		$cat_id = (int) $cat_id;
53
+        $cat_id = (int) $cat_id;
54 54
 
55
-		if ($hide_private_feeds)
56
-			$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
-		else
58
-			$hide_qpart = "true";
55
+        if ($hide_private_feeds)
56
+            $hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
+        else
58
+            $hide_qpart = "true";
59 59
 
60
-		$out = "";
60
+        $out = "";
61 61
 
62
-		$ttrss_specific_qpart = "";
62
+        $ttrss_specific_qpart = "";
63 63
 
64
-		if ($cat_id) {
65
-			$sth = $this->pdo->prepare("SELECT title,order_id
64
+        if ($cat_id) {
65
+            $sth = $this->pdo->prepare("SELECT title,order_id
66 66
 				FROM ttrss_feed_categories WHERE id = ?
67 67
 					AND owner_uid = ?");
68
-			$sth->execute([$cat_id, $owner_uid]);
69
-			$row = $sth->fetch();
70
-			$cat_title = htmlspecialchars($row['title']);
68
+            $sth->execute([$cat_id, $owner_uid]);
69
+            $row = $sth->fetch();
70
+            $cat_title = htmlspecialchars($row['title']);
71 71
 
72
-			if ($include_settings) {
73
-				$order_id = (int)$row["order_id"];
74
-				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
75
-			}
76
-		} else {
77
-			$cat_title = "";
78
-		}
72
+            if ($include_settings) {
73
+                $order_id = (int)$row["order_id"];
74
+                $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\"";
75
+            }
76
+        } else {
77
+            $cat_title = "";
78
+        }
79 79
 
80
-		if ($cat_title) $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
80
+        if ($cat_title) $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
81 81
 
82
-		$sth = $this->pdo->prepare("SELECT id,title
82
+        $sth = $this->pdo->prepare("SELECT id,title
83 83
 			FROM ttrss_feed_categories WHERE
84 84
 				(parent_cat = :cat OR (:cat = 0 AND parent_cat IS NULL)) AND
85 85
 				owner_uid = :uid ORDER BY order_id, title");
86 86
 
87
-		$sth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
87
+        $sth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
88 88
 
89
-		while ($line = $sth->fetch()) {
90
-			$out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds, $include_settings);
91
-		}
89
+        while ($line = $sth->fetch()) {
90
+            $out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds, $include_settings);
91
+        }
92 92
 
93
-		$fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id
93
+        $fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id
94 94
 				FROM ttrss_feeds WHERE
95 95
 					(cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND owner_uid = :uid AND $hide_qpart
96 96
 				ORDER BY order_id, title");
97 97
 
98
-		$fsth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
98
+        $fsth->execute([':cat' => $cat_id, ':uid' => $owner_uid]);
99 99
 
100
-		while ($fline = $fsth->fetch()) {
101
-			$title = htmlspecialchars($fline["title"]);
102
-			$url = htmlspecialchars($fline["feed_url"]);
103
-			$site_url = htmlspecialchars($fline["site_url"]);
100
+        while ($fline = $fsth->fetch()) {
101
+            $title = htmlspecialchars($fline["title"]);
102
+            $url = htmlspecialchars($fline["feed_url"]);
103
+            $site_url = htmlspecialchars($fline["site_url"]);
104 104
 
105
-			if ($include_settings) {
106
-				$update_interval = (int)$fline["update_interval"];
107
-				$order_id = (int)$fline["order_id"];
105
+            if ($include_settings) {
106
+                $update_interval = (int)$fline["update_interval"];
107
+                $order_id = (int)$fline["order_id"];
108 108
 
109
-				$ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
110
-			} else {
111
-				$ttrss_specific_qpart = "";
112
-			}
109
+                $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\"";
110
+            } else {
111
+                $ttrss_specific_qpart = "";
112
+            }
113 113
 
114
-			if ($site_url) {
115
-				$html_url_qpart = "htmlUrl=\"$site_url\"";
116
-			} else {
117
-				$html_url_qpart = "";
118
-			}
114
+            if ($site_url) {
115
+                $html_url_qpart = "htmlUrl=\"$site_url\"";
116
+            } else {
117
+                $html_url_qpart = "";
118
+            }
119 119
 
120
-			$out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
121
-		}
120
+            $out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
121
+        }
122 122
 
123
-		if ($cat_title) $out .= "</outline>\n";
123
+        if ($cat_title) $out .= "</outline>\n";
124 124
 
125
-		return $out;
126
-	}
125
+        return $out;
126
+    }
127 127
 
128
-	public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
129
-		if (!$owner_uid) return;
128
+    public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
129
+        if (!$owner_uid) return;
130 130
 
131
-		if (!isset($_REQUEST["debug"])) {
132
-			header("Content-type: application/xml+opml");
133
-			header("Content-Disposition: attachment; filename=" . $name );
134
-		} else {
135
-			header("Content-type: text/xml");
136
-		}
131
+        if (!isset($_REQUEST["debug"])) {
132
+            header("Content-type: application/xml+opml");
133
+            header("Content-Disposition: attachment; filename=" . $name );
134
+        } else {
135
+            header("Content-type: text/xml");
136
+        }
137 137
 
138
-		$out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
138
+        $out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">";
139 139
 
140
-		$out .= "<opml version=\"1.0\">";
141
-		$out .= "<head>
140
+        $out .= "<opml version=\"1.0\">";
141
+        $out .= "<head>
142 142
 			<dateCreated>" . date("r", time()) . "</dateCreated>
143 143
 			<title>Tiny Tiny RSS Feed Export</title>
144 144
 		</head>";
145
-		$out .= "<body>";
145
+        $out .= "<body>";
146 146
 
147
-		$out .= $this->opml_export_category($owner_uid, 0, $hide_private_feeds, $include_settings);
147
+        $out .= $this->opml_export_category($owner_uid, 0, $hide_private_feeds, $include_settings);
148 148
 
149
-		# export tt-rss settings
149
+        # export tt-rss settings
150 150
 
151
-		if ($include_settings) {
152
-			$out .= "<outline text=\"tt-rss-prefs\" schema-version=\"".SCHEMA_VERSION."\">";
151
+        if ($include_settings) {
152
+            $out .= "<outline text=\"tt-rss-prefs\" schema-version=\"".SCHEMA_VERSION."\">";
153 153
 
154
-			$sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs WHERE
154
+            $sth = $this->pdo->prepare("SELECT pref_name, value FROM ttrss_user_prefs WHERE
155 155
 			   profile IS NULL AND owner_uid = ? ORDER BY pref_name");
156
-			$sth->execute([$owner_uid]);
156
+            $sth->execute([$owner_uid]);
157 157
 
158
-			while ($line = $sth->fetch()) {
159
-				$name = $line["pref_name"];
160
-				$value = htmlspecialchars($line["value"]);
158
+            while ($line = $sth->fetch()) {
159
+                $name = $line["pref_name"];
160
+                $value = htmlspecialchars($line["value"]);
161 161
 
162
-				$out .= "<outline pref-name=\"$name\" value=\"$value\"/>";
163
-			}
162
+                $out .= "<outline pref-name=\"$name\" value=\"$value\"/>";
163
+            }
164 164
 
165
-			$out .= "</outline>";
165
+            $out .= "</outline>";
166 166
 
167
-			$out .= "<outline text=\"tt-rss-labels\" schema-version=\"".SCHEMA_VERSION."\">";
167
+            $out .= "<outline text=\"tt-rss-labels\" schema-version=\"".SCHEMA_VERSION."\">";
168 168
 
169
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
169
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_labels2 WHERE
170 170
 				owner_uid = ?");
171
-			$sth->execute([$owner_uid]);
171
+            $sth->execute([$owner_uid]);
172 172
 
173
-			while ($line = $sth->fetch()) {
174
-				$name = htmlspecialchars($line['caption']);
175
-				$fg_color = htmlspecialchars($line['fg_color']);
176
-				$bg_color = htmlspecialchars($line['bg_color']);
173
+            while ($line = $sth->fetch()) {
174
+                $name = htmlspecialchars($line['caption']);
175
+                $fg_color = htmlspecialchars($line['fg_color']);
176
+                $bg_color = htmlspecialchars($line['bg_color']);
177 177
 
178
-				$out .= "<outline label-name=\"$name\" label-fg-color=\"$fg_color\" label-bg-color=\"$bg_color\"/>";
178
+                $out .= "<outline label-name=\"$name\" label-fg-color=\"$fg_color\" label-bg-color=\"$bg_color\"/>";
179 179
 
180
-			}
180
+            }
181 181
 
182
-			$out .= "</outline>";
182
+            $out .= "</outline>";
183 183
 
184
-			$out .= "<outline text=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
184
+            $out .= "<outline text=\"tt-rss-filters\" schema-version=\"".SCHEMA_VERSION."\">";
185 185
 
186
-			$sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
186
+            $sth = $this->pdo->prepare("SELECT * FROM ttrss_filters2
187 187
 				WHERE owner_uid = ? ORDER BY id");
188
-			$sth->execute([$owner_uid]);
188
+            $sth->execute([$owner_uid]);
189 189
 
190
-			while ($line = $sth->fetch()) {
191
-				$line["rules"] = array();
192
-				$line["actions"] = array();
190
+            while ($line = $sth->fetch()) {
191
+                $line["rules"] = array();
192
+                $line["actions"] = array();
193 193
 
194
-				$tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
194
+                $tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_rules
195 195
 					WHERE filter_id = ?");
196
-				$tmph->execute([$line['id']]);
196
+                $tmph->execute([$line['id']]);
197 197
 
198
-				while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
199
-					unset($tmp_line["id"]);
200
-					unset($tmp_line["filter_id"]);
198
+                while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
199
+                    unset($tmp_line["id"]);
200
+                    unset($tmp_line["filter_id"]);
201 201
 
202
-					$cat_filter = $tmp_line["cat_filter"];
202
+                    $cat_filter = $tmp_line["cat_filter"];
203 203
 
204
-					if (!$tmp_line["match_on"]) {
204
+                    if (!$tmp_line["match_on"]) {
205 205
                         if ($cat_filter && $tmp_line["cat_id"] || $tmp_line["feed_id"]) {
206 206
                             $tmp_line["feed"] = Feeds::getFeedTitle(
207 207
                                 $cat_filter ? $tmp_line["cat_id"] : $tmp_line["feed_id"],
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
                             $tmp_line["feed"] = "";
211 211
                         }
212 212
                     } else {
213
-					    $match = [];
214
-					    foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
213
+                        $match = [];
214
+                        foreach (json_decode($tmp_line["match_on"], true) as $feed_id) {
215 215
 
216 216
                             if (strpos($feed_id, "CAT:") === 0) {
217 217
                                 $feed_id = (int)substr($feed_id, 4);
@@ -230,56 +230,56 @@  discard block
 block discarded – undo
230 230
                         }
231 231
 
232 232
                         $tmp_line["match"] = $match;
233
-					    unset($tmp_line["match_on"]);
233
+                        unset($tmp_line["match_on"]);
234 234
                     }
235 235
 
236
-					unset($tmp_line["feed_id"]);
237
-					unset($tmp_line["cat_id"]);
236
+                    unset($tmp_line["feed_id"]);
237
+                    unset($tmp_line["cat_id"]);
238 238
 
239
-					array_push($line["rules"], $tmp_line);
240
-				}
239
+                    array_push($line["rules"], $tmp_line);
240
+                }
241 241
 
242
-				$tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
242
+                $tmph = $this->pdo->prepare("SELECT * FROM ttrss_filters2_actions
243 243
 					WHERE filter_id = ?");
244
-				$tmph->execute([$line['id']]);
244
+                $tmph->execute([$line['id']]);
245 245
 
246
-				while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
247
-					unset($tmp_line["id"]);
248
-					unset($tmp_line["filter_id"]);
246
+                while ($tmp_line = $tmph->fetch(PDO::FETCH_ASSOC)) {
247
+                    unset($tmp_line["id"]);
248
+                    unset($tmp_line["filter_id"]);
249 249
 
250
-					array_push($line["actions"], $tmp_line);
251
-				}
250
+                    array_push($line["actions"], $tmp_line);
251
+                }
252 252
 
253
-				unset($line["id"]);
254
-				unset($line["owner_uid"]);
255
-				$filter = json_encode($line);
253
+                unset($line["id"]);
254
+                unset($line["owner_uid"]);
255
+                $filter = json_encode($line);
256 256
 
257
-				$out .= "<outline filter-type=\"2\"><![CDATA[$filter]]></outline>";
257
+                $out .= "<outline filter-type=\"2\"><![CDATA[$filter]]></outline>";
258 258
 
259
-			}
259
+            }
260 260
 
261 261
 
262
-			$out .= "</outline>";
263
-		}
262
+            $out .= "</outline>";
263
+        }
264 264
 
265
-		$out .= "</body></opml>";
265
+        $out .= "</body></opml>";
266 266
 
267
-		// Format output.
268
-		$doc = new DOMDocument();
269
-		$doc->formatOutput = true;
270
-		$doc->preserveWhiteSpace = false;
271
-		$doc->loadXML($out);
267
+        // Format output.
268
+        $doc = new DOMDocument();
269
+        $doc->formatOutput = true;
270
+        $doc->preserveWhiteSpace = false;
271
+        $doc->loadXML($out);
272 272
 
273
-		$xpath = new DOMXpath($doc);
274
-		$outlines = $xpath->query("//outline[@title]");
273
+        $xpath = new DOMXpath($doc);
274
+        $outlines = $xpath->query("//outline[@title]");
275 275
 
276
-		// cleanup empty categories
277
-		foreach ($outlines as $node) {
278
-			if ($node->getElementsByTagName('outline')->length == 0)
279
-				$node->parentNode->removeChild($node);
280
-		}
276
+        // cleanup empty categories
277
+        foreach ($outlines as $node) {
278
+            if ($node->getElementsByTagName('outline')->length == 0)
279
+                $node->parentNode->removeChild($node);
280
+        }
281 281
 
282
-		$res = $doc->saveXML();
282
+        $res = $doc->saveXML();
283 283
 
284 284
 /*		// saveXML uses a two-space indent.  Change to tabs.
285 285
 		$res = preg_replace_callback('/^(?:  )+/mu',
@@ -288,128 +288,128 @@  discard block
 block discarded – undo
288 288
 				'return str_repeat("\t", intval(strlen($matches[0])/2));'),
289 289
 			$res); */
290 290
 
291
-		print $res;
292
-	}
291
+        print $res;
292
+    }
293 293
 
294
-	// Import
294
+    // Import
295 295
 
296
-	private function opml_import_feed($node, $cat_id, $owner_uid) {
297
-		$attrs = $node->attributes;
296
+    private function opml_import_feed($node, $cat_id, $owner_uid) {
297
+        $attrs = $node->attributes;
298 298
 
299
-		$feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
300
-		if (!$feed_title) $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
299
+        $feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
300
+        if (!$feed_title) $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
301 301
 
302
-		$feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
303
-		if (!$feed_url) $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
302
+        $feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
303
+        if (!$feed_url) $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
304 304
 
305
-		$site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
305
+        $site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
306 306
 
307
-		if ($feed_url) {
308
-			$sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
307
+        if ($feed_url) {
308
+            $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE
309 309
 				feed_url = ? AND owner_uid = ?");
310
-			$sth->execute([$feed_url, $owner_uid]);
310
+            $sth->execute([$feed_url, $owner_uid]);
311 311
 
312
-			if (!$feed_title) $feed_title = '[Unknown]';
312
+            if (!$feed_title) $feed_title = '[Unknown]';
313 313
 
314
-			if (!$sth->fetch()) {
315
-				#$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
316
-				$this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
314
+            if (!$sth->fetch()) {
315
+                #$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
316
+                $this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
317 317
 
318
-				if (!$cat_id) $cat_id = null;
318
+                if (!$cat_id) $cat_id = null;
319 319
 
320
-				$update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
321
-				if (!$update_interval) $update_interval = 0;
320
+                $update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
321
+                if (!$update_interval) $update_interval = 0;
322 322
 
323
-				$order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
324
-				if (!$order_id) $order_id = 0;
323
+                $order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
324
+                if (!$order_id) $order_id = 0;
325 325
 
326
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
326
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
327 327
 					(title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES
328 328
 					(?, ?, ?, ?, ?, ?, ?)");
329 329
 
330
-				$sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval]);
330
+                $sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval]);
331 331
 
332
-			} else {
333
-				$this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
334
-			}
335
-		}
336
-	}
332
+            } else {
333
+                $this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
334
+            }
335
+        }
336
+    }
337 337
 
338
-	private function opml_import_label($node, $owner_uid) {
339
-		$attrs = $node->attributes;
340
-		$label_name = $attrs->getNamedItem('label-name')->nodeValue;
338
+    private function opml_import_label($node, $owner_uid) {
339
+        $attrs = $node->attributes;
340
+        $label_name = $attrs->getNamedItem('label-name')->nodeValue;
341 341
 
342
-		if ($label_name) {
343
-			$fg_color = $attrs->getNamedItem('label-fg-color')->nodeValue;
344
-			$bg_color = $attrs->getNamedItem('label-bg-color')->nodeValue;
342
+        if ($label_name) {
343
+            $fg_color = $attrs->getNamedItem('label-fg-color')->nodeValue;
344
+            $bg_color = $attrs->getNamedItem('label-bg-color')->nodeValue;
345 345
 
346
-			if (!Labels::find_id($label_name, $_SESSION['uid'])) {
347
-				$this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
348
-				Labels::create($label_name, $fg_color, $bg_color, $owner_uid);
349
-			} else {
350
-				$this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
351
-			}
352
-		}
353
-	}
346
+            if (!Labels::find_id($label_name, $_SESSION['uid'])) {
347
+                $this->opml_notice(T_sprintf("Adding label %s", htmlspecialchars($label_name)));
348
+                Labels::create($label_name, $fg_color, $bg_color, $owner_uid);
349
+            } else {
350
+                $this->opml_notice(T_sprintf("Duplicate label: %s", htmlspecialchars($label_name)));
351
+            }
352
+        }
353
+    }
354 354
 
355
-	private function opml_import_preference($node) {
356
-		$attrs = $node->attributes;
357
-		$pref_name = $attrs->getNamedItem('pref-name')->nodeValue;
355
+    private function opml_import_preference($node) {
356
+        $attrs = $node->attributes;
357
+        $pref_name = $attrs->getNamedItem('pref-name')->nodeValue;
358 358
 
359
-		if ($pref_name) {
360
-			$pref_value = $attrs->getNamedItem('value')->nodeValue;
359
+        if ($pref_name) {
360
+            $pref_value = $attrs->getNamedItem('value')->nodeValue;
361 361
 
362
-			$this->opml_notice(T_sprintf("Setting preference key %s to %s",
363
-				$pref_name, $pref_value));
362
+            $this->opml_notice(T_sprintf("Setting preference key %s to %s",
363
+                $pref_name, $pref_value));
364 364
 
365
-			set_pref($pref_name, $pref_value);
366
-		}
367
-	}
365
+            set_pref($pref_name, $pref_value);
366
+        }
367
+    }
368 368
 
369
-	private function opml_import_filter($node) {
370
-		$attrs = $node->attributes;
369
+    private function opml_import_filter($node) {
370
+        $attrs = $node->attributes;
371 371
 
372
-		$filter_type = $attrs->getNamedItem('filter-type')->nodeValue;
372
+        $filter_type = $attrs->getNamedItem('filter-type')->nodeValue;
373 373
 
374
-		if ($filter_type == '2') {
375
-			$filter = json_decode($node->nodeValue, true);
374
+        if ($filter_type == '2') {
375
+            $filter = json_decode($node->nodeValue, true);
376 376
 
377
-			if ($filter) {
378
-				$match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
379
-				$enabled = bool_to_sql_bool($filter["enabled"]);
380
-				$inverse = bool_to_sql_bool($filter["inverse"]);
381
-				$title = $filter["title"];
377
+            if ($filter) {
378
+                $match_any_rule = bool_to_sql_bool($filter["match_any_rule"]);
379
+                $enabled = bool_to_sql_bool($filter["enabled"]);
380
+                $inverse = bool_to_sql_bool($filter["inverse"]);
381
+                $title = $filter["title"];
382 382
 
383
-				//print "F: $title, $inverse, $enabled, $match_any_rule";
383
+                //print "F: $title, $inverse, $enabled, $match_any_rule";
384 384
 
385
-				$sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 (match_any_rule,enabled,inverse,title,owner_uid)
385
+                $sth = $this->pdo->prepare("INSERT INTO ttrss_filters2 (match_any_rule,enabled,inverse,title,owner_uid)
386 386
 					VALUES (?, ?, ?, ?, ?)");
387 387
 
388
-				$sth->execute([$match_any_rule, $enabled, $inverse, $title, $_SESSION['uid']]);
388
+                $sth->execute([$match_any_rule, $enabled, $inverse, $title, $_SESSION['uid']]);
389 389
 
390
-				$sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
390
+                $sth = $this->pdo->prepare("SELECT MAX(id) AS id FROM ttrss_filters2 WHERE
391 391
 					owner_uid = ?");
392
-				$sth->execute([$_SESSION['uid']]);
392
+                $sth->execute([$_SESSION['uid']]);
393 393
 
394
-				$row = $sth->fetch();
395
-				$filter_id = $row['id'];
394
+                $row = $sth->fetch();
395
+                $filter_id = $row['id'];
396 396
 
397
-				if ($filter_id) {
398
-					$this->opml_notice(T_sprintf("Adding filter %s...", $title));
397
+                if ($filter_id) {
398
+                    $this->opml_notice(T_sprintf("Adding filter %s...", $title));
399 399
 
400
-					foreach ($filter["rules"] as $rule) {
401
-						$feed_id = null;
402
-						$cat_id = null;
400
+                    foreach ($filter["rules"] as $rule) {
401
+                        $feed_id = null;
402
+                        $cat_id = null;
403 403
 
404
-						if ($rule["match"]) {
404
+                        if ($rule["match"]) {
405 405
 
406 406
                             $match_on = [];
407 407
 
408
-						    foreach ($rule["match"] as $match) {
409
-						        list ($name, $is_cat, $is_id) = $match;
408
+                            foreach ($rule["match"] as $match) {
409
+                                list ($name, $is_cat, $is_id) = $match;
410 410
 
411
-						        if ($is_id) {
412
-						            array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
411
+                                if ($is_id) {
412
+                                    array_push($match_on, ($is_cat ? "CAT:" : "") . $name);
413 413
                                 } else {
414 414
 
415 415
                                     if (!$is_cat) {
@@ -421,18 +421,18 @@  discard block
 block discarded – undo
421 421
                                         if ($row = $tsth->fetch()) {
422 422
                                             $match_id = $row['id'];
423 423
 
424
-											array_push($match_on, $match_id);
424
+                                            array_push($match_on, $match_id);
425 425
                                         }
426 426
                                     } else {
427 427
                                         $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
428 428
                                     		WHERE title = ? AND owner_uid = ?");
429
-										$tsth->execute([$name, $_SESSION['uid']]);
429
+                                        $tsth->execute([$name, $_SESSION['uid']]);
430 430
 
431
-										if ($row = $tsth->fetch()) {
432
-											$match_id = $row['id'];
431
+                                        if ($row = $tsth->fetch()) {
432
+                                            $match_id = $row['id'];
433 433
 
434
-											array_push($match_on, "CAT:$match_id");
435
-										}
434
+                                            array_push($match_on, "CAT:$match_id");
435
+                                        }
436 436
                                     }
437 437
                                 }
438 438
                             }
@@ -460,14 +460,14 @@  discard block
 block discarded – undo
460 460
                                     $feed_id = $row['id'];
461 461
                                 }
462 462
                             } else {
463
-								$tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
463
+                                $tsth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
464 464
                                     WHERE title = ? AND owner_uid = ?");
465 465
 
466
-								$tsth->execute([$rule['feed'], $_SESSION['uid']]);
466
+                                $tsth->execute([$rule['feed'], $_SESSION['uid']]);
467 467
 
468
-								if ($row = $tsth->fetch()) {
469
-									$feed_id = $row['id'];
470
-								}
468
+                                if ($row = $tsth->fetch()) {
469
+                                    $feed_id = $row['id'];
470
+                                }
471 471
                             }
472 472
 
473 473
                             $cat_filter = bool_to_sql_bool($rule["cat_filter"]);
@@ -481,174 +481,174 @@  discard block
 block discarded – undo
481 481
                                 (?, ?, ?, ?, ?, ?, ?)");
482 482
                             $usth->execute([$feed_id, $cat_id, $filter_id, $filter_type, $reg_exp, $cat_filter, $inverse]);
483 483
                         }
484
-					}
484
+                    }
485 485
 
486
-					foreach ($filter["actions"] as $action) {
486
+                    foreach ($filter["actions"] as $action) {
487 487
 
488
-						$action_id = (int)$action["action_id"];
489
-						$action_param = $action["action_param"];
488
+                        $action_id = (int)$action["action_id"];
489
+                        $action_param = $action["action_param"];
490 490
 
491
-						$usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
491
+                        $usth = $this->pdo->prepare("INSERT INTO ttrss_filters2_actions
492 492
 							(filter_id,action_id,action_param)
493 493
 							VALUES
494 494
 							(?, ?, ?)");
495
-						$usth->execute([$filter_id, $action_id, $action_param]);
496
-					}
497
-				}
498
-			}
499
-		}
500
-	}
501
-
502
-	private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
503
-		$default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
504
-
505
-		if ($root_node) {
506
-			$cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
507
-
508
-			if (!$cat_title)
509
-				$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
510
-
511
-			if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
512
-				$cat_id = $this->get_feed_category($cat_title, $parent_id);
513
-
514
-				if ($cat_id === false) {
515
-					$order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
516
-					if (!$order_id) $order_id = 0;
517
-
518
-					Feeds::add_feed_category($cat_title, $parent_id, $order_id);
519
-					$cat_id = $this->get_feed_category($cat_title, $parent_id);
520
-				}
521
-
522
-			} else {
523
-				$cat_id = 0;
524
-			}
525
-
526
-			$outlines = $root_node->childNodes;
527
-
528
-		} else {
529
-			$xpath = new DOMXpath($doc);
530
-			$outlines = $xpath->query("//opml/body/outline");
531
-
532
-			$cat_id = 0;
533
-		}
534
-
535
-		#$this->opml_notice("[CAT] $cat_title id: $cat_id P_id: $parent_id");
536
-		$this->opml_notice(T_sprintf("Processing category: %s", $cat_title ? $cat_title : __("Uncategorized")));
537
-
538
-		foreach ($outlines as $node) {
539
-			if ($node->hasAttributes() && strtolower($node->tagName) == "outline") {
540
-				$attrs = $node->attributes;
541
-				$node_cat_title = $attrs->getNamedItem('text')->nodeValue;
542
-
543
-				if (!$node_cat_title)
544
-					$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
545
-
546
-				$node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
547
-
548
-				if ($node_cat_title && !$node_feed_url) {
549
-					$this->opml_import_category($doc, $node, $owner_uid, $cat_id);
550
-				} else {
551
-
552
-					if (!$cat_id) {
553
-						$dst_cat_id = $default_cat_id;
554
-					} else {
555
-						$dst_cat_id = $cat_id;
556
-					}
557
-
558
-					switch ($cat_title) {
559
-					case "tt-rss-prefs":
560
-						$this->opml_import_preference($node);
561
-						break;
562
-					case "tt-rss-labels":
563
-						$this->opml_import_label($node, $owner_uid);
564
-						break;
565
-					case "tt-rss-filters":
566
-						$this->opml_import_filter($node);
567
-						break;
568
-					default:
569
-						$this->opml_import_feed($node, $dst_cat_id, $owner_uid);
570
-					}
571
-				}
572
-			}
573
-		}
574
-	}
575
-
576
-	public function opml_import($owner_uid) {
577
-		if (!$owner_uid) return;
578
-
579
-		$doc = false;
580
-
581
-		if ($_FILES['opml_file']['error'] != 0) {
582
-			print_error(T_sprintf("Upload failed with error code %d",
583
-				$_FILES['opml_file']['error']));
584
-			return;
585
-		}
586
-
587
-		if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
588
-			$tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
589
-
590
-			$result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
591
-				$tmp_file);
592
-
593
-			if (!$result) {
594
-				print_error(__("Unable to move uploaded file."));
595
-				return;
596
-			}
597
-		} else {
598
-			print_error(__('Error: please upload OPML file.'));
599
-			return;
600
-		}
601
-
602
-		if (is_file($tmp_file)) {
603
-			$doc = new DOMDocument();
604
-			libxml_disable_entity_loader(false);
605
-			$doc->load($tmp_file);
606
-			libxml_disable_entity_loader(true);
607
-			unlink($tmp_file);
608
-		} else if (!$doc) {
609
-			print_error(__('Error: unable to find moved OPML file.'));
610
-			return;
611
-		}
612
-
613
-		if ($doc) {
614
-			$this->pdo->beginTransaction();
615
-			$this->opml_import_category($doc, false, $owner_uid, false);
616
-			$this->pdo->commit();
617
-		} else {
618
-			print_error(__('Error while parsing document.'));
619
-		}
620
-	}
621
-
622
-	private function opml_notice($msg) {
623
-		print "$msg<br/>";
624
-	}
625
-
626
-	public static function opml_publish_url(){
627
-
628
-		$url_path = get_self_url_prefix();
629
-		$url_path .= "/opml.php?op=publish&key=" .
630
-			Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
631
-
632
-		return $url_path;
633
-	}
634
-
635
-	public function get_feed_category($feed_cat, $parent_cat_id = false) {
636
-
637
-		$parent_cat_id = (int) $parent_cat_id;
638
-
639
-		$sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
495
+                        $usth->execute([$filter_id, $action_id, $action_param]);
496
+                    }
497
+                }
498
+            }
499
+        }
500
+    }
501
+
502
+    private function opml_import_category($doc, $root_node, $owner_uid, $parent_id) {
503
+        $default_cat_id = (int) $this->get_feed_category('Imported feeds', false);
504
+
505
+        if ($root_node) {
506
+            $cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
507
+
508
+            if (!$cat_title)
509
+                $cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
510
+
511
+            if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
512
+                $cat_id = $this->get_feed_category($cat_title, $parent_id);
513
+
514
+                if ($cat_id === false) {
515
+                    $order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
516
+                    if (!$order_id) $order_id = 0;
517
+
518
+                    Feeds::add_feed_category($cat_title, $parent_id, $order_id);
519
+                    $cat_id = $this->get_feed_category($cat_title, $parent_id);
520
+                }
521
+
522
+            } else {
523
+                $cat_id = 0;
524
+            }
525
+
526
+            $outlines = $root_node->childNodes;
527
+
528
+        } else {
529
+            $xpath = new DOMXpath($doc);
530
+            $outlines = $xpath->query("//opml/body/outline");
531
+
532
+            $cat_id = 0;
533
+        }
534
+
535
+        #$this->opml_notice("[CAT] $cat_title id: $cat_id P_id: $parent_id");
536
+        $this->opml_notice(T_sprintf("Processing category: %s", $cat_title ? $cat_title : __("Uncategorized")));
537
+
538
+        foreach ($outlines as $node) {
539
+            if ($node->hasAttributes() && strtolower($node->tagName) == "outline") {
540
+                $attrs = $node->attributes;
541
+                $node_cat_title = $attrs->getNamedItem('text')->nodeValue;
542
+
543
+                if (!$node_cat_title)
544
+                    $node_cat_title = $attrs->getNamedItem('title')->nodeValue;
545
+
546
+                $node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
547
+
548
+                if ($node_cat_title && !$node_feed_url) {
549
+                    $this->opml_import_category($doc, $node, $owner_uid, $cat_id);
550
+                } else {
551
+
552
+                    if (!$cat_id) {
553
+                        $dst_cat_id = $default_cat_id;
554
+                    } else {
555
+                        $dst_cat_id = $cat_id;
556
+                    }
557
+
558
+                    switch ($cat_title) {
559
+                    case "tt-rss-prefs":
560
+                        $this->opml_import_preference($node);
561
+                        break;
562
+                    case "tt-rss-labels":
563
+                        $this->opml_import_label($node, $owner_uid);
564
+                        break;
565
+                    case "tt-rss-filters":
566
+                        $this->opml_import_filter($node);
567
+                        break;
568
+                    default:
569
+                        $this->opml_import_feed($node, $dst_cat_id, $owner_uid);
570
+                    }
571
+                }
572
+            }
573
+        }
574
+    }
575
+
576
+    public function opml_import($owner_uid) {
577
+        if (!$owner_uid) return;
578
+
579
+        $doc = false;
580
+
581
+        if ($_FILES['opml_file']['error'] != 0) {
582
+            print_error(T_sprintf("Upload failed with error code %d",
583
+                $_FILES['opml_file']['error']));
584
+            return;
585
+        }
586
+
587
+        if (is_uploaded_file($_FILES['opml_file']['tmp_name'])) {
588
+            $tmp_file = tempnam(CACHE_DIR . '/upload', 'opml');
589
+
590
+            $result = move_uploaded_file($_FILES['opml_file']['tmp_name'],
591
+                $tmp_file);
592
+
593
+            if (!$result) {
594
+                print_error(__("Unable to move uploaded file."));
595
+                return;
596
+            }
597
+        } else {
598
+            print_error(__('Error: please upload OPML file.'));
599
+            return;
600
+        }
601
+
602
+        if (is_file($tmp_file)) {
603
+            $doc = new DOMDocument();
604
+            libxml_disable_entity_loader(false);
605
+            $doc->load($tmp_file);
606
+            libxml_disable_entity_loader(true);
607
+            unlink($tmp_file);
608
+        } else if (!$doc) {
609
+            print_error(__('Error: unable to find moved OPML file.'));
610
+            return;
611
+        }
612
+
613
+        if ($doc) {
614
+            $this->pdo->beginTransaction();
615
+            $this->opml_import_category($doc, false, $owner_uid, false);
616
+            $this->pdo->commit();
617
+        } else {
618
+            print_error(__('Error while parsing document.'));
619
+        }
620
+    }
621
+
622
+    private function opml_notice($msg) {
623
+        print "$msg<br/>";
624
+    }
625
+
626
+    public static function opml_publish_url(){
627
+
628
+        $url_path = get_self_url_prefix();
629
+        $url_path .= "/opml.php?op=publish&key=" .
630
+            Feeds::get_feed_access_key('OPML:Publish', false, $_SESSION["uid"]);
631
+
632
+        return $url_path;
633
+    }
634
+
635
+    public function get_feed_category($feed_cat, $parent_cat_id = false) {
636
+
637
+        $parent_cat_id = (int) $parent_cat_id;
638
+
639
+        $sth = $this->pdo->prepare("SELECT id FROM ttrss_feed_categories
640 640
 			WHERE title = :title
641 641
 			AND (parent_cat = :parent OR (:parent = 0 AND parent_cat IS NULL))
642 642
 			AND owner_uid = :uid");
643 643
 
644
-		$sth->execute([':title' => $feed_cat, ':parent' => $parent_cat_id, ':uid' => $_SESSION['uid']]);
644
+        $sth->execute([':title' => $feed_cat, ':parent' => $parent_cat_id, ':uid' => $_SESSION['uid']]);
645 645
 
646
-		if ($row = $sth->fetch()) {
647
-			return $row['id'];
648
-		} else {
649
-			return false;
650
-		}
651
-	}
646
+        if ($row = $sth->fetch()) {
647
+            return $row['id'];
648
+        } else {
649
+            return false;
650
+        }
651
+    }
652 652
 
653 653
 
654 654
 }
Please login to merge, or discard this patch.
Braces   +47 added lines, -21 removed lines patch added patch discarded remove patch
@@ -52,10 +52,11 @@  discard block
 block discarded – undo
52 52
 
53 53
 		$cat_id = (int) $cat_id;
54 54
 
55
-		if ($hide_private_feeds)
56
-			$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
-		else
58
-			$hide_qpart = "true";
55
+		if ($hide_private_feeds) {
56
+					$hide_qpart = "(private IS false AND auth_login = '' AND auth_pass = '')";
57
+		} else {
58
+					$hide_qpart = "true";
59
+		}
59 60
 
60 61
 		$out = "";
61 62
 
@@ -77,7 +78,9 @@  discard block
 block discarded – undo
77 78
 			$cat_title = "";
78 79
 		}
79 80
 
80
-		if ($cat_title) $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
81
+		if ($cat_title) {
82
+		    $out .= "<outline text=\"$cat_title\" $ttrss_specific_qpart>\n";
83
+		}
81 84
 
82 85
 		$sth = $this->pdo->prepare("SELECT id,title
83 86
 			FROM ttrss_feed_categories WHERE
@@ -120,13 +123,17 @@  discard block
 block discarded – undo
120 123
 			$out .= "<outline type=\"rss\" text=\"$title\" xmlUrl=\"$url\" $ttrss_specific_qpart $html_url_qpart/>\n";
121 124
 		}
122 125
 
123
-		if ($cat_title) $out .= "</outline>\n";
126
+		if ($cat_title) {
127
+		    $out .= "</outline>\n";
128
+		}
124 129
 
125 130
 		return $out;
126 131
 	}
127 132
 
128 133
 	public function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) {
129
-		if (!$owner_uid) return;
134
+		if (!$owner_uid) {
135
+		    return;
136
+		}
130 137
 
131 138
 		if (!isset($_REQUEST["debug"])) {
132 139
 			header("Content-type: application/xml+opml");
@@ -275,8 +282,9 @@  discard block
 block discarded – undo
275 282
 
276 283
 		// cleanup empty categories
277 284
 		foreach ($outlines as $node) {
278
-			if ($node->getElementsByTagName('outline')->length == 0)
279
-				$node->parentNode->removeChild($node);
285
+			if ($node->getElementsByTagName('outline')->length == 0) {
286
+							$node->parentNode->removeChild($node);
287
+			}
280 288
 		}
281 289
 
282 290
 		$res = $doc->saveXML();
@@ -297,10 +305,14 @@  discard block
 block discarded – undo
297 305
 		$attrs = $node->attributes;
298 306
 
299 307
 		$feed_title = mb_substr($attrs->getNamedItem('text')->nodeValue, 0, 250);
300
-		if (!$feed_title) $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
308
+		if (!$feed_title) {
309
+		    $feed_title = mb_substr($attrs->getNamedItem('title')->nodeValue, 0, 250);
310
+		}
301 311
 
302 312
 		$feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
303
-		if (!$feed_url) $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
313
+		if (!$feed_url) {
314
+		    $feed_url = $attrs->getNamedItem('xmlURL')->nodeValue;
315
+		}
304 316
 
305 317
 		$site_url = mb_substr($attrs->getNamedItem('htmlUrl')->nodeValue, 0, 250);
306 318
 
@@ -309,19 +321,27 @@  discard block
 block discarded – undo
309 321
 				feed_url = ? AND owner_uid = ?");
310 322
 			$sth->execute([$feed_url, $owner_uid]);
311 323
 
312
-			if (!$feed_title) $feed_title = '[Unknown]';
324
+			if (!$feed_title) {
325
+			    $feed_title = '[Unknown]';
326
+			}
313 327
 
314 328
 			if (!$sth->fetch()) {
315 329
 				#$this->opml_notice("[FEED] [$feed_title/$feed_url] dst_CAT=$cat_id");
316 330
 				$this->opml_notice(T_sprintf("Adding feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title));
317 331
 
318
-				if (!$cat_id) $cat_id = null;
332
+				if (!$cat_id) {
333
+				    $cat_id = null;
334
+				}
319 335
 
320 336
 				$update_interval = (int) $attrs->getNamedItem('ttrssUpdateInterval')->nodeValue;
321
-				if (!$update_interval) $update_interval = 0;
337
+				if (!$update_interval) {
338
+				    $update_interval = 0;
339
+				}
322 340
 
323 341
 				$order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue;
324
-				if (!$order_id) $order_id = 0;
342
+				if (!$order_id) {
343
+				    $order_id = 0;
344
+				}
325 345
 
326 346
 				$sth = $this->pdo->prepare("INSERT INTO ttrss_feeds
327 347
 					(title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES
@@ -505,15 +525,18 @@  discard block
 block discarded – undo
505 525
 		if ($root_node) {
506 526
 			$cat_title = mb_substr($root_node->attributes->getNamedItem('text')->nodeValue, 0, 250);
507 527
 
508
-			if (!$cat_title)
509
-				$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
528
+			if (!$cat_title) {
529
+							$cat_title = mb_substr($root_node->attributes->getNamedItem('title')->nodeValue, 0, 250);
530
+			}
510 531
 
511 532
 			if (!in_array($cat_title, array("tt-rss-filters", "tt-rss-labels", "tt-rss-prefs"))) {
512 533
 				$cat_id = $this->get_feed_category($cat_title, $parent_id);
513 534
 
514 535
 				if ($cat_id === false) {
515 536
 					$order_id = (int) $root_node->attributes->getNamedItem('ttrssSortOrder')->nodeValue;
516
-					if (!$order_id) $order_id = 0;
537
+					if (!$order_id) {
538
+					    $order_id = 0;
539
+					}
517 540
 
518 541
 					Feeds::add_feed_category($cat_title, $parent_id, $order_id);
519 542
 					$cat_id = $this->get_feed_category($cat_title, $parent_id);
@@ -540,8 +563,9 @@  discard block
 block discarded – undo
540 563
 				$attrs = $node->attributes;
541 564
 				$node_cat_title = $attrs->getNamedItem('text')->nodeValue;
542 565
 
543
-				if (!$node_cat_title)
544
-					$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
566
+				if (!$node_cat_title) {
567
+									$node_cat_title = $attrs->getNamedItem('title')->nodeValue;
568
+				}
545 569
 
546 570
 				$node_feed_url = $attrs->getNamedItem('xmlUrl')->nodeValue;
547 571
 
@@ -574,7 +598,9 @@  discard block
 block discarded – undo
574 598
 	}
575 599
 
576 600
 	public function opml_import($owner_uid) {
577
-		if (!$owner_uid) return;
601
+		if (!$owner_uid) {
602
+		    return;
603
+		}
578 604
 
579 605
 		$doc = false;
580 606
 
Please login to merge, or discard this patch.
include/colors.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 ### HSL >> RGB
184 184
 function _color_hsl2rgb($hsl) {
185 185
     $h = $hsl[0]; $s = $hsl[1]; $l = $hsl[2];
186
-    $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l*$s;
186
+    $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s;
187 187
     $m1 = $l * 2 - $m2;
188 188
     return array(_color_hue2rgb($m1, $m2, $h + 0.33333),
189 189
         _color_hue2rgb($m1, $m2, $h),
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         $hex = substr($hex, 1);
209 209
 
210 210
     if (strlen($hex) == 4) {
211
-        $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
211
+        $hex = $hex[1].$hex[1].$hex[2].$hex[2].$hex[3].$hex[3];
212 212
     }
213 213
     $c = hexdec($hex);
214 214
     for ($i = 16; $i >= 0; $i -= 8) {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 function _color_pack($rgb, $normalize = false) {
221 221
     foreach ($rgb as $k => $v) {
222 222
         $out |= (($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
223
-    }return '#'. str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
223
+    }return '#'.str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
224 224
 }
225 225
 
226 226
 function rgb2hsl($arr) {
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
     } else {
245 245
         $s = $del_Max / $var_Max;
246 246
 
247
-        $del_R = ((($var_Max - $var_R ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
248
-        $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
249
-        $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
247
+        $del_R = ((($var_Max - $var_R) / 6) + ($del_Max / 2)) / $del_Max;
248
+        $del_G = ((($var_Max - $var_G) / 6) + ($del_Max / 2)) / $del_Max;
249
+        $del_B = ((($var_Max - $var_B) / 6) + ($del_Max / 2)) / $del_Max;
250 250
 
251
-        if      ($var_R == $var_Max) $h = $del_B - $del_G;
252
-        else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B;
253
-        else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R;
251
+        if ($var_R == $var_Max) $h = $del_B - $del_G;
252
+        else if ($var_G == $var_Max) $h = (1 / 3) + $del_R - $del_B;
253
+        else if ($var_B == $var_Max) $h = (2 / 3) + $del_G - $del_R;
254 254
 
255 255
         if ($h < 0) $h++;
256 256
         if ($h > 1) $h--;
@@ -264,21 +264,21 @@  discard block
 block discarded – undo
264 264
     $s = $arr[1];
265 265
     $v = $arr[2];
266 266
 
267
-    if($s == 0) {
267
+    if ($s == 0) {
268 268
         $r = $g = $B = $v * 255;
269 269
     } else {
270 270
         $var_H = $h * 6;
271
-        $var_i = floor($var_H );
272
-        $var_1 = $v * (1 - $s );
273
-        $var_2 = $v * (1 - $s * ($var_H - $var_i ) );
274
-        $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i ) ) );
275
-
276
-        if       ($var_i == 0) { $var_R = $v     ; $var_G = $var_3  ; $var_B = $var_1 ; }
277
-        else if  ($var_i == 1) { $var_R = $var_2 ; $var_G = $v      ; $var_B = $var_1 ; }
278
-        else if  ($var_i == 2) { $var_R = $var_1 ; $var_G = $v      ; $var_B = $var_3 ; }
279
-        else if  ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2  ; $var_B = $v     ; }
280
-        else if  ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1  ; $var_B = $v     ; }
281
-        else                   { $var_R = $v     ; $var_G = $var_1  ; $var_B = $var_2 ; }
271
+        $var_i = floor($var_H);
272
+        $var_1 = $v * (1 - $s);
273
+        $var_2 = $v * (1 - $s * ($var_H - $var_i));
274
+        $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i)));
275
+
276
+        if ($var_i == 0) { $var_R = $v; $var_G = $var_3; $var_B = $var_1; }
277
+        else if ($var_i == 1) { $var_R = $var_2; $var_G = $v; $var_B = $var_1; }
278
+        else if ($var_i == 2) { $var_R = $var_1; $var_G = $v; $var_B = $var_3; }
279
+        else if ($var_i == 3) { $var_R = $var_1; $var_G = $var_2; $var_B = $v; }
280
+        else if ($var_i == 4) { $var_R = $var_3; $var_G = $var_1; $var_B = $v; }
281
+        else { $var_R = $v; $var_G = $var_1; $var_B = $var_2; }
282 282
 
283 283
         $r = $var_R * 255;
284 284
         $g = $var_G * 255;
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 }
289 289
 
290 290
 function colorPalette($imageFile, $numColors, $granularity = 5) {
291
-    $granularity = max(1, abs((int)$granularity));
291
+    $granularity = max(1, abs((int) $granularity));
292 292
     $colors = array();
293 293
 
294 294
     $size = @getimagesize($imageFile);
@@ -301,10 +301,10 @@  discard block
 block discarded – undo
301 301
             $ico = new floIcon();
302 302
             @$ico->readICO($imageFile);
303 303
 
304
-            if(count($ico->images)==0)
304
+            if (count($ico->images) == 0)
305 305
                 return false;
306 306
             else
307
-                $img = @$ico->images[count($ico->images)-1]->getImageResource();
307
+                $img = @$ico->images[count($ico->images) - 1]->getImageResource();
308 308
 
309 309
         } else {
310 310
             return false;
@@ -316,17 +316,17 @@  discard block
 block discarded – undo
316 316
 
317 317
     if (!$img) return false;
318 318
 
319
-    for($x = 0; $x < $size[0]; $x += $granularity) {
320
-        for($y = 0; $y < $size[1]; $y += $granularity) {
319
+    for ($x = 0; $x < $size[0]; $x += $granularity) {
320
+        for ($y = 0; $y < $size[1]; $y += $granularity) {
321 321
             $thisColor = imagecolorat($img, $x, $y);
322 322
             $rgb = imagecolorsforindex($img, $thisColor);
323 323
             $red = round(round(($rgb['red'] / 0x33)) * 0x33);
324 324
             $green = round(round(($rgb['green'] / 0x33)) * 0x33);
325 325
             $blue = round(round(($rgb['blue'] / 0x33)) * 0x33);
326 326
             $thisRGB = sprintf('%02X%02X%02X', $red, $green, $blue);
327
-            if(array_key_exists($thisRGB, $colors)) {
327
+            if (array_key_exists($thisRGB, $colors)) {
328 328
                 $colors[$thisRGB]++;
329
-            } else{
329
+            } else {
330 330
                 $colors[$thisRGB] = 1;
331 331
             }
332 332
         }
Please login to merge, or discard this patch.
Braces   +51 added lines, -31 removed lines patch added patch discarded remove patch
@@ -157,11 +157,12 @@  discard block
 block discarded – undo
157 157
 
158 158
     $color = strtolower($color);
159 159
 
160
-    if (isset($htmlcolors[$color]))
161
-        return $htmlcolors[$color];
162
-    else
163
-        return $color;
164
-}
160
+    if (isset($htmlcolors[$color])) {
161
+            return $htmlcolors[$color];
162
+    } else {
163
+            return $color;
164
+    }
165
+    }
165 166
 
166 167
 ### RGB >> HSL
167 168
 function _color_rgb2hsl($rgb) {
@@ -173,9 +174,15 @@  discard block
 block discarded – undo
173 174
     }
174 175
     $h = 0;
175 176
     if ($delta > 0) {
176
-        if ($max == $r && $max != $g) $h += ($g - $b) / $delta;
177
-        if ($max == $g && $max != $b) $h += (2 + ($b - $r) / $delta);
178
-        if ($max == $b && $max != $r) $h += (4 + ($r - $g) / $delta);
177
+        if ($max == $r && $max != $g) {
178
+            $h += ($g - $b) / $delta;
179
+        }
180
+        if ($max == $g && $max != $b) {
181
+            $h += (2 + ($b - $r) / $delta);
182
+        }
183
+        if ($max == $b && $max != $r) {
184
+            $h += (4 + ($r - $g) / $delta);
185
+        }
179 186
         $h /= 6;
180 187
     } return array($h, $s, $l);
181 188
 }
@@ -193,19 +200,26 @@  discard block
 block discarded – undo
193 200
 ### Helper function for _color_hsl2rgb().
194 201
 function _color_hue2rgb($m1, $m2, $h) {
195 202
     $h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
196
-    if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
197
-    if ($h * 2 < 1) return $m2;
198
-    if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
203
+    if ($h * 6 < 1) {
204
+        return $m1 + ($m2 - $m1) * $h * 6;
205
+    }
206
+    if ($h * 2 < 1) {
207
+        return $m2;
208
+    }
209
+    if ($h * 3 < 2) {
210
+        return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
211
+    }
199 212
     return $m1;
200 213
 }
201 214
 
202 215
 ### Convert a hex color into an RGB triplet.
203 216
 function _color_unpack($hex, $normalize = false) {
204 217
 
205
-    if (strpos($hex, '#') !== 0)
206
-        $hex = _resolve_htmlcolor($hex);
207
-    else
208
-        $hex = substr($hex, 1);
218
+    if (strpos($hex, '#') !== 0) {
219
+            $hex = _resolve_htmlcolor($hex);
220
+    } else {
221
+            $hex = substr($hex, 1);
222
+    }
209 223
 
210 224
     if (strlen($hex) == 4) {
211 225
         $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
@@ -248,12 +262,20 @@  discard block
 block discarded – undo
248 262
         $del_G = ((($var_Max - $var_G ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
249 263
         $del_B = ((($var_Max - $var_B ) / 6 ) + ($del_Max / 2 ) ) / $del_Max;
250 264
 
251
-        if      ($var_R == $var_Max) $h = $del_B - $del_G;
252
-        else if ($var_G == $var_Max) $h = (1 / 3 ) + $del_R - $del_B;
253
-        else if ($var_B == $var_Max) $h = (2 / 3 ) + $del_G - $del_R;
265
+        if      ($var_R == $var_Max) {
266
+            $h = $del_B - $del_G;
267
+        } else if ($var_G == $var_Max) {
268
+            $h = (1 / 3 ) + $del_R - $del_B;
269
+        } else if ($var_B == $var_Max) {
270
+            $h = (2 / 3 ) + $del_G - $del_R;
271
+        }
254 272
 
255
-        if ($h < 0) $h++;
256
-        if ($h > 1) $h--;
273
+        if ($h < 0) {
274
+            $h++;
275
+        }
276
+        if ($h > 1) {
277
+            $h--;
278
+        }
257 279
     }
258 280
 
259 281
     return array($h, $s, $v);
@@ -273,12 +295,7 @@  discard block
 block discarded – undo
273 295
         $var_2 = $v * (1 - $s * ($var_H - $var_i ) );
274 296
         $var_3 = $v * (1 - $s * (1 - ($var_H - $var_i ) ) );
275 297
 
276
-        if       ($var_i == 0) { $var_R = $v     ; $var_G = $var_3  ; $var_B = $var_1 ; }
277
-        else if  ($var_i == 1) { $var_R = $var_2 ; $var_G = $v      ; $var_B = $var_1 ; }
278
-        else if  ($var_i == 2) { $var_R = $var_1 ; $var_G = $v      ; $var_B = $var_3 ; }
279
-        else if  ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2  ; $var_B = $v     ; }
280
-        else if  ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1  ; $var_B = $v     ; }
281
-        else                   { $var_R = $v     ; $var_G = $var_1  ; $var_B = $var_2 ; }
298
+        if       ($var_i == 0) { $var_R = $v     ; $var_G = $var_3  ; $var_B = $var_1 ; } else if  ($var_i == 1) { $var_R = $var_2 ; $var_G = $v      ; $var_B = $var_1 ; } else if  ($var_i == 2) { $var_R = $var_1 ; $var_G = $v      ; $var_B = $var_3 ; } else if  ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2  ; $var_B = $v     ; } else if  ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1  ; $var_B = $v     ; } else                   { $var_R = $v     ; $var_G = $var_1  ; $var_B = $var_2 ; }
282 299
 
283 300
         $r = $var_R * 255;
284 301
         $g = $var_G * 255;
@@ -301,10 +318,11 @@  discard block
 block discarded – undo
301 318
             $ico = new floIcon();
302 319
             @$ico->readICO($imageFile);
303 320
 
304
-            if(count($ico->images)==0)
305
-                return false;
306
-            else
307
-                $img = @$ico->images[count($ico->images)-1]->getImageResource();
321
+            if(count($ico->images)==0) {
322
+                            return false;
323
+            } else {
324
+                            $img = @$ico->images[count($ico->images)-1]->getImageResource();
325
+            }
308 326
 
309 327
         } else {
310 328
             return false;
@@ -314,7 +332,9 @@  discard block
 block discarded – undo
314 332
         $img = @imagecreatefromstring(file_get_contents($imageFile));
315 333
     }
316 334
 
317
-    if (!$img) return false;
335
+    if (!$img) {
336
+        return false;
337
+    }
318 338
 
319 339
     for($x = 0; $x < $size[0]; $x += $granularity) {
320 340
         for($y = 0; $y < $size[1]; $y += $granularity) {
Please login to merge, or discard this patch.
include/functions.php 4 patches
Spacing   +53 added lines, -54 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 define('LABEL_BASE_INDEX', -1024);
6 6
 define('PLUGIN_FEED_BASE_INDEX', -128);
7 7
 
8
-define('COOKIE_LIFETIME_LONG', 86400*365);
8
+define('COOKIE_LIFETIME_LONG', 86400 * 365);
9 9
 
10 10
 $fetch_last_error = false;
11 11
 $fetch_last_error_code = false;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 // feed limit for one update batch
58 58
 define_default('DAEMON_SLEEP_INTERVAL', 120);
59 59
 // default sleep interval between feed updates (sec)
60
-define_default('MAX_CACHE_FILE_SIZE', 64*1024*1024);
60
+define_default('MAX_CACHE_FILE_SIZE', 64 * 1024 * 1024);
61 61
 // do not cache files larger than that (bytes)
62
-define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024);
62
+define_default('MAX_DOWNLOAD_FILE_SIZE', 16 * 1024 * 1024);
63 63
 // do not download general files larger than that (bytes)
64 64
 define_default('CACHE_MAX_DAYS', 7);
65 65
 // max age in days for various automatically cached (temporary) files
66
-define_default('MAX_CONDITIONAL_INTERVAL', 3600*12);
66
+define_default('MAX_CONDITIONAL_INTERVAL', 3600 * 12);
67 67
 // max interval between forced unconditional updates for servers
68 68
 // not complying with http if-modified-since (seconds)
69 69
 define_default('MAX_FETCH_REQUESTS_PER_HOST', 25);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 require_once 'db-prefs.php';
158 158
 require_once 'controls.php';
159 159
 
160
-define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)');
160
+define('SELF_USER_AGENT', 'Tiny Tiny RSS/'.get_version().' (http://tt-rss.org/)');
161 161
 ini_set('user_agent', SELF_USER_AGENT);
162 162
 
163 163
 $schema_version = false;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
     if (!is_array($options)) {
202 202
 
203 203
         // falling back on compatibility shim
204
-        $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ];
204
+        $option_names = ["url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent"];
205 205
         $tmp = [];
206 206
 
207 207
         for ($i = 0; $i < func_num_args(); $i++) {
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
     $url = str_replace(' ', '%20', $url);
229 229
 
230 230
     if (strpos($url, "//") === 0)
231
-        $url = 'http:' . $url;
231
+        $url = 'http:'.$url;
232 232
 
233 233
     $url_host = parse_url($url, PHP_URL_HOST);
234 234
     $fetch_domain_hits[$url_host] += 1;
235 235
 
236 236
     if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) {
237
-        user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING);
237
+        user_error("Exceeded fetch request quota for $url_host: ".$fetch_domain_hits[$url_host], E_USER_WARNING);
238 238
         #return false;
239 239
     }
240 240
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
             array_push($curl_http_headers, "If-Modified-Since: $last_modified");
251 251
 
252 252
         if ($http_accept)
253
-            array_push($curl_http_headers, "Accept: " . $http_accept);
253
+            array_push($curl_http_headers, "Accept: ".$http_accept);
254 254
 
255 255
         if (count($curl_http_headers) > 0)
256 256
             curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers);
@@ -263,11 +263,10 @@  discard block
 block discarded – undo
263 263
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
264 264
         curl_setopt($ch, CURLOPT_HEADER, true);
265 265
         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
266
-        curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent :
267
-            SELF_USER_AGENT);
266
+        curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : SELF_USER_AGENT);
268 267
         curl_setopt($ch, CURLOPT_ENCODING, "");
269 268
 
270
-        if  ($http_referrer)
269
+        if ($http_referrer)
271 270
             curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
272 271
 
273 272
         if ($max_size) {
@@ -276,7 +275,7 @@  discard block
 block discarded – undo
276 275
 
277 276
             // holy shit closures in php
278 277
             // download & upload are *expected* sizes respectively, could be zero
279
-            curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) {
278
+            curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use(&$max_size) {
280 279
                 Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED);
281 280
 
282 281
                 return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it
@@ -336,7 +335,7 @@  discard block
 block discarded – undo
336 335
         if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) {
337 336
 
338 337
             if (curl_errno($ch) != 0) {
339
-                $fetch_last_error .=  "; " . curl_errno($ch) . " " . curl_error($ch);
338
+                $fetch_last_error .= "; ".curl_errno($ch)." ".curl_error($ch);
340 339
             }
341 340
 
342 341
             $fetch_last_error_content = $contents;
@@ -345,7 +344,7 @@  discard block
 block discarded – undo
345 344
         }
346 345
 
347 346
         if (!$contents) {
348
-            $fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
347
+            $fetch_last_error = curl_errno($ch)." ".curl_error($ch);
349 348
             curl_close($ch);
350 349
             return false;
351 350
         }
@@ -365,7 +364,7 @@  discard block
 block discarded – undo
365 364
 
366 365
         $fetch_curl_used = false;
367 366
 
368
-        if ($login && $pass){
367
+        if ($login && $pass) {
369 368
             $url_parts = array();
370 369
 
371 370
             preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts);
@@ -373,7 +372,7 @@  discard block
 block discarded – undo
373 372
             $pass = urlencode($pass);
374 373
 
375 374
             if ($url_parts[1] && $url_parts[2]) {
376
-                $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2];
375
+                $url = $url_parts[1]."://$login:$pass@".$url_parts[2];
377 376
             }
378 377
         }
379 378
 
@@ -441,7 +440,7 @@  discard block
 block discarded – undo
441 440
             $error = error_get_last();
442 441
 
443 442
             if ($error['message'] != $old_error['message']) {
444
-                $fetch_last_error .= "; " . $error["message"];
443
+                $fetch_last_error .= "; ".$error["message"];
445 444
             }
446 445
 
447 446
             $fetch_last_error_content = $data;
@@ -516,15 +515,15 @@  discard block
 block discarded – undo
516 515
 
517 516
 function get_ssl_certificate_id() {
518 517
     if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) {
519
-        return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] .
520
-            $_SERVER["REDIRECT_SSL_CLIENT_V_START"] .
521
-            $_SERVER["REDIRECT_SSL_CLIENT_V_END"] .
518
+        return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"].
519
+            $_SERVER["REDIRECT_SSL_CLIENT_V_START"].
520
+            $_SERVER["REDIRECT_SSL_CLIENT_V_END"].
522 521
             $_SERVER["REDIRECT_SSL_CLIENT_S_DN"]);
523 522
     }
524 523
     if ($_SERVER["SSL_CLIENT_M_SERIAL"]) {
525
-        return sha1($_SERVER["SSL_CLIENT_M_SERIAL"] .
526
-            $_SERVER["SSL_CLIENT_V_START"] .
527
-            $_SERVER["SSL_CLIENT_V_END"] .
524
+        return sha1($_SERVER["SSL_CLIENT_M_SERIAL"].
525
+            $_SERVER["SSL_CLIENT_V_START"].
526
+            $_SERVER["SSL_CLIENT_V_END"].
528 527
             $_SERVER["SSL_CLIENT_S_DN"]);
529 528
     }
530 529
     return "";
@@ -659,7 +658,7 @@  discard block
 block discarded – undo
659 658
 function logout_user() {
660 659
     @session_destroy();
661 660
     if (isset($_COOKIE[session_name()])) {
662
-       setcookie(session_name(), '', time()-42000, '/');
661
+       setcookie(session_name(), '', time() - 42000, '/');
663 662
     }
664 663
     session_commit();
665 664
 }
@@ -743,7 +742,7 @@  discard block
 block discarded – undo
743 742
 
744 743
 function truncate_string($str, $max_len, $suffix = '&hellip;') {
745 744
     if (mb_strlen($str, "utf-8") > $max_len) {
746
-        return mb_substr($str, 0, $max_len, "utf-8") . $suffix;
745
+        return mb_substr($str, 0, $max_len, "utf-8").$suffix;
747 746
     } else {
748 747
         return $str;
749 748
     }
@@ -753,7 +752,7 @@  discard block
 block discarded – undo
753 752
     $startString = mb_substr($original, 0, $position, "UTF-8");
754 753
     $endString = mb_substr($original, $position + $length, mb_strlen($original), "UTF-8");
755 754
 
756
-    $out = $startString . $replacement . $endString;
755
+    $out = $startString.$replacement.$endString;
757 756
 
758 757
     return $out;
759 758
 }
@@ -891,9 +890,9 @@  discard block
 block discarded – undo
891 890
 }
892 891
 
893 892
 function file_is_locked($filename) {
894
-    if (file_exists(LOCK_DIRECTORY . "/$filename")) {
893
+    if (file_exists(LOCK_DIRECTORY."/$filename")) {
895 894
         if (function_exists('flock')) {
896
-            $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r");
895
+            $fp = @fopen(LOCK_DIRECTORY."/$filename", "r");
897 896
             if ($fp) {
898 897
                 if (flock($fp, LOCK_EX | LOCK_NB)) {
899 898
                     flock($fp, LOCK_UN);
@@ -914,11 +913,11 @@  discard block
 block discarded – undo
914 913
 
915 914
 
916 915
 function make_lockfile($filename) {
917
-    $fp = fopen(LOCK_DIRECTORY . "/$filename", "w");
916
+    $fp = fopen(LOCK_DIRECTORY."/$filename", "w");
918 917
 
919 918
     if ($fp && flock($fp, LOCK_EX | LOCK_NB)) {
920 919
         $stat_h = fstat($fp);
921
-        $stat_f = stat(LOCK_DIRECTORY . "/$filename");
920
+        $stat_f = stat(LOCK_DIRECTORY."/$filename");
922 921
 
923 922
         if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
924 923
             if ($stat_h["ino"] != $stat_f["ino"] ||
@@ -929,7 +928,7 @@  discard block
 block discarded – undo
929 928
         }
930 929
 
931 930
         if (function_exists('posix_getpid')) {
932
-            fwrite($fp, posix_getpid() . "\n");
931
+            fwrite($fp, posix_getpid()."\n");
933 932
         }
934 933
         return $fp;
935 934
     } else {
@@ -938,10 +937,10 @@  discard block
 block discarded – undo
938 937
 }
939 938
 
940 939
 function make_stampfile($filename) {
941
-    $fp = fopen(LOCK_DIRECTORY . "/$filename", "w");
940
+    $fp = fopen(LOCK_DIRECTORY."/$filename", "w");
942 941
 
943 942
     if (flock($fp, LOCK_EX | LOCK_NB)) {
944
-        fwrite($fp, time() . "\n");
943
+        fwrite($fp, time()."\n");
945 944
         flock($fp, LOCK_UN);
946 945
         fclose($fp);
947 946
         return true;
@@ -991,7 +990,7 @@  discard block
 block discarded – undo
991 990
     $params["is_default_pw"] = Pref_Prefs::isdefaultpassword();
992 991
     $params["label_base_index"] = (int) LABEL_BASE_INDEX;
993 992
 
994
-    $theme = get_pref( "USER_CSS_THEME", false, false);
993
+    $theme = get_pref("USER_CSS_THEME", false, false);
995 994
     $params["theme"] = theme_exists($theme) ? $theme : "";
996 995
 
997 996
     $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names());
@@ -1215,13 +1214,13 @@  discard block
 block discarded – undo
1215 1214
         }
1216 1215
     }
1217 1216
 
1218
-    if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
1217
+    if (file_exists(LOCK_DIRECTORY."/update_daemon.lock")) {
1219 1218
 
1220 1219
         $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock");
1221 1220
 
1222 1221
         if (time() - $_SESSION["daemon_stamp_check"] > 30) {
1223 1222
 
1224
-            $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp");
1223
+            $stamp = (int) @file_get_contents(LOCK_DIRECTORY."/update_daemon.stamp");
1225 1224
 
1226 1225
             if ($stamp) {
1227 1226
                 $stamp_delta = time() - $stamp;
@@ -1264,7 +1263,7 @@  discard block
 block discarded – undo
1264 1263
     $res = trim($str); if (!$res) return '';
1265 1264
 
1266 1265
     $doc = new DOMDocument();
1267
-    $doc->loadHTML('<?xml encoding="UTF-8">' . $res);
1266
+    $doc->loadHTML('<?xml encoding="UTF-8">'.$res);
1268 1267
     $xpath = new DOMXPath($doc);
1269 1268
 
1270 1269
     $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix();
@@ -1363,7 +1362,7 @@  discard block
 block discarded – undo
1363 1362
         'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section',
1364 1363
         'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary',
1365 1364
         'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time',
1366
-        'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' );
1365
+        'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace');
1367 1366
 
1368 1367
     if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe';
1369 1368
 
@@ -1498,8 +1497,8 @@  discard block
 block discarded – undo
1498 1497
 
1499 1498
 // this returns SELF_URL_PATH sans ending slash
1500 1499
 function get_self_url_prefix() {
1501
-    if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH)-1) {
1502
-        return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH)-1);
1500
+    if (strrpos(SELF_URL_PATH, "/") === strlen(SELF_URL_PATH) - 1) {
1501
+        return substr(SELF_URL_PATH, 0, strlen(SELF_URL_PATH) - 1);
1503 1502
     } else {
1504 1503
         return SELF_URL_PATH;
1505 1504
     }
@@ -1508,11 +1507,11 @@  discard block
 block discarded – undo
1508 1507
 /* TODO: This needs to use bcrypt */
1509 1508
 function encrypt_password($pass, $salt = '', $mode2 = false) {
1510 1509
     if ($salt && $mode2) {
1511
-        return "MODE2:" . hash('sha256', $salt . $pass);
1510
+        return "MODE2:".hash('sha256', $salt.$pass);
1512 1511
     } else if ($salt) {
1513
-        return "SHA1X:" . sha1("$salt:$pass");
1512
+        return "SHA1X:".sha1("$salt:$pass");
1514 1513
     } else {
1515
-        return "SHA1:" . sha1($pass);
1514
+        return "SHA1:".sha1($pass);
1516 1515
     }
1517 1516
 }
1518 1517
 
@@ -1523,7 +1522,7 @@  discard block
 block discarded – undo
1523 1522
 }
1524 1523
 
1525 1524
 function build_url($parts) {
1526
-    return $parts['scheme'] . "://" . $parts['host'] . $parts['path'];
1525
+    return $parts['scheme']."://".$parts['host'].$parts['path'];
1527 1526
 }
1528 1527
 
1529 1528
 function cleanup_url_path($path) {
@@ -1567,7 +1566,7 @@  discard block
 block discarded – undo
1567 1566
             $dir = dirname($parts['path']);
1568 1567
             $dir !== '/' && $dir .= '/';
1569 1568
         }
1570
-        $parts['path'] = $dir . $rel_url;
1569
+        $parts['path'] = $dir.$rel_url;
1571 1570
         $parts['path'] = cleanup_url_path($parts['path']);
1572 1571
 
1573 1572
         return build_url($parts);
@@ -1654,12 +1653,12 @@  discard block
 block discarded – undo
1654 1653
 
1655 1654
         for ($i = 0; $i < $l10n->total; $i++) {
1656 1655
             $orig = $l10n->get_original_string($i);
1657
-            if(strpos($orig, "\000") !== FALSE) { // Plural forms
1656
+            if (strpos($orig, "\000") !== FALSE) { // Plural forms
1658 1657
                 $key = explode(chr(0), $orig);
1659 1658
                 print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular
1660 1659
                 print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural
1661 1660
             } else {
1662
-                $translation = _dgettext($domain,$orig);
1661
+                $translation = _dgettext($domain, $orig);
1663 1662
                 print T_js_decl($orig, $translation);
1664 1663
             }
1665 1664
         }
@@ -1715,7 +1714,7 @@  discard block
 block discarded – undo
1715 1714
     if (file_exists($filename)) {
1716 1715
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
1717 1716
 
1718
-        return "data:image/$ext;base64," . base64_encode(file_get_contents($filename));
1717
+        return "data:image/$ext;base64,".base64_encode(file_get_contents($filename));
1719 1718
     } else {
1720 1719
         return "";
1721 1720
     }
@@ -1752,7 +1751,7 @@  discard block
 block discarded – undo
1752 1751
 
1753 1752
         header("Content-type: $mimetype");
1754 1753
 
1755
-        $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT";
1754
+        $stamp = gmdate("D, d M Y H:i:s", filemtime($filename))." GMT";
1756 1755
         header("Last-Modified: $stamp", true);
1757 1756
 
1758 1757
         return readfile($filename);
@@ -1762,7 +1761,7 @@  discard block
 block discarded – undo
1762 1761
 }
1763 1762
 
1764 1763
 function arr_qmarks($arr) {
1765
-    return str_repeat('?,', count($arr) - 1) . '?';
1764
+    return str_repeat('?,', count($arr) - 1).'?';
1766 1765
 }
1767 1766
 
1768 1767
 function get_scripts_timestamp() {
@@ -1797,7 +1796,7 @@  discard block
 block discarded – undo
1797 1796
     } else if (PHP_OS === "Darwin") {
1798 1797
         $ttrss_version = "UNKNOWN (Unsupported, Darwin)";
1799 1798
     } else if (file_exists("$root_dir/version_static.txt")) {
1800
-        $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)";
1799
+        $ttrss_version = trim(file_get_contents("$root_dir/version_static.txt"))." (Unsupported)";
1801 1800
     } else if (is_dir("$root_dir/.git")) {
1802 1801
         $rc = 0;
1803 1802
         $output = [];
@@ -1815,10 +1814,10 @@  discard block
 block discarded – undo
1815 1814
                 $git_commit = $commit;
1816 1815
                 $git_timestamp = $timestamp;
1817 1816
 
1818
-                $ttrss_version = strftime("%y.%m", $timestamp) . "-$commit";
1817
+                $ttrss_version = strftime("%y.%m", $timestamp)."-$commit";
1819 1818
             }
1820 1819
         } else {
1821
-            user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING);
1820
+            user_error("Unable to determine version (using $root_dir): ".implode("\n", $output), E_USER_WARNING);
1822 1821
         }
1823 1822
     }
1824 1823
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $contents = substr($ret, $headers_length);
308 308
 
309 309
         foreach ($headers as $header) {
310
-            if (strstr($header, ": ") !== FALSE) {
310
+            if (strstr($header, ": ") !== false) {
311 311
                 list ($key, $value) = explode(": ", $header);
312 312
 
313 313
                 if (strtolower($key) == "last-modified") {
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
         if (isset($http_response_header) && is_array($http_response_header)) {
416 416
             foreach ($http_response_header as $header) {
417
-                if (strstr($header, ": ") !== FALSE) {
417
+                if (strstr($header, ": ") !== false) {
418 418
                     list ($key, $value) = explode(": ", $header);
419 419
 
420 420
                     $key = strtolower($key);
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
     }
492 492
 
493 493
     while ($line = $sth->fetch()) {
494
-        if (array_search($line["pref_name"], $active_prefs) === FALSE) {
494
+        if (array_search($line["pref_name"], $active_prefs) === false) {
495 495
 //				print "adding " . $line["pref_name"] . "<br>";
496 496
 
497 497
             if (get_schema_version() < 63) {
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 
1655 1655
         for ($i = 0; $i < $l10n->total; $i++) {
1656 1656
             $orig = $l10n->get_original_string($i);
1657
-            if(strpos($orig, "\000") !== FALSE) { // Plural forms
1657
+            if(strpos($orig, "\000") !== false) { // Plural forms
1658 1658
                 $key = explode(chr(0), $orig);
1659 1659
                 print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular
1660 1660
                 print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 
380 380
         // TODO: should this support POST requests or not? idk
381 381
 
382
-         $context_options = array(
383
-              'http' => array(
382
+            $context_options = array(
383
+                'http' => array(
384 384
                     'header' => array(
385 385
                         'Connection: close'
386 386
                     ),
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
                     'ignore_errors' => true,
389 389
                     'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT,
390 390
                     'protocol_version'=> 1.1)
391
-              );
391
+                );
392 392
 
393 393
         if (!$post_query && $last_modified)
394 394
             array_push($context_options['http']['header'], "If-Modified-Since: $last_modified");
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 function logout_user() {
660 660
     @session_destroy();
661 661
     if (isset($_COOKIE[session_name()])) {
662
-       setcookie(session_name(), '', time()-42000, '/');
662
+        setcookie(session_name(), '', time()-42000, '/');
663 663
     }
664 664
     session_commit();
665 665
 }
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
             if (AUTH_AUTO_LOGIN && authenticate_user(null, null)) {
700 700
                 $_SESSION["ref_schema_version"] = get_schema_version(true);
701 701
             } else {
702
-                 authenticate_user(null, null, true);
702
+                    authenticate_user(null, null, true);
703 703
             }
704 704
 
705 705
             if (!$_SESSION["uid"]) {
@@ -974,9 +974,9 @@  discard block
 block discarded – undo
974 974
     $params = array();
975 975
 
976 976
     foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS",
977
-                 "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP",
978
-                 "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE",
979
-                 "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) {
977
+                    "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP",
978
+                    "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE",
979
+                    "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) {
980 980
 
981 981
         $params[strtolower($param)] = (int) get_pref($param);
982 982
     }
Please login to merge, or discard this patch.
Braces   +128 added lines, -65 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 libxml_use_internal_errors(true);
19 19
 
20 20
 // separate test because this is included before sanity checks
21
-if (function_exists("mb_internal_encoding")) mb_internal_encoding("UTF-8");
21
+if (function_exists("mb_internal_encoding")) {
22
+    mb_internal_encoding("UTF-8");
23
+}
22 24
 
23 25
 date_default_timezone_set('UTC');
24 26
 if (defined('E_DEPRECATED')) {
@@ -195,8 +197,9 @@  discard block
 block discarded – undo
195 197
     $fetch_last_modified = "";
196 198
     $fetch_effective_url = "";
197 199
 
198
-    if (!is_array($fetch_domain_hits))
199
-        $fetch_domain_hits = [];
200
+    if (!is_array($fetch_domain_hits)) {
201
+            $fetch_domain_hits = [];
202
+    }
200 203
 
201 204
     if (!is_array($options)) {
202 205
 
@@ -227,8 +230,9 @@  discard block
 block discarded – undo
227 230
     $url = ltrim($url, ' ');
228 231
     $url = str_replace(' ', '%20', $url);
229 232
 
230
-    if (strpos($url, "//") === 0)
231
-        $url = 'http:' . $url;
233
+    if (strpos($url, "//") === 0) {
234
+            $url = 'http:' . $url;
235
+    }
232 236
 
233 237
     $url_host = parse_url($url, PHP_URL_HOST);
234 238
     $fetch_domain_hits[$url_host] += 1;
@@ -246,14 +250,17 @@  discard block
 block discarded – undo
246 250
 
247 251
         $curl_http_headers = [];
248 252
 
249
-        if ($last_modified && !$post_query)
250
-            array_push($curl_http_headers, "If-Modified-Since: $last_modified");
253
+        if ($last_modified && !$post_query) {
254
+                    array_push($curl_http_headers, "If-Modified-Since: $last_modified");
255
+        }
251 256
 
252
-        if ($http_accept)
253
-            array_push($curl_http_headers, "Accept: " . $http_accept);
257
+        if ($http_accept) {
258
+                    array_push($curl_http_headers, "Accept: " . $http_accept);
259
+        }
254 260
 
255
-        if (count($curl_http_headers) > 0)
256
-            curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers);
261
+        if (count($curl_http_headers) > 0) {
262
+                    curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers);
263
+        }
257 264
 
258 265
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT);
259 266
         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT);
@@ -267,8 +274,9 @@  discard block
 block discarded – undo
267 274
             SELF_USER_AGENT);
268 275
         curl_setopt($ch, CURLOPT_ENCODING, "");
269 276
 
270
-        if  ($http_referrer)
271
-            curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
277
+        if  ($http_referrer) {
278
+                    curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
279
+        }
272 280
 
273 281
         if ($max_size) {
274 282
             curl_setopt($ch, CURLOPT_NOPROGRESS, false);
@@ -297,8 +305,9 @@  discard block
 block discarded – undo
297 305
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query);
298 306
         }
299 307
 
300
-        if ($login && $pass)
301
-            curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
308
+        if ($login && $pass) {
309
+                    curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass");
310
+        }
302 311
 
303 312
         $ret = @curl_exec($ch);
304 313
 
@@ -357,7 +366,9 @@  discard block
 block discarded – undo
357 366
         if ($is_gzipped) {
358 367
             $tmp = @gzdecode($contents);
359 368
 
360
-            if ($tmp) $contents = $tmp;
369
+            if ($tmp) {
370
+                $contents = $tmp;
371
+            }
361 372
         }
362 373
 
363 374
         return $contents;
@@ -390,14 +401,17 @@  discard block
 block discarded – undo
390 401
                     'protocol_version'=> 1.1)
391 402
               );
392 403
 
393
-        if (!$post_query && $last_modified)
394
-            array_push($context_options['http']['header'], "If-Modified-Since: $last_modified");
404
+        if (!$post_query && $last_modified) {
405
+                    array_push($context_options['http']['header'], "If-Modified-Since: $last_modified");
406
+        }
395 407
 
396
-        if ($http_accept)
397
-            array_push($context_options['http']['header'], "Accept: $http_accept");
408
+        if ($http_accept) {
409
+                    array_push($context_options['http']['header'], "Accept: $http_accept");
410
+        }
398 411
 
399
-        if ($http_referrer)
400
-            array_push($context_options['http']['header'], "Referer: $http_referrer");
412
+        if ($http_referrer) {
413
+                    array_push($context_options['http']['header'], "Referer: $http_referrer");
414
+        }
401 415
 
402 416
         if (defined('_HTTP_PROXY')) {
403 417
             $context_options['http']['request_fulluri'] = true;
@@ -454,7 +468,9 @@  discard block
 block discarded – undo
454 468
         if ($is_gzipped) {
455 469
             $tmp = @gzdecode($data);
456 470
 
457
-            if ($tmp) $data = $tmp;
471
+            if ($tmp) {
472
+                $data = $tmp;
473
+            }
458 474
         }
459 475
 
460 476
         return $data;
@@ -464,7 +480,9 @@  discard block
 block discarded – undo
464 480
 
465 481
 function initialize_user_prefs($uid, $profile = false) {
466 482
 
467
-    if (get_schema_version() < 63) $profile_qpart = "";
483
+    if (get_schema_version() < 63) {
484
+        $profile_qpart = "";
485
+    }
468 486
 
469 487
     $pdo = DB::pdo();
470 488
     $in_nested_tr = false;
@@ -477,7 +495,9 @@  discard block
 block discarded – undo
477 495
 
478 496
     $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs");
479 497
 
480
-    if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null;
498
+    if (!is_numeric($profile) || !$profile || get_schema_version() < 63) {
499
+        $profile = null;
500
+    }
481 501
 
482 502
     $u_sth = $pdo->prepare("SELECT pref_name
483 503
         FROM ttrss_user_prefs WHERE owner_uid = :uid AND
@@ -510,7 +530,9 @@  discard block
 block discarded – undo
510 530
         }
511 531
     }
512 532
 
513
-    if (!$in_nested_tr) $pdo->commit();
533
+    if (!$in_nested_tr) {
534
+        $pdo->commit();
535
+    }
514 536
 
515 537
 }
516 538
 
@@ -670,7 +692,9 @@  discard block
 block discarded – undo
670 692
 
671 693
 function load_user_plugins($owner_uid, $pluginhost = false) {
672 694
 
673
-    if (!$pluginhost) $pluginhost = PluginHost::getInstance();
695
+    if (!$pluginhost) {
696
+        $pluginhost = PluginHost::getInstance();
697
+    }
674 698
 
675 699
     if ($owner_uid && SCHEMA_VERSION >= 100) {
676 700
         $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid);
@@ -692,7 +716,9 @@  discard block
 block discarded – undo
692 716
         startup_gettext();
693 717
         load_user_plugins($_SESSION["uid"]);
694 718
     } else {
695
-        if (!validate_session()) $_SESSION["uid"] = false;
719
+        if (!validate_session()) {
720
+            $_SESSION["uid"] = false;
721
+        }
696 722
 
697 723
         if (!$_SESSION["uid"]) {
698 724
 
@@ -787,13 +813,19 @@  discard block
 block discarded – undo
787 813
 function make_local_datetime($timestamp, $long, $owner_uid = false,
788 814
                 $no_smart_dt = false, $eta_min = false) {
789 815
 
790
-    if (!$owner_uid) $owner_uid = $_SESSION['uid'];
791
-    if (!$timestamp) $timestamp = '1970-01-01 0:00';
816
+    if (!$owner_uid) {
817
+        $owner_uid = $_SESSION['uid'];
818
+    }
819
+    if (!$timestamp) {
820
+        $timestamp = '1970-01-01 0:00';
821
+    }
792 822
 
793 823
     global $utc_tz;
794 824
     global $user_tz;
795 825
 
796
-    if (!$utc_tz) $utc_tz = new DateTimeZone('UTC');
826
+    if (!$utc_tz) {
827
+        $utc_tz = new DateTimeZone('UTC');
828
+    }
797 829
 
798 830
     $timestamp = substr($timestamp, 0, 19);
799 831
 
@@ -805,7 +837,9 @@  discard block
 block discarded – undo
805 837
     if ($user_tz_string != 'Automatic') {
806 838
 
807 839
         try {
808
-            if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string);
840
+            if (!$user_tz) {
841
+                $user_tz = new DateTimeZone($user_tz_string);
842
+            }
809 843
         } catch (Exception $e) {
810 844
             $user_tz = $utc_tz;
811 845
         }
@@ -821,26 +855,30 @@  discard block
 block discarded – undo
821 855
         return smart_date_time($user_timestamp,
822 856
             $tz_offset, $owner_uid, $eta_min);
823 857
     } else {
824
-        if ($long)
825
-            $format = get_pref('LONG_DATE_FORMAT', $owner_uid);
826
-        else
827
-            $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
858
+        if ($long) {
859
+                    $format = get_pref('LONG_DATE_FORMAT', $owner_uid);
860
+        } else {
861
+                    $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
862
+        }
828 863
 
829 864
         return date($format, $user_timestamp);
830 865
     }
831 866
 }
832 867
 
833 868
 function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) {
834
-    if (!$owner_uid) $owner_uid = $_SESSION['uid'];
869
+    if (!$owner_uid) {
870
+        $owner_uid = $_SESSION['uid'];
871
+    }
835 872
 
836 873
     if ($eta_min && time() + $tz_offset - $timestamp < 3600) {
837 874
         return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp));
838 875
     } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) {
839 876
         $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
840
-        if (strpos((strtolower($format)), "a") === false)
841
-            return date("G:i", $timestamp);
842
-        else
843
-            return date("g:i a", $timestamp);
877
+        if (strpos((strtolower($format)), "a") === false) {
878
+                    return date("G:i", $timestamp);
879
+        } else {
880
+                    return date("g:i a", $timestamp);
881
+        }
844 882
     } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) {
845 883
         $format = get_pref('SHORT_DATE_FORMAT', $owner_uid);
846 884
         return date($format, $timestamp);
@@ -1250,8 +1288,9 @@  discard block
 block discarded – undo
1250 1288
 
1251 1289
     if ($src) {
1252 1290
         foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) {
1253
-            if ($plugin->hook_iframe_whitelisted($src))
1254
-                return true;
1291
+            if ($plugin->hook_iframe_whitelisted($src)) {
1292
+                            return true;
1293
+            }
1255 1294
         }
1256 1295
     }
1257 1296
 
@@ -1259,9 +1298,13 @@  discard block
 block discarded – undo
1259 1298
 }
1260 1299
 
1261 1300
 function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) {
1262
-    if (!$owner) $owner = $_SESSION["uid"];
1301
+    if (!$owner) {
1302
+        $owner = $_SESSION["uid"];
1303
+    }
1263 1304
 
1264
-    $res = trim($str); if (!$res) return '';
1305
+    $res = trim($str); if (!$res) {
1306
+        return '';
1307
+    }
1265 1308
 
1266 1309
     $doc = new DOMDocument();
1267 1310
     $doc->loadHTML('<?xml encoding="UTF-8">' . $res);
@@ -1323,13 +1366,15 @@  discard block
 block discarded – undo
1323 1366
 
1324 1367
             if ($entry->nodeName == 'source') {
1325 1368
 
1326
-                if ($entry->parentNode && $entry->parentNode->parentNode)
1327
-                    $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
1369
+                if ($entry->parentNode && $entry->parentNode->parentNode) {
1370
+                                    $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode);
1371
+                }
1328 1372
 
1329 1373
             } else if ($entry->nodeName == 'img') {
1330 1374
 
1331
-                if ($entry->parentNode)
1332
-                    $entry->parentNode->replaceChild($p, $entry);
1375
+                if ($entry->parentNode) {
1376
+                                    $entry->parentNode->replaceChild($p, $entry);
1377
+                }
1333 1378
 
1334 1379
             }
1335 1380
         }
@@ -1365,7 +1410,9 @@  discard block
 block discarded – undo
1365 1410
         'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time',
1366 1411
         'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' );
1367 1412
 
1368
-    if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe';
1413
+    if ($_SESSION['hasSandbox']) {
1414
+        $allowed_elements[] = 'iframe';
1415
+    }
1369 1416
 
1370 1417
     $disallowed_attributes = array('id', 'style', 'class');
1371 1418
 
@@ -1405,7 +1452,9 @@  discard block
 block discarded – undo
1405 1452
                     $text = mb_substr($text, $pos + mb_strlen($word));
1406 1453
                 }
1407 1454
 
1408
-                if (!empty($text)) $fragment->appendChild(new DomText($text));
1455
+                if (!empty($text)) {
1456
+                    $fragment->appendChild(new DomText($text));
1457
+                }
1409 1458
 
1410 1459
                 $child->parentNode->replaceChild($fragment, $child);
1411 1460
             }
@@ -1596,8 +1645,9 @@  discard block
 block discarded – undo
1596 1645
     } else {
1597 1646
         $output = "";
1598 1647
 
1599
-        for ($i = 0; $i < $length; $i++)
1600
-            $output .= chr(mt_rand(0, 255));
1648
+        for ($i = 0; $i < $length; $i++) {
1649
+                    $output .= chr(mt_rand(0, 255));
1650
+        }
1601 1651
 
1602 1652
         return $output;
1603 1653
     }
@@ -1667,15 +1717,20 @@  discard block
 block discarded – undo
1667 1717
 }
1668 1718
 
1669 1719
 function get_theme_path($theme) {
1670
-    if ($theme == "default.php")
1671
-        return "css/default.css";
1720
+    if ($theme == "default.php") {
1721
+            return "css/default.css";
1722
+    }
1672 1723
 
1673 1724
     $check = "themes/$theme";
1674
-    if (file_exists($check)) return $check;
1725
+    if (file_exists($check)) {
1726
+        return $check;
1727
+    }
1675 1728
 
1676 1729
     $check = "themes.local/$theme";
1677
-    if (file_exists($check)) return $check;
1678
-}
1730
+    if (file_exists($check)) {
1731
+        return $check;
1732
+    }
1733
+    }
1679 1734
 
1680 1735
 function theme_exists($theme) {
1681 1736
     return file_exists("themes/$theme") || file_exists("themes.local/$theme");
@@ -1731,7 +1786,9 @@  discard block
 block discarded – undo
1731 1786
 function send_local_file($filename) {
1732 1787
     if (file_exists($filename)) {
1733 1788
 
1734
-        if (is_writable($filename)) touch($filename);
1789
+        if (is_writable($filename)) {
1790
+            touch($filename);
1791
+        }
1735 1792
 
1736 1793
         $tmppluginhost = new PluginHost();
1737 1794
 
@@ -1739,7 +1796,9 @@  discard block
 block discarded – undo
1739 1796
         $tmppluginhost->load_data();
1740 1797
 
1741 1798
         foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) {
1742
-            if ($plugin->hook_send_local_file($filename)) return true;
1799
+            if ($plugin->hook_send_local_file($filename)) {
1800
+                return true;
1801
+            }
1743 1802
         }
1744 1803
 
1745 1804
         $mimetype = mime_content_type($filename);
@@ -1747,8 +1806,9 @@  discard block
 block discarded – undo
1747 1806
         // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4
1748 1807
         // video files are detected as octet-stream by mime_content_type()
1749 1808
 
1750
-        if ($mimetype == "application/octet-stream")
1751
-            $mimetype = "video/mp4";
1809
+        if ($mimetype == "application/octet-stream") {
1810
+                    $mimetype = "video/mp4";
1811
+        }
1752 1812
 
1753 1813
         header("Content-type: $mimetype");
1754 1814
 
@@ -1771,7 +1831,9 @@  discard block
 block discarded – undo
1771 1831
 
1772 1832
     foreach ($files as $file) {
1773 1833
         $file_ts = filemtime($file);
1774
-        if ($file_ts > $ts) $ts = $file_ts;
1834
+        if ($file_ts > $ts) {
1835
+            $ts = $file_ts;
1836
+        }
1775 1837
     }
1776 1838
 
1777 1839
     return $ts;
@@ -1784,8 +1846,9 @@  discard block
 block discarded – undo
1784 1846
 function get_version(&$git_commit = false, &$git_timestamp = false) {
1785 1847
     global $ttrss_version;
1786 1848
 
1787
-    if (isset($ttrss_version))
1788
-        return $ttrss_version;
1849
+    if (isset($ttrss_version)) {
1850
+            return $ttrss_version;
1851
+    }
1789 1852
 
1790 1853
     $ttrss_version = "UNKNOWN (Unsupported)";
1791 1854
 
Please login to merge, or discard this patch.
include/sessions.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
     return true;
79 79
 }
80 80
 
81
-function ttrss_open () {
81
+function ttrss_open() {
82 82
     return true;
83 83
 }
84 84
 
85
-function ttrss_read ($id){
85
+function ttrss_read($id) {
86 86
     global $session_expire;
87 87
 
88 88
     $sth = Db::pdo()->prepare("SELECT data FROM ttrss_sessions WHERE id=?");
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     }
102 102
 }
103 103
 
104
-function ttrss_write ($id, $data) {
104
+function ttrss_write($id, $data) {
105 105
     global $session_expire;
106 106
 
107 107
     $data = base64_encode($data);
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     return true;
122 122
 }
123 123
 
124
-function ttrss_close () {
124
+function ttrss_close() {
125 125
     return true;
126 126
 }
127 127
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
     return true;
133 133
 }
134 134
 
135
-function ttrss_gc () {
136
-    Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < " . time());
135
+function ttrss_gc() {
136
+    Db::pdo()->query("DELETE FROM ttrss_sessions WHERE expire < ".time());
137 137
 
138 138
     return true;
139 139
 }
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             __("Session failed to validate (schema version changed)");
43 43
         return false;
44 44
     }
45
-      $pdo = Db::pdo();
45
+        $pdo = Db::pdo();
46 46
 
47 47
     if ($_SESSION["uid"]) {
48 48
 
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
 
57 57
         // user not found
58 58
         if ($row = $sth->fetch()) {
59
-                 $pwd_hash = $row["pwd_hash"];
59
+                    $pwd_hash = $row["pwd_hash"];
60 60
 
61
-                 if ($pwd_hash != $_SESSION["pwd_hash"]) {
61
+                    if ($pwd_hash != $_SESSION["pwd_hash"]) {
62 62
 
63
-                      $_SESSION["login_error_msg"] =
63
+                        $_SESSION["login_error_msg"] =
64 64
                             __("Session failed to validate (password changed)");
65 65
 
66
-                      return false;
67
-                 }
66
+                        return false;
67
+                    }
68 68
         } else {
69 69
 
70
-                 $_SESSION["login_error_msg"] =
71
-                      __("Session failed to validate (user not found)");
70
+                    $_SESSION["login_error_msg"] =
71
+                        __("Session failed to validate (user not found)");
72 72
 
73
-                 return false;
73
+                    return false;
74 74
 
75 75
         }
76 76
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@
 block discarded – undo
35 35
 }
36 36
 
37 37
 function validate_session() {
38
-    if (SINGLE_USER_MODE) return true;
38
+    if (SINGLE_USER_MODE) {
39
+        return true;
40
+    }
39 41
 
40 42
     if (isset($_SESSION["ref_schema_version"]) && $_SESSION["ref_schema_version"] != session_get_schema_version()) {
41 43
         $_SESSION["login_error_msg"] =
Please login to merge, or discard this patch.
plugins/nsfw/init.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	}
20 20
 
21 21
 	public function get_js() {
22
-		return file_get_contents(dirname(__FILE__) . "/init.js");
22
+		return file_get_contents(dirname(__FILE__)."/init.js");
23 23
 	}
24 24
 
25 25
 	public function hook_render_article($article) {
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -1,64 +1,64 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class NSFW extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Hide article content based on tags",
8
-			"fox",
9
-			false);
10
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Hide article content based on tags",
8
+            "fox",
9
+            false);
10
+    }
11 11
 
12
-	public function init($host) {
13
-		$this->host = $host;
12
+    public function init($host) {
13
+        $this->host = $host;
14 14
 
15
-		$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
16
-		$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
17
-		$host->add_hook($host::HOOK_PREFS_TAB, $this);
15
+        $host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
16
+        $host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
17
+        $host->add_hook($host::HOOK_PREFS_TAB, $this);
18 18
 
19
-	}
19
+    }
20 20
 
21
-	public function get_js() {
22
-		return file_get_contents(dirname(__FILE__) . "/init.js");
23
-	}
21
+    public function get_js() {
22
+        return file_get_contents(dirname(__FILE__) . "/init.js");
23
+    }
24 24
 
25
-	public function hook_render_article($article) {
26
-		$tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
27
-		$a_tags = array_map("trim", explode(",", $article["tag_cache"]));
25
+    public function hook_render_article($article) {
26
+        $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
27
+        $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
28 28
 
29
-		if (count(array_intersect($tags, $a_tags)) > 0) {
30
-			$article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
29
+        if (count(array_intersect($tags, $a_tags)) > 0) {
30
+            $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
31 31
 				<div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
32
-		}
32
+        }
33 33
 
34
-		return $article;
35
-	}
34
+        return $article;
35
+    }
36 36
 
37
-	public function hook_render_article_cdm($article) {
38
-		$tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
39
-		$a_tags = array_map("trim", explode(",", $article["tag_cache"]));
37
+    public function hook_render_article_cdm($article) {
38
+        $tags = array_map("trim", explode(",", $this->host->get($this, "tags")));
39
+        $a_tags = array_map("trim", explode(",", $article["tag_cache"]));
40 40
 
41
-		if (count(array_intersect($tags, $a_tags)) > 0) {
42
-			$article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
41
+        if (count(array_intersect($tags, $a_tags)) > 0) {
42
+            $article["content"] = "<div class='nswf wrapper'><button onclick=\"nsfwShow(this)\">".__("Not work safe (click to toggle)")."</button>
43 43
 				<div class='nswf content' style='display : none'>".$article["content"]."</div></div>";
44
-		}
44
+        }
45 45
 
46
-		return $article;
47
-	}
46
+        return $article;
47
+    }
48 48
 
49
-	public function hook_prefs_tab($args) {
50
-		if ($args != "prefPrefs") return;
49
+    public function hook_prefs_tab($args) {
50
+        if ($args != "prefPrefs") return;
51 51
 
52
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
52
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
53 53
 			title=\"<i class='material-icons'>extension</i> ".__("NSFW Plugin")."\">";
54 54
 
55
-		print "<br/>";
55
+        print "<br/>";
56 56
 
57
-		$tags = $this->host->get($this, "tags");
57
+        $tags = $this->host->get($this, "tags");
58 58
 
59
-		print "<form dojoType=\"dijit.form.Form\">";
59
+        print "<form dojoType=\"dijit.form.Form\">";
60 60
 
61
-		print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
61
+        print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
62 62
 			evt.preventDefault();
63 63
 			if (this.validate()) {
64 64
 				new Ajax.Request('backend.php', {
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
 			}
72 72
 			</script>";
73 73
 
74
-			print_hidden("op", "pluginhandler");
75
-			print_hidden("method", "save");
76
-			print_hidden("plugin", "nsfw");
74
+            print_hidden("op", "pluginhandler");
75
+            print_hidden("method", "save");
76
+            print_hidden("plugin", "nsfw");
77 77
 
78
-			print "<table width=\"100%\" class=\"prefPrefsList\">";
78
+            print "<table width=\"100%\" class=\"prefPrefsList\">";
79 79
 
80
-			print "<tr><td width=\"40%\">".__("Tags to consider NSFW (comma-separated)")."</td>";
81
-			print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"tags\" value=\"$tags\"></td></tr>";
80
+            print "<tr><td width=\"40%\">".__("Tags to consider NSFW (comma-separated)")."</td>";
81
+            print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"tags\" value=\"$tags\"></td></tr>";
82 82
 
83
-			print "</table>";
83
+            print "</table>";
84 84
 
85
-			print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
86
-				__("Save")."</button>";
85
+            print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
86
+                __("Save")."</button>";
87 87
 
88
-			print "</form>";
88
+            print "</form>";
89 89
 
90
-			print "</div>"; #pane
91
-	}
90
+            print "</div>"; #pane
91
+    }
92 92
 
93
-	public function save() {
94
-		$tags = explode(",", $_POST["tags"]);
95
-		$tags = array_map("trim", $tags);
96
-		$tags = array_map("mb_strtolower", $tags);
97
-		$tags = join(", ", $tags);
93
+    public function save() {
94
+        $tags = explode(",", $_POST["tags"]);
95
+        $tags = array_map("trim", $tags);
96
+        $tags = array_map("mb_strtolower", $tags);
97
+        $tags = join(", ", $tags);
98 98
 
99
-		$this->host->set($this, "tags", $tags);
99
+        $this->host->set($this, "tags", $tags);
100 100
 
101
-		echo __("Configuration saved.");
102
-	}
101
+        echo __("Configuration saved.");
102
+    }
103 103
 
104
-	public function api_version() {
105
-		return 2;
106
-	}
104
+    public function api_version() {
105
+        return 2;
106
+    }
107 107
 
108 108
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,9 @@
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	public function hook_prefs_tab($args) {
50
-		if ($args != "prefPrefs") return;
50
+		if ($args != "prefPrefs") {
51
+		    return;
52
+		}
51 53
 
52 54
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
53 55
 			title=\"<i class='material-icons'>extension</i> ".__("NSFW Plugin")."\">";
Please login to merge, or discard this patch.
plugins/auth_remote/init.php 3 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	}
14 14
 
15 15
 	/* @var PluginHost $host */
16
-	public function init($host ) {
16
+	public function init($host) {
17 17
 		$this->host = $host;
18 18
 		$this->base = new Auth_Base();
19 19
 
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
 				$_SESSION["hide_logout"] = true;
60 60
 
61 61
 				// LemonLDAP can send user informations via HTTP HEADER
62
-				if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){
62
+				if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE) {
63 63
 					// update user name
64 64
 					$fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN'];
65
-					if ($fullname){
65
+					if ($fullname) {
66 66
 						$sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?");
67 67
 						$sth->execute([$fullname, $user_id]);
68 68
 					}
69 69
 					// update user mail
70 70
 					$email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL'];
71
-					if ($email){
71
+					if ($email) {
72 72
 						$sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?");
73 73
 						$sth->execute([$email, $user_id]);
74 74
 					}
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -1,88 +1,88 @@
 block discarded – undo
1 1
 <?php
2 2
 class Auth_Remote extends Plugin implements IAuthModule {
3 3
 
4
-	private $host;
5
-	/* @var Auth_Base $base */
6
-	private $base;
7
-
8
-	public function about() {
9
-		return array(1.0,
10
-			"Authenticates against remote password (e.g. supplied by Apache)",
11
-			"fox",
12
-			true);
13
-	}
14
-
15
-	/* @var PluginHost $host */
16
-	public function init($host ) {
17
-		$this->host = $host;
18
-		$this->base = new Auth_Base();
19
-
20
-		$host->add_hook($host::HOOK_AUTH_USER, $this);
21
-	}
22
-
23
-	public function get_login_by_ssl_certificate() {
24
-		$cert_serial = get_ssl_certificate_id();
25
-
26
-		if ($cert_serial) {
27
-			$sth = $this->pdo->prepare("SELECT login FROM ttrss_user_prefs, ttrss_users
4
+    private $host;
5
+    /* @var Auth_Base $base */
6
+    private $base;
7
+
8
+    public function about() {
9
+        return array(1.0,
10
+            "Authenticates against remote password (e.g. supplied by Apache)",
11
+            "fox",
12
+            true);
13
+    }
14
+
15
+    /* @var PluginHost $host */
16
+    public function init($host ) {
17
+        $this->host = $host;
18
+        $this->base = new Auth_Base();
19
+
20
+        $host->add_hook($host::HOOK_AUTH_USER, $this);
21
+    }
22
+
23
+    public function get_login_by_ssl_certificate() {
24
+        $cert_serial = get_ssl_certificate_id();
25
+
26
+        if ($cert_serial) {
27
+            $sth = $this->pdo->prepare("SELECT login FROM ttrss_user_prefs, ttrss_users
28 28
 				WHERE pref_name = 'SSL_CERT_SERIAL' AND value = ? AND
29 29
 				owner_uid = ttrss_users.id");
30
-			$sth->execute([$cert_serial]);
31
-
32
-			if ($row = $sth->fetch()) {
33
-				return $row['login'];
34
-			}
35
-		}
36
-
37
-		return "";
38
-	}
39
-
40
-	/**
41
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
42
-	 */
43
-	public function authenticate($login, $password) {
44
-		$try_login = $_SERVER["REMOTE_USER"];
45
-
46
-		// php-cgi
47
-		if (!$try_login) $try_login = $_SERVER["REDIRECT_REMOTE_USER"];
48
-		if (!$try_login) $try_login = $_SERVER["PHP_AUTH_USER"];
49
-
50
-		if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
51
-
52
-		if ($try_login) {
53
-			$user_id = $this->base->auto_create_user($try_login, $password);
54
-
55
-			if ($user_id) {
56
-				$_SESSION["fake_login"] = $try_login;
57
-				$_SESSION["fake_password"] = "******";
58
-				$_SESSION["hide_hello"] = true;
59
-				$_SESSION["hide_logout"] = true;
60
-
61
-				// LemonLDAP can send user informations via HTTP HEADER
62
-				if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){
63
-					// update user name
64
-					$fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN'];
65
-					if ($fullname){
66
-						$sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?");
67
-						$sth->execute([$fullname, $user_id]);
68
-					}
69
-					// update user mail
70
-					$email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL'];
71
-					if ($email){
72
-						$sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?");
73
-						$sth->execute([$email, $user_id]);
74
-					}
75
-				}
76
-
77
-				return $user_id;
78
-			}
79
-		}
80
-
81
-		return false;
82
-	}
83
-
84
-	public function api_version() {
85
-		return 2;
86
-	}
30
+            $sth->execute([$cert_serial]);
31
+
32
+            if ($row = $sth->fetch()) {
33
+                return $row['login'];
34
+            }
35
+        }
36
+
37
+        return "";
38
+    }
39
+
40
+    /**
41
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
42
+     */
43
+    public function authenticate($login, $password) {
44
+        $try_login = $_SERVER["REMOTE_USER"];
45
+
46
+        // php-cgi
47
+        if (!$try_login) $try_login = $_SERVER["REDIRECT_REMOTE_USER"];
48
+        if (!$try_login) $try_login = $_SERVER["PHP_AUTH_USER"];
49
+
50
+        if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
51
+
52
+        if ($try_login) {
53
+            $user_id = $this->base->auto_create_user($try_login, $password);
54
+
55
+            if ($user_id) {
56
+                $_SESSION["fake_login"] = $try_login;
57
+                $_SESSION["fake_password"] = "******";
58
+                $_SESSION["hide_hello"] = true;
59
+                $_SESSION["hide_logout"] = true;
60
+
61
+                // LemonLDAP can send user informations via HTTP HEADER
62
+                if (defined('AUTH_AUTO_CREATE') && AUTH_AUTO_CREATE){
63
+                    // update user name
64
+                    $fullname = $_SERVER['HTTP_USER_NAME'] ? $_SERVER['HTTP_USER_NAME'] : $_SERVER['AUTHENTICATE_CN'];
65
+                    if ($fullname){
66
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users SET full_name = ? WHERE id = ?");
67
+                        $sth->execute([$fullname, $user_id]);
68
+                    }
69
+                    // update user mail
70
+                    $email = $_SERVER['HTTP_USER_MAIL'] ? $_SERVER['HTTP_USER_MAIL'] : $_SERVER['AUTHENTICATE_MAIL'];
71
+                    if ($email){
72
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users SET email = ? WHERE id = ?");
73
+                        $sth->execute([$email, $user_id]);
74
+                    }
75
+                }
76
+
77
+                return $user_id;
78
+            }
79
+        }
80
+
81
+        return false;
82
+    }
83
+
84
+    public function api_version() {
85
+        return 2;
86
+    }
87 87
 
88 88
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,10 +44,16 @@
 block discarded – undo
44 44
 		$try_login = $_SERVER["REMOTE_USER"];
45 45
 
46 46
 		// php-cgi
47
-		if (!$try_login) $try_login = $_SERVER["REDIRECT_REMOTE_USER"];
48
-		if (!$try_login) $try_login = $_SERVER["PHP_AUTH_USER"];
47
+		if (!$try_login) {
48
+		    $try_login = $_SERVER["REDIRECT_REMOTE_USER"];
49
+		}
50
+		if (!$try_login) {
51
+		    $try_login = $_SERVER["PHP_AUTH_USER"];
52
+		}
49 53
 
50
-		if (!$try_login) $try_login = $this->get_login_by_ssl_certificate();
54
+		if (!$try_login) {
55
+		    $try_login = $this->get_login_by_ssl_certificate();
56
+		}
51 57
 
52 58
 		if ($try_login) {
53 59
 			$user_id = $this->base->auto_create_user($try_login, $password);
Please login to merge, or discard this patch.
plugins/bookmarklets/init.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 		print "<div dojoType=\"dijit.layout.AccordionPane\"
23 23
 			title=\"<i class='material-icons'>bookmark</i> ".__('Bookmarklets')."\">";
24 24
 
25
-		print "<h3>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</h3>";
25
+		print "<h3>".__("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.")."</h3>";
26 26
 
27 27
 		$bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url());
28 28
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 		$bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
32 32
 
33 33
 		print "<p><label class='dijitButton'>";
34
-		print "<a href=\"$bm_url\">" . __('Subscribe in Tiny Tiny RSS'). "</a>";
34
+		print "<a href=\"$bm_url\">".__('Subscribe in Tiny Tiny RSS')."</a>";
35 35
 		print "</label></p>";
36 36
 
37
-		print "<h3>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</h3>";
37
+		print "<h3>".__("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS")."</h3>";
38 38
 
39 39
 		print "<label class='dijitButton'>";
40 40
 		$bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()");
41
-		print "<a href=\"$bm_url\">" . __('Share with Tiny Tiny RSS'). "</a>";
41
+		print "<a href=\"$bm_url\">".__('Share with Tiny Tiny RSS')."</a>";
42 42
 		print "</label>";
43 43
 
44 44
 		print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'>
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,56 +1,56 @@
 block discarded – undo
1 1
 <?php
2 2
 class Bookmarklets extends Plugin {
3
-  private $host;
3
+    private $host;
4 4
 
5
-  function about() {
5
+    function about() {
6 6
     return array(1.0,
7
-		 "Easy feed subscription and web page sharing using bookmarklets",
8
-		 "fox",
9
-	     false,
10
-		 "https://git.tt-rss.org/fox/tt-rss/wiki/ShareAnything");
11
-  }
7
+            "Easy feed subscription and web page sharing using bookmarklets",
8
+            "fox",
9
+            false,
10
+            "https://git.tt-rss.org/fox/tt-rss/wiki/ShareAnything");
11
+    }
12 12
 
13
-  function init($host) {
13
+    function init($host) {
14 14
     $this->host = $host;
15 15
 
16 16
     $host->add_hook($host::HOOK_PREFS_TAB, $this);
17
-  }
17
+    }
18 18
 
19
-  function hook_prefs_tab($args) {
19
+    function hook_prefs_tab($args) {
20 20
     if ($args == "prefFeeds") {
21 21
 
22
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
22
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
23 23
 			title=\"<i class='material-icons'>bookmark</i> ".__('Bookmarklets')."\">";
24 24
 
25
-		print "<h3>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</h3>";
25
+        print "<h3>" . __("Drag the link below to your browser toolbar, open the feed you're interested in in your browser and click on the link to subscribe to it.") . "</h3>";
26 26
 
27
-		$bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url());
27
+        $bm_subscribe_url = str_replace('%s', '', Pref_Feeds::subscribe_to_feed_url());
28 28
 
29
-		$confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?'));
29
+        $confirm_str = str_replace("'", "\'", __('Subscribe to %s in Tiny Tiny RSS?'));
30 30
 
31
-		$bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
31
+        $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
32 32
 
33
-		print "<p><label class='dijitButton'>";
34
-		print "<a href=\"$bm_url\">" . __('Subscribe in Tiny Tiny RSS'). "</a>";
35
-		print "</label></p>";
33
+        print "<p><label class='dijitButton'>";
34
+        print "<a href=\"$bm_url\">" . __('Subscribe in Tiny Tiny RSS'). "</a>";
35
+        print "</label></p>";
36 36
 
37
-		print "<h3>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</h3>";
37
+        print "<h3>" . __("Use this bookmarklet to publish arbitrary pages using Tiny Tiny RSS") . "</h3>";
38 38
 
39
-		print "<label class='dijitButton'>";
40
-		$bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()");
41
-		print "<a href=\"$bm_url\">" . __('Share with Tiny Tiny RSS'). "</a>";
42
-		print "</label>";
39
+        print "<label class='dijitButton'>";
40
+        $bm_url = htmlspecialchars("javascript:(function(){var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='".get_self_url_prefix()."/public.php?op=sharepopup',l=d.location,e=encodeURIComponent,g=f+'&title='+((e(s))?e(s):e(document.title))+'&url='+e(l.href);function a(){if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=500,height=250')){l.href=g;}}a();})()");
41
+        print "<a href=\"$bm_url\">" . __('Share with Tiny Tiny RSS'). "</a>";
42
+        print "</label>";
43 43
 
44
-		print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'>
44
+        print "<button dojoType='dijit.form.Button' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ShareAnything\")'>
45 45
 					<i class='material-icons'>help</i> ".__("More info...")."</button>";
46 46
 
47
-		print "</div>"; #pane
47
+        print "</div>"; #pane
48 48
 
49
-	 }
50
-  }
49
+        }
50
+    }
51 51
 
52
-	public function api_version() {
53
-		return 2;
54
-	}
52
+    public function api_version() {
53
+        return 2;
54
+    }
55 55
 
56 56
 }
Please login to merge, or discard this patch.
plugins/note/init.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	public function get_js() {
20
-		return file_get_contents(dirname(__FILE__) . "/note.js");
20
+		return file_get_contents(dirname(__FILE__)."/note.js");
21 21
 	}
22 22
 
23 23
 
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,78 +1,78 @@
 block discarded – undo
1 1
 <?php
2 2
 class Note extends Plugin {
3 3
 
4
-	/* @var PluginHost $host */
5
-	private $host;
4
+    /* @var PluginHost $host */
5
+    private $host;
6 6
 
7
-	public function about() {
8
-		return array(1.0,
9
-			"Adds support for setting article notes",
10
-			"fox");
11
-	}
7
+    public function about() {
8
+        return array(1.0,
9
+            "Adds support for setting article notes",
10
+            "fox");
11
+    }
12 12
 
13
-	public function init($host) {
14
-		$this->host = $host;
13
+    public function init($host) {
14
+        $this->host = $host;
15 15
 
16
-		$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
17
-	}
16
+        $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
17
+    }
18 18
 
19
-	public function get_js() {
20
-		return file_get_contents(dirname(__FILE__) . "/note.js");
21
-	}
19
+    public function get_js() {
20
+        return file_get_contents(dirname(__FILE__) . "/note.js");
21
+    }
22 22
 
23 23
 
24
-	public function hook_article_button($line) {
25
-		return "<i class='material-icons' onclick=\"Plugins.Note.edit(".$line["id"].")\"
24
+    public function hook_article_button($line) {
25
+        return "<i class='material-icons' onclick=\"Plugins.Note.edit(".$line["id"].")\"
26 26
 			style='cursor : pointer' title='".__('Edit article note')."'>note</i>";
27
-	}
27
+    }
28 28
 
29
-	public function edit() {
30
-		$param = $_REQUEST['param'];
29
+    public function edit() {
30
+        $param = $_REQUEST['param'];
31 31
 
32
-		$sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE
32
+        $sth = $this->pdo->prepare("SELECT note FROM ttrss_user_entries WHERE
33 33
 			ref_id = ? AND owner_uid = ?");
34
-		$sth->execute([$param, $_SESSION['uid']]);
34
+        $sth->execute([$param, $_SESSION['uid']]);
35 35
 
36
-		if ($row = $sth->fetch()) {
36
+        if ($row = $sth->fetch()) {
37 37
 
38
-			$note = $row['note'];
38
+            $note = $row['note'];
39 39
 
40
-			print_hidden("id", "$param");
41
-			print_hidden("op", "pluginhandler");
42
-			print_hidden("method", "setNote");
43
-			print_hidden("plugin", "note");
40
+            print_hidden("id", "$param");
41
+            print_hidden("op", "pluginhandler");
42
+            print_hidden("method", "setNote");
43
+            print_hidden("plugin", "note");
44 44
 
45
-			print "<textarea dojoType='dijit.form.SimpleTextarea'
45
+            print "<textarea dojoType='dijit.form.SimpleTextarea'
46 46
 				style='font-size : 12px; width : 98%; height: 100px;'
47 47
 				name='note'>$note</textarea>";
48 48
 
49
-		}
49
+        }
50 50
 
51
-		print "<footer class='text-center'>";
52
-		print "<button dojoType=\"dijit.form.Button\"
51
+        print "<footer class='text-center'>";
52
+        print "<button dojoType=\"dijit.form.Button\"
53 53
 			onclick=\"dijit.byId('editNoteDlg').execute()\">".__('Save')."</button> ";
54
-		print "<button dojoType=\"dijit.form.Button\"
54
+        print "<button dojoType=\"dijit.form.Button\"
55 55
 			onclick=\"dijit.byId('editNoteDlg').hide()\">".__('Cancel')."</button>";
56
-		print "</footer>";
56
+        print "</footer>";
57 57
 
58
-	}
58
+    }
59 59
 
60
-	public function setNote() {
61
-		$id = $_REQUEST["id"];
62
-		$note = trim(strip_tags($_REQUEST["note"]));
60
+    public function setNote() {
61
+        $id = $_REQUEST["id"];
62
+        $note = trim(strip_tags($_REQUEST["note"]));
63 63
 
64
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ?
64
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET note = ?
65 65
 			WHERE ref_id = ? AND owner_uid = ?");
66
-		$sth->execute([$note, $id, $_SESSION['uid']]);
66
+        $sth->execute([$note, $id, $_SESSION['uid']]);
67 67
 
68
-		$formatted_note = Article::format_article_note($id, $note);
68
+        $formatted_note = Article::format_article_note($id, $note);
69 69
 
70
-		print json_encode(array("note" => $formatted_note,
71
-				"raw_length" => mb_strlen($note)));
72
-	}
70
+        print json_encode(array("note" => $formatted_note,
71
+                "raw_length" => mb_strlen($note)));
72
+    }
73 73
 
74
-	public function api_version() {
75
-		return 2;
76
-	}
74
+    public function api_version() {
75
+        return 2;
76
+    }
77 77
 
78 78
 }
Please login to merge, or discard this patch.
plugins/no_title_counters/init.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function get_js() {
17
-		return file_get_contents(__DIR__ . "/init.js");
17
+		return file_get_contents(__DIR__."/init.js");
18 18
 	}
19 19
 
20 20
 	public function api_version() {
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,24 +1,24 @@
 block discarded – undo
1 1
 <?php
2 2
 class No_Title_Counters extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Remove counters from window title (prevents tab flashing on new articles)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Remove counters from window title (prevents tab flashing on new articles)",
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
-	}
14
+    }
15 15
 
16
-	public function get_js() {
17
-		return file_get_contents(__DIR__ . "/init.js");
18
-	}
16
+    public function get_js() {
17
+        return file_get_contents(__DIR__ . "/init.js");
18
+    }
19 19
 
20
-	public function api_version() {
21
-		return 2;
22
-	}
20
+    public function api_version() {
21
+        return 2;
22
+    }
23 23
 
24 24
 }
Please login to merge, or discard this patch.