@@ -12,7 +12,9 @@ |
||
12 | 12 | false, false, 0, |
13 | 13 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
14 | 14 | |
15 | - if (!$res) return $article; |
|
15 | + if (!$res) { |
|
16 | + return $article; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $doc = new DOMDocument(); |
18 | 20 |
@@ -17,11 +17,13 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -53,8 +53,9 @@ |
||
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"])); |
@@ -86,15 +86,17 @@ discard block |
||
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 |
||
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(); |
@@ -18,10 +18,11 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -19,8 +19,9 @@ discard block |
||
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 |
||
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" ]; |
@@ -82,8 +82,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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)); |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | $this->pdo = Db::pdo(); |
9 | 9 | $this->cache = array(); |
10 | 10 | |
11 | - if ($_SESSION["uid"]) $this->cache(); |
|
11 | + if ($_SESSION["uid"]) { |
|
12 | + $this->cache(); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | private function __clone() { |
@@ -16,8 +18,9 @@ discard block |
||
16 | 18 | } |
17 | 19 | |
18 | 20 | public static function get() { |
19 | - if (self::$instance == null) |
|
20 | - self::$instance = new self(); |
|
21 | + if (self::$instance == null) { |
|
22 | + self::$instance = new self(); |
|
23 | + } |
|
21 | 24 | |
22 | 25 | return self::$instance; |
23 | 26 | } |
@@ -26,7 +29,9 @@ discard block |
||
26 | 29 | $user_id = $_SESSION["uid"]; |
27 | 30 | @$profile = $_SESSION["profile"]; |
28 | 31 | |
29 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
32 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
33 | + $profile = null; |
|
34 | + } |
|
30 | 35 | |
31 | 36 | $sth = $this->pdo->prepare("SELECT |
32 | 37 | value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name |
@@ -65,7 +70,9 @@ discard block |
||
65 | 70 | return $this->convert($tuple["value"], $tuple["type"]); |
66 | 71 | } |
67 | 72 | |
68 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
73 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
74 | + $profile = null; |
|
75 | + } |
|
69 | 76 | |
70 | 77 | $sth = $this->pdo->prepare("SELECT |
71 | 78 | value,ttrss_prefs_types.type_name as type_name |
@@ -109,7 +116,9 @@ discard block |
||
109 | 116 | } |
110 | 117 | |
111 | 118 | function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
112 | - if ($strip_tags) $value = strip_tags($value); |
|
119 | + if ($strip_tags) { |
|
120 | + $value = strip_tags($value); |
|
121 | + } |
|
113 | 122 | |
114 | 123 | if (!$user_id) { |
115 | 124 | $user_id = $_SESSION["uid"]; |
@@ -118,7 +127,9 @@ discard block |
||
118 | 127 | $profile = null; |
119 | 128 | } |
120 | 129 | |
121 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
130 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
131 | + $profile = null; |
|
132 | + } |
|
122 | 133 | |
123 | 134 | $type_name = ""; |
124 | 135 | $current_value = ""; |
@@ -134,8 +145,9 @@ discard block |
||
134 | 145 | WHERE pref_name = ? AND type_id = ttrss_prefs_types.id"); |
135 | 146 | $sth->execute([$pref_name]); |
136 | 147 | |
137 | - if ($row = $sth->fetch()) |
|
138 | - $type_name = $row["type_name"]; |
|
148 | + if ($row = $sth->fetch()) { |
|
149 | + $type_name = $row["type_name"]; |
|
150 | + } |
|
139 | 151 | |
140 | 152 | } else if ($current_value == $value) { |
141 | 153 | return; |
@@ -4,10 +4,11 @@ discard block |
||
4 | 4 | private $last_error; |
5 | 5 | |
6 | 6 | function connect($host, $user, $pass, $db, $port) { |
7 | - if ($port) |
|
8 | - $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
9 | - else |
|
10 | - $this->link = mysqli_connect($host, $user, $pass, $db); |
|
7 | + if ($port) { |
|
8 | + $this->link = mysqli_connect($host, $user, $pass, $db, $port); |
|
9 | + } else { |
|
10 | + $this->link = mysqli_connect($host, $user, $pass, $db); |
|
11 | + } |
|
11 | 12 | |
12 | 13 | if ($this->link) { |
13 | 14 | $this->init(); |
@@ -20,7 +21,9 @@ discard block |
||
20 | 21 | } |
21 | 22 | |
22 | 23 | function escape_string($s, $strip_tags = true) { |
23 | - if ($strip_tags) $s = strip_tags($s); |
|
24 | + if ($strip_tags) { |
|
25 | + $s = strip_tags($s); |
|
26 | + } |
|
24 | 27 | |
25 | 28 | return mysqli_real_escape_string($this->link, $s); |
26 | 29 | } |