Passed
Pull Request — master (#1)
by
unknown
04:51
created
plugins/cache_starred_images/init.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 	private $host;
6 6
 	/* @var DiskCache $cache */
7 7
 	private $cache;
8
-    private $max_cache_attempts = 5; // per-article
8
+	private $max_cache_attempts = 5; // per-article
9 9
 
10 10
 	function about() {
11 11
 		return array(1.0,
@@ -167,30 +167,30 @@  discard block
 block discarded – undo
167 167
 
168 168
 		Debug::log("status: $status_filename", Debug::$LOG_VERBOSE);
169 169
 
170
-        if ($this->cache->exists($status_filename))
171
-            $status = json_decode($this->cache->get($status_filename), true);
172
-        else
173
-            $status = [];
170
+		if ($this->cache->exists($status_filename))
171
+			$status = json_decode($this->cache->get($status_filename), true);
172
+		else
173
+			$status = [];
174 174
 
175
-        $status["attempt"] += 1;
175
+		$status["attempt"] += 1;
176 176
 
177
-        // only allow several download attempts for article
178
-        if ($status["attempt"] > $this->max_cache_attempts) {
179
-            Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE);
180
-            return false;
181
-        }
177
+		// only allow several download attempts for article
178
+		if ($status["attempt"] > $this->max_cache_attempts) {
179
+			Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE);
180
+			return false;
181
+		}
182 182
 
183
-        if (!$this->cache->put($status_filename, json_encode($status))) {
184
-            user_error("unable to write status file: $status_filename", E_USER_WARNING);
185
-            return false;
186
-        }
183
+		if (!$this->cache->put($status_filename, json_encode($status))) {
184
+			user_error("unable to write status file: $status_filename", E_USER_WARNING);
185
+			return false;
186
+		}
187 187
 
188 188
 		$doc = new DOMDocument();
189 189
 
190 190
 		$has_images = false;
191 191
 		$success = false;
192 192
 
193
-        if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) {
193
+		if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) {
194 194
 			$xpath = new DOMXPath($doc);
195 195
 			$entries = $xpath->query('(//img[@src])|(//video/source[@src])');
196 196
 
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 		$esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND
213 213
 			(content_type LIKE '%image%' OR content_type LIKE '%video%')");
214 214
 
215
-        if ($esth->execute([$article_id])) {
216
-        	while ($enc = $esth->fetch()) {
215
+		if ($esth->execute([$article_id])) {
216
+			while ($enc = $esth->fetch()) {
217 217
 
218
-        		$has_images = true;
219
-        		$url = rewrite_relative_url($site_url, $enc["content_url"]);
218
+				$has_images = true;
219
+				$url = rewrite_relative_url($site_url, $enc["content_url"]);
220 220
 
221 221
 				if ($this->cache_url($article_id, $url)) {
222 222
 					$success = true;
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	function hook_house_keeping() {
39 39
 		/* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */
40 40
 
41
-		Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "...");
41
+		Debug::log("caching media of starred articles for user ".$this->host->get_owner_uid()."...");
42 42
 
43 43
 		$sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, 
44 44
        		ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 			$usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?");
57 57
 
58 58
 			while ($line = $sth->fetch()) {
59
-				Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE);
59
+				Debug::log("processing article ".$line["title"], Debug::$LOG_VERBOSE);
60 60
 
61 61
 				if ($line["site_url"]) {
62 62
 					$success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]);
63 63
 
64 64
 					if ($success) {
65
-						$plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"];
65
+						$plugin_data = "starred_cache_images,${line['owner_uid']}:".$line["plugin_data"];
66 66
 
67 67
 						$usth->execute([$plugin_data, $line['id']]);
68 68
 					}
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 
73 73
 		/* actual housekeeping */
74 74
 
75
-		Debug::log("expiring " . $this->cache->getDir() . "...");
75
+		Debug::log("expiring ".$this->cache->getDir()."...");
76 76
 
77
-		$files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE);
77
+		$files = glob($this->cache->getDir()."/*.{png,mp4,status}", GLOB_BRACE);
78 78
 
79 79
 		$last_article_id = 0;
80 80
 		$article_exists = 1;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	function hook_enclosure_entry($enc, $article_id) {
101
-		$local_filename = $article_id . "-" . sha1($enc["content_url"]);
101
+		$local_filename = $article_id."-".sha1($enc["content_url"]);
102 102
 
103 103
 		if ($this->cache->exists($local_filename)) {
104 104
 			$enc["content_url"] = $this->cache->getUrl($local_filename);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				if ($entry->hasAttribute('src')) {
121 121
 					$src = rewrite_relative_url($site_url, $entry->getAttribute('src'));
122 122
 
123
-					$local_filename = $article_id . "-" . sha1($src);
123
+					$local_filename = $article_id."-".sha1($src);
124 124
 
125 125
 					if ($this->cache->exists($local_filename)) {
126 126
 						$entry->setAttribute("src", $this->cache->getUrl($local_filename));
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 	private function cache_url($article_id, $url) {
137
-		$local_filename = $article_id . "-" . sha1($url);
137
+		$local_filename = $article_id."-".sha1($url);
138 138
 
139 139
 		if (!$this->cache->exists($local_filename)) {
140 140
 			Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE);
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 			$data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
143 143
 
144 144
 			if ($data)
145
-				return $this->cache->put($local_filename, $data);;
145
+				return $this->cache->put($local_filename, $data); ;
146 146
 
147 147
 		} else {
148 148
 			//Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
158 158
 	 */
159 159
 	private function cache_article_images($content, $site_url, $owner_uid, $article_id) {
160
-		$status_filename = $article_id . "-" . sha1($site_url) . ".status";
160
+		$status_filename = $article_id."-".sha1($site_url).".status";
161 161
 
162 162
 		/* housekeeping might run as a separate user, in this case status/media might not be writable */
163 163
 		if (!$this->cache->isWritable($status_filename)) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$has_images = false;
191 191
 		$success = false;
192 192
 
193
-        if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) {
193
+        if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) {
194 194
 			$xpath = new DOMXPath($doc);
195 195
 			$entries = $xpath->query('(//img[@src])|(//video/source[@src])');
196 196
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,11 +17,13 @@  discard block
 block discarded – undo
17 17
 		$this->host = $host;
18 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
 
23
-		if (!$this->cache->exists(".no-auto-expiry"))
24
-			$this->cache->touch(".no-auto-expiry");
24
+		if (!$this->cache->exists(".no-auto-expiry")) {
25
+					$this->cache->touch(".no-auto-expiry");
26
+		}
25 27
 
26 28
 		if ($this->cache->isWritable()) {
27 29
 			$host->add_hook($host::HOOK_HOUSE_KEEPING, $this);
@@ -141,8 +143,10 @@  discard block
 block discarded – undo
141 143
 
142 144
 			$data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
143 145
 
144
-			if ($data)
145
-				return $this->cache->put($local_filename, $data);;
146
+			if ($data) {
147
+							return $this->cache->put($local_filename, $data);
148
+			}
149
+			;
146 150
 
147 151
 		} else {
148 152
 			//Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE);
@@ -167,10 +171,11 @@  discard block
 block discarded – undo
167 171
 
168 172
 		Debug::log("status: $status_filename", Debug::$LOG_VERBOSE);
169 173
 
170
-        if ($this->cache->exists($status_filename))
171
-            $status = json_decode($this->cache->get($status_filename), true);
172
-        else
173
-            $status = [];
174
+        if ($this->cache->exists($status_filename)) {
175
+                    $status = json_decode($this->cache->get($status_filename), true);
176
+        } else {
177
+                    $status = [];
178
+        }
174 179
 
175 180
         $status["attempt"] += 1;
176 181
 
Please login to merge, or discard this patch.
plugins/mailto/init.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	}
16 16
 
17 17
 	function get_js() {
18
-		return file_get_contents(dirname(__FILE__) . "/init.js");
18
+		return file_get_contents(dirname(__FILE__)."/init.js");
19 19
 	}
20 20
 
21 21
 	function hook_article_button($line) {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$sth->execute(array_merge($ids, [$_SESSION['uid']]));
47 47
 
48 48
 		if (count($ids) > 1) {
49
-			$subject = __("[Forwarded]") . " " . __("Multiple articles");
49
+			$subject = __("[Forwarded]")." ".__("Multiple articles");
50 50
 		} else {
51 51
 			$subject = "";
52 52
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		while ($line = $sth->fetch()) {
55 55
 
56 56
 			if (!$subject)
57
-				$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
57
+				$subject = __("[Forwarded]")." ".htmlspecialchars($line["title"]);
58 58
 
59 59
 			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
60 60
 			$tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@
 block discarded – undo
53 53
 
54 54
 		while ($line = $sth->fetch()) {
55 55
 
56
-			if (!$subject)
57
-				$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
56
+			if (!$subject) {
57
+							$subject = __("[Forwarded]") . " " . htmlspecialchars($line["title"]);
58
+			}
58 59
 
59 60
 			$tpl->setVariable('ARTICLE_TITLE', strip_tags($line["title"]));
60 61
 			$tpl->setVariable('ARTICLE_URL', strip_tags($line["link"]));
Please login to merge, or discard this patch.
plugins/toggle_sidebar/init.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 	}
17 17
 
18 18
 	function get_js() {
19
-		return file_get_contents(__DIR__ . "/init.js");
19
+		return file_get_contents(__DIR__."/init.js");
20 20
 	}
21 21
 
22 22
 	function hook_main_toolbar_button() {
Please login to merge, or discard this patch.
plugins/note/init.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 	}
18 18
 
19 19
 	function get_js() {
20
-		return file_get_contents(dirname(__FILE__) . "/note.js");
20
+		return file_get_contents(dirname(__FILE__)."/note.js");
21 21
 	}
22 22
 
23 23
 
Please login to merge, or discard this patch.
plugins/af_fsckportal/init.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 
20 20
 			$doc = new DOMDocument();
21 21
 
22
-			@$doc->loadHTML('<?xml encoding="UTF-8">' . $article["content"]);
22
+			@$doc->loadHTML('<?xml encoding="UTF-8">'.$article["content"]);
23 23
 
24 24
 			if ($doc) {
25 25
 				$xpath = new DOMXPath($doc);
Please login to merge, or discard this patch.
classes/db.php 3 patches
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
 		$er = error_reporting(E_ALL);
25 25
 
26 26
 		switch (DB_TYPE) {
27
-			case "mysql":
28
-				$this->adapter = new Db_Mysqli();
29
-				break;
30
-			case "pgsql":
31
-				$this->adapter = new Db_Pgsql();
32
-				break;
33
-			default:
34
-				die("Unknown DB_TYPE: " . DB_TYPE);
27
+		case "mysql":
28
+			$this->adapter = new Db_Mysqli();
29
+			break;
30
+		case "pgsql":
31
+			$this->adapter = new Db_Pgsql();
32
+			break;
33
+		default:
34
+			die("Unknown DB_TYPE: " . DB_TYPE);
35 35
 		}
36 36
 
37 37
 		if (!$this->adapter) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 	private function legacy_connect() {
21 21
 
22
-		user_error("Legacy connect requested to " . DB_TYPE, E_USER_NOTICE);
22
+		user_error("Legacy connect requested to ".DB_TYPE, E_USER_NOTICE);
23 23
 
24 24
 		$er = error_reporting(E_ALL);
25 25
 
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 				$this->adapter = new Db_Pgsql();
32 32
 				break;
33 33
 			default:
34
-				die("Unknown DB_TYPE: " . DB_TYPE);
34
+				die("Unknown DB_TYPE: ".DB_TYPE);
35 35
 		}
36 36
 
37 37
 		if (!$this->adapter) {
38
-			print("Error initializing database adapter for " . DB_TYPE);
38
+			print("Error initializing database adapter for ".DB_TYPE);
39 39
 			exit(100);
40 40
 		}
41 41
 
42 42
 		$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
43 43
 
44 44
 		if (!$this->link) {
45
-			print("Error connecting through adapter: " . $this->adapter->last_error());
45
+			print("Error connecting through adapter: ".$this->adapter->last_error());
46 46
 			exit(101);
47 47
 		}
48 48
 
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 	// normal usage is Db::pdo()->prepare(...) etc
54 54
 	public function pdo_connect() {
55 55
 
56
-		$db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : '';
57
-		$db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : '';
56
+		$db_port = defined('DB_PORT') && DB_PORT ? ';port='.DB_PORT : '';
57
+		$db_host = defined('DB_HOST') && DB_HOST ? ';host='.DB_HOST : '';
58 58
 
59 59
 		try {
60
-			$pdo = new PDO(DB_TYPE . ':dbname=' . DB_NAME . $db_host . $db_port,
60
+			$pdo = new PDO(DB_TYPE.':dbname='.DB_NAME.$db_host.$db_port,
61 61
 				DB_USER,
62 62
 				DB_PASS);
63 63
 		} catch (Exception $e) {
64
-			print "<pre>Exception while creating PDO object:" . $e->getMessage() . "</pre>";
64
+			print "<pre>Exception while creating PDO object:".$e->getMessage()."</pre>";
65 65
 			exit(101);
66 66
 		}
67 67
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			$pdo->query("SET time_zone = '+0:0'");
79 79
 
80 80
 			if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
81
-				$pdo->query("SET NAMES " . MYSQL_CHARSET);
81
+				$pdo->query("SET NAMES ".MYSQL_CHARSET);
82 82
 			}
83 83
 		}
84 84
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,15 +86,17 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	public static function instance() {
89
-		if (self::$instance == null)
90
-			self::$instance = new self();
89
+		if (self::$instance == null) {
90
+					self::$instance = new self();
91
+		}
91 92
 
92 93
 		return self::$instance;
93 94
 	}
94 95
 
95 96
 	public static function get() {
96
-		if (self::$instance == null)
97
-			self::$instance = new self();
97
+		if (self::$instance == null) {
98
+					self::$instance = new self();
99
+		}
98 100
 
99 101
 		if (!self::$instance->adapter) {
100 102
 			self::$instance->legacy_connect();
@@ -104,8 +106,9 @@  discard block
 block discarded – undo
104 106
 	}
105 107
 
106 108
 	public static function pdo() {
107
-		if (self::$instance == null)
108
-			self::$instance = new self();
109
+		if (self::$instance == null) {
110
+					self::$instance = new self();
111
+		}
109 112
 
110 113
 		if (!self::$instance->pdo) {
111 114
 			self::$instance->pdo = self::$instance->pdo_connect();
Please login to merge, or discard this patch.
classes/diskcache.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 	private $dir;
4 4
 
5 5
 	public function __construct($dir) {
6
-		$this->dir = CACHE_DIR . "/" . clean_filename($dir);
6
+		$this->dir = CACHE_DIR."/".clean_filename($dir);
7 7
 	}
8 8
 
9 9
 	public function getDir() {
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public function getFullPath($filename) {
42 42
 		$filename = clean_filename($filename);
43 43
 
44
-		return $this->dir . "/" . $filename;
44
+		return $this->dir."/".$filename;
45 45
 	}
46 46
 
47 47
 	public function put($filename, $data) {
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	public function getUrl($filename) {
76
-		return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename;
76
+		return get_self_url_prefix()."/public.php?op=cached_url&file=".basename($this->dir)."/".$filename;
77 77
 	}
78 78
 
79 79
 	// check for locally cached (media) URLs and rewrite to local versions
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		if (!$res) return '';
86 86
 
87 87
 		$doc = new DOMDocument();
88
-		if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) {
88
+		if ($doc->loadHTML('<?xml encoding="UTF-8">'.$res)) {
89 89
 			$xpath = new DOMXPath($doc);
90 90
 			$cache = new DiskCache("images");
91 91
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	static function expire() {
129
-		$dirs = array_filter(glob(CACHE_DIR . "/*"), "is_dir");
129
+		$dirs = array_filter(glob(CACHE_DIR."/*"), "is_dir");
130 130
 
131 131
 		foreach ($dirs as $cache_dir) {
132 132
 			$num_deleted = 0;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 				if ($files) {
138 138
 					foreach ($files as $file) {
139
-						if (time() - filemtime($file) > 86400*CACHE_MAX_DAYS) {
139
+						if (time() - filemtime($file) > 86400 * CACHE_MAX_DAYS) {
140 140
 							unlink($file);
141 141
 
142 142
 							++$num_deleted;
Please login to merge, or discard this patch.
Braces   +26 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,10 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
 	public function isWritable($filename = "") {
20 20
 		if ($filename) {
21
-			if (file_exists($this->getFullPath($filename)))
22
-				return is_writable($this->getFullPath($filename));
23
-			else
24
-				return is_writable($this->dir);
21
+			if (file_exists($this->getFullPath($filename))) {
22
+							return is_writable($this->getFullPath($filename));
23
+			} else {
24
+							return is_writable($this->dir);
25
+			}
25 26
 		} else {
26 27
 			return is_writable($this->dir);
27 28
 		}
@@ -32,10 +33,11 @@  discard block
 block discarded – undo
32 33
 	}
33 34
 
34 35
 	public function getSize($filename) {
35
-		if ($this->exists($filename))
36
-			return filesize($this->getFullPath($filename));
37
-		else
38
-			return -1;
36
+		if ($this->exists($filename)) {
37
+					return filesize($this->getFullPath($filename));
38
+		} else {
39
+					return -1;
40
+		}
39 41
 	}
40 42
 
41 43
 	public function getFullPath($filename) {
@@ -53,17 +55,19 @@  discard block
 block discarded – undo
53 55
 	}
54 56
 
55 57
 	public function get($filename) {
56
-		if ($this->exists($filename))
57
-			return file_get_contents($this->getFullPath($filename));
58
-		else
59
-			return null;
58
+		if ($this->exists($filename)) {
59
+					return file_get_contents($this->getFullPath($filename));
60
+		} else {
61
+					return null;
62
+		}
60 63
 	}
61 64
 
62 65
 	public function getMimeType($filename) {
63
-		if ($this->exists($filename))
64
-			return mime_content_type($this->getFullPath($filename));
65
-		else
66
-			return null;
66
+		if ($this->exists($filename)) {
67
+					return mime_content_type($this->getFullPath($filename));
68
+		} else {
69
+					return null;
70
+		}
67 71
 	}
68 72
 
69 73
 	public function send($filename) {
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	static public function rewriteUrls($str)
83 87
 	{
84 88
 		$res = trim($str);
85
-		if (!$res) return '';
89
+		if (!$res) {
90
+			return '';
91
+		}
86 92
 
87 93
 		$doc = new DOMDocument();
88 94
 		if ($doc->loadHTML('<?xml encoding="UTF-8">' . $res)) {
@@ -105,9 +111,9 @@  discard block
 block discarded – undo
105 111
 
106 112
 						$src = $cache->getUrl(sha1($src));
107 113
 
108
-						if ($entry->hasAttribute('poster'))
109
-							$entry->setAttribute('poster', $src);
110
-						else {
114
+						if ($entry->hasAttribute('poster')) {
115
+													$entry->setAttribute('poster', $src);
116
+						} else {
111 117
 							$entry->setAttribute('src', $src);
112 118
 							$entry->removeAttribute("srcset");
113 119
 						}
Please login to merge, or discard this patch.
classes/mailer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 				return 0;
39 39
 		}
40 40
 
41
-		$headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ];
41
+		$headers = ["From: $from_combined", "Content-Type: text/plain; charset=UTF-8"];
42 42
 
43 43
 		return mail($to_combined, $subject, $message, implode("\r\n", array_merge($headers, $additional_headers)));
44 44
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,8 +19,9 @@  discard block
 block discarded – undo
19 19
 		$from_combined = $from_name ? "$from_name <$from_address>" : $from_address;
20 20
 		$to_combined = $to_name ? "$to_name <$to_address>" : $to_address;
21 21
 
22
-		if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL)
23
-			Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message");
22
+		if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) {
23
+					Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message");
24
+		}
24 25
 
25 26
 		// HOOK_SEND_MAIL plugin instructions:
26 27
 		// 1. return 1 or true if mail is handled
@@ -31,11 +32,13 @@  discard block
 block discarded – undo
31 32
 		foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SEND_MAIL) as $p) {
32 33
 			$rc = $p->hook_send_mail($this, $params);
33 34
 
34
-			if ($rc == 1)
35
-				return $rc;
35
+			if ($rc == 1) {
36
+							return $rc;
37
+			}
36 38
 
37
-			if ($rc == -1)
38
-				return 0;
39
+			if ($rc == -1) {
40
+							return 0;
41
+			}
39 42
 		}
40 43
 
41 44
 		$headers = [ "From: $from_combined", "Content-Type: text/plain; charset=UTF-8" ];
Please login to merge, or discard this patch.
classes/pluginhost.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
 					!is_dir(__DIR__."/../plugins.local/$class_file")) continue;
195 195
 
196 196
 			// try system plugin directory first
197
-			$file = __DIR__ . "/../plugins/$class_file/init.php";
198
-			$vendor_dir = __DIR__ . "/../plugins/$class_file/vendor";
197
+			$file = __DIR__."/../plugins/$class_file/init.php";
198
+			$vendor_dir = __DIR__."/../plugins/$class_file/vendor";
199 199
 
200 200
 			if (!file_exists($file)) {
201
-				$file = __DIR__ . "/../plugins.local/$class_file/init.php";
202
-				$vendor_dir = __DIR__ . "/../plugins.local/$class_file/vendor";
201
+				$file = __DIR__."/../plugins.local/$class_file/init.php";
202
+				$vendor_dir = __DIR__."/../plugins.local/$class_file/vendor";
203 203
 			}
204 204
 
205 205
 			if (!isset($this->plugins[$class])) {
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 								list ($namespace, $class_name) = explode('\\', $class, 2);
218 218
 
219 219
 								if ($namespace && $class_name) {
220
-									$class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php";
220
+									$class_file = "$vendor_dir/$namespace/".str_replace('\\', '/', $class_name).".php";
221 221
 
222 222
 									if (file_exists($class_file))
223 223
 										require_once $class_file;
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 					$plugin_api = $plugin->api_version();
232 232
 
233 233
 					if ($plugin_api < PluginHost::API_VERSION) {
234
-						user_error("Plugin $class is not compatible with current API version (need: " . PluginHost::API_VERSION . ", got: $plugin_api)", E_USER_WARNING);
234
+						user_error("Plugin $class is not compatible with current API version (need: ".PluginHost::API_VERSION.", got: $plugin_api)", E_USER_WARNING);
235 235
 						continue;
236 236
 					}
237 237
 
238
-					if (file_exists(dirname($file) . "/locale")) {
239
-						_bindtextdomain($class, dirname($file) . "/locale");
238
+					if (file_exists(dirname($file)."/locale")) {
239
+						_bindtextdomain($class, dirname($file)."/locale");
240 240
 						_bind_textdomain_codeset($class, "UTF-8");
241 241
 					}
242 242
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
 	}
320 320
 
321 321
 	function del_command($command) {
322
-		$command = "-" . strtolower($command);
322
+		$command = "-".strtolower($command);
323 323
 
324 324
 		unset($this->commands[$command]);
325 325
 	}
326 326
 
327 327
 	function lookup_command($command) {
328
-		$command = "-" . strtolower($command);
328
+		$command = "-".strtolower($command);
329 329
 
330 330
 		if (is_array($this->commands[$command])) {
331 331
 			return $this->commands[$command]["class"];
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	}
349 349
 
350 350
 	function load_data() {
351
-		if ($this->owner_uid)  {
351
+		if ($this->owner_uid) {
352 352
 			$sth = $this->pdo->prepare("SELECT name, content FROM ttrss_plugin_storage
353 353
 				WHERE owner_uid = ?");
354 354
 			$sth->execute([$this->owner_uid]);
@@ -375,13 +375,13 @@  discard block
 block discarded – undo
375 375
 			if ($sth->fetch()) {
376 376
 				$sth = $this->pdo->prepare("UPDATE ttrss_plugin_storage SET content = ?
377 377
 					WHERE owner_uid= ? AND name = ?");
378
-				$sth->execute([(string)$content, $this->owner_uid, $plugin]);
378
+				$sth->execute([(string) $content, $this->owner_uid, $plugin]);
379 379
 
380 380
 			} else {
381 381
 				$sth = $this->pdo->prepare("INSERT INTO ttrss_plugin_storage
382 382
 					(name,owner_uid,content) VALUES
383 383
 					(?, ?, ?)");
384
-				$sth->execute([$plugin, $this->owner_uid, (string)$content]);
384
+				$sth->execute([$plugin, $this->owner_uid, (string) $content]);
385 385
 			}
386 386
 
387 387
 			$this->pdo->commit();
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	}
496 496
 
497 497
 	// handled by classes/pluginhandler.php, requires valid session
498
-	function get_method_url($sender, $method, $params)  {
499
-		return get_self_url_prefix() . "/backend.php?" .
498
+	function get_method_url($sender, $method, $params) {
499
+		return get_self_url_prefix()."/backend.php?".
500 500
 			http_build_query(
501 501
 				array_merge(
502 502
 					[
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	}
509 509
 
510 510
 	// WARNING: endpoint in public.php, exposed to unauthenticated users
511
-	function get_public_method_url($sender, $method, $params)  {
511
+	function get_public_method_url($sender, $method, $params) {
512 512
 		if ($sender->is_public_method($method)) {
513
-			return get_self_url_prefix() . "/public.php?" .
513
+			return get_self_url_prefix()."/public.php?".
514 514
 				http_build_query(
515 515
 					array_merge(
516 516
 						[
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 						],
521 521
 						$params));
522 522
 		} else {
523
-			user_error("get_public_method_url: requested method '$method' of '" . get_class($sender) . "' is private.");
523
+			user_error("get_public_method_url: requested method '$method' of '".get_class($sender)."' is private.");
524 524
 		}
525 525
 	}
526 526
 }
Please login to merge, or discard this patch.
Braces   +36 added lines, -17 removed lines patch added patch discarded remove patch
@@ -82,8 +82,9 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	public static function getInstance() {
85
-		if (self::$instance == null)
86
-			self::$instance = new self();
85
+		if (self::$instance == null) {
86
+					self::$instance = new self();
87
+		}
87 88
 
88 89
 		return self::$instance;
89 90
 	}
@@ -191,7 +192,9 @@  discard block
 block discarded – undo
191 192
 			$class_file = strtolower(clean_filename($class));
192 193
 
193 194
 			if (!is_dir(__DIR__."/../plugins/$class_file") &&
194
-					!is_dir(__DIR__."/../plugins.local/$class_file")) continue;
195
+					!is_dir(__DIR__."/../plugins.local/$class_file")) {
196
+				continue;
197
+			}
195 198
 
196 199
 			// try system plugin directory first
197 200
 			$file = __DIR__ . "/../plugins/$class_file/init.php";
@@ -203,7 +206,9 @@  discard block
 block discarded – undo
203 206
 			}
204 207
 
205 208
 			if (!isset($this->plugins[$class])) {
206
-				if (file_exists($file)) require_once $file;
209
+				if (file_exists($file)) {
210
+					require_once $file;
211
+				}
207 212
 
208 213
 				if (class_exists($class) && is_subclass_of($class, "Plugin")) {
209 214
 
@@ -219,8 +224,9 @@  discard block
 block discarded – undo
219 224
 								if ($namespace && $class_name) {
220 225
 									$class_file = "$vendor_dir/$namespace/" . str_replace('\\', '/', $class_name) . ".php";
221 226
 
222
-									if (file_exists($class_file))
223
-										require_once $class_file;
227
+									if (file_exists($class_file)) {
228
+																			require_once $class_file;
229
+									}
224 230
 								}
225 231
 							}
226 232
 						});
@@ -245,18 +251,24 @@  discard block
 block discarded – undo
245 251
 					switch ($kind) {
246 252
 					case $this::KIND_SYSTEM:
247 253
 						if ($this->is_system($plugin)) {
248
-							if (!$skip_init) $plugin->init($this);
254
+							if (!$skip_init) {
255
+								$plugin->init($this);
256
+							}
249 257
 							$this->register_plugin($class, $plugin);
250 258
 						}
251 259
 						break;
252 260
 					case $this::KIND_USER:
253 261
 						if (!$this->is_system($plugin)) {
254
-							if (!$skip_init) $plugin->init($this);
262
+							if (!$skip_init) {
263
+								$plugin->init($this);
264
+							}
255 265
 							$this->register_plugin($class, $plugin);
256 266
 						}
257 267
 						break;
258 268
 					case $this::KIND_ALL:
259
-						if (!$skip_init) $plugin->init($this);
269
+						if (!$skip_init) {
270
+							$plugin->init($this);
271
+						}
260 272
 						$this->register_plugin($class, $plugin);
261 273
 						break;
262 274
 					}
@@ -367,8 +379,9 @@  discard block
 block discarded – undo
367 379
 				owner_uid= ? AND name = ?");
368 380
 			$sth->execute([$this->owner_uid, $plugin]);
369 381
 
370
-			if (!isset($this->storage[$plugin]))
371
-				$this->storage[$plugin] = array();
382
+			if (!isset($this->storage[$plugin])) {
383
+							$this->storage[$plugin] = array();
384
+			}
372 385
 
373 386
 			$content = serialize($this->storage[$plugin]);
374 387
 
@@ -391,12 +404,15 @@  discard block
 block discarded – undo
391 404
 	function set($sender, $name, $value, $sync = true) {
392 405
 		$idx = get_class($sender);
393 406
 
394
-		if (!isset($this->storage[$idx]))
395
-			$this->storage[$idx] = array();
407
+		if (!isset($this->storage[$idx])) {
408
+					$this->storage[$idx] = array();
409
+		}
396 410
 
397 411
 		$this->storage[$idx][$name] = $value;
398 412
 
399
-		if ($sync) $this->save_data(get_class($sender));
413
+		if ($sync) {
414
+			$this->save_data(get_class($sender));
415
+		}
400 416
 	}
401 417
 
402 418
 	function get($sender, $name, $default_value = false) {
@@ -433,7 +449,9 @@  discard block
 block discarded – undo
433 449
 
434 450
 	// cat_id: only -1 is supported (Special)
435 451
 	function add_feed($cat_id, $title, $icon, $sender) {
436
-		if (!$this->feeds[$cat_id]) $this->feeds[$cat_id] = array();
452
+		if (!$this->feeds[$cat_id]) {
453
+			$this->feeds[$cat_id] = array();
454
+		}
437 455
 
438 456
 		$id = count($this->feeds[$cat_id]);
439 457
 
@@ -479,8 +497,9 @@  discard block
 block discarded – undo
479 497
 	function add_filter_action($sender, $action_name, $action_desc) {
480 498
 		$sender_class = get_class($sender);
481 499
 
482
-		if (!isset($this->plugin_actions[$sender_class]))
483
-			$this->plugin_actions[$sender_class] = array();
500
+		if (!isset($this->plugin_actions[$sender_class])) {
501
+					$this->plugin_actions[$sender_class] = array();
502
+		}
484 503
 
485 504
 		array_push($this->plugin_actions[$sender_class],
486 505
 			array("action" => $action_name, "description" => $action_desc, "sender" => $sender));
Please login to merge, or discard this patch.