@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -15,7 +15,7 @@ discard block |
||
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 |
||
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 |
||
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"])); |
@@ -16,7 +16,7 @@ |
||
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() { |
@@ -17,7 +17,7 @@ |
||
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 |
@@ -19,7 +19,7 @@ |
||
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); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | function get_js() { |
16 | - return file_get_contents(__DIR__ . "/init.js"); |
|
16 | + return file_get_contents(__DIR__."/init.js"); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | function api_version() { |
@@ -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 |
@@ -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 | 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 | } |