@@ -24,14 +24,14 @@ |
||
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) { |
@@ -19,7 +19,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -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 | } |
@@ -3,7 +3,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
126 | 126 | } |
127 | 127 | |
128 | 128 | public 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 |
||
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; |
@@ -38,7 +38,7 @@ |
||
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 | } |
@@ -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" ]; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($type_name == "bool") { |
103 | 103 | return $value == "true"; |
104 | 104 | } else if ($type_name == "integer") { |
105 | - return (int)$value; |
|
105 | + return (int) $value; |
|
106 | 106 | } else { |
107 | 107 | return $value; |
108 | 108 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $value = "false"; |
150 | 150 | } |
151 | 151 | } else if ($type_name == "integer") { |
152 | - $value = (int)$value; |
|
152 | + $value = (int) $value; |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | if ($pref_name == 'USER_TIMEZONE' && $value == '') { |
@@ -8,12 +8,15 @@ 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 | public static function get() { |
15 | - if (self::$instance == null) |
|
16 | - self::$instance = new self(); |
|
17 | + if (self::$instance == null) { |
|
18 | + self::$instance = new self(); |
|
19 | + } |
|
17 | 20 | |
18 | 21 | return self::$instance; |
19 | 22 | } |
@@ -22,7 +25,9 @@ discard block |
||
22 | 25 | $user_id = $_SESSION["uid"]; |
23 | 26 | @$profile = $_SESSION["profile"]; |
24 | 27 | |
25 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
28 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
29 | + $profile = null; |
|
30 | + } |
|
26 | 31 | |
27 | 32 | $sth = $this->pdo->prepare("SELECT |
28 | 33 | value,ttrss_prefs_types.type_name as type_name,ttrss_prefs.pref_name AS pref_name |
@@ -61,7 +66,9 @@ discard block |
||
61 | 66 | return $this->convert($tuple["value"], $tuple["type"]); |
62 | 67 | } |
63 | 68 | |
64 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
69 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
70 | + $profile = null; |
|
71 | + } |
|
65 | 72 | |
66 | 73 | $sth = $this->pdo->prepare("SELECT |
67 | 74 | value,ttrss_prefs_types.type_name as type_name |
@@ -105,7 +112,9 @@ discard block |
||
105 | 112 | } |
106 | 113 | |
107 | 114 | public function write($pref_name, $value, $user_id = false, $strip_tags = true) { |
108 | - if ($strip_tags) $value = strip_tags($value); |
|
115 | + if ($strip_tags) { |
|
116 | + $value = strip_tags($value); |
|
117 | + } |
|
109 | 118 | |
110 | 119 | if (!$user_id) { |
111 | 120 | $user_id = $_SESSION["uid"]; |
@@ -114,7 +123,9 @@ discard block |
||
114 | 123 | $profile = null; |
115 | 124 | } |
116 | 125 | |
117 | - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; |
|
126 | + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) { |
|
127 | + $profile = null; |
|
128 | + } |
|
118 | 129 | |
119 | 130 | $type_name = ""; |
120 | 131 | $current_value = ""; |
@@ -130,8 +141,9 @@ discard block |
||
130 | 141 | WHERE pref_name = ? AND type_id = ttrss_prefs_types.id"); |
131 | 142 | $sth->execute([$pref_name]); |
132 | 143 | |
133 | - if ($row = $sth->fetch()) |
|
134 | - $type_name = $row["type_name"]; |
|
144 | + if ($row = $sth->fetch()) { |
|
145 | + $type_name = $row["type_name"]; |
|
146 | + } |
|
135 | 147 | |
136 | 148 | } else if ($current_value == $value) { |
137 | 149 | return; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | return $this->link; |
16 | 16 | } else { |
17 | - print("Unable to connect to database (as $user to $host, database $db): " . mysqli_connect_error()); |
|
17 | + print("Unable to connect to database (as $user to $host, database $db): ".mysqli_connect_error()); |
|
18 | 18 | exit(102); |
19 | 19 | } |
20 | 20 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $this->last_error = @mysqli_error($this->link); |
32 | 32 | |
33 | 33 | @mysqli_query($this->link, "ROLLBACK"); |
34 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
34 | + user_error("Query $query failed: ".($this->link ? $this->last_error : "No connection"), |
|
35 | 35 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
36 | 36 | } |
37 | 37 |
@@ -4,10 +4,11 @@ discard block |
||
4 | 4 | private $last_error; |
5 | 5 | |
6 | 6 | public 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 | public 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 | } |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | if (is_numeric($port) && $port > 0) { |
18 | - $string = "$string port=" . $port; |
|
18 | + $string = "$string port=".$port; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | $this->link = pg_connect($string); |
22 | 22 | |
23 | 23 | if (!$this->link) { |
24 | - print("Unable to connect to database (as $user to $host, database $db):" . pg_last_error()); |
|
24 | + print("Unable to connect to database (as $user to $host, database $db):".pg_last_error()); |
|
25 | 25 | exit(102); |
26 | 26 | } |
27 | 27 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | @pg_query($this->link, "ROLLBACK"); |
46 | 46 | $query = htmlspecialchars($query); // just in case |
47 | - user_error("Query $query failed: " . ($this->link ? $this->last_error : "No connection"), |
|
47 | + user_error("Query $query failed: ".($this->link ? $this->last_error : "No connection"), |
|
48 | 48 | $die_on_error ? E_USER_ERROR : E_USER_WARNING); |
49 | 49 | } |
50 | 50 | return $result; |
@@ -31,7 +31,9 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | public function escape_string($s, $strip_tags = true) { |
34 | - if ($strip_tags) $s = strip_tags($s); |
|
34 | + if ($strip_tags) { |
|
35 | + $s = strip_tags($s); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | return pg_escape_string($s); |
37 | 39 | } |
@@ -597,7 +597,7 @@ |
||
597 | 597 | "title" => $line["title"], |
598 | 598 | "unread" => $unread, |
599 | 599 | "is_cat" => true, |
600 | - "order_id" => (int) $line["order_id"] |
|
600 | + "order_id" => (int) $line["order_id"] |
|
601 | 601 | ); |
602 | 602 | array_push($feeds, $row); |
603 | 603 | } |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | |
219 | 219 | $override_order = false; |
220 | 220 | switch (clean($_REQUEST["order_by"])) { |
221 | - case "title": |
|
222 | - $override_order = "ttrss_entries.title, date_entered, updated"; |
|
223 | - break; |
|
224 | - case "date_reverse": |
|
225 | - $override_order = "score DESC, date_entered, updated"; |
|
226 | - $skip_first_id_check = true; |
|
227 | - break; |
|
228 | - case "feed_dates": |
|
229 | - $override_order = "updated DESC"; |
|
230 | - break; |
|
221 | + case "title": |
|
222 | + $override_order = "ttrss_entries.title, date_entered, updated"; |
|
223 | + break; |
|
224 | + case "date_reverse": |
|
225 | + $override_order = "score DESC, date_entered, updated"; |
|
226 | + $skip_first_id_check = true; |
|
227 | + break; |
|
228 | + case "feed_dates": |
|
229 | + $override_order = "updated DESC"; |
|
230 | + break; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /* do not rely on params below */ |
@@ -259,32 +259,32 @@ discard block |
||
259 | 259 | $set_to = ""; |
260 | 260 | |
261 | 261 | switch ($field_raw) { |
262 | - case 0: |
|
263 | - $field = "marked"; |
|
264 | - $additional_fields = ",last_marked = NOW()"; |
|
265 | - break; |
|
266 | - case 1: |
|
267 | - $field = "published"; |
|
268 | - $additional_fields = ",last_published = NOW()"; |
|
269 | - break; |
|
270 | - case 2: |
|
271 | - $field = "unread"; |
|
272 | - $additional_fields = ",last_read = NOW()"; |
|
273 | - break; |
|
274 | - case 3: |
|
275 | - $field = "note"; |
|
262 | + case 0: |
|
263 | + $field = "marked"; |
|
264 | + $additional_fields = ",last_marked = NOW()"; |
|
265 | + break; |
|
266 | + case 1: |
|
267 | + $field = "published"; |
|
268 | + $additional_fields = ",last_published = NOW()"; |
|
269 | + break; |
|
270 | + case 2: |
|
271 | + $field = "unread"; |
|
272 | + $additional_fields = ",last_read = NOW()"; |
|
273 | + break; |
|
274 | + case 3: |
|
275 | + $field = "note"; |
|
276 | 276 | }; |
277 | 277 | |
278 | 278 | switch ($mode) { |
279 | - case 1: |
|
280 | - $set_to = "true"; |
|
281 | - break; |
|
282 | - case 0: |
|
283 | - $set_to = "false"; |
|
284 | - break; |
|
285 | - case 2: |
|
286 | - $set_to = "NOT $field"; |
|
287 | - break; |
|
279 | + case 1: |
|
280 | + $set_to = "true"; |
|
281 | + break; |
|
282 | + case 0: |
|
283 | + $set_to = "false"; |
|
284 | + break; |
|
285 | + case 2: |
|
286 | + $set_to = "NOT $field"; |
|
287 | + break; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | if ($field == "note") $set_to = $this->pdo->quote($data); |
@@ -57,7 +57,9 @@ discard block |
||
57 | 57 | $password = clean($_REQUEST["password"]); |
58 | 58 | $password_base64 = base64_decode(clean($_REQUEST["password"])); |
59 | 59 | |
60 | - if (SINGLE_USER_MODE) $login = "admin"; |
|
60 | + if (SINGLE_USER_MODE) { |
|
61 | + $login = "admin"; |
|
62 | + } |
|
61 | 63 | |
62 | 64 | $sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); |
63 | 65 | $sth->execute([$login]); |
@@ -134,10 +136,11 @@ discard block |
||
134 | 136 | |
135 | 137 | // TODO do not return empty categories, return Uncategorized and standard virtual cats |
136 | 138 | |
137 | - if ($enable_nested) |
|
138 | - $nested_qpart = "parent_cat IS NULL"; |
|
139 | - else |
|
140 | - $nested_qpart = "true"; |
|
139 | + if ($enable_nested) { |
|
140 | + $nested_qpart = "parent_cat IS NULL"; |
|
141 | + } else { |
|
142 | + $nested_qpart = "true"; |
|
143 | + } |
|
141 | 144 | |
142 | 145 | $sth = $this->pdo->prepare("SELECT |
143 | 146 | id, title, order_id, (SELECT COUNT(id) FROM |
@@ -156,8 +159,9 @@ discard block |
||
156 | 159 | if ($include_empty || $line["num_feeds"] > 0 || $line["num_cats"] > 0) { |
157 | 160 | $unread = getFeedUnread($line["id"], true); |
158 | 161 | |
159 | - if ($enable_nested) |
|
160 | - $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
162 | + if ($enable_nested) { |
|
163 | + $unread += Feeds::getCategoryChildrenUnread($line["id"]); |
|
164 | + } |
|
161 | 165 | |
162 | 166 | if ($unread || !$unread_only) { |
163 | 167 | array_push($cats, array("id" => $line["id"], |
@@ -188,11 +192,15 @@ discard block |
||
188 | 192 | $feed_id = clean($_REQUEST["feed_id"]); |
189 | 193 | if ($feed_id !== "") { |
190 | 194 | |
191 | - if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
|
195 | + if (is_numeric($feed_id)) { |
|
196 | + $feed_id = (int) $feed_id; |
|
197 | + } |
|
192 | 198 | |
193 | 199 | $limit = (int)clean($_REQUEST["limit"]); |
194 | 200 | |
195 | - if (!$limit || $limit >= 200) $limit = 200; |
|
201 | + if (!$limit || $limit >= 200) { |
|
202 | + $limit = 200; |
|
203 | + } |
|
196 | 204 | |
197 | 205 | $offset = (int)clean($_REQUEST["skip"]); |
198 | 206 | $filter = clean($_REQUEST["filter"]); |
@@ -287,7 +295,9 @@ discard block |
||
287 | 295 | break; |
288 | 296 | } |
289 | 297 | |
290 | - if ($field == "note") $set_to = $this->pdo->quote($data); |
|
298 | + if ($field == "note") { |
|
299 | + $set_to = $this->pdo->quote($data); |
|
300 | + } |
|
291 | 301 | |
292 | 302 | if ($field && $set_to && count($article_ids) > 0) { |
293 | 303 | |
@@ -443,10 +453,11 @@ discard block |
||
443 | 453 | WHERE owner_uid = ? ORDER BY caption"); |
444 | 454 | $sth->execute([$_SESSION['uid']]); |
445 | 455 | |
446 | - if ($article_id) |
|
447 | - $article_labels = Article::get_article_labels($article_id); |
|
448 | - else |
|
449 | - $article_labels = array(); |
|
456 | + if ($article_id) { |
|
457 | + $article_labels = Article::get_article_labels($article_id); |
|
458 | + } else { |
|
459 | + $article_labels = array(); |
|
460 | + } |
|
450 | 461 | |
451 | 462 | while ($line = $sth->fetch()) { |
452 | 463 | |
@@ -483,10 +494,11 @@ discard block |
||
483 | 494 | |
484 | 495 | foreach ($article_ids as $id) { |
485 | 496 | |
486 | - if ($assign) |
|
487 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
488 | - else |
|
489 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
497 | + if ($assign) { |
|
498 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
499 | + } else { |
|
500 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
501 | + } |
|
490 | 502 | |
491 | 503 | ++$num_updated; |
492 | 504 | |
@@ -738,14 +750,17 @@ discard block |
||
738 | 750 | $label_cache = json_decode($label_cache, true); |
739 | 751 | |
740 | 752 | if ($label_cache) { |
741 | - if ($label_cache["no-labels"] == 1) |
|
742 | - $labels = array(); |
|
743 | - else |
|
744 | - $labels = $label_cache; |
|
753 | + if ($label_cache["no-labels"] == 1) { |
|
754 | + $labels = array(); |
|
755 | + } else { |
|
756 | + $labels = $label_cache; |
|
757 | + } |
|
745 | 758 | } |
746 | 759 | } |
747 | 760 | |
748 | - if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
|
761 | + if (!is_array($labels)) { |
|
762 | + $labels = Article::get_article_labels($line["id"]); |
|
763 | + } |
|
749 | 764 | |
750 | 765 | $headline_row = array( |
751 | 766 | "id" => (int)$line["id"], |
@@ -763,11 +778,13 @@ discard block |
||
763 | 778 | |
764 | 779 | $enclosures = Article::get_article_enclosures($line['id']); |
765 | 780 | |
766 | - if ($include_attachments) |
|
767 | - $headline_row['attachments'] = $enclosures; |
|
781 | + if ($include_attachments) { |
|
782 | + $headline_row['attachments'] = $enclosures; |
|
783 | + } |
|
768 | 784 | |
769 | - if ($show_excerpt) |
|
770 | - $headline_row["excerpt"] = $line["content_preview"]; |
|
785 | + if ($show_excerpt) { |
|
786 | + $headline_row["excerpt"] = $line["content_preview"]; |
|
787 | + } |
|
771 | 788 | |
772 | 789 | if ($show_content) { |
773 | 790 | |
@@ -782,7 +799,9 @@ discard block |
||
782 | 799 | } |
783 | 800 | |
784 | 801 | // unify label output to ease parsing |
785 | - if ($labels["no-labels"] == 1) $labels = array(); |
|
802 | + if ($labels["no-labels"] == 1) { |
|
803 | + $labels = array(); |
|
804 | + } |
|
786 | 805 | |
787 | 806 | $headline_row["labels"] = $labels; |
788 | 807 |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | if (get_pref("ENABLE_API_ACCESS", $uid)) { |
77 | - if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
77 | + if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password |
|
78 | 78 | $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
79 | 79 | "api_level" => self::API_LEVEL)); |
80 | 80 | } else if (authenticate_user($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password |
81 | - $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
81 | + $this->wrap(self::STATUS_OK, array("session_id" => session_id(), |
|
82 | 82 | "api_level" => self::API_LEVEL)); |
83 | 83 | } else { // else we are not logged in |
84 | 84 | user_error("Failed login attempt for $login from {$_SERVER['REMOTE_ADDR']}", E_USER_WARNING); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - foreach (array(-2,-1,0) as $cat_id) { |
|
172 | + foreach (array(-2, -1, 0) as $cat_id) { |
|
173 | 173 | if ($include_empty || !$this->isCategoryEmpty($cat_id)) { |
174 | 174 | $unread = getFeedUnread($cat_id, true); |
175 | 175 | |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | |
191 | 191 | if (is_numeric($feed_id)) $feed_id = (int) $feed_id; |
192 | 192 | |
193 | - $limit = (int)clean($_REQUEST["limit"]); |
|
193 | + $limit = (int) clean($_REQUEST["limit"]); |
|
194 | 194 | |
195 | 195 | if (!$limit || $limit >= 200) $limit = 200; |
196 | 196 | |
197 | - $offset = (int)clean($_REQUEST["skip"]); |
|
197 | + $offset = (int) clean($_REQUEST["skip"]); |
|
198 | 198 | $filter = clean($_REQUEST["filter"]); |
199 | 199 | $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); |
200 | 200 | $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | /* all_articles, unread, adaptive, marked, updated */ |
203 | 203 | $view_mode = clean($_REQUEST["view_mode"]); |
204 | 204 | $include_attachments = API::param_to_bool(clean($_REQUEST["include_attachments"])); |
205 | - $since_id = (int)clean($_REQUEST["since_id"]); |
|
205 | + $since_id = (int) clean($_REQUEST["since_id"]); |
|
206 | 206 | $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); |
207 | 207 | $sanitize_content = !isset($_REQUEST["sanitize"]) || |
208 | 208 | API::param_to_bool($_REQUEST["sanitize"]); |
209 | 209 | $force_update = API::param_to_bool(clean($_REQUEST["force_update"])); |
210 | 210 | $has_sandbox = API::param_to_bool(clean($_REQUEST["has_sandbox"])); |
211 | - $excerpt_length = (int)clean($_REQUEST["excerpt_length"]); |
|
212 | - $check_first_id = (int)clean($_REQUEST["check_first_id"]); |
|
211 | + $excerpt_length = (int) clean($_REQUEST["excerpt_length"]); |
|
212 | + $check_first_id = (int) clean($_REQUEST["check_first_id"]); |
|
213 | 213 | $include_header = API::param_to_bool(clean($_REQUEST["include_header"])); |
214 | 214 | |
215 | 215 | $_SESSION['hasSandbox'] = $has_sandbox; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $article_ids = explode(",", clean($_REQUEST["article_ids"])); |
254 | 254 | $mode = (int) clean($_REQUEST["mode"]); |
255 | 255 | $data = clean($_REQUEST["data"]); |
256 | - $field_raw = (int)clean($_REQUEST["field"]); |
|
256 | + $field_raw = (int) clean($_REQUEST["field"]); |
|
257 | 257 | |
258 | 258 | $field = ""; |
259 | 259 | $set_to = ""; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | "updated" => (int) strtotime($line["updated"]), |
361 | 361 | "feed_id" => $line["feed_id"], |
362 | 362 | "attachments" => $attachments, |
363 | - "score" => (int)$line["score"], |
|
363 | + "score" => (int) $line["score"], |
|
364 | 364 | "feed_title" => $line["feed_title"], |
365 | 365 | "note" => $line["note"], |
366 | 366 | "lang" => $line["lang"] |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | public function getLabels() { |
437 | - $article_id = (int)clean($_REQUEST['article_id']); |
|
437 | + $article_id = (int) clean($_REQUEST['article_id']); |
|
438 | 438 | |
439 | 439 | $rv = array(); |
440 | 440 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | |
461 | 461 | array_push($rv, array( |
462 | - "id" => (int)Labels::label_to_feed_id($line['id']), |
|
462 | + "id" => (int) Labels::label_to_feed_id($line['id']), |
|
463 | 463 | "caption" => $line['caption'], |
464 | 464 | "fg_color" => $line['fg_color'], |
465 | 465 | "bg_color" => $line['bg_color'], |
@@ -644,10 +644,10 @@ discard block |
||
644 | 644 | $row = array( |
645 | 645 | "feed_url" => $line["feed_url"], |
646 | 646 | "title" => $line["title"], |
647 | - "id" => (int)$line["id"], |
|
648 | - "unread" => (int)$unread, |
|
647 | + "id" => (int) $line["id"], |
|
648 | + "unread" => (int) $unread, |
|
649 | 649 | "has_icon" => $has_icon, |
650 | - "cat_id" => (int)$line["cat_id"], |
|
650 | + "cat_id" => (int) $line["cat_id"], |
|
651 | 651 | "last_updated" => (int) strtotime($line["last_updated"]), |
652 | 652 | "order_id" => (int) $line["order_id"], |
653 | 653 | ); |
@@ -748,12 +748,12 @@ discard block |
||
748 | 748 | if (!is_array($labels)) $labels = Article::get_article_labels($line["id"]); |
749 | 749 | |
750 | 750 | $headline_row = array( |
751 | - "id" => (int)$line["id"], |
|
751 | + "id" => (int) $line["id"], |
|
752 | 752 | "guid" => $line["guid"], |
753 | 753 | "unread" => API::param_to_bool($line["unread"]), |
754 | 754 | "marked" => API::param_to_bool($line["marked"]), |
755 | 755 | "published" => API::param_to_bool($line["published"]), |
756 | - "updated" => (int)strtotime($line["updated"]), |
|
756 | + "updated" => (int) strtotime($line["updated"]), |
|
757 | 757 | "is_updated" => $is_updated, |
758 | 758 | "title" => $line["title"], |
759 | 759 | "link" => $line["link"], |
@@ -786,17 +786,16 @@ discard block |
||
786 | 786 | |
787 | 787 | $headline_row["labels"] = $labels; |
788 | 788 | |
789 | - $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : |
|
790 | - $feed_title; |
|
789 | + $headline_row["feed_title"] = $line["feed_title"] ? $line["feed_title"] : $feed_title; |
|
791 | 790 | |
792 | - $headline_row["comments_count"] = (int)$line["num_comments"]; |
|
791 | + $headline_row["comments_count"] = (int) $line["num_comments"]; |
|
793 | 792 | $headline_row["comments_link"] = $line["comments"]; |
794 | 793 | |
795 | 794 | $headline_row["always_display_attachments"] = API::param_to_bool($line["always_display_enclosures"]); |
796 | 795 | |
797 | 796 | $headline_row["author"] = $line["author"]; |
798 | 797 | |
799 | - $headline_row["score"] = (int)$line["score"]; |
|
798 | + $headline_row["score"] = (int) $line["score"]; |
|
800 | 799 | $headline_row["note"] = $line["note"]; |
801 | 800 | $headline_row["lang"] = $line["lang"]; |
802 | 801 | |
@@ -858,7 +857,7 @@ discard block |
||
858 | 857 | $_REQUEST['mode'] = 2; |
859 | 858 | $_REQUEST['force_show_empty'] = $include_empty; |
860 | 859 | |
861 | - if ($pf){ |
|
860 | + if ($pf) { |
|
862 | 861 | $data = $pf->makefeedtree(); |
863 | 862 | $this->wrap(self::STATUS_OK, array("categories" => $data)); |
864 | 863 | } else { |
@@ -126,14 +126,14 @@ |
||
126 | 126 | $tmp = ''; |
127 | 127 | foreach (str_split($keys[$i]) as $c) { |
128 | 128 | switch ($c) { |
129 | - case '*': |
|
130 | - $tmp .= __('Shift') . '+'; |
|
131 | - break; |
|
132 | - case '^': |
|
133 | - $tmp .= __('Ctrl') . '+'; |
|
134 | - break; |
|
135 | - default: |
|
136 | - $tmp .= $c; |
|
129 | + case '*': |
|
130 | + $tmp .= __('Shift') . '+'; |
|
131 | + break; |
|
132 | + case '^': |
|
133 | + $tmp .= __('Ctrl') . '+'; |
|
134 | + break; |
|
135 | + default: |
|
136 | + $tmp .= $c; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | $keys[$i] = $tmp; |
@@ -30,7 +30,9 @@ discard block |
||
30 | 30 | $omap = array(); |
31 | 31 | |
32 | 32 | foreach ($imap[1] as $sequence => $action) { |
33 | - if (!isset($omap[$action])) $omap[$action] = array(); |
|
33 | + if (!isset($omap[$action])) { |
|
34 | + $omap[$action] = array(); |
|
35 | + } |
|
34 | 36 | |
35 | 37 | array_push($omap[$action], $sequence); |
36 | 38 | } |
@@ -40,7 +42,9 @@ discard block |
||
40 | 42 | $cur_section = ""; |
41 | 43 | foreach ($info as $section => $hotkeys) { |
42 | 44 | |
43 | - if ($cur_section) print "<li> </li>"; |
|
45 | + if ($cur_section) { |
|
46 | + print "<li> </li>"; |
|
47 | + } |
|
44 | 48 | print "<li><h3>" . $section . "</h3></li>"; |
45 | 49 | $cur_section = $section; |
46 | 50 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | class Backend extends Handler { |
3 | 3 | public function loading() { |
4 | 4 | header("Content-type: text/html"); |
5 | - print __("Loading, please wait...") . " " . |
|
5 | + print __("Loading, please wait...")." ". |
|
6 | 6 | "<img src='images/indicator_tiny.gif'>"; |
7 | 7 | } |
8 | 8 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | foreach ($info as $section => $hotkeys) { |
42 | 42 | |
43 | 43 | if ($cur_section) print "<li> </li>"; |
44 | - print "<li><h3>" . $section . "</h3></li>"; |
|
44 | + print "<li><h3>".$section."</h3></li>"; |
|
45 | 45 | $cur_section = $section; |
46 | 46 | |
47 | 47 | foreach ($hotkeys as $action => $description) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | foreach ($omap[$action] as $sequence) { |
51 | 51 | if (strpos($sequence, "|") !== FALSE) { |
52 | 52 | $sequence = substr($sequence, |
53 | - strpos($sequence, "|")+1, |
|
53 | + strpos($sequence, "|") + 1, |
|
54 | 54 | strlen($sequence)); |
55 | 55 | } else { |
56 | 56 | $keys = explode(" ", $sequence); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | foreach (str_split($keys[$i]) as $c) { |
62 | 62 | switch ($c) { |
63 | 63 | case '*': |
64 | - $tmp .= __('Shift') . '+'; |
|
64 | + $tmp .= __('Shift').'+'; |
|
65 | 65 | break; |
66 | 66 | case '^': |
67 | - $tmp .= __('Ctrl') . '+'; |
|
67 | + $tmp .= __('Ctrl').'+'; |
|
68 | 68 | break; |
69 | 69 | default: |
70 | 70 | $tmp .= $c; |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | $line[$k] = htmlspecialchars($v); |
61 | 61 | } |
62 | 62 | |
63 | - print "<td class='errno'>" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")</td>"; |
|
64 | - print "<td class='filename'>" . $line["filename"] . ":" . $line["lineno"] . "</td>"; |
|
65 | - print "<td class='errstr'>" . $line["errstr"] . "<hr/>" . nl2br($line["context"]) . "</td>"; |
|
66 | - print "<td class='login'>" . $line["login"] . "</td>"; |
|
63 | + print "<td class='errno'>".Logger::$errornames[$line["errno"]]." (".$line["errno"].")</td>"; |
|
64 | + print "<td class='filename'>".$line["filename"].":".$line["lineno"]."</td>"; |
|
65 | + print "<td class='errstr'>".$line["errstr"]."<hr/>".nl2br($line["context"])."</td>"; |
|
66 | + print "<td class='login'>".$line["login"]."</td>"; |
|
67 | 67 | |
68 | - print "<td class='timestamp'>" . |
|
68 | + print "<td class='timestamp'>". |
|
69 | 69 | make_local_datetime( |
70 | - $line["created_at"], false) . "</td>"; |
|
70 | + $line["created_at"], false)."</td>"; |
|
71 | 71 | |
72 | 72 | print "</tr>"; |
73 | 73 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ob_end_clean(); |
91 | 91 | |
92 | 92 | print "<div class='phpinfo'>"; |
93 | - print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $info); |
|
93 | + print preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $info); |
|
94 | 94 | print "</div>"; |
95 | 95 | |
96 | 96 | print "</div>"; |