@@ -280,36 +280,36 @@ |
||
| 280 | 280 | $found = true; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - // imgur via link rel="image_src" href="..." |
|
| 284 | - if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) { |
|
| 283 | + // imgur via link rel="image_src" href="..." |
|
| 284 | + if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) { |
|
| 285 | 285 | |
| 286 | - Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE); |
|
| 286 | + Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE); |
|
| 287 | 287 | |
| 288 | - $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
| 289 | - "http_accept" => "text/*"]); |
|
| 288 | + $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
| 289 | + "http_accept" => "text/*"]); |
|
| 290 | 290 | |
| 291 | - if ($content) { |
|
| 292 | - $cdoc = new DOMDocument(); |
|
| 291 | + if ($content) { |
|
| 292 | + $cdoc = new DOMDocument(); |
|
| 293 | 293 | |
| 294 | - if (@$cdoc->loadHTML($content)) { |
|
| 295 | - $cxpath = new DOMXPath($cdoc); |
|
| 294 | + if (@$cdoc->loadHTML($content)) { |
|
| 295 | + $cxpath = new DOMXPath($cdoc); |
|
| 296 | 296 | |
| 297 | - $rel_image = $cxpath->query("//link[@rel='image_src']")->item(0); |
|
| 297 | + $rel_image = $cxpath->query("//link[@rel='image_src']")->item(0); |
|
| 298 | 298 | |
| 299 | - if ($rel_image) { |
|
| 299 | + if ($rel_image) { |
|
| 300 | 300 | |
| 301 | - $img = $doc->createElement('img'); |
|
| 302 | - $img->setAttribute("src", $rel_image->getAttribute("href")); |
|
| 301 | + $img = $doc->createElement('img'); |
|
| 302 | + $img->setAttribute("src", $rel_image->getAttribute("href")); |
|
| 303 | 303 | |
| 304 | - $br = $doc->createElement('br'); |
|
| 305 | - $entry->parentNode->insertBefore($img, $entry); |
|
| 306 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 304 | + $br = $doc->createElement('br'); |
|
| 305 | + $entry->parentNode->insertBefore($img, $entry); |
|
| 306 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 307 | 307 | |
| 308 | - $found = true; |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - } |
|
| 308 | + $found = true; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | 314 | // wtf is this even |
| 315 | 315 | if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) { |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | print "<fieldset class='narrow'>"; |
| 58 | 58 | print "<label class='checkbox'>"; |
| 59 | 59 | print_checkbox("enable_readability", $enable_readability); |
| 60 | - print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>"; |
|
| 60 | + print " ".__("Extract missing content using Readability (requires af_readability)")."</label>"; |
|
| 61 | 61 | print "</fieldset>"; |
| 62 | 62 | |
| 63 | 63 | print "<fieldset class='narrow'>"; |
| 64 | 64 | print "<label class='checkbox'>"; |
| 65 | 65 | print_checkbox("enable_content_dupcheck", $enable_content_dupcheck); |
| 66 | - print " " . __("Enable additional duplicate checking") . "</label>"; |
|
| 66 | + print " ".__("Enable additional duplicate checking")."</label>"; |
|
| 67 | 67 | print "</fieldset>"; |
| 68 | 68 | |
| 69 | 69 | print_button("submit", __("Save"), 'class="alt-primary"'); |
@@ -96,14 +96,14 @@ discard block |
||
| 96 | 96 | foreach ($entries as $entry) { |
| 97 | 97 | if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) { |
| 98 | 98 | |
| 99 | - Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE); |
|
| 99 | + Debug::log("processing href: ".$entry->getAttribute("href"), Debug::$LOG_VERBOSE); |
|
| 100 | 100 | |
| 101 | 101 | $matches = array(); |
| 102 | 102 | |
| 103 | 103 | if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) { |
| 104 | - Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE); |
|
| 104 | + Debug::log("handling as twitter: ".$matches[1]." ".$matches[2], Debug::$LOG_VERBOSE); |
|
| 105 | 105 | |
| 106 | - $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href"))); |
|
| 106 | + $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=".urlencode($entry->getAttribute("href"))); |
|
| 107 | 107 | |
| 108 | 108 | if ($oembed_result) { |
| 109 | 109 | $oembed_result = json_decode($oembed_result, true); |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if ($oembed_result && isset($oembed_result["html"])) { |
| 112 | 112 | |
| 113 | 113 | $tmp = new DOMDocument(); |
| 114 | - if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) { |
|
| 114 | + if ($tmp->loadHTML('<?xml encoding="utf-8" ?>'.$oembed_result["html"])) { |
|
| 115 | 115 | $p = $doc->createElement("p"); |
| 116 | 116 | |
| 117 | 117 | $p->appendChild($doc->importNode( |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE); |
| 137 | 137 | |
| 138 | - $source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4'; |
|
| 139 | - $poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg'; |
|
| 138 | + $source_stream = 'https://giant.gfycat.com/'.$matches[2].'.mp4'; |
|
| 139 | + $poster_url = 'https://thumbs.gfycat.com/'.$matches[2].'-mobile.jpg'; |
|
| 140 | 140 | |
| 141 | 141 | $content_type = $this->get_content_type($source_stream); |
| 142 | 142 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | if (!$source_stream) { |
| 187 | - $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K"; |
|
| 187 | + $source_stream = "https://v.redd.it/".$matches[1]."/DASH_600_K"; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | |
| 543 | 543 | // do not try to embed posts linking back to other reddit posts |
| 544 | 544 | // readability.php requires PHP 5.6 |
| 545 | - if ($url && strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) { |
|
| 545 | + if ($url && strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) { |
|
| 546 | 546 | |
| 547 | 547 | /* link may lead to a huge video file or whatever, we need to check content type before trying to |
| 548 | 548 | parse it which p much requires curl */ |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function hook_prefs_tab($args) { |
| 25 | - if ($args != "prefFeeds") return; |
|
| 25 | + if ($args != "prefFeeds") { |
|
| 26 | + return; |
|
| 27 | + } |
|
| 26 | 28 | |
| 27 | 29 | print "<div dojoType=\"dijit.layout.AccordionPane\" |
| 28 | 30 | title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">"; |
@@ -173,8 +175,7 @@ discard block |
||
| 173 | 175 | if ($child["data"]["url"] == $matches[0]) { |
| 174 | 176 | try { |
| 175 | 177 | $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"]; |
| 176 | - } |
|
| 177 | - catch (Exception $e) { |
|
| 178 | + } catch (Exception $e) { |
|
| 178 | 179 | } |
| 179 | 180 | break 2; |
| 180 | 181 | } |
@@ -230,8 +231,9 @@ discard block |
||
| 230 | 231 | |
| 231 | 232 | $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href")); |
| 232 | 233 | |
| 233 | - if (strpos($source_stream, "imgur.com") !== FALSE) |
|
| 234 | - $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
| 234 | + if (strpos($source_stream, "imgur.com") !== FALSE) { |
|
| 235 | + $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
| 236 | + } |
|
| 235 | 237 | |
| 236 | 238 | $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
| 237 | 239 | |
@@ -426,7 +428,9 @@ discard block |
||
| 426 | 428 | if ($row = $sth->fetch()) { |
| 427 | 429 | $num_found = $row['cid']; |
| 428 | 430 | |
| 429 | - if ($num_found > 0) $article["force_catchup"] = true; |
|
| 431 | + if ($num_found > 0) { |
|
| 432 | + $article["force_catchup"] = true; |
|
| 433 | + } |
|
| 430 | 434 | } |
| 431 | 435 | } |
| 432 | 436 | } |
@@ -458,7 +462,9 @@ discard block |
||
| 458 | 462 | $video->setAttribute("controls", "1"); |
| 459 | 463 | $video->setAttribute("loop", "1"); |
| 460 | 464 | |
| 461 | - if ($poster_url) $video->setAttribute("poster", $poster_url); |
|
| 465 | + if ($poster_url) { |
|
| 466 | + $video->setAttribute("poster", $poster_url); |
|
| 467 | + } |
|
| 462 | 468 | |
| 463 | 469 | $source = $doc->createElement('source'); |
| 464 | 470 | $source->setAttribute("src", $source_stream); |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | global $fetch_last_error_content; |
| 16 | 16 | |
| 17 | - if (!$res && $fetch_last_error_content) |
|
| 18 | - $res = $fetch_last_error_content; |
|
| 17 | + if (!$res && $fetch_last_error_content) { |
|
| 18 | + $res = $fetch_last_error_content; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | $doc = new DOMDocument(); |
| 21 | 22 | |
@@ -15,8 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | global $fetch_last_error_content; |
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) { |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $doc = new DOMDocument(); |
| 22 | 23 | |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | $i->parentNode->removeChild($i); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - if ($basenode){ |
|
| 57 | + if ($basenode) { |
|
| 58 | 58 | $article["content"] = $doc->saveHTML($basenode); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -46,8 +46,9 @@ |
||
| 46 | 46 | |
| 47 | 47 | $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
| 48 | 48 | |
| 49 | - if ($basenode) |
|
| 50 | - $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 49 | + if ($basenode) { |
|
| 50 | + $basenode->insertBefore($avatar, $basenode->firstChild); |
|
| 51 | + } |
|
| 51 | 52 | |
| 52 | 53 | $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
| 53 | 54 | foreach ($uninteresting as $i) { |
@@ -17,8 +17,9 @@ |
||
| 17 | 17 | false, false, 0, |
| 18 | 18 | "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
| 19 | 19 | |
| 20 | - if (!$res && $fetch_last_error_content) |
|
| 21 | - $res = $fetch_last_error_content; |
|
| 20 | + if (!$res && $fetch_last_error_content) { |
|
| 21 | + $res = $fetch_last_error_content; |
|
| 22 | + } |
|
| 22 | 23 | |
| 23 | 24 | if (@$doc->loadHTML($res)) { |
| 24 | 25 | $xpath = new DOMXPath($doc); |
@@ -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 | |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | public function process(&$article) { |
| 9 | 9 | if (strpos($article["link"], "toothpastefordinner.com") !== FALSE || |
| 10 | - strpos($article["link"], "marriedtothesea.com") !== FALSE) { |
|
| 10 | + strpos($article["link"], "marriedtothesea.com") !== FALSE) { |
|
| 11 | 11 | $res = fetch_file_contents($article["link"], false, false, false, |
| 12 | 12 | false, false, 0, |
| 13 | 13 | "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | foreach ($matches as $tag) { |
| 38 | 38 | // Only strings starting with a number sign are considered tags |
| 39 | - if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 39 | + if (substr($tag->textContent, 0, 1) == '#') { |
|
| 40 | 40 | $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
| 41 | 41 | } |
| 42 | 42 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | // Add comic title to article type if not empty (mostly Sunday strips) |
| 56 | 56 | if ($comic_title) { |
| 57 | - $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 57 | + $article["title"] = $article["title"]." - ".$comic_title; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!empty($tags)) { |
@@ -15,8 +15,9 @@ |
||
| 15 | 15 | |
| 16 | 16 | global $fetch_last_error_content; |
| 17 | 17 | |
| 18 | - if (!$res && $fetch_last_error_content) |
|
| 19 | - $res = $fetch_last_error_content; |
|
| 18 | + if (!$res && $fetch_last_error_content) { |
|
| 19 | + $res = $fetch_last_error_content; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | $doc = new DOMDocument(); |
| 22 | 23 | |
@@ -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 | |
@@ -5,7 +5,7 @@ discard block |
||
| 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 | public function about() { |
| 11 | 11 | return array(1.0, |
@@ -158,30 +158,30 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | Debug::log("status: $status_filename", Debug::$LOG_VERBOSE); |
| 160 | 160 | |
| 161 | - if ($this->cache->exists($status_filename)) |
|
| 162 | - $status = json_decode($this->cache->get($status_filename), true); |
|
| 163 | - else |
|
| 164 | - $status = []; |
|
| 161 | + if ($this->cache->exists($status_filename)) |
|
| 162 | + $status = json_decode($this->cache->get($status_filename), true); |
|
| 163 | + else |
|
| 164 | + $status = []; |
|
| 165 | 165 | |
| 166 | - $status["attempt"] += 1; |
|
| 166 | + $status["attempt"] += 1; |
|
| 167 | 167 | |
| 168 | - // only allow several download attempts for article |
|
| 169 | - if ($status["attempt"] > $this->max_cache_attempts) { |
|
| 170 | - Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); |
|
| 171 | - return false; |
|
| 172 | - } |
|
| 168 | + // only allow several download attempts for article |
|
| 169 | + if ($status["attempt"] > $this->max_cache_attempts) { |
|
| 170 | + Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE); |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - if (!$this->cache->put($status_filename, json_encode($status))) { |
|
| 175 | - user_error("unable to write status file: $status_filename", E_USER_WARNING); |
|
| 176 | - return false; |
|
| 177 | - } |
|
| 174 | + if (!$this->cache->put($status_filename, json_encode($status))) { |
|
| 175 | + user_error("unable to write status file: $status_filename", E_USER_WARNING); |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | 179 | $doc = new DOMDocument(); |
| 180 | 180 | |
| 181 | 181 | $has_images = false; |
| 182 | 182 | $success = false; |
| 183 | 183 | |
| 184 | - if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) { |
|
| 184 | + if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) { |
|
| 185 | 185 | $xpath = new DOMXPath($doc); |
| 186 | 186 | $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
| 187 | 187 | |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | $esth = $this->pdo->prepare("SELECT content_url FROM ttrss_enclosures WHERE post_id = ? AND |
| 204 | 204 | (content_type LIKE '%image%' OR content_type LIKE '%video%')"); |
| 205 | 205 | |
| 206 | - if ($esth->execute([$article_id])) { |
|
| 207 | - while ($enc = $esth->fetch()) { |
|
| 206 | + if ($esth->execute([$article_id])) { |
|
| 207 | + while ($enc = $esth->fetch()) { |
|
| 208 | 208 | |
| 209 | - $has_images = true; |
|
| 210 | - $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 209 | + $has_images = true; |
|
| 210 | + $url = rewrite_relative_url($site_url, $enc["content_url"]); |
|
| 211 | 211 | |
| 212 | 212 | if ($this->cache_url($article_id, $url)) { |
| 213 | 213 | $success = true; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | public function hook_house_keeping() { |
| 36 | 36 | /* since HOOK_UPDATE_TASK is not available to user plugins, this hook is a next best thing */ |
| 37 | 37 | |
| 38 | - Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); |
|
| 38 | + Debug::log("caching media of starred articles for user ".$this->host->get_owner_uid()."..."); |
|
| 39 | 39 | |
| 40 | 40 | $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, |
| 41 | 41 | ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data |
@@ -53,13 +53,13 @@ discard block |
||
| 53 | 53 | $usth = $this->pdo->prepare("UPDATE ttrss_entries SET plugin_data = ? WHERE id = ?"); |
| 54 | 54 | |
| 55 | 55 | while ($line = $sth->fetch()) { |
| 56 | - Debug::log("processing article " . $line["title"], Debug::$LOG_VERBOSE); |
|
| 56 | + Debug::log("processing article ".$line["title"], Debug::$LOG_VERBOSE); |
|
| 57 | 57 | |
| 58 | 58 | if ($line["site_url"]) { |
| 59 | 59 | $success = $this->cache_article_images($line["content"], $line["site_url"], $line["owner_uid"], $line["id"]); |
| 60 | 60 | |
| 61 | 61 | if ($success) { |
| 62 | - $plugin_data = "starred_cache_images,${line['owner_uid']}:" . $line["plugin_data"]; |
|
| 62 | + $plugin_data = "starred_cache_images,${line['owner_uid']}:".$line["plugin_data"]; |
|
| 63 | 63 | |
| 64 | 64 | $usth->execute([$plugin_data, $line['id']]); |
| 65 | 65 | } |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | /* actual housekeeping */ |
| 71 | 71 | |
| 72 | - Debug::log("expiring " . $this->cache->getDir() . "..."); |
|
| 72 | + Debug::log("expiring ".$this->cache->getDir()."..."); |
|
| 73 | 73 | |
| 74 | - $files = glob($this->cache->getDir() . "/*.{png,mp4,status}", GLOB_BRACE); |
|
| 74 | + $files = glob($this->cache->getDir()."/*.{png,mp4,status}", GLOB_BRACE); |
|
| 75 | 75 | |
| 76 | 76 | $last_article_id = 0; |
| 77 | 77 | $article_exists = 1; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function hook_enclosure_entry($enc, $article_id) { |
| 98 | - $local_filename = $article_id . "-" . sha1($enc["content_url"]); |
|
| 98 | + $local_filename = $article_id."-".sha1($enc["content_url"]); |
|
| 99 | 99 | |
| 100 | 100 | if ($this->cache->exists($local_filename)) { |
| 101 | 101 | $enc["content_url"] = $this->cache->getUrl($local_filename); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | if ($entry->hasAttribute('src')) { |
| 115 | 115 | $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); |
| 116 | 116 | |
| 117 | - $local_filename = $article_id . "-" . sha1($src); |
|
| 117 | + $local_filename = $article_id."-".sha1($src); |
|
| 118 | 118 | |
| 119 | 119 | if ($this->cache->exists($local_filename)) { |
| 120 | 120 | $entry->setAttribute("src", $this->cache->getUrl($local_filename)); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | private function cache_url($article_id, $url) { |
| 131 | - $local_filename = $article_id . "-" . sha1($url); |
|
| 131 | + $local_filename = $article_id."-".sha1($url); |
|
| 132 | 132 | |
| 133 | 133 | if (!$this->cache->exists($local_filename)) { |
| 134 | 134 | Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); |
| 137 | 137 | |
| 138 | 138 | if ($data) |
| 139 | - return $this->cache->put($local_filename, $data);; |
|
| 139 | + return $this->cache->put($local_filename, $data); ; |
|
| 140 | 140 | |
| 141 | 141 | } else { |
| 142 | 142 | //Debug::log("cache_images: local file exists for $url", Debug::$LOG_VERBOSE); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | private function cache_article_images($content, $site_url, $owner_uid, $article_id) { |
| 151 | - $status_filename = $article_id . "-" . sha1($site_url) . ".status"; |
|
| 151 | + $status_filename = $article_id."-".sha1($site_url).".status"; |
|
| 152 | 152 | |
| 153 | 153 | /* housekeeping might run as a separate user, in this case status/media might not be writable */ |
| 154 | 154 | if (!$this->cache->isWritable($status_filename)) { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $has_images = false; |
| 182 | 182 | $success = false; |
| 183 | 183 | |
| 184 | - if ($doc->loadHTML('<?xml encoding="UTF-8">' . $content)) { |
|
| 184 | + if ($doc->loadHTML('<?xml encoding="UTF-8">'.$content)) { |
|
| 185 | 185 | $xpath = new DOMXPath($doc); |
| 186 | 186 | $entries = $xpath->query('(//img[@src])|(//video/source[@src])'); |
| 187 | 187 | |
@@ -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"])); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | public 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 | public 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"])); |