Passed
Branch master (a3c0d0)
by Cody
02:54
created
plugins/auth_internal/init.php 1 patch
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,63 +1,63 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Auth_Internal extends Plugin implements IAuthModule {
3 3
 
4
-	private $host;
4
+    private $host;
5 5
 
6
-	public function about() {
7
-		return array(1.0,
8
-			"Authenticates against internal tt-rss database",
9
-			"fox",
10
-			true);
11
-	}
6
+    public function about() {
7
+        return array(1.0,
8
+            "Authenticates against internal tt-rss database",
9
+            "fox",
10
+            true);
11
+    }
12 12
 
13
-	/* @var PluginHost $host */
14
-	public function init($host) {
15
-		$this->host = $host;
16
-		$this->pdo = Db::pdo();
13
+    /* @var PluginHost $host */
14
+    public function init($host) {
15
+        $this->host = $host;
16
+        $this->pdo = Db::pdo();
17 17
 
18
-		$host->add_hook($host::HOOK_AUTH_USER, $this);
19
-	}
18
+        $host->add_hook($host::HOOK_AUTH_USER, $this);
19
+    }
20 20
 
21
-	public function authenticate($login, $password, $service = '') {
21
+    public function authenticate($login, $password, $service = '') {
22 22
 
23
-		$pwd_hash1 = encrypt_password($password);
24
-		$pwd_hash2 = encrypt_password($password, $login);
25
-		$otp = $_REQUEST["otp"];
23
+        $pwd_hash1 = encrypt_password($password);
24
+        $pwd_hash2 = encrypt_password($password, $login);
25
+        $otp = $_REQUEST["otp"];
26 26
 
27
-		if (get_schema_version() > 96) {
27
+        if (get_schema_version() > 96) {
28 28
 
29
-			$sth = $this->pdo->prepare("SELECT otp_enabled,salt FROM ttrss_users WHERE
29
+            $sth = $this->pdo->prepare("SELECT otp_enabled,salt FROM ttrss_users WHERE
30 30
 				login = ?");
31
-			$sth->execute([$login]);
31
+            $sth->execute([$login]);
32 32
 
33
-			if ($row = $sth->fetch()) {
34
-				$otp_enabled = $row['otp_enabled'];
33
+            if ($row = $sth->fetch()) {
34
+                $otp_enabled = $row['otp_enabled'];
35 35
 
36
-				if ($otp_enabled) {
36
+                if ($otp_enabled) {
37 37
 
38
-					// only allow app password checking if OTP is enabled
39
-					if ($service && get_schema_version() > 138) {
40
-						return $this->check_app_password($login, $password, $service);
41
-					}
38
+                    // only allow app password checking if OTP is enabled
39
+                    if ($service && get_schema_version() > 138) {
40
+                        return $this->check_app_password($login, $password, $service);
41
+                    }
42 42
 
43
-					if ($otp) {
44
-						$base32 = new \OTPHP\Base32();
43
+                    if ($otp) {
44
+                        $base32 = new \OTPHP\Base32();
45 45
 
46
-						$secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false);
47
-						$secret_legacy = $base32->encode(sha1($row["salt"]));
46
+                        $secret = $base32->encode(mb_substr(sha1($row["salt"]), 0, 12), false);
47
+                        $secret_legacy = $base32->encode(sha1($row["salt"]));
48 48
 
49
-						$totp = new \OTPHP\TOTP($secret);
50
-						$otp_check = $totp->now();
49
+                        $totp = new \OTPHP\TOTP($secret);
50
+                        $otp_check = $totp->now();
51 51
 
52
-						$totp_legacy = new \OTPHP\TOTP($secret_legacy);
53
-						$otp_check_legacy = $totp_legacy->now();
52
+                        $totp_legacy = new \OTPHP\TOTP($secret_legacy);
53
+                        $otp_check_legacy = $totp_legacy->now();
54 54
 
55
-						if ($otp != $otp_check && $otp != $otp_check_legacy) {
56
-							return false;
57
-						}
58
-					} else {
59
-						$return = urlencode($_REQUEST["return"]);
60
-						?>
55
+                        if ($otp != $otp_check && $otp != $otp_check_legacy) {
56
+                            return false;
57
+                        }
58
+                    } else {
59
+                        $return = urlencode($_REQUEST["return"]);
60
+                        ?>
61 61
 						<!DOCTYPE html>
62 62
 						<html>
63 63
 							<head>
@@ -87,208 +87,208 @@  discard block
 block discarded – undo
87 87
 							document.forms[0].otp.focus();
88 88
 						</script>
89 89
 						<?php
90
-						exit;
91
-					}
92
-				}
93
-			}
94
-		}
90
+                        exit;
91
+                    }
92
+                }
93
+            }
94
+        }
95 95
 
96
-		// check app passwords first but allow regular password as a fallback for the time being
97
-		// if OTP is not enabled
96
+        // check app passwords first but allow regular password as a fallback for the time being
97
+        // if OTP is not enabled
98 98
 
99
-		if ($service && get_schema_version() > 138) {
100
-			$user_id = $this->check_app_password($login, $password, $service);
99
+        if ($service && get_schema_version() > 138) {
100
+            $user_id = $this->check_app_password($login, $password, $service);
101 101
 
102
-			if ($user_id)
103
-				return $user_id;
104
-		}
102
+            if ($user_id)
103
+                return $user_id;
104
+        }
105 105
 
106
-		if (get_schema_version() > 87) {
106
+        if (get_schema_version() > 87) {
107 107
 
108
-			$sth = $this->pdo->prepare("SELECT salt FROM ttrss_users WHERE login = ?");
109
-			$sth->execute([$login]);
108
+            $sth = $this->pdo->prepare("SELECT salt FROM ttrss_users WHERE login = ?");
109
+            $sth->execute([$login]);
110 110
 
111
-			if ($row = $sth->fetch()) {
112
-				$salt = $row['salt'];
111
+            if ($row = $sth->fetch()) {
112
+                $salt = $row['salt'];
113 113
 
114
-				if ($salt == "") {
114
+                if ($salt == "") {
115 115
 
116
-					$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
116
+                    $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
117 117
 						login = ? AND (pwd_hash = ? OR pwd_hash = ?)");
118 118
 
119
-					$sth->execute([$login, $pwd_hash1, $pwd_hash2]);
119
+                    $sth->execute([$login, $pwd_hash1, $pwd_hash2]);
120 120
 
121
-					// verify and upgrade password to new salt base
121
+                    // verify and upgrade password to new salt base
122 122
 
123
-					if ($row = $sth->fetch()) {
124
-						// upgrade password to MODE2
123
+                    if ($row = $sth->fetch()) {
124
+                        // upgrade password to MODE2
125 125
 
126
-						$user_id = $row['id'];
126
+                        $user_id = $row['id'];
127 127
 
128
-						$salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
129
-						$pwd_hash = encrypt_password($password, $salt, true);
128
+                        $salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
129
+                        $pwd_hash = encrypt_password($password, $salt, true);
130 130
 
131
-						$sth = $this->pdo->prepare("UPDATE ttrss_users SET
131
+                        $sth = $this->pdo->prepare("UPDATE ttrss_users SET
132 132
 							pwd_hash = ?, salt = ? WHERE login = ?");
133 133
 
134
-						$sth->execute([$pwd_hash, $salt, $login]);
134
+                        $sth->execute([$pwd_hash, $salt, $login]);
135 135
 
136
-						return $user_id;
136
+                        return $user_id;
137 137
 
138
-					} else {
139
-						return false;
140
-					}
138
+                    } else {
139
+                        return false;
140
+                    }
141 141
 
142
-				} else {
143
-					$pwd_hash = encrypt_password($password, $salt, true);
142
+                } else {
143
+                    $pwd_hash = encrypt_password($password, $salt, true);
144 144
 
145
-					$sth = $this->pdo->prepare("SELECT id
145
+                    $sth = $this->pdo->prepare("SELECT id
146 146
 						  FROM ttrss_users WHERE
147 147
 						  login = ? AND pwd_hash = ?");
148
-					$sth->execute([$login, $pwd_hash]);
148
+                    $sth->execute([$login, $pwd_hash]);
149 149
 
150
-					if ($row = $sth->fetch()) {
151
-						return $row['id'];
152
-					}
153
-				}
150
+                    if ($row = $sth->fetch()) {
151
+                        return $row['id'];
152
+                    }
153
+                }
154 154
 
155
-			} else {
156
-				$sth = $this->pdo->prepare("SELECT id
155
+            } else {
156
+                $sth = $this->pdo->prepare("SELECT id
157 157
 					FROM ttrss_users WHERE
158 158
 					  login = ? AND (pwd_hash = ? OR pwd_hash = ?)");
159 159
 
160
-				$sth->execute([$login, $pwd_hash1, $pwd_hash2]);
160
+                $sth->execute([$login, $pwd_hash1, $pwd_hash2]);
161 161
 
162
-				if ($row = $sth->fetch()) {
163
-					return $row['id'];
164
-				}
165
-			}
166
-		} else {
167
-			$sth = $this->pdo->prepare("SELECT id
162
+                if ($row = $sth->fetch()) {
163
+                    return $row['id'];
164
+                }
165
+            }
166
+        } else {
167
+            $sth = $this->pdo->prepare("SELECT id
168 168
 					FROM ttrss_users WHERE
169 169
 					  login = ? AND (pwd_hash = ? OR pwd_hash = ?)");
170 170
 
171
-			$sth->execute([$login, $pwd_hash1, $pwd_hash2]);
171
+            $sth->execute([$login, $pwd_hash1, $pwd_hash2]);
172 172
 
173
-			if ($row = $sth->fetch()) {
174
-				return $row['id'];
175
-			}
176
-		}
173
+            if ($row = $sth->fetch()) {
174
+                return $row['id'];
175
+            }
176
+        }
177 177
 
178
-		return false;
179
-	}
178
+        return false;
179
+    }
180 180
 
181
-	public function check_password($owner_uid, $password) {
181
+    public function check_password($owner_uid, $password) {
182 182
 
183
-		$sth = $this->pdo->prepare("SELECT salt,login,otp_enabled FROM ttrss_users WHERE
183
+        $sth = $this->pdo->prepare("SELECT salt,login,otp_enabled FROM ttrss_users WHERE
184 184
 			id = ?");
185
-		$sth->execute([$owner_uid]);
185
+        $sth->execute([$owner_uid]);
186 186
 
187
-		if ($row = $sth->fetch()) {
187
+        if ($row = $sth->fetch()) {
188 188
 
189
-			$salt = $row['salt'];
190
-			$login = $row['login'];
189
+            $salt = $row['salt'];
190
+            $login = $row['login'];
191 191
 
192
-			if (!$salt) {
193
-				$password_hash1 = encrypt_password($password);
194
-				$password_hash2 = encrypt_password($password, $login);
192
+            if (!$salt) {
193
+                $password_hash1 = encrypt_password($password);
194
+                $password_hash2 = encrypt_password($password, $login);
195 195
 
196
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
196
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
197 197
 					id = ? AND (pwd_hash = ? OR pwd_hash = ?)");
198 198
 
199
-				$sth->execute([$owner_uid, $password_hash1, $password_hash2]);
199
+                $sth->execute([$owner_uid, $password_hash1, $password_hash2]);
200 200
 
201
-				return $sth->fetch();
201
+                return $sth->fetch();
202 202
 
203
-			} else {
204
-				$password_hash = encrypt_password($password, $salt, true);
203
+            } else {
204
+                $password_hash = encrypt_password($password, $salt, true);
205 205
 
206
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
206
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE
207 207
 					id = ? AND pwd_hash = ?");
208 208
 
209
-				$sth->execute([$owner_uid, $password_hash]);
209
+                $sth->execute([$owner_uid, $password_hash]);
210 210
 
211
-				return $sth->fetch();
212
-			}
213
-		}
211
+                return $sth->fetch();
212
+            }
213
+        }
214 214
 
215
-		return false;
216
-	}
215
+        return false;
216
+    }
217 217
 
218
-	public function change_password($owner_uid, $old_password, $new_password) {
218
+    public function change_password($owner_uid, $old_password, $new_password) {
219 219
 
220
-		if ($this->check_password($owner_uid, $old_password)) {
220
+        if ($this->check_password($owner_uid, $old_password)) {
221 221
 
222
-			$new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
223
-			$new_password_hash = encrypt_password($new_password, $new_salt, true);
222
+            $new_salt = substr(bin2hex(get_random_bytes(125)), 0, 250);
223
+            $new_password_hash = encrypt_password($new_password, $new_salt, true);
224 224
 
225
-			$sth = $this->pdo->prepare("UPDATE ttrss_users SET
225
+            $sth = $this->pdo->prepare("UPDATE ttrss_users SET
226 226
 				pwd_hash = ?, salt = ?, otp_enabled = false
227 227
 					WHERE id = ?");
228
-			$sth->execute([$new_password_hash, $new_salt, $owner_uid]);
228
+            $sth->execute([$new_password_hash, $new_salt, $owner_uid]);
229 229
 
230
-			$_SESSION["pwd_hash"] = $new_password_hash;
230
+            $_SESSION["pwd_hash"] = $new_password_hash;
231 231
 
232
-			$sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?");
233
-			$sth->execute([$owner_uid]);
232
+            $sth = $this->pdo->prepare("SELECT email, login FROM ttrss_users WHERE id = ?");
233
+            $sth->execute([$owner_uid]);
234 234
 
235
-			if ($row = $sth->fetch()) {
236
-				$mailer = new Mailer();
235
+            if ($row = $sth->fetch()) {
236
+                $mailer = new Mailer();
237 237
 
238
-				require_once "lib/MiniTemplator.class.php";
238
+                require_once "lib/MiniTemplator.class.php";
239 239
 
240
-				$tpl = new MiniTemplator;
240
+                $tpl = new MiniTemplator;
241 241
 
242
-				$tpl->readTemplateFromFile("templates/password_change_template.txt");
242
+                $tpl->readTemplateFromFile("templates/password_change_template.txt");
243 243
 
244
-				$tpl->setVariable('LOGIN', $row["login"]);
245
-				$tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
244
+                $tpl->setVariable('LOGIN', $row["login"]);
245
+                $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH);
246 246
 
247
-				$tpl->addBlock('message');
247
+                $tpl->addBlock('message');
248 248
 
249
-				$tpl->generateOutputToString($message);
249
+                $tpl->generateOutputToString($message);
250 250
 
251
-				$mailer->mail(["to_name" => $row["login"],
252
-					"to_address" => $row["email"],
253
-					"subject" => "[tt-rss] Password change notification",
254
-					"message" => $message]);
251
+                $mailer->mail(["to_name" => $row["login"],
252
+                    "to_address" => $row["email"],
253
+                    "subject" => "[tt-rss] Password change notification",
254
+                    "message" => $message]);
255 255
 
256
-			}
256
+            }
257 257
 
258
-			return __("Password has been changed.");
259
-		} else {
260
-			return "ERROR: ".__('Old password is incorrect.');
261
-		}
262
-	}
258
+            return __("Password has been changed.");
259
+        } else {
260
+            return "ERROR: ".__('Old password is incorrect.');
261
+        }
262
+    }
263 263
 
264
-	private function check_app_password($login, $password, $service) {
265
-		$sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid
264
+    private function check_app_password($login, $password, $service) {
265
+        $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid
266 266
 			FROM ttrss_app_passwords p, ttrss_users u
267 267
 			WHERE p.owner_uid = u.id AND u.login = ? AND service = ?");
268
-		$sth->execute([$login, $service]);
268
+        $sth->execute([$login, $service]);
269 269
 
270
-		while ($row = $sth->fetch()) {
271
-			list ($algo, $hash, $salt) = explode(":", $row["pwd_hash"]);
270
+        while ($row = $sth->fetch()) {
271
+            list ($algo, $hash, $salt) = explode(":", $row["pwd_hash"]);
272 272
 
273
-			if ($algo == "SSHA-512") {
274
-				$test_hash = hash('sha512', $salt . $password);
273
+            if ($algo == "SSHA-512") {
274
+                $test_hash = hash('sha512', $salt . $password);
275 275
 
276
-				if ($test_hash == $hash) {
277
-					$usth = $this->pdo->prepare("UPDATE ttrss_app_passwords SET last_used = NOW() WHERE id = ?");
278
-					$usth->execute([$row['id']]);
276
+                if ($test_hash == $hash) {
277
+                    $usth = $this->pdo->prepare("UPDATE ttrss_app_passwords SET last_used = NOW() WHERE id = ?");
278
+                    $usth->execute([$row['id']]);
279 279
 
280
-					return $row['uid'];
281
-				}
282
-			} else {
283
-				user_error("Got unknown algo of app password for user $login: $algo");
284
-			}
285
-		}
280
+                    return $row['uid'];
281
+                }
282
+            } else {
283
+                user_error("Got unknown algo of app password for user $login: $algo");
284
+            }
285
+        }
286 286
 
287
-		return false;
288
-	}
287
+        return false;
288
+    }
289 289
 
290
-	public function api_version() {
291
-		return 2;
292
-	}
290
+    public function api_version() {
291
+        return 2;
292
+    }
293 293
 
294 294
 }
Please login to merge, or discard this patch.
plugins/cache_starred_images/init.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -1,43 +1,43 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Cache_Starred_Images extends Plugin {
3 3
 
4
-	/* @var PluginHost $host */
5
-	private $host;
6
-	/* @var DiskCache $cache */
7
-	private $cache;
4
+    /* @var PluginHost $host */
5
+    private $host;
6
+    /* @var DiskCache $cache */
7
+    private $cache;
8 8
     private $max_cache_attempts = 5; // per-article
9 9
 
10
-	public function about() {
11
-		return array(1.0,
12
-			"Automatically cache media files in Starred articles",
13
-			"fox");
14
-	}
10
+    public function about() {
11
+        return array(1.0,
12
+            "Automatically cache media files in Starred articles",
13
+            "fox");
14
+    }
15 15
 
16
-	public function init($host) {
17
-		$this->host = $host;
18
-		$this->cache = new DiskCache("starred-images");
16
+    public function init($host) {
17
+        $this->host = $host;
18
+        $this->cache = new DiskCache("starred-images");
19 19
 
20
-		if ($this->cache->makeDir())
21
-			chmod($this->cache->getDir(), 0777);
20
+        if ($this->cache->makeDir())
21
+            chmod($this->cache->getDir(), 0777);
22 22
 
23
-		if (!$this->cache->exists(".no-auto-expiry"))
24
-			$this->cache->touch(".no-auto-expiry");
23
+        if (!$this->cache->exists(".no-auto-expiry"))
24
+            $this->cache->touch(".no-auto-expiry");
25 25
 
26
-		if ($this->cache->isWritable()) {
27
-			$host->add_hook($host::HOOK_HOUSE_KEEPING, $this);
28
-			$host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
29
-			$host->add_hook($host::HOOK_SANITIZE, $this);
30
-		} else {
31
-			user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING);
32
-		}
33
-	}
26
+        if ($this->cache->isWritable()) {
27
+            $host->add_hook($host::HOOK_HOUSE_KEEPING, $this);
28
+            $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
29
+            $host->add_hook($host::HOOK_SANITIZE, $this);
30
+        } else {
31
+            user_error("Starred cache directory ".$this->cache->getDir()." is not writable.", E_USER_WARNING);
32
+        }
33
+    }
34 34
 
35
-	public function hook_house_keeping() {
36
-		/* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */
35
+    public function hook_house_keeping() {
36
+        /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */
37 37
 
38
-		Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
38
+        Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
39 39
 
40
-		$sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
40
+        $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title,
41 41
        		ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
42 42
 			FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON
43 43
 				(ttrss_user_entries.feed_id = ttrss_feeds.id)
@@ -48,115 +48,115 @@  discard block
 block discarded – undo
48 48
 				plugin_data NOT LIKE '%starred_cache_images%'
49 49
 			ORDER BY ".sql_random_function()." LIMIT 100");
50 50
 
51
-		if ($sth->execute([$this->host->get_owner_uid()])) {
51
+        if ($sth->execute([$this->host->get_owner_uid()])) {
52 52
 
53
-			$usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?");
53
+            $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?");
54 54
 
55
-			while ($line = $sth->fetch()) {
56
-				Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE);
55
+            while ($line = $sth->fetch()) {
56
+                Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE);
57 57
 
58
-				if ($line["site_url"]) {
59
-					$success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]);
58
+                if ($line["site_url"]) {
59
+                    $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]);
60 60
 
61
-					if ($success) {
62
-						$plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"];
61
+                    if ($success) {
62
+                        $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"];
63 63
 
64
-						$usth->execute([$plugin_data, $line['id']]);
65
-					}
66
-				}
67
-			}
68
-		}
64
+                        $usth->execute([$plugin_data, $line['id']]);
65
+                    }
66
+                }
67
+            }
68
+        }
69 69
 
70
-		/* actual housekeeping */
70
+        /* actual housekeeping */
71 71
 
72
-		Debug::log("expiring " . $this->cache->getDir() . "...");
72
+        Debug::log("expiring " . $this->cache->getDir() . "...");
73 73
 
74
-		$files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE);
74
+        $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE);
75 75
 
76
-		$last_article_id = 0;
77
-		$article_exists = 1;
76
+        $last_article_id = 0;
77
+        $article_exists = 1;
78 78
 
79
-		foreach ($files as $file) {
80
-			list ($article_id, $hash) = explode("-", basename($file));
79
+        foreach ($files as $file) {
80
+            list ($article_id, $hash) = explode("-", basename($file));
81 81
 
82
-			if ($article_id != $last_article_id) {
83
-				$last_article_id = $article_id;
82
+            if ($article_id != $last_article_id) {
83
+                $last_article_id = $article_id;
84 84
 
85
-				$sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?");
86
-				$sth->execute([$article_id]);
85
+                $sth = $this->pdo->prepare("SELECT id FROM ttrss_entries WHERE id = ?");
86
+                $sth->execute([$article_id]);
87 87
 
88
-				$article_exists = $sth->fetch();
89
-			}
88
+                $article_exists = $sth->fetch();
89
+            }
90 90
 
91
-			if (!$article_exists) {
92
-				unlink($file);
93
-			}
94
-		}
95
-	}
91
+            if (!$article_exists) {
92
+                unlink($file);
93
+            }
94
+        }
95
+    }
96 96
 
97
-	public function hook_enclosure_entry($enc, $article_id) {
98
-		$local_filename = $article_id . "-" . sha1($enc["content_url"]);
97
+    public function hook_enclosure_entry($enc, $article_id) {
98
+        $local_filename = $article_id . "-" . sha1($enc["content_url"]);
99 99
 
100
-		if ($this->cache->exists($local_filename)) {
101
-			$enc["content_url"] = $this->cache->getUrl($local_filename);
102
-		}
100
+        if ($this->cache->exists($local_filename)) {
101
+            $enc["content_url"] = $this->cache->getUrl($local_filename);
102
+        }
103 103
 
104
-		return $enc;
105
-	}
104
+        return $enc;
105
+    }
106 106
 
107
-	public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
108
-		$xpath = new DOMXpath($doc);
107
+    public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id) {
108
+        $xpath = new DOMXpath($doc);
109 109
 
110
-		if ($article_id) {
111
-			$entries = $xpath->query('(//img[@src])|(//video/source[@src])');
110
+        if ($article_id) {
111
+            $entries = $xpath->query('(//img[@src])|(//video/source[@src])');
112 112
 
113
-			foreach ($entries as $entry) {
114
-				if ($entry->hasAttribute('src')) {
115
-					$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
113
+            foreach ($entries as $entry) {
114
+                if ($entry->hasAttribute('src')) {
115
+                    $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
116 116
 
117
-					$local_filename = $article_id . "-" . sha1($src);
117
+                    $local_filename = $article_id . "-" . sha1($src);
118 118
 
119
-					if ($this->cache->exists($local_filename)) {
120
-						$entry->setAttribute("src", $this->cache->getUrl($local_filename));
121
-						$entry->removeAttribute("srcset");
122
-					}
123
-				}
124
-			}
125
-		}
119
+                    if ($this->cache->exists($local_filename)) {
120
+                        $entry->setAttribute("src", $this->cache->getUrl($local_filename));
121
+                        $entry->removeAttribute("srcset");
122
+                    }
123
+                }
124
+            }
125
+        }
126 126
 
127
-		return $doc;
128
-	}
127
+        return $doc;
128
+    }
129 129
 
130
-	private function cache_url($article_id, $url) {
131
-		$local_filename = $article_id . "-" . sha1($url);
130
+    private function cache_url($article_id, $url) {
131
+        $local_filename = $article_id . "-" . sha1($url);
132 132
 
133
-		if (!$this->cache->exists($local_filename)) {
134
-			Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE);
133
+        if (!$this->cache->exists($local_filename)) {
134
+            Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE);
135 135
 
136
-			$data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
136
+            $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
137 137
 
138
-			if ($data)
139
-				return $this->cache->put($local_filename, $data);;
138
+            if ($data)
139
+                return $this->cache->put($local_filename, $data);;
140 140
 
141
-		} else {
142
-			//Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE);
141
+        } else {
142
+            //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE);
143 143
 
144
-			return true;
145
-		}
144
+            return true;
145
+        }
146 146
 
147
-		return false;
148
-	}
147
+        return false;
148
+    }
149 149
 
150
-	private function cache_article_images($content, $site_url, $owner_uid, $article_id) {
151
-		$status_filename = $article_id . "-" . sha1($site_url) . ".status";
150
+    private function cache_article_images($content, $site_url, $owner_uid, $article_id) {
151
+        $status_filename = $article_id . "-" . sha1($site_url) . ".status";
152 152
 
153
-		/* housekeeping might run as a separate user, in this case status/media might not be writable */
154
-		if (!$this->cache->isWritable($status_filename)) {
155
-			Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE);
156
-			return false;
157
-		}
153
+        /* housekeeping might run as a separate user, in this case status/media might not be writable */
154
+        if (!$this->cache->isWritable($status_filename)) {
155
+            Debug::log("status not writable: $status_filename", Debug::$LOG_VERBOSE);
156
+            return false;
157
+        }
158 158
 
159
-		Debug::log("status: $status_filename", Debug::$LOG_VERBOSE);
159
+        Debug::log("status: $status_filename", Debug::$LOG_VERBOSE);
160 160
 
161 161
         if ($this->cache->exists($status_filename))
162 162
             $status = json_decode($this->cache->get($status_filename), true);
@@ -176,49 +176,49 @@  discard block
 block discarded – undo
176 176
             return false;
177 177
         }
178 178
 
179
-		$doc = new DOMDocument();
179
+        $doc = new DOMDocument();
180 180
 
181
-		$has_images = false;
182
-		$success = false;
181
+        $has_images = false;
182
+        $success = false;
183 183
 
184 184
         if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) {
185
-			$xpath = new DOMXPath($doc);
186
-			$entries = $xpath->query('(//img[@src])|(//video/source[@src])');
185
+            $xpath = new DOMXPath($doc);
186
+            $entries = $xpath->query('(//img[@src])|(//video/source[@src])');
187 187
 
188
-			foreach ($entries as $entry) {
188
+            foreach ($entries as $entry) {
189 189
 
190
-				if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
190
+                if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) {
191 191
 
192
-					$has_images = true;
192
+                    $has_images = true;
193 193
 
194
-					$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
194
+                    $src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
195 195
 
196
-					if ($this->cache_url($article_id, $src)) {
197
-						$success = true;
198
-					}
199
-				}
200
-			}
201
-		}
196
+                    if ($this->cache_url($article_id, $src)) {
197
+                        $success = true;
198
+                    }
199
+                }
200
+            }
201
+        }
202 202
 
203
-		$esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND
203
+        $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND
204 204
 			(content_type LIKE '%image%' OR content_type LIKE '%video%')");
205 205
 
206 206
         if ($esth->execute([$article_id])) {
207
-        	while ($enc = $esth->fetch()) {
207
+            while ($enc = $esth->fetch()) {
208 208
 
209
-        		$has_images = true;
210
-        		$url = rewrite_relative_url($site_url, $enc["content_url"]);
209
+                $has_images = true;
210
+                $url = rewrite_relative_url($site_url, $enc["content_url"]);
211 211
 
212
-				if ($this->cache_url($article_id, $url)) {
213
-					$success = true;
214
-				}
215
-			}
216
-		}
212
+                if ($this->cache_url($article_id, $url)) {
213
+                    $success = true;
214
+                }
215
+            }
216
+        }
217 217
 
218
-		return $success || !$has_images;
219
-	}
218
+        return $success || !$has_images;
219
+    }
220 220
 
221
-	public function api_version() {
222
-		return 2;
223
-	}
221
+    public function api_version() {
222
+        return 2;
223
+    }
224 224
 }
Please login to merge, or discard this patch.
plugins/vf_shared/init.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,78 +1,78 @@
 block discarded – undo
1 1
 <?php
2 2
 class VF_Shared 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
-			"Feed for all articles actively shared by URL",
10
-			"fox",
11
-			false);
12
-	}
7
+    public function about() {
8
+        return array(1.0,
9
+            "Feed for all articles actively shared by URL",
10
+            "fox",
11
+            false);
12
+    }
13 13
 
14
-	public function init($host) {
15
-		$this->host = $host;
14
+    public function init($host) {
15
+        $this->host = $host;
16 16
 
17
-		$host->add_feed(-1, __("Shared articles"), 'link', $this);
18
-	}
17
+        $host->add_feed(-1, __("Shared articles"), 'link', $this);
18
+    }
19 19
 
20
-	public function api_version() {
21
-		return 2;
22
-	}
20
+    public function api_version() {
21
+        return 2;
22
+    }
23 23
 
24
-	/**
25
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
26
-	 */
27
-	public function get_unread($feed_id) {
28
-		$sth = $this->pdo->prepare("select count(int_id) AS count
24
+    /**
25
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
26
+     */
27
+    public function get_unread($feed_id) {
28
+        $sth = $this->pdo->prepare("select count(int_id) AS count
29 29
 			from ttrss_user_entries where owner_uid = ? and unread = true and uuid != ''");
30
-		$sth->execute([$_SESSION['uid']]);
30
+        $sth->execute([$_SESSION['uid']]);
31 31
 
32
-		if ($row = $sth->fetch()) {
33
-			return $row['count'];
34
-		}
32
+        if ($row = $sth->fetch()) {
33
+            return $row['count'];
34
+        }
35 35
 
36
-		return 0;
37
-	}
36
+        return 0;
37
+    }
38 38
 
39
-	/**
40
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
41
-	 */
42
-	public function get_total($feed_id) {
43
-		$sth = $this->pdo->prepare("select count(int_id) AS count
39
+    /**
40
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
41
+     */
42
+    public function get_total($feed_id) {
43
+        $sth = $this->pdo->prepare("select count(int_id) AS count
44 44
 			from ttrss_user_entries where owner_uid = ? and uuid != ''");
45
-		$sth->execute([$_SESSION['uid']]);
45
+        $sth->execute([$_SESSION['uid']]);
46 46
 
47
-		if ($row = $sth->fetch()) {
48
-			return $row['count'];
49
-		}
47
+        if ($row = $sth->fetch()) {
48
+            return $row['count'];
49
+        }
50 50
 
51
-		return 0;
52
-	}
51
+        return 0;
52
+    }
53 53
 
54
-	/**
55
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
56
-	 */
57
-	public function get_headlines($feed_id, $options) {
58
-		$params = array(
59
-			"feed" => -4,
60
-			"limit" => $options["limit"],
61
-			"view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles",
62
-			"search" => $options['search'],
63
-			"override_order" => $options['override_order'],
64
-			"offset" => $options["offset"],
65
-			"filter" => $options["filter"],
66
-			"since_id" => $options["since_id"],
67
-			"include_children" => $options["include_children"],
68
-			"override_strategy" => "uuid != ''",
69
-			"override_vfeed" => "ttrss_feeds.title AS feed_title,"
70
-		);
54
+    /**
55
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
56
+     */
57
+    public function get_headlines($feed_id, $options) {
58
+        $params = array(
59
+            "feed" => -4,
60
+            "limit" => $options["limit"],
61
+            "view_mode" => $this->get_unread(-1) > 0 ? "adaptive" : "all_articles",
62
+            "search" => $options['search'],
63
+            "override_order" => $options['override_order'],
64
+            "offset" => $options["offset"],
65
+            "filter" => $options["filter"],
66
+            "since_id" => $options["since_id"],
67
+            "include_children" => $options["include_children"],
68
+            "override_strategy" => "uuid != ''",
69
+            "override_vfeed" => "ttrss_feeds.title AS feed_title,"
70
+        );
71 71
 
72
-		$qfh_ret = Feeds::queryFeedHeadlines($params);
73
-		$qfh_ret[1] = __("Shared articles");
72
+        $qfh_ret = Feeds::queryFeedHeadlines($params);
73
+        $qfh_ret[1] = __("Shared articles");
74 74
 
75
-		return $qfh_ret;
76
-	}
75
+        return $qfh_ret;
76
+    }
77 77
 
78 78
 }
Please login to merge, or discard this patch.
plugins/no_iframes/init.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@
 block discarded – undo
1 1
 <?php
2 2
 class No_Iframes extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Remove embedded iframes (unless whitelisted)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Remove embedded iframes (unless whitelisted)",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
11
+    public function init($host) {
12
+        $this->host = $host;
13 13
 
14
-		$host->add_hook($host::HOOK_SANITIZE, $this);
15
-	}
14
+        $host->add_hook($host::HOOK_SANITIZE, $this);
15
+    }
16 16
 
17
-	/**
18
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
19
-	 */
20
-	public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
17
+    /**
18
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
19
+     */
20
+    public function hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes) {
21 21
 
22
-		$xpath = new DOMXpath($doc);
23
-		$entries = $xpath->query('//iframe');
22
+        $xpath = new DOMXpath($doc);
23
+        $entries = $xpath->query('//iframe');
24 24
 
25
-		foreach ($entries as $entry) {
26
-			if (!iframe_whitelisted($entry))
27
-				$entry->parentNode->removeChild($entry);
28
-		}
25
+        foreach ($entries as $entry) {
26
+            if (!iframe_whitelisted($entry))
27
+                $entry->parentNode->removeChild($entry);
28
+        }
29 29
 
30
-		return array($doc, $allowed_elements, $disallowed_attributes);
31
-	}
30
+        return array($doc, $allowed_elements, $disallowed_attributes);
31
+    }
32 32
 
33
-	public function api_version() {
34
-		return 2;
35
-	}
33
+    public function api_version() {
34
+        return 2;
35
+    }
36 36
 
37 37
 }
Please login to merge, or discard this patch.
plugins/share/init.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,142 +1,142 @@
 block discarded – undo
1 1
 <?php
2 2
 class Share extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Share article by unique URL",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Share article by unique URL",
8
+            "fox");
9
+    }
10 10
 
11
-	/* @var PluginHost $host */
12
-	public function init($host) {
13
-		$this->host = $host;
11
+    /* @var PluginHost $host */
12
+    public function init($host) {
13
+        $this->host = $host;
14 14
 
15
-		$host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
16
-		$host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this);
17
-	}
15
+        $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
16
+        $host->add_hook($host::HOOK_PREFS_TAB_SECTION, $this);
17
+    }
18 18
 
19
-	public function get_js() {
20
-		return file_get_contents(dirname(__FILE__) . "/share.js");
21
-	}
19
+    public function get_js() {
20
+        return file_get_contents(dirname(__FILE__) . "/share.js");
21
+    }
22 22
 
23
-	public function get_css() {
24
-		return file_get_contents(dirname(__FILE__) . "/share.css");
25
-	}
23
+    public function get_css() {
24
+        return file_get_contents(dirname(__FILE__) . "/share.css");
25
+    }
26 26
 
27
-	public function get_prefs_js() {
28
-		return file_get_contents(dirname(__FILE__) . "/share_prefs.js");
29
-	}
27
+    public function get_prefs_js() {
28
+        return file_get_contents(dirname(__FILE__) . "/share_prefs.js");
29
+    }
30 30
 
31 31
 
32
-	public function unshare() {
33
-		$id = $_REQUEST['id'];
32
+    public function unshare() {
33
+        $id = $_REQUEST['id'];
34 34
 
35
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = ?
35
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE int_id = ?
36 36
 			AND owner_uid = ?");
37
-		$sth->execute([$id, $_SESSION['uid']]);
37
+        $sth->execute([$id, $_SESSION['uid']]);
38 38
 
39
-		print "OK";
40
-	}
39
+        print "OK";
40
+    }
41 41
 
42
-	public function hook_prefs_tab_section($id) {
43
-		if ($id == "prefFeedsPublishedGenerated") {
42
+    public function hook_prefs_tab_section($id) {
43
+        if ($id == "prefFeedsPublishedGenerated") {
44 44
 
45
-			print "<h3>" . __("You can disable all articles shared by unique URLs here.") . "</h3>";
45
+            print "<h3>" . __("You can disable all articles shared by unique URLs here.") . "</h3>";
46 46
 
47
-			print "<button class='alt-danger' dojoType='dijit.form.Button' onclick=\"return Plugins.Share.clearKeys()\">".
48
-				__('Unshare all articles')."</button> ";
47
+            print "<button class='alt-danger' dojoType='dijit.form.Button' onclick=\"return Plugins.Share.clearKeys()\">".
48
+                __('Unshare all articles')."</button> ";
49 49
 
50
-			print "</p>";
50
+            print "</p>";
51 51
 
52
-		}
53
-	}
52
+        }
53
+    }
54 54
 
55
-	// Silent
56
-	public function clearArticleKeys() {
57
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE
55
+    // Silent
56
+    public function clearArticleKeys() {
57
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = '' WHERE
58 58
 			owner_uid = ?");
59
-		$sth->execute([$_SESSION['uid']]);
59
+        $sth->execute([$_SESSION['uid']]);
60 60
 
61
-		return;
62
-	}
61
+        return;
62
+    }
63 63
 
64 64
 
65
-	public function newkey() {
66
-		$id = $_REQUEST['id'];
67
-		$uuid = uniqid_short();
65
+    public function newkey() {
66
+        $id = $_REQUEST['id'];
67
+        $uuid = uniqid_short();
68 68
 
69
-		$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
69
+        $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
70 70
 			AND owner_uid = ?");
71
-		$sth->execute([$uuid, $id, $_SESSION['uid']]);
71
+        $sth->execute([$uuid, $id, $_SESSION['uid']]);
72 72
 
73
-		print json_encode(array("link" => $uuid));
74
-	}
73
+        print json_encode(array("link" => $uuid));
74
+    }
75 75
 
76
-	public function hook_article_button($line) {
77
-		$img_class = $line['uuid'] ? "shared" : "";
76
+    public function hook_article_button($line) {
77
+        $img_class = $line['uuid'] ? "shared" : "";
78 78
 
79
-		return "<i id='SHARE-IMG-".$line['int_id']."' class='material-icons icon-share $img_class'
79
+        return "<i id='SHARE-IMG-".$line['int_id']."' class='material-icons icon-share $img_class'
80 80
 			style='cursor : pointer' onclick=\"Plugins.Share.shareArticle(".$line['int_id'].")\"
81 81
 			title='".__('Share by URL')."'>link</i>";
82
-	}
82
+    }
83 83
 
84
-	public function shareArticle() {
85
-		$param = $_REQUEST['param'];
84
+    public function shareArticle() {
85
+        $param = $_REQUEST['param'];
86 86
 
87
-		$sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ?
87
+        $sth = $this->pdo->prepare("SELECT uuid FROM ttrss_user_entries WHERE int_id = ?
88 88
 			AND owner_uid = ?");
89
-		$sth->execute([$param, $_SESSION['uid']]);
89
+        $sth->execute([$param, $_SESSION['uid']]);
90 90
 
91
-		if ($row = $sth->fetch()) {
91
+        if ($row = $sth->fetch()) {
92 92
 
93
-			$uuid = $row['uuid'];
93
+            $uuid = $row['uuid'];
94 94
 
95
-			if (!$uuid) {
96
-				$uuid = uniqid_short();
95
+            if (!$uuid) {
96
+                $uuid = uniqid_short();
97 97
 
98
-				$sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
98
+                $sth = $this->pdo->prepare("UPDATE ttrss_user_entries SET uuid = ? WHERE int_id = ?
99 99
 					AND owner_uid = ?");
100
-				$sth->execute([$uuid, $param, $_SESSION['uid']]);
101
-			}
100
+                $sth->execute([$uuid, $param, $_SESSION['uid']]);
101
+            }
102 102
 
103
-			print "<header>" . __("You can share this article by the following unique URL:") . "</header>";
103
+            print "<header>" . __("You can share this article by the following unique URL:") . "</header>";
104 104
 
105
-			$url_path = get_self_url_prefix();
106
-			$url_path .= "/public.php?op=share&key=$uuid";
105
+            $url_path = get_self_url_prefix();
106
+            $url_path .= "/public.php?op=share&key=$uuid";
107 107
 
108
-			print "<section>
108
+            print "<section>
109 109
 				<div class='panel text-center'>
110 110
 				<a id='gen_article_url' href='$url_path' target='_blank' rel='noopener noreferrer'>$url_path</a>
111 111
 				</div>
112 112
 				</section>";
113 113
 
114
-			/* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
114
+            /* if (!label_find_id(__('Shared'), $_SESSION["uid"]))
115 115
 				label_create(__('Shared'), $_SESSION["uid"]);
116 116
 
117 117
 			label_add_article($ref_id, __('Shared'), $_SESSION['uid']); */
118 118
 
119 119
 
120
-		} else {
121
-			print "Article not found.";
122
-		}
120
+        } else {
121
+            print "Article not found.";
122
+        }
123 123
 
124
-		print "<footer class='text-center'>";
124
+        print "<footer class='text-center'>";
125 125
 
126
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').unshare()\">".
127
-			__('Unshare article')."</button>";
126
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').unshare()\">".
127
+            __('Unshare article')."</button>";
128 128
 
129
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').newurl()\">".
130
-			__('Generate new URL')."</button>";
129
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').newurl()\">".
130
+            __('Generate new URL')."</button>";
131 131
 
132
-		print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
133
-			__('Close this window')."</button>";
132
+        print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('shareArticleDlg').hide()\">".
133
+            __('Close this window')."</button>";
134 134
 
135
-		print "</footer>";
136
-	}
135
+        print "</footer>";
136
+    }
137 137
 
138
-	public function api_version() {
139
-		return 2;
140
-	}
138
+    public function api_version() {
139
+        return 2;
140
+    }
141 141
 
142 142
 }
Please login to merge, or discard this patch.
plugins/af_zz_noautoplay/init.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 class Af_Zz_NoAutoPlay extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Don't autoplay HTML5 videos",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Don't autoplay HTML5 videos",
8
+            "fox");
9
+    }
10 10
 
11
-	public function init($host) {
12
-		$this->host = $host;
13
-	}
11
+    public function init($host) {
12
+        $this->host = $host;
13
+    }
14 14
 
15
-	public function get_js() {
16
-		return file_get_contents(__DIR__ . "/init.js");
17
-	}
15
+    public function get_js() {
16
+        return file_get_contents(__DIR__ . "/init.js");
17
+    }
18 18
 
19
-	public function api_version() {
20
-		return 2;
21
-	}
19
+    public function api_version() {
20
+        return 2;
21
+    }
22 22
 
23 23
 }
Please login to merge, or discard this patch.
plugins/af_redditimgur/init.php 1 patch
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Af_RedditImgur 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
-			"Inline images (and other content) in Reddit RSS feeds",
10
-			"fox");
11
-	}
7
+    public function about() {
8
+        return array(1.0,
9
+            "Inline images (and other content) in Reddit RSS feeds",
10
+            "fox");
11
+    }
12 12
 
13
-	public function flags() {
14
-		return array("needs_curl" => true);
15
-	}
13
+    public function flags() {
14
+        return array("needs_curl" => true);
15
+    }
16 16
 
17
-	public function init($host) {
18
-		$this->host = $host;
17
+    public function init($host) {
18
+        $this->host = $host;
19 19
 
20
-		$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
21
-		$host->add_hook($host::HOOK_PREFS_TAB, $this);
22
-	}
20
+        $host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
21
+        $host->add_hook($host::HOOK_PREFS_TAB, $this);
22
+    }
23 23
 
24
-	public function hook_prefs_tab($args) {
25
-		if ($args != "prefFeeds") return;
24
+    public function hook_prefs_tab($args) {
25
+        if ($args != "prefFeeds") return;
26 26
 
27
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
27
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
28 28
 			title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">";
29 29
 
30
-		$enable_readability = $this->host->get($this, "enable_readability");
31
-		$enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
30
+        $enable_readability = $this->host->get($this, "enable_readability");
31
+        $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck");
32 32
 
33
-		if (version_compare(PHP_VERSION, '5.6.0', '<')) {
34
-			print_error("Readability requires PHP version 5.6.");
35
-		}
33
+        if (version_compare(PHP_VERSION, '5.6.0', '<')) {
34
+            print_error("Readability requires PHP version 5.6.");
35
+        }
36 36
 
37
-		print "<form dojoType='dijit.form.Form'>";
37
+        print "<form dojoType='dijit.form.Form'>";
38 38
 
39
-		print "<script type='dojo/method' event='onSubmit' args='evt'>
39
+        print "<script type='dojo/method' event='onSubmit' args='evt'>
40 40
 			evt.preventDefault();
41 41
 			if (this.validate()) {
42 42
 				console.log(dojo.objectToQuery(this.getValues()));
@@ -50,235 +50,235 @@  discard block
 block discarded – undo
50 50
 			}
51 51
 			</script>";
52 52
 
53
-		print_hidden("op", "pluginhandler");
54
-		print_hidden("method", "save");
55
-		print_hidden("plugin", "af_redditimgur");
53
+        print_hidden("op", "pluginhandler");
54
+        print_hidden("method", "save");
55
+        print_hidden("plugin", "af_redditimgur");
56 56
 
57
-		print "<fieldset class='narrow'>";
58
-		print "<label class='checkbox'>";
59
-		print_checkbox("enable_readability", $enable_readability);
60
-		print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
61
-		print "</fieldset>";
57
+        print "<fieldset class='narrow'>";
58
+        print "<label class='checkbox'>";
59
+        print_checkbox("enable_readability", $enable_readability);
60
+        print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
61
+        print "</fieldset>";
62 62
 
63
-		print "<fieldset class='narrow'>";
64
-		print "<label class='checkbox'>";
65
-		print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
66
-		print " " . __("Enable additional duplicate checking") . "</label>";
67
-		print "</fieldset>";
63
+        print "<fieldset class='narrow'>";
64
+        print "<label class='checkbox'>";
65
+        print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
66
+        print " " . __("Enable additional duplicate checking") . "</label>";
67
+        print "</fieldset>";
68 68
 
69
-		print_button("submit", __("Save"), 'class="alt-primary"');
70
-		print "</form>";
69
+        print_button("submit", __("Save"), 'class="alt-primary"');
70
+        print "</form>";
71 71
 
72
-		print "</div>";
73
-	}
72
+        print "</div>";
73
+    }
74 74
 
75
-	public function save() {
76
-		$enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]);
77
-		$enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]);
75
+    public function save() {
76
+        $enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]);
77
+        $enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]);
78 78
 
79
-		$this->host->set($this, "enable_readability", $enable_readability, false);
80
-		$this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck);
79
+        $this->host->set($this, "enable_readability", $enable_readability, false);
80
+        $this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck);
81 81
 
82
-		echo __("Configuration saved");
83
-	}
82
+        echo __("Configuration saved");
83
+    }
84 84
 
85
-	/**
86
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
87
-	 */
88
-	private function inline_stuff($article, &$doc, $xpath) {
85
+    /**
86
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
87
+     */
88
+    private function inline_stuff($article, &$doc, $xpath) {
89 89
 
90
-		$entries = $xpath->query('(//a[@href]|//img[@src])');
91
-		$img_entries = $xpath->query("(//img[@src])");
90
+        $entries = $xpath->query('(//a[@href]|//img[@src])');
91
+        $img_entries = $xpath->query("(//img[@src])");
92 92
 
93
-		$found = false;
94
-		//$debug = 1;
93
+        $found = false;
94
+        //$debug = 1;
95 95
 
96
-		foreach ($entries as $entry) {
97
-			if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) {
96
+        foreach ($entries as $entry) {
97
+            if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) {
98 98
 
99
-				Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
99
+                Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
100 100
 
101
-				$matches = array();
101
+                $matches = array();
102 102
 
103
-				if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
104
-					Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
103
+                if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
104
+                    Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
105 105
 
106
-					$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
106
+                    $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
107 107
 
108
-					if ($oembed_result) {
109
-						$oembed_result = json_decode($oembed_result, true);
108
+                    if ($oembed_result) {
109
+                        $oembed_result = json_decode($oembed_result, true);
110 110
 
111
-						if ($oembed_result && isset($oembed_result["html"])) {
111
+                        if ($oembed_result && isset($oembed_result["html"])) {
112 112
 
113
-							$tmp = new DOMDocument();
114
-							if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
115
-								$p = $doc->createElement("p");
113
+                            $tmp = new DOMDocument();
114
+                            if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) {
115
+                                $p = $doc->createElement("p");
116 116
 
117
-								$p->appendChild($doc->importNode(
118
-									$tmp->getElementsByTagName("blockquote")->item(0), TRUE));
117
+                                $p->appendChild($doc->importNode(
118
+                                    $tmp->getElementsByTagName("blockquote")->item(0), TRUE));
119 119
 
120
-								$br = $doc->createElement('br');
121
-								$entry->parentNode->insertBefore($p, $entry);
122
-								$entry->parentNode->insertBefore($br, $entry);
120
+                                $br = $doc->createElement('br');
121
+                                $entry->parentNode->insertBefore($p, $entry);
122
+                                $entry->parentNode->insertBefore($br, $entry);
123 123
 
124
-								$found = 1;
125
-							}
126
-						}
127
-					}
128
-				}
124
+                                $found = 1;
125
+                            }
126
+                        }
127
+                    }
128
+                }
129 129
 
130
-				if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
131
-					$entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
132
-				}
130
+                if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
131
+                    $entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]);
132
+                }
133 133
 
134
-				if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
134
+                if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
135 135
 
136
-					Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
136
+                    Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
137 137
 
138
-					$source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
139
-					$poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
138
+                    $source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
139
+                    $poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
140 140
 
141
-					$content_type = $this->get_content_type($source_stream);
141
+                    $content_type = $this->get_content_type($source_stream);
142 142
 
143
-					if (strpos($content_type, "video/") !== FALSE) {
144
-						$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
145
-						$found = 1;
146
-					}
147
-				}
143
+                    if (strpos($content_type, "video/") !== FALSE) {
144
+                        $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
145
+                        $found = 1;
146
+                    }
147
+                }
148 148
 
149
-				if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
149
+                if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
150 150
 
151
-					Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE);
151
+                    Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE);
152 152
 
153
-					$img = $img_entries->item(0);
153
+                    $img = $img_entries->item(0);
154 154
 
155
-					if ($img) {
156
-						$poster_url = $img->getAttribute("src");
157
-					} else {
158
-						$poster_url = false;
159
-					}
155
+                    if ($img) {
156
+                        $poster_url = $img->getAttribute("src");
157
+                    } else {
158
+                        $poster_url = false;
159
+                    }
160 160
 
161
-					// Get original article URL from v.redd.it redirects
162
-					$source_article_url = $this->get_location($matches[0]);
163
-					Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE);
164
-
165
-					$source_stream = false;
166
-
167
-					if ($source_article_url) {
168
-						$j = json_decode(fetch_file_contents($source_article_url.".json"), true);
169
-
170
-						if ($j) {
171
-							foreach ($j as $listing) {
172
-								foreach ($listing["data"]["children"] as $child) {
173
-									if ($child["data"]["url"] == $matches[0]) {
174
-										try {
175
-											$source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
-										}
177
-										catch (Exception $e) {
178
-										}
179
-										break 2;
180
-									}
181
-								}
182
-							}
183
-						}
184
-					}
161
+                    // Get original article URL from v.redd.it redirects
162
+                    $source_article_url = $this->get_location($matches[0]);
163
+                    Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE);
164
+
165
+                    $source_stream = false;
166
+
167
+                    if ($source_article_url) {
168
+                        $j = json_decode(fetch_file_contents($source_article_url.".json"), true);
169
+
170
+                        if ($j) {
171
+                            foreach ($j as $listing) {
172
+                                foreach ($listing["data"]["children"] as $child) {
173
+                                    if ($child["data"]["url"] == $matches[0]) {
174
+                                        try {
175
+                                            $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"];
176
+                                        }
177
+                                        catch (Exception $e) {
178
+                                        }
179
+                                        break 2;
180
+                                    }
181
+                                }
182
+                            }
183
+                        }
184
+                    }
185 185
 
186
-					if (!$source_stream) {
187
-						$source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
188
-					}
186
+                    if (!$source_stream) {
187
+                        $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K";
188
+                    }
189 189
 
190
-					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
191
-					$found = 1;
192
-				}
190
+                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
191
+                    $found = 1;
192
+                }
193 193
 
194
-				if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
194
+                if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
195 195
 
196
-					Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
196
+                    Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
197 197
 
198
-					$tmp = fetch_file_contents($entry->getAttribute("href"));
198
+                    $tmp = fetch_file_contents($entry->getAttribute("href"));
199 199
 
200
-					if ($tmp) {
201
-						$tmpdoc = new DOMDocument();
200
+                    if ($tmp) {
201
+                        $tmpdoc = new DOMDocument();
202 202
 
203
-						if (@$tmpdoc->loadHTML($tmp)) {
204
-							$tmpxpath = new DOMXPath($tmpdoc);
203
+                        if (@$tmpdoc->loadHTML($tmp)) {
204
+                            $tmpxpath = new DOMXPath($tmpdoc);
205 205
 
206
-							$source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0);
207
-							$poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0);
206
+                            $source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0);
207
+                            $poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0);
208 208
 
209
-							if ($source_node && $poster_node) {
210
-								$source_stream = $source_node->getAttribute("src");
211
-								$poster_url = $poster_node->getAttribute("poster");
209
+                            if ($source_node && $poster_node) {
210
+                                $source_stream = $source_node->getAttribute("src");
211
+                                $poster_url = $poster_node->getAttribute("poster");
212 212
 
213
-								$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
214
-								$found = 1;
215
-							}
216
-						}
217
-					}
218
-				}
213
+                                $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
214
+                                $found = 1;
215
+                            }
216
+                        }
217
+                    }
218
+                }
219 219
 
220
-				// imgur .gif -> .gifv
221
-				if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
222
-					Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE);
220
+                // imgur .gif -> .gifv
221
+                if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
222
+                    Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE);
223 223
 
224
-					$entry->setAttribute("href",
225
-						str_replace(".gif", ".gifv", $entry->getAttribute("href")));
226
-				}
224
+                    $entry->setAttribute("href",
225
+                        str_replace(".gif", ".gifv", $entry->getAttribute("href")));
226
+                }
227 227
 
228
-				if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
229
-					Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE);
228
+                if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
229
+                    Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE);
230 230
 
231
-					$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
231
+                    $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
232 232
 
233
-					if (strpos($source_stream, "imgur.com") !== FALSE)
234
-						$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
233
+                    if (strpos($source_stream, "imgur.com") !== FALSE)
234
+                        $poster_url = str_replace(".mp4", "h.jpg", $source_stream);
235 235
 
236
-					$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
236
+                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
237 237
 
238
-					$found = true;
239
-				}
238
+                    $found = true;
239
+                }
240 240
 
241
-				$matches = array();
242
-				if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
243
-					preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
244
-					preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
245
-					preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
241
+                $matches = array();
242
+                if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) ||
243
+                    preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
244
+                    preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) ||
245
+                    preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) {
246 246
 
247
-					$vid_id = $matches[1];
247
+                    $vid_id = $matches[1];
248 248
 
249
-					Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE);
249
+                    Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE);
250 250
 
251
-					$iframe = $doc->createElement("iframe");
252
-					$iframe->setAttribute("class", "youtube-player");
253
-					$iframe->setAttribute("type", "text/html");
254
-					$iframe->setAttribute("width", "640");
255
-					$iframe->setAttribute("height", "385");
256
-					$iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
257
-					$iframe->setAttribute("allowfullscreen", "1");
258
-					$iframe->setAttribute("frameborder", "0");
251
+                    $iframe = $doc->createElement("iframe");
252
+                    $iframe->setAttribute("class", "youtube-player");
253
+                    $iframe->setAttribute("type", "text/html");
254
+                    $iframe->setAttribute("width", "640");
255
+                    $iframe->setAttribute("height", "385");
256
+                    $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id");
257
+                    $iframe->setAttribute("allowfullscreen", "1");
258
+                    $iframe->setAttribute("frameborder", "0");
259 259
 
260
-					$br = $doc->createElement('br');
261
-					$entry->parentNode->insertBefore($iframe, $entry);
262
-					$entry->parentNode->insertBefore($br, $entry);
260
+                    $br = $doc->createElement('br');
261
+                    $entry->parentNode->insertBefore($iframe, $entry);
262
+                    $entry->parentNode->insertBefore($br, $entry);
263 263
 
264
-					$found = true;
265
-				}
264
+                    $found = true;
265
+                }
266 266
 
267
-				if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) ||
268
-					mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE ||
269
-					mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE) {
267
+                if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) ||
268
+                    mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE ||
269
+                    mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE) {
270 270
 
271
-					Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
271
+                    Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
272 272
 
273
-					$img = $doc->createElement('img');
274
-					$img->setAttribute("src", $entry->getAttribute("href"));
273
+                    $img = $doc->createElement('img');
274
+                    $img->setAttribute("src", $entry->getAttribute("href"));
275 275
 
276
-					$br = $doc->createElement('br');
277
-					$entry->parentNode->insertBefore($img, $entry);
278
-					$entry->parentNode->insertBefore($br, $entry);
276
+                    $br = $doc->createElement('br');
277
+                    $entry->parentNode->insertBefore($img, $entry);
278
+                    $entry->parentNode->insertBefore($br, $entry);
279 279
 
280
-					$found = true;
281
-				}
280
+                    $found = true;
281
+                }
282 282
 
283 283
                 // imgur via link rel="image_src" href="..."
284 284
                 if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) {
@@ -311,109 +311,109 @@  discard block
 block discarded – undo
311 311
                     }
312 312
                 }
313 313
 
314
-				// wtf is this even
315
-				if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
316
-					$img_id = $matches[1];
314
+                // wtf is this even
315
+                if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
316
+                    $img_id = $matches[1];
317 317
 
318
-					Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE);
318
+                    Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE);
319 319
 
320
-					$img = $doc->createElement('img');
321
-					$img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
320
+                    $img = $doc->createElement('img');
321
+                    $img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
322 322
 
323
-					$br = $doc->createElement('br');
324
-					$entry->parentNode->insertBefore($img, $entry);
325
-					$entry->parentNode->insertBefore($br, $entry);
323
+                    $br = $doc->createElement('br');
324
+                    $entry->parentNode->insertBefore($img, $entry);
325
+                    $entry->parentNode->insertBefore($br, $entry);
326 326
 
327
-					$found = true;
328
-				}
327
+                    $found = true;
328
+                }
329 329
 
330
-				// let's try meta properties
331
-				if (!$found) {
332
-					Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
330
+                // let's try meta properties
331
+                if (!$found) {
332
+                    Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
333 333
 
334
-					$content = fetch_file_contents(["url" => $entry->getAttribute("href"),
335
-						"http_accept" => "text/*"]);
334
+                    $content = fetch_file_contents(["url" => $entry->getAttribute("href"),
335
+                        "http_accept" => "text/*"]);
336 336
 
337
-					if ($content) {
338
-						$cdoc = new DOMDocument();
337
+                    if ($content) {
338
+                        $cdoc = new DOMDocument();
339 339
 
340
-						if (@$cdoc->loadHTML($content)) {
341
-							$cxpath = new DOMXPath($cdoc);
340
+                        if (@$cdoc->loadHTML($content)) {
341
+                            $cxpath = new DOMXPath($cdoc);
342 342
 
343
-							$og_image = $cxpath->query("//meta[@property='og:image']")->item(0);
344
-							$og_video = $cxpath->query("//meta[@property='og:video']")->item(0);
343
+                            $og_image = $cxpath->query("//meta[@property='og:image']")->item(0);
344
+                            $og_video = $cxpath->query("//meta[@property='og:video']")->item(0);
345 345
 
346
-							if ($og_video) {
346
+                            if ($og_video) {
347 347
 
348
-								$source_stream = $og_video->getAttribute("content");
348
+                                $source_stream = $og_video->getAttribute("content");
349 349
 
350
-								if ($source_stream) {
350
+                                if ($source_stream) {
351 351
 
352
-									if ($og_image) {
353
-										$poster_url = $og_image->getAttribute("content");
354
-									} else {
355
-										$poster_url = false;
356
-									}
352
+                                    if ($og_image) {
353
+                                        $poster_url = $og_image->getAttribute("content");
354
+                                    } else {
355
+                                        $poster_url = false;
356
+                                    }
357 357
 
358
-									$this->handle_as_video($doc, $entry, $source_stream, $poster_url);
359
-									$found = true;
360
-								}
358
+                                    $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
359
+                                    $found = true;
360
+                                }
361 361
 
362
-							} else if ($og_image) {
362
+                            } else if ($og_image) {
363 363
 
364
-								$og_src = $og_image->getAttribute("content");
364
+                                $og_src = $og_image->getAttribute("content");
365 365
 
366
-								if ($og_src) {
367
-									$img = $doc->createElement('img');
368
-									$img->setAttribute("src", $og_src);
366
+                                if ($og_src) {
367
+                                    $img = $doc->createElement('img');
368
+                                    $img->setAttribute("src", $og_src);
369 369
 
370
-									$br = $doc->createElement('br');
371
-									$entry->parentNode->insertBefore($img, $entry);
372
-									$entry->parentNode->insertBefore($br, $entry);
370
+                                    $br = $doc->createElement('br');
371
+                                    $entry->parentNode->insertBefore($img, $entry);
372
+                                    $entry->parentNode->insertBefore($br, $entry);
373 373
 
374
-									$found = true;
375
-								}
376
-							}
377
-						}
378
-					}
379
-				}
374
+                                    $found = true;
375
+                                }
376
+                            }
377
+                        }
378
+                    }
379
+                }
380 380
 
381
-			}
381
+            }
382 382
 
383
-			// remove tiny thumbnails
384
-			if ($entry->hasAttribute("src")) {
385
-				if ($entry->parentNode && $entry->parentNode->parentNode) {
386
-					$entry->parentNode->parentNode->removeChild($entry->parentNode);
387
-				}
388
-			}
389
-		}
383
+            // remove tiny thumbnails
384
+            if ($entry->hasAttribute("src")) {
385
+                if ($entry->parentNode && $entry->parentNode->parentNode) {
386
+                    $entry->parentNode->parentNode->removeChild($entry->parentNode);
387
+                }
388
+            }
389
+        }
390 390
 
391
-		return $found;
392
-	}
391
+        return $found;
392
+    }
393 393
 
394
-	public function hook_article_filter($article) {
394
+    public function hook_article_filter($article) {
395 395
 
396
-		if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
397
-			$doc = new DOMDocument();
398
-			@$doc->loadHTML($article["content"]);
399
-			$xpath = new DOMXPath($doc);
396
+        if (strpos($article["link"], "reddit.com/r/") !== FALSE) {
397
+            $doc = new DOMDocument();
398
+            @$doc->loadHTML($article["content"]);
399
+            $xpath = new DOMXPath($doc);
400 400
 
401
-			$content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
401
+            $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0);
402 402
 
403
-			if ($this->host->get($this, "enable_content_dupcheck")) {
403
+            if ($this->host->get($this, "enable_content_dupcheck")) {
404 404
 
405
-				if ($content_link) {
406
-					$content_href = $content_link->getAttribute("href");
407
-					$entry_guid = $article["guid_hashed"];
408
-					$owner_uid = $article["owner_uid"];
405
+                if ($content_link) {
406
+                    $content_href = $content_link->getAttribute("href");
407
+                    $entry_guid = $article["guid_hashed"];
408
+                    $owner_uid = $article["owner_uid"];
409 409
 
410
-					if (DB_TYPE == "pgsql") {
411
-						$interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
412
-					} else {
413
-						$interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
414
-					}
410
+                    if (DB_TYPE == "pgsql") {
411
+                        $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'";
412
+                    } else {
413
+                        $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)";
414
+                    }
415 415
 
416
-					$sth = $this->pdo->prepare("SELECT COUNT(id) AS cid
416
+                    $sth = $this->pdo->prepare("SELECT COUNT(id) AS cid
417 417
 						FROM ttrss_entries, ttrss_user_entries WHERE
418 418
 							ref_id = id AND
419 419
 							$interval_qpart AND
@@ -421,149 +421,149 @@  discard block
 block discarded – undo
421 421
 							owner_uid = ? AND
422 422
 							content LIKE ?");
423 423
 
424
-					$sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]);
424
+                    $sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]);
425 425
 
426
-					if ($row = $sth->fetch()) {
427
-						$num_found = $row['cid'];
426
+                    if ($row = $sth->fetch()) {
427
+                        $num_found = $row['cid'];
428 428
 
429
-						if ($num_found > 0) $article["force_catchup"] = true;
430
-					}
431
-				}
432
-			}
429
+                        if ($num_found > 0) $article["force_catchup"] = true;
430
+                    }
431
+                }
432
+            }
433 433
 
434
-			$found = $this->inline_stuff($article, $doc, $xpath);
434
+            $found = $this->inline_stuff($article, $doc, $xpath);
435 435
 
436
-			$node = $doc->getElementsByTagName('body')->item(0);
436
+            $node = $doc->getElementsByTagName('body')->item(0);
437 437
 
438
-			if ($node && $found) {
439
-				$article["content"] = $doc->saveHTML($node);
440
-			} else if ($content_link) {
441
-				$article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
442
-			}
443
-		}
438
+            if ($node && $found) {
439
+                $article["content"] = $doc->saveHTML($node);
440
+            } else if ($content_link) {
441
+                $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath);
442
+            }
443
+        }
444 444
 
445
-		return $article;
446
-	}
445
+        return $article;
446
+    }
447 447
 
448
-	public function api_version() {
449
-		return 2;
450
-	}
448
+    public function api_version() {
449
+        return 2;
450
+    }
451 451
 
452
-	private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) {
452
+    private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) {
453 453
 
454
-		Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE);
454
+        Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE);
455 455
 
456
-		$video = $doc->createElement('video');
457
-		$video->setAttribute("autoplay", "1");
458
-		$video->setAttribute("controls", "1");
459
-		$video->setAttribute("loop", "1");
456
+        $video = $doc->createElement('video');
457
+        $video->setAttribute("autoplay", "1");
458
+        $video->setAttribute("controls", "1");
459
+        $video->setAttribute("loop", "1");
460 460
 
461
-		if ($poster_url) $video->setAttribute("poster", $poster_url);
461
+        if ($poster_url) $video->setAttribute("poster", $poster_url);
462 462
 
463
-		$source = $doc->createElement('source');
464
-		$source->setAttribute("src", $source_stream);
465
-		$source->setAttribute("type", "video/mp4");
463
+        $source = $doc->createElement('source');
464
+        $source->setAttribute("src", $source_stream);
465
+        $source->setAttribute("type", "video/mp4");
466 466
 
467
-		$video->appendChild($source);
467
+        $video->appendChild($source);
468 468
 
469
-		$br = $doc->createElement('br');
470
-		$entry->parentNode->insertBefore($video, $entry);
471
-		$entry->parentNode->insertBefore($br, $entry);
469
+        $br = $doc->createElement('br');
470
+        $entry->parentNode->insertBefore($video, $entry);
471
+        $entry->parentNode->insertBefore($br, $entry);
472 472
 
473
-		$img = $doc->createElement('img');
474
-		$img->setAttribute("src",
475
-			"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
473
+        $img = $doc->createElement('img');
474
+        $img->setAttribute("src",
475
+            "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D");
476 476
 
477
-		$entry->parentNode->insertBefore($img, $entry);
478
-	}
477
+        $entry->parentNode->insertBefore($img, $entry);
478
+    }
479 479
 
480
-	public function testurl() {
481
-		$url = htmlspecialchars($_REQUEST["url"]);
480
+    public function testurl() {
481
+        $url = htmlspecialchars($_REQUEST["url"]);
482 482
 
483
-		header("Content-type: text/plain");
483
+        header("Content-type: text/plain");
484 484
 
485
-		print "URL: $url\n";
485
+        print "URL: $url\n";
486 486
 
487
-		$doc = new DOMDocument();
488
-		@$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
489
-		$xpath = new DOMXPath($doc);
487
+        $doc = new DOMDocument();
488
+        @$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
489
+        $xpath = new DOMXPath($doc);
490 490
 
491
-		$found = $this->inline_stuff([], $doc, $xpath);
491
+        $found = $this->inline_stuff([], $doc, $xpath);
492 492
 
493
-		print "Inline result: $found\n";
493
+        print "Inline result: $found\n";
494 494
 
495
-		if (!$found) {
496
-			print "\nReadability result:\n";
495
+        if (!$found) {
496
+            print "\nReadability result:\n";
497 497
 
498
-			$article = $this->readability([], $url, $doc, $xpath);
498
+            $article = $this->readability([], $url, $doc, $xpath);
499 499
 
500
-			print_r($article);
501
-		} else {
502
-			print "\nResulting HTML:\n";
500
+            print_r($article);
501
+        } else {
502
+            print "\nResulting HTML:\n";
503 503
 
504
-			print $doc->saveHTML();
505
-		}
506
-	}
504
+            print $doc->saveHTML();
505
+        }
506
+    }
507 507
 
508
-	private function get_header($url, $useragent = SELF_USER_AGENT, $header) {
509
-		$ret = false;
508
+    private function get_header($url, $useragent = SELF_USER_AGENT, $header) {
509
+        $ret = false;
510 510
 
511
-		if (function_exists("curl_init") && !defined("NO_CURL")) {
512
-			$ch = curl_init($url);
513
-			curl_setopt($ch, CURLOPT_TIMEOUT, 5);
514
-			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
515
-			curl_setopt($ch, CURLOPT_HEADER, true);
516
-			curl_setopt($ch, CURLOPT_NOBODY, true);
517
-			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
518
-			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
511
+        if (function_exists("curl_init") && !defined("NO_CURL")) {
512
+            $ch = curl_init($url);
513
+            curl_setopt($ch, CURLOPT_TIMEOUT, 5);
514
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
515
+            curl_setopt($ch, CURLOPT_HEADER, true);
516
+            curl_setopt($ch, CURLOPT_NOBODY, true);
517
+            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir"));
518
+            curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
519 519
 
520
-			@curl_exec($ch);
521
-			$ret = curl_getinfo($ch, $header);
522
-		}
520
+            @curl_exec($ch);
521
+            $ret = curl_getinfo($ch, $header);
522
+        }
523 523
 
524
-		return $ret;
525
-	}
524
+        return $ret;
525
+    }
526 526
 
527
-	private function get_content_type($url, $useragent = SELF_USER_AGENT) {
528
-		return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE);
529
-	}
527
+    private function get_content_type($url, $useragent = SELF_USER_AGENT) {
528
+        return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE);
529
+    }
530 530
 
531
-	private function get_location($url, $useragent = SELF_USER_AGENT) {
532
-		return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL);
533
-	}
531
+    private function get_location($url, $useragent = SELF_USER_AGENT) {
532
+        return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL);
533
+    }
534 534
 
535
-	/**
536
-	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
537
-	 */
538
-	private function readability($article, $url, $doc, $xpath, $debug = false) {
535
+    /**
536
+     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
537
+     */
538
+    private function readability($article, $url, $doc, $xpath, $debug = false) {
539 539
 
540
-		if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
541
-			mb_strlen(strip_tags($article["content"])) <= 150) {
540
+        if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") &&
541
+            mb_strlen(strip_tags($article["content"])) <= 150) {
542 542
 
543
-			// do not try to embed posts linking back to other reddit posts
544
-			// readability.php requires PHP 5.6
545
-			if ($url &&	strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) {
543
+            // do not try to embed posts linking back to other reddit posts
544
+            // readability.php requires PHP 5.6
545
+            if ($url &&	strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) {
546 546
 
547
-				/* link may lead to a huge video file or whatever, we need to check content type before trying to
547
+                /* link may lead to a huge video file or whatever, we need to check content type before trying to
548 548
 				parse it which p much requires curl */
549 549
 
550
-				$useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
551
-				$content_type = $this->get_content_type($url, $useragent_compat);
550
+                $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)";
551
+                $content_type = $this->get_content_type($url, $useragent_compat);
552 552
 
553
-				if ($content_type && strpos($content_type, "text/html") !== FALSE) {
553
+                if ($content_type && strpos($content_type, "text/html") !== FALSE) {
554 554
 
555
-					foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
556
-						$extracted_content = $p->hook_get_full_text($url);
555
+                    foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) {
556
+                        $extracted_content = $p->hook_get_full_text($url);
557 557
 
558
-						if ($extracted_content) {
559
-							$article["content"] = $extracted_content;
560
-							break;
561
-						}
562
-					}
563
-				}
564
-			}
565
-		}
558
+                        if ($extracted_content) {
559
+                            $article["content"] = $extracted_content;
560
+                            break;
561
+                        }
562
+                    }
563
+                }
564
+            }
565
+        }
566 566
 
567
-		return $article;
568
-	}
567
+        return $article;
568
+    }
569 569
 }
Please login to merge, or discard this patch.
plugins/no_url_hashes/init.php 1 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_URL_Hashes extends Plugin {
3
-	private $host;
3
+    private $host;
4 4
 
5
-	public function about() {
6
-		return array(1.0,
7
-			"Disable URL hash usage (e.g. #f=10, etc)",
8
-			"fox");
9
-	}
5
+    public function about() {
6
+        return array(1.0,
7
+            "Disable URL hash usage (e.g. #f=10, etc)",
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.
plugins/mail/init.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,45 +1,45 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 class Mail 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
-			"Share article via email",
10
-			"fox");
11
-	}
7
+    public function about() {
8
+        return array(1.0,
9
+            "Share article via email",
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
-		$host->add_hook($host::HOOK_PREFS_TAB, $this);
18
-	}
16
+        $host->add_hook($host::HOOK_ARTICLE_BUTTON, $this);
17
+        $host->add_hook($host::HOOK_PREFS_TAB, $this);
18
+    }
19 19
 
20
-	public function get_js() {
21
-		return file_get_contents(dirname(__FILE__) . "/mail.js");
22
-	}
20
+    public function get_js() {
21
+        return file_get_contents(dirname(__FILE__) . "/mail.js");
22
+    }
23 23
 
24
-	public function save() {
25
-		$addresslist = $_POST["addresslist"];
24
+    public function save() {
25
+        $addresslist = $_POST["addresslist"];
26 26
 
27
-		$this->host->set($this, "addresslist", $addresslist);
27
+        $this->host->set($this, "addresslist", $addresslist);
28 28
 
29
-		echo __("Mail addresses saved.");
30
-	}
29
+        echo __("Mail addresses saved.");
30
+    }
31 31
 
32
-	public function hook_prefs_tab($args) {
33
-		if ($args != "prefPrefs") return;
32
+    public function hook_prefs_tab($args) {
33
+        if ($args != "prefPrefs") return;
34 34
 
35
-		print "<div dojoType=\"dijit.layout.AccordionPane\"
35
+        print "<div dojoType=\"dijit.layout.AccordionPane\"
36 36
 			title=\"<i class='material-icons'>mail</i> ".__('Mail plugin')."\">";
37 37
 
38
-		print "<p>" . __("You can set predefined email addressed here (comma-separated list):") . "</p>";
38
+        print "<p>" . __("You can set predefined email addressed here (comma-separated list):") . "</p>";
39 39
 
40
-		print "<form dojoType=\"dijit.form.Form\">";
40
+        print "<form dojoType=\"dijit.form.Form\">";
41 41
 
42
-		print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
42
+        print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
43 43
 			evt.preventDefault();
44 44
 			if (this.validate()) {
45 45
 				console.log(dojo.objectToQuery(this.getValues()));
@@ -53,138 +53,138 @@  discard block
 block discarded – undo
53 53
 			}
54 54
 			</script>";
55 55
 
56
-			print_hidden("op", "pluginhandler");
57
-			print_hidden("method", "save");
58
-			print_hidden("plugin", "mail");
56
+            print_hidden("op", "pluginhandler");
57
+            print_hidden("method", "save");
58
+            print_hidden("plugin", "mail");
59 59
 
60
-			$addresslist = $this->host->get($this, "addresslist");
60
+            $addresslist = $this->host->get($this, "addresslist");
61 61
 
62
-			print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\"
62
+            print "<textarea dojoType=\"dijit.form.SimpleTextarea\" style='font-size : 12px; width : 50%' rows=\"3\"
63 63
 				name='addresslist'>$addresslist</textarea>";
64 64
 
65
-			print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
66
-				__("Save")."</button>";
65
+            print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
66
+                __("Save")."</button>";
67 67
 
68
-			print "</form>";
68
+            print "</form>";
69 69
 
70
-		print "</div>";
71
-	}
70
+        print "</div>";
71
+    }
72 72
 
73
-	public function hook_article_button($line) {
74
-		return "<i class='material-icons' style=\"cursor : pointer\"
73
+    public function hook_article_button($line) {
74
+        return "<i class='material-icons' style=\"cursor : pointer\"
75 75
 					onclick=\"Plugins.Mail.send(".$line["id"].")\"
76 76
 					title='".__('Forward by email')."'>mail</i>";
77
-	}
77
+    }
78 78
 
79
-	public function emailArticle() {
79
+    public function emailArticle() {
80 80
 
81
-		$ids = explode(",", $_REQUEST['param']);
82
-		$ids_qmarks = arr_qmarks($ids);
81
+        $ids = explode(",", $_REQUEST['param']);
82
+        $ids_qmarks = arr_qmarks($ids);
83 83
 
84
-		print_hidden("op", "pluginhandler");
85
-		print_hidden("plugin", "mail");
86
-		print_hidden("method", "sendEmail");
84
+        print_hidden("op", "pluginhandler");
85
+        print_hidden("plugin", "mail");
86
+        print_hidden("method", "sendEmail");
87 87
 
88
-		$sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE
88
+        $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE
89 89
 			id = ?");
90
-		$sth->execute([$_SESSION['uid']]);
90
+        $sth->execute([$_SESSION['uid']]);
91 91
 
92
-		if ($row = $sth->fetch()) {
93
-			$user_email = htmlspecialchars($row['email']);
94
-			$user_name = htmlspecialchars($row['full_name']);
95
-		}
92
+        if ($row = $sth->fetch()) {
93
+            $user_email = htmlspecialchars($row['email']);
94
+            $user_name = htmlspecialchars($row['full_name']);
95
+        }
96 96
 
97
-		if (!$user_name) $user_name = $_SESSION['name'];
97
+        if (!$user_name) $user_name = $_SESSION['name'];
98 98
 
99
-		print_hidden("from_email", "$user_email");
100
-		print_hidden("from_name", "$user_name");
99
+        print_hidden("from_email", "$user_email");
100
+        print_hidden("from_name", "$user_name");
101 101
 
102
-		require_once "lib/MiniTemplator.class.php";
102
+        require_once "lib/MiniTemplator.class.php";
103 103
 
104
-		$tpl = new MiniTemplator;
104
+        $tpl = new MiniTemplator;
105 105
 
106
-		$tpl->readTemplateFromFile("templates/email_article_template.txt");
106
+        $tpl->readTemplateFromFile("templates/email_article_template.txt");
107 107
 
108
-		$tpl->setVariable('USER_NAME', $_SESSION["name"], true);
109
-		$tpl->setVariable('USER_EMAIL', $user_email, true);
110
-		$tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
108
+        $tpl->setVariable('USER_NAME', $_SESSION["name"], true);
109
+        $tpl->setVariable('USER_EMAIL', $user_email, true);
110
+        $tpl->setVariable('TTRSS_HOST', $_SERVER["HTTP_HOST"], true);
111 111
 
112
-		$sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note
112
+        $sth = $this->pdo->prepare("SELECT DISTINCT link, content, title, note
113 113
 			FROM ttrss_user_entries, ttrss_entries WHERE id = ref_id AND
114 114
 			id IN ($ids_qmarks) AND owner_uid = ?");
115
-		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
115
+        $sth->execute(array_merge($ids, [$_SESSION['uid']]));
116 116
 
117
-		if (count($ids) > 1) {
118
-			$subject = __("[Forwarded]") . " " . __("Multiple articles");
119
-		}
117
+        if (count($ids) > 1) {
118
+            $subject = __("[Forwarded]") . " " . __("Multiple articles");
119
+        }
120 120
 
121
-		while ($line = $sth->fetch()) {
121
+        while ($line = $sth->fetch()) {
122 122
 
123
-			if (!$subject)
124
-				$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
123
+            if (!$subject)
124
+                $subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
125 125
 
126
-			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
127
-			$tnote = strip_tags($line["note"]);
128
-			if( $tnote != ''){
129
-				$tpl->setVariable('ARTICLE_NOTE', $tnote, true);
130
-				$tpl->addBlock('note');
131
-			}
132
-			$tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
126
+            $tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
127
+            $tnote = strip_tags($line["note"]);
128
+            if( $tnote != ''){
129
+                $tpl->setVariable('ARTICLE_NOTE', $tnote, true);
130
+                $tpl->addBlock('note');
131
+            }
132
+            $tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
133 133
 
134
-			$tpl->addBlock('article');
135
-		}
134
+            $tpl->addBlock('article');
135
+        }
136 136
 
137
-		$tpl->addBlock('email');
137
+        $tpl->addBlock('email');
138 138
 
139
-		$content = "";
140
-		$tpl->generateOutputToString($content);
139
+        $content = "";
140
+        $tpl->generateOutputToString($content);
141 141
 
142
-		print "<table width='100%'><tr><td>";
142
+        print "<table width='100%'><tr><td>";
143 143
 
144
-		$addresslist = explode(",", $this->host->get($this, "addresslist"));
144
+        $addresslist = explode(",", $this->host->get($this, "addresslist"));
145 145
 
146
-		print __('To:');
146
+        print __('To:');
147 147
 
148
-		print "</td><td>";
148
+        print "</td><td>";
149 149
 
150 150
 /*		print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"true\"
151 151
 				style=\"width : 30em;\"
152 152
 				name=\"destination\" id=\"emailArticleDlg_destination\">"; */
153 153
 
154
-		print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"');
154
+        print_select("destination", "", $addresslist, 'style="width: 30em" dojoType="dijit.form.ComboBox"');
155 155
 
156 156
 /*		print "<div class=\"autocomplete\" id=\"emailArticleDlg_dst_choices\"
157 157
 	style=\"z-index: 30; display : none\"></div>"; */
158 158
 
159
-		print "</td></tr><tr><td>";
159
+        print "</td></tr><tr><td>";
160 160
 
161
-		print __('Subject:');
161
+        print __('Subject:');
162 162
 
163
-		print "</td><td>";
163
+        print "</td><td>";
164 164
 
165
-		print "<input dojoType='dijit.form.ValidationTextBox' required='true'
165
+        print "<input dojoType='dijit.form.ValidationTextBox' required='true'
166 166
 				style='width : 30em;' name='subject' value=\"$subject\" id='subject'>";
167 167
 
168
-		print "</td></tr>";
168
+        print "</td></tr>";
169 169
 
170
-		print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea'
170
+        print "<tr><td colspan='2'><textarea dojoType='dijit.form.SimpleTextarea'
171 171
 			style='height : 200px; font-size : 12px; width : 98%' rows=\"20\"
172 172
 			name='content'>$content</textarea>";
173 173
 
174
-		print "</td></tr></table>";
174
+        print "</td></tr></table>";
175 175
 
176
-		print "<footer>";
177
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
178
-		print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
179
-		print "</footer>";
176
+        print "<footer>";
177
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').execute()\">".__('Send e-mail')."</button> ";
178
+        print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('emailArticleDlg').hide()\">".__('Cancel')."</button>";
179
+        print "</footer>";
180 180
 
181
-		//return;
182
-	}
181
+        //return;
182
+    }
183 183
 
184
-	public function sendEmail() {
185
-		$reply = array();
184
+    public function sendEmail() {
185
+        $reply = array();
186 186
 
187
-		/*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
187
+        /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
188 188
 			strip_tags($_REQUEST['from_name']));
189 189
 		//$mail->AddAddress($_REQUEST['destination']);
190 190
 		$addresses = explode(';', $_REQUEST['destination']);
@@ -197,29 +197,29 @@  discard block
 block discarded – undo
197 197
 
198 198
 		$rc = $mail->Send(); */
199 199
 
200
-		$to = $_REQUEST["destination"];
201
-		$subject = strip_tags($_REQUEST["subject"]);
202
-		$message = strip_tags($_REQUEST["content"]);
203
-		$from = strip_tags($_REQUEST["from_email"]);
200
+        $to = $_REQUEST["destination"];
201
+        $subject = strip_tags($_REQUEST["subject"]);
202
+        $message = strip_tags($_REQUEST["content"]);
203
+        $from = strip_tags($_REQUEST["from_email"]);
204 204
 
205
-		$mailer = new Mailer();
205
+        $mailer = new Mailer();
206 206
 
207
-		$rc = $mailer->mail(["to_address" => $to,
208
-			"headers" => ["Reply-To: $from"],
209
-			"subject" => $subject,
210
-			"message" => $message]);
207
+        $rc = $mailer->mail(["to_address" => $to,
208
+            "headers" => ["Reply-To: $from"],
209
+            "subject" => $subject,
210
+            "message" => $message]);
211 211
 
212
-		if (!$rc) {
213
-			$reply['error'] =  $mailer->error();
214
-		} else {
215
-			//save_email_address($destination);
216
-			$reply['message'] = "UPDATE_COUNTERS";
217
-		}
212
+        if (!$rc) {
213
+            $reply['error'] =  $mailer->error();
214
+        } else {
215
+            //save_email_address($destination);
216
+            $reply['message'] = "UPDATE_COUNTERS";
217
+        }
218 218
 
219
-		print json_encode($reply);
220
-	}
219
+        print json_encode($reply);
220
+    }
221 221
 
222
-	/* function completeEmails() {
222
+    /* function completeEmails() {
223 223
 		$search = $_REQUEST["search"];
224 224
 
225 225
 		print "<ul>";
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 		print "</ul>";
234 234
 	} */
235 235
 
236
-	public function api_version() {
237
-		return 2;
238
-	}
236
+    public function api_version() {
237
+        return 2;
238
+    }
239 239
 
240 240
 }
Please login to merge, or discard this patch.