@@ -1,28 +1,28 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Explosm extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Cyanide and Happiness"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Cyanide and Happiness"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | 9 | |
| 10 | - if (strpos($article["link"], "explosm.net/comics") !== false) { |
|
| 10 | + if (strpos($article["link"], "explosm.net/comics") !== false) { |
|
| 11 | 11 | |
| 12 | - $doc = new DOMDocument(); |
|
| 12 | + $doc = new DOMDocument(); |
|
| 13 | 13 | |
| 14 | - if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 15 | - $xpath = new DOMXPath($doc); |
|
| 16 | - $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); |
|
| 14 | + if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 15 | + $xpath = new DOMXPath($doc); |
|
| 16 | + $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); |
|
| 17 | 17 | |
| 18 | - if ($basenode) { |
|
| 19 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 20 | - } |
|
| 21 | - } |
|
| 18 | + if ($basenode) { |
|
| 19 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 20 | + } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return true; |
|
| 24 | - } |
|
| 23 | + return true; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return false; |
|
| 27 | - } |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -2,72 +2,72 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Af_Comics_Dilbert extends Af_ComicFilter { |
| 4 | 4 | |
| 5 | - public function supported() { |
|
| 6 | - return array("Dilbert"); |
|
| 7 | - } |
|
| 5 | + public function supported() { |
|
| 6 | + return array("Dilbert"); |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public function process(&$article) { |
|
| 10 | - if (strpos($article["link"], "dilbert.com") !== false || |
|
| 11 | - strpos($article["link"], "/DilbertDailyStrip") !== false) { |
|
| 9 | + public function process(&$article) { |
|
| 10 | + if (strpos($article["link"], "dilbert.com") !== false || |
|
| 11 | + strpos($article["link"], "/DilbertDailyStrip") !== false) { |
|
| 12 | 12 | |
| 13 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 14 | - false, false, 0, |
|
| 15 | - "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 13 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 14 | + false, false, 0, |
|
| 15 | + "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 16 | 16 | |
| 17 | - global $fetch_last_error_content; |
|
| 17 | + global $fetch_last_error_content; |
|
| 18 | 18 | |
| 19 | - if (!$res && $fetch_last_error_content) |
|
| 20 | - $res = $fetch_last_error_content; |
|
| 19 | + if (!$res && $fetch_last_error_content) |
|
| 20 | + $res = $fetch_last_error_content; |
|
| 21 | 21 | |
| 22 | - $doc = new DOMDocument(); |
|
| 22 | + $doc = new DOMDocument(); |
|
| 23 | 23 | |
| 24 | - if (@$doc->loadHTML($res)) { |
|
| 25 | - $xpath = new DOMXPath($doc); |
|
| 24 | + if (@$doc->loadHTML($res)) { |
|
| 25 | + $xpath = new DOMXPath($doc); |
|
| 26 | 26 | |
| 27 | - // Get the image container |
|
| 28 | - $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); |
|
| 27 | + // Get the image container |
|
| 28 | + $basenode = $xpath->query('(//div[@class="img-comic-container"]/a[@class="img-comic-link"])')->item(0); |
|
| 29 | 29 | |
| 30 | - // Get the comic title |
|
| 31 | - $comic_title = $xpath->query('(//span[@class="comic-title-name"])')->item(0)->textContent; |
|
| 30 | + // Get the comic title |
|
| 31 | + $comic_title = $xpath->query('(//span[@class="comic-title-name"])')->item(0)->textContent; |
|
| 32 | 32 | |
| 33 | - // Get tags from the article |
|
| 34 | - $matches = $xpath->query('(//p[contains(@class, "comic-tags")][1]//a)'); |
|
| 35 | - $tags = array(); |
|
| 33 | + // Get tags from the article |
|
| 34 | + $matches = $xpath->query('(//p[contains(@class, "comic-tags")][1]//a)'); |
|
| 35 | + $tags = array(); |
|
| 36 | 36 | |
| 37 | - foreach ($matches as $tag) { |
|
| 38 | - // Only strings starting with a number sign are considered tags |
|
| 39 | - if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 40 | - $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 37 | + foreach ($matches as $tag) { |
|
| 38 | + // Only strings starting with a number sign are considered tags |
|
| 39 | + if ( substr($tag->textContent, 0, 1) == '#' ) { |
|
| 40 | + $tags[] = mb_strtolower(substr($tag->textContent, 1), 'utf-8'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // Get the current comics transcript and set it |
|
| 45 | - // as the title so it will be visible on mousover |
|
| 46 | - $transcript = $xpath->query('(//div[starts-with(@id, "js-toggle-transcript-")]//p)')->item(0); |
|
| 47 | - if ($transcript) { |
|
| 48 | - $basenode->setAttribute("title", $transcript->textContent); |
|
| 49 | - } |
|
| 44 | + // Get the current comics transcript and set it |
|
| 45 | + // as the title so it will be visible on mousover |
|
| 46 | + $transcript = $xpath->query('(//div[starts-with(@id, "js-toggle-transcript-")]//p)')->item(0); |
|
| 47 | + if ($transcript) { |
|
| 48 | + $basenode->setAttribute("title", $transcript->textContent); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($basenode) { |
|
| 52 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 53 | - } |
|
| 51 | + if ($basenode) { |
|
| 52 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // Add comic title to article type if not empty (mostly Sunday strips) |
|
| 56 | - if ($comic_title) { |
|
| 57 | - $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 58 | - } |
|
| 55 | + // Add comic title to article type if not empty (mostly Sunday strips) |
|
| 56 | + if ($comic_title) { |
|
| 57 | + $article["title"] = $article["title"] . " - " . $comic_title; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - if (!empty($tags)) { |
|
| 61 | - // Ignore existing tags and just replace them all |
|
| 62 | - $article["tags"] = array_unique($tags); |
|
| 63 | - } |
|
| 60 | + if (!empty($tags)) { |
|
| 61 | + // Ignore existing tags and just replace them all |
|
| 62 | + $article["tags"] = array_unique($tags); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return true; |
|
| 68 | - } |
|
| 67 | + return true; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - return false; |
|
| 71 | - } |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | ?> |
@@ -1,39 +1,39 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Cad extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Ctrl+Alt+Del"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Ctrl+Alt+Del"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["link"], "cad-comic.com") !== false) { |
|
| 10 | - if (strpos($article["title"], "News:") === false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["link"], "cad-comic.com") !== false) { |
|
| 10 | + if (strpos($article["title"], "News:") === false) { |
|
| 11 | 11 | |
| 12 | - global $fetch_last_error_content; |
|
| 12 | + global $fetch_last_error_content; |
|
| 13 | 13 | |
| 14 | - $doc = new DOMDocument(); |
|
| 14 | + $doc = new DOMDocument(); |
|
| 15 | 15 | |
| 16 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 17 | - false, false, 0, |
|
| 18 | - "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); |
|
| 16 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 17 | + false, false, 0, |
|
| 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 | - if (@$doc->loadHTML($res)) { |
|
| 24 | - $xpath = new DOMXPath($doc); |
|
| 25 | - $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); |
|
| 23 | + if (@$doc->loadHTML($res)) { |
|
| 24 | + $xpath = new DOMXPath($doc); |
|
| 25 | + $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); |
|
| 26 | 26 | |
| 27 | - if ($basenode) { |
|
| 28 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 29 | - } |
|
| 30 | - } |
|
| 27 | + if ($basenode) { |
|
| 28 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return true; |
|
| 35 | - } |
|
| 34 | + return true; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return false; |
|
| 38 | - } |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -1,34 +1,34 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_ComicClass extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Loading Artist"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Loading Artist"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["guid"], "loadingartist.com") !== false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["guid"], "loadingartist.com") !== false) { |
|
| 10 | 10 | |
| 11 | - // lol at people who block clients by user agent |
|
| 12 | - // oh noes my ad revenue Q_Q |
|
| 11 | + // lol at people who block clients by user agent |
|
| 12 | + // oh noes my ad revenue Q_Q |
|
| 13 | 13 | |
| 14 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 15 | - false, false, 0, |
|
| 16 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 14 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 15 | + false, false, 0, |
|
| 16 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 17 | 17 | |
| 18 | - $doc = new DOMDocument(); |
|
| 18 | + $doc = new DOMDocument(); |
|
| 19 | 19 | |
| 20 | - if (@$doc->loadHTML($res)) { |
|
| 21 | - $xpath = new DOMXPath($doc); |
|
| 22 | - $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
| 20 | + if (@$doc->loadHTML($res)) { |
|
| 21 | + $xpath = new DOMXPath($doc); |
|
| 22 | + $basenode = $xpath->query('//div[@class="comic"]')->item(0); |
|
| 23 | 23 | |
| 24 | - if ($basenode) { |
|
| 25 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 26 | - } |
|
| 27 | - } |
|
| 24 | + if ($basenode) { |
|
| 25 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 26 | + } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - return true; |
|
| 30 | - } |
|
| 29 | + return true; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return false; |
|
| 33 | - } |
|
| 32 | + return false; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -1,31 +1,31 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Pvp extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("PvP Online"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("PvP Online"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["guid"], "pvponline.com") !== false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["guid"], "pvponline.com") !== false) { |
|
| 10 | 10 | |
| 11 | - $res = fetch_file_contents($article["link"], false, false, false, |
|
| 12 | - false, false, 0, |
|
| 13 | - "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 11 | + $res = fetch_file_contents($article["link"], false, false, false, |
|
| 12 | + false, false, 0, |
|
| 13 | + "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); |
|
| 14 | 14 | |
| 15 | - $doc = new DOMDocument(); |
|
| 15 | + $doc = new DOMDocument(); |
|
| 16 | 16 | |
| 17 | - if (@$doc->loadHTML($res)) { |
|
| 18 | - $xpath = new DOMXPath($doc); |
|
| 19 | - $basenode = $xpath->query('//section[@class="comic-art"]')->item(0); |
|
| 17 | + if (@$doc->loadHTML($res)) { |
|
| 18 | + $xpath = new DOMXPath($doc); |
|
| 19 | + $basenode = $xpath->query('//section[@class="comic-art"]')->item(0); |
|
| 20 | 20 | |
| 21 | - if ($basenode) { |
|
| 22 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 23 | - } |
|
| 24 | - } |
|
| 21 | + if ($basenode) { |
|
| 22 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 23 | + } |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - return true; |
|
| 27 | - } |
|
| 26 | + return true; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - return false; |
|
| 30 | - } |
|
| 29 | + return false; |
|
| 30 | + } |
|
| 31 | 31 | } |
@@ -1,67 +1,67 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_Pa extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Penny Arcade"); |
|
| 6 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Penny Arcade"); |
|
| 6 | + } |
|
| 7 | 7 | |
| 8 | - public function process(&$article) { |
|
| 9 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
| 8 | + public function process(&$article) { |
|
| 9 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { |
|
| 10 | 10 | |
| 11 | - $doc = new DOMDocument(); |
|
| 11 | + $doc = new DOMDocument(); |
|
| 12 | 12 | |
| 13 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 14 | - $xpath = new DOMXPath($doc); |
|
| 15 | - $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
| 13 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 14 | + $xpath = new DOMXPath($doc); |
|
| 15 | + $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); |
|
| 16 | 16 | |
| 17 | - if ($basenode) { |
|
| 18 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 19 | - } |
|
| 20 | - } |
|
| 17 | + if ($basenode) { |
|
| 18 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - return true; |
|
| 23 | - } |
|
| 22 | + return true; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
| 26 | - $doc = new DOMDocument(); |
|
| 25 | + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { |
|
| 26 | + $doc = new DOMDocument(); |
|
| 27 | 27 | |
| 28 | - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 29 | - $xpath = new DOMXPath($doc); |
|
| 30 | - $entries = $xpath->query('(//div[@class="post"])'); |
|
| 28 | + if ($doc->loadHTML(fetch_file_contents($article["link"]))) { |
|
| 29 | + $xpath = new DOMXPath($doc); |
|
| 30 | + $entries = $xpath->query('(//div[@class="post"])'); |
|
| 31 | 31 | |
| 32 | - $basenode = false; |
|
| 32 | + $basenode = false; |
|
| 33 | 33 | |
| 34 | - foreach ($entries as $entry) { |
|
| 35 | - $basenode = $entry; |
|
| 36 | - } |
|
| 34 | + foreach ($entries as $entry) { |
|
| 35 | + $basenode = $entry; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
| 39 | - if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
| 38 | + $meta = $xpath->query('(//div[@class="meta"])')->item(0); |
|
| 39 | + if ($meta->parentNode) { $meta->parentNode->removeChild($meta); } |
|
| 40 | 40 | |
| 41 | - $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
| 42 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 41 | + $header = $xpath->query('(//div[@class="postBody"]/h2)')->item(0); |
|
| 42 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 43 | 43 | |
| 44 | - $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
| 45 | - if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 44 | + $header = $xpath->query('(//div[@class="postBody"]/div[@class="comicPost"])')->item(0); |
|
| 45 | + if ($header->parentNode) { $header->parentNode->removeChild($header); } |
|
| 46 | 46 | |
| 47 | - $avatar = $xpath->query('(//div[@class="avatar"]//img)')->item(0); |
|
| 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 | - $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
| 53 | - foreach ($uninteresting as $i) { |
|
| 54 | - $i->parentNode->removeChild($i); |
|
| 55 | - } |
|
| 52 | + $uninteresting = $xpath->query('(//div[@class="avatar"])'); |
|
| 53 | + foreach ($uninteresting as $i) { |
|
| 54 | + $i->parentNode->removeChild($i); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - if ($basenode){ |
|
| 58 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 59 | - } |
|
| 60 | - } |
|
| 57 | + if ($basenode){ |
|
| 58 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return true; |
|
| 63 | - } |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return false; |
|
| 66 | - } |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -1,64 +1,64 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Comics_ComicPress extends Af_ComicFilter { |
| 3 | 3 | |
| 4 | - public function supported() { |
|
| 5 | - return array("Buni", "Buttersafe", "Happy Jar", "CSection", |
|
| 6 | - "Extra Fabulous Comics", "Nedroid", "Stonetoss"); |
|
| 7 | - } |
|
| 4 | + public function supported() { |
|
| 5 | + return array("Buni", "Buttersafe", "Happy Jar", "CSection", |
|
| 6 | + "Extra Fabulous Comics", "Nedroid", "Stonetoss"); |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public function process(&$article) { |
|
| 10 | - if (strpos($article["guid"], "bunicomic.com") !== false || |
|
| 11 | - strpos($article["guid"], "buttersafe.com") !== false || |
|
| 12 | - strpos($article["guid"], "extrafabulouscomics.com") !== false || |
|
| 13 | - strpos($article["guid"], "happyjar.com") !== false || |
|
| 14 | - strpos($article["guid"], "nedroid.com") !== false || |
|
| 15 | - strpos($article["guid"], "stonetoss.com") !== false || |
|
| 16 | - strpos($article["guid"], "csectioncomics.com") !== false) { |
|
| 9 | + public function process(&$article) { |
|
| 10 | + if (strpos($article["guid"], "bunicomic.com") !== false || |
|
| 11 | + strpos($article["guid"], "buttersafe.com") !== false || |
|
| 12 | + strpos($article["guid"], "extrafabulouscomics.com") !== false || |
|
| 13 | + strpos($article["guid"], "happyjar.com") !== false || |
|
| 14 | + strpos($article["guid"], "nedroid.com") !== false || |
|
| 15 | + strpos($article["guid"], "stonetoss.com") !== false || |
|
| 16 | + strpos($article["guid"], "csectioncomics.com") !== false) { |
|
| 17 | 17 | |
| 18 | - // lol at people who block clients by user agent |
|
| 19 | - // oh noes my ad revenue Q_Q |
|
| 18 | + // lol at people who block clients by user agent |
|
| 19 | + // oh noes my ad revenue Q_Q |
|
| 20 | 20 | |
| 21 | - $res = fetch_file_contents(["url" => $article["link"], |
|
| 22 | - "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); |
|
| 21 | + $res = fetch_file_contents(["url" => $article["link"], |
|
| 22 | + "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); |
|
| 23 | 23 | |
| 24 | - $doc = new DOMDocument(); |
|
| 24 | + $doc = new DOMDocument(); |
|
| 25 | 25 | |
| 26 | - if (@$doc->loadHTML($res)) { |
|
| 27 | - $xpath = new DOMXPath($doc); |
|
| 28 | - $basenode = $xpath->query('//div[@id="comic"]')->item(0); |
|
| 26 | + if (@$doc->loadHTML($res)) { |
|
| 27 | + $xpath = new DOMXPath($doc); |
|
| 28 | + $basenode = $xpath->query('//div[@id="comic"]')->item(0); |
|
| 29 | 29 | |
| 30 | - if ($basenode) { |
|
| 31 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 32 | - return true; |
|
| 33 | - } |
|
| 30 | + if ($basenode) { |
|
| 31 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 32 | + return true; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - // buni-specific |
|
| 36 | - $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0); |
|
| 35 | + // buni-specific |
|
| 36 | + $webtoon_link = $xpath->query("//a[contains(@href,'www.webtoons.com')]")->item(0); |
|
| 37 | 37 | |
| 38 | - if ($webtoon_link) { |
|
| 38 | + if ($webtoon_link) { |
|
| 39 | 39 | |
| 40 | - $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"), |
|
| 41 | - "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); |
|
| 40 | + $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"), |
|
| 41 | + "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); |
|
| 42 | 42 | |
| 43 | - if (@$doc->loadHTML($res)) { |
|
| 44 | - $xpath = new DOMXPath($doc); |
|
| 45 | - $basenode = $xpath->query('//div[@id="_viewerBox"]')->item(0); |
|
| 43 | + if (@$doc->loadHTML($res)) { |
|
| 44 | + $xpath = new DOMXPath($doc); |
|
| 45 | + $basenode = $xpath->query('//div[@id="_viewerBox"]')->item(0); |
|
| 46 | 46 | |
| 47 | - if ($basenode) { |
|
| 48 | - $imgs = $xpath->query("//img[@data-url]", $basenode); |
|
| 47 | + if ($basenode) { |
|
| 48 | + $imgs = $xpath->query("//img[@data-url]", $basenode); |
|
| 49 | 49 | |
| 50 | - foreach ($imgs as $img) { |
|
| 51 | - $img->setAttribute("src", $img->getAttribute("data-url")); |
|
| 52 | - } |
|
| 50 | + foreach ($imgs as $img) { |
|
| 51 | + $img->setAttribute("src", $img->getAttribute("data-url")); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - $article["content"] = $doc->saveHTML($basenode); |
|
| 55 | - return true; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 54 | + $article["content"] = $doc->saveHTML($basenode); |
|
| 55 | + return true; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return false; |
|
| 63 | - } |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -1,84 +1,84 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_Unburn extends Plugin { |
| 3 | - private $host; |
|
| 3 | + private $host; |
|
| 4 | 4 | |
| 5 | - public function about() { |
|
| 6 | - return array(1.0, |
|
| 7 | - "Resolves feedburner and similar feed redirector URLs (requires CURL)", |
|
| 8 | - "fox"); |
|
| 9 | - } |
|
| 5 | + public function about() { |
|
| 6 | + return array(1.0, |
|
| 7 | + "Resolves feedburner and similar feed redirector URLs (requires CURL)", |
|
| 8 | + "fox"); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function flags() { |
|
| 12 | - return array("needs_curl" => true); |
|
| 13 | - } |
|
| 11 | + public function flags() { |
|
| 12 | + return array("needs_curl" => true); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function init($host) { |
|
| 16 | - $this->host = $host; |
|
| 15 | + public function init($host) { |
|
| 16 | + $this->host = $host; |
|
| 17 | 17 | |
| 18 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 19 | - } |
|
| 18 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - public function hook_article_filter($article) { |
|
| 22 | - $owner_uid = $article["owner_uid"]; |
|
| 21 | + public function hook_article_filter($article) { |
|
| 22 | + $owner_uid = $article["owner_uid"]; |
|
| 23 | 23 | |
| 24 | - if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
| 25 | - return $article; |
|
| 24 | + if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
| 25 | + return $article; |
|
| 26 | 26 | |
| 27 | - if ((strpos($article["link"], "feedproxy.google.com") !== false || |
|
| 28 | - strpos($article["link"], "/~r/") !== false || |
|
| 29 | - strpos($article["link"], "feedsportal.com") !== false)) { |
|
| 27 | + if ((strpos($article["link"], "feedproxy.google.com") !== false || |
|
| 28 | + strpos($article["link"], "/~r/") !== false || |
|
| 29 | + strpos($article["link"], "feedsportal.com") !== false)) { |
|
| 30 | 30 | |
| 31 | - $ch = curl_init($article["link"]); |
|
| 31 | + $ch = curl_init($article["link"]); |
|
| 32 | 32 | |
| 33 | - curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 34 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 35 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 36 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 37 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 38 | - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
| 33 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 34 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 35 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 36 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 37 | + curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 38 | + curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); |
|
| 39 | 39 | |
| 40 | - if (defined('_CURL_HTTP_PROXY')) { |
|
| 41 | - curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY); |
|
| 42 | - } |
|
| 40 | + if (defined('_CURL_HTTP_PROXY')) { |
|
| 41 | + curl_setopt($ch, CURLOPT_PROXY, _CURL_HTTP_PROXY); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - @curl_exec($ch); |
|
| 44 | + @curl_exec($ch); |
|
| 45 | 45 | |
| 46 | - $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
| 46 | + $real_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
|
| 47 | 47 | |
| 48 | - curl_close($ch); |
|
| 48 | + curl_close($ch); |
|
| 49 | 49 | |
| 50 | - if ($real_url) { |
|
| 51 | - /* remove the rest of it */ |
|
| 50 | + if ($real_url) { |
|
| 51 | + /* remove the rest of it */ |
|
| 52 | 52 | |
| 53 | - $query = parse_url($real_url, PHP_URL_QUERY); |
|
| 53 | + $query = parse_url($real_url, PHP_URL_QUERY); |
|
| 54 | 54 | |
| 55 | - if ($query && strpos($query, "utm_source") !== false) { |
|
| 56 | - $args = array(); |
|
| 57 | - parse_str($query, $args); |
|
| 55 | + if ($query && strpos($query, "utm_source") !== false) { |
|
| 56 | + $args = array(); |
|
| 57 | + parse_str($query, $args); |
|
| 58 | 58 | |
| 59 | - foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
|
| 60 | - if (isset($args[$param])) unset($args[$param]); |
|
| 61 | - } |
|
| 59 | + foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
|
| 60 | + if (isset($args[$param])) unset($args[$param]); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $new_query = http_build_query($args); |
|
| 63 | + $new_query = http_build_query($args); |
|
| 64 | 64 | |
| 65 | - if ($new_query != $query) { |
|
| 66 | - $real_url = str_replace("?$query", "?$new_query", $real_url); |
|
| 67 | - } |
|
| 68 | - } |
|
| 65 | + if ($new_query != $query) { |
|
| 66 | + $real_url = str_replace("?$query", "?$new_query", $real_url); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - $real_url = preg_replace("/\?$/", "", $real_url); |
|
| 70 | + $real_url = preg_replace("/\?$/", "", $real_url); |
|
| 71 | 71 | |
| 72 | - $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"]; |
|
| 73 | - $article["link"] = $real_url; |
|
| 74 | - } |
|
| 75 | - } |
|
| 72 | + $article["plugin_data"] = "unburn,$owner_uid:" . $article["plugin_data"]; |
|
| 73 | + $article["link"] = $real_url; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - return $article; |
|
| 78 | - } |
|
| 77 | + return $article; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function api_version() { |
|
| 81 | - return 2; |
|
| 82 | - } |
|
| 80 | + public function api_version() { |
|
| 81 | + return 2; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | 84 | } |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | public function hook_article_filter($article) { |
| 22 | 22 | $owner_uid = $article["owner_uid"]; |
| 23 | 23 | |
| 24 | - if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) |
|
| 25 | - return $article; |
|
| 24 | + if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) { |
|
| 25 | + return $article; |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | if ((strpos($article["link"], "feedproxy.google.com") !== false || |
| 28 | 29 | strpos($article["link"], "/~r/") !== false || |
@@ -57,7 +58,9 @@ discard block |
||
| 57 | 58 | parse_str($query, $args); |
| 58 | 59 | |
| 59 | 60 | foreach (array("utm_source", "utm_medium", "utm_campaign") as $param) { |
| 60 | - if (isset($args[$param])) unset($args[$param]); |
|
| 61 | + if (isset($args[$param])) { |
|
| 62 | + unset($args[$param]); |
|
| 63 | + } |
|
| 61 | 64 | } |
| 62 | 65 | |
| 63 | 66 | $new_query = http_build_query($args); |
@@ -1,42 +1,42 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class Af_RedditImgur extends Plugin { |
| 3 | 3 | |
| 4 | - /* @var PluginHost $host */ |
|
| 5 | - private $host; |
|
| 4 | + /* @var PluginHost $host */ |
|
| 5 | + private $host; |
|
| 6 | 6 | |
| 7 | - public function about() { |
|
| 8 | - return array(1.0, |
|
| 9 | - "Inline images (and other content) in Reddit RSS feeds", |
|
| 10 | - "fox"); |
|
| 11 | - } |
|
| 7 | + public function about() { |
|
| 8 | + return array(1.0, |
|
| 9 | + "Inline images (and other content) in Reddit RSS feeds", |
|
| 10 | + "fox"); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - public function flags() { |
|
| 14 | - return array("needs_curl" => true); |
|
| 15 | - } |
|
| 13 | + public function flags() { |
|
| 14 | + return array("needs_curl" => true); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function init($host) { |
|
| 18 | - $this->host = $host; |
|
| 17 | + public function init($host) { |
|
| 18 | + $this->host = $host; |
|
| 19 | 19 | |
| 20 | - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 21 | - $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 22 | - } |
|
| 20 | + $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); |
|
| 21 | + $host->add_hook($host::HOOK_PREFS_TAB, $this); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - public function hook_prefs_tab($args) { |
|
| 25 | - if ($args != "prefFeeds") return; |
|
| 24 | + public function hook_prefs_tab($args) { |
|
| 25 | + if ($args != "prefFeeds") return; |
|
| 26 | 26 | |
| 27 | - print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 27 | + print "<div dojoType=\"dijit.layout.AccordionPane\" |
|
| 28 | 28 | title=\"<i class='material-icons'>extension</i> ".__('Reddit content settings (af_redditimgur)')."\">"; |
| 29 | 29 | |
| 30 | - $enable_readability = $this->host->get($this, "enable_readability"); |
|
| 31 | - $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); |
|
| 30 | + $enable_readability = $this->host->get($this, "enable_readability"); |
|
| 31 | + $enable_content_dupcheck = $this->host->get($this, "enable_content_dupcheck"); |
|
| 32 | 32 | |
| 33 | - if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
| 34 | - print_error("Readability requires PHP version 5.6."); |
|
| 35 | - } |
|
| 33 | + if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
|
| 34 | + print_error("Readability requires PHP version 5.6."); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - print "<form dojoType='dijit.form.Form'>"; |
|
| 37 | + print "<form dojoType='dijit.form.Form'>"; |
|
| 38 | 38 | |
| 39 | - print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 39 | + print "<script type='dojo/method' event='onSubmit' args='evt'> |
|
| 40 | 40 | evt.preventDefault(); |
| 41 | 41 | if (this.validate()) { |
| 42 | 42 | console.log(dojo.objectToQuery(this.getValues())); |
@@ -50,235 +50,235 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | </script>"; |
| 52 | 52 | |
| 53 | - print_hidden("op", "pluginhandler"); |
|
| 54 | - print_hidden("method", "save"); |
|
| 55 | - print_hidden("plugin", "af_redditimgur"); |
|
| 53 | + print_hidden("op", "pluginhandler"); |
|
| 54 | + print_hidden("method", "save"); |
|
| 55 | + print_hidden("plugin", "af_redditimgur"); |
|
| 56 | 56 | |
| 57 | - print "<fieldset class='narrow'>"; |
|
| 58 | - print "<label class='checkbox'>"; |
|
| 59 | - print_checkbox("enable_readability", $enable_readability); |
|
| 60 | - print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>"; |
|
| 61 | - print "</fieldset>"; |
|
| 57 | + print "<fieldset class='narrow'>"; |
|
| 58 | + print "<label class='checkbox'>"; |
|
| 59 | + print_checkbox("enable_readability", $enable_readability); |
|
| 60 | + print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>"; |
|
| 61 | + print "</fieldset>"; |
|
| 62 | 62 | |
| 63 | - print "<fieldset class='narrow'>"; |
|
| 64 | - print "<label class='checkbox'>"; |
|
| 65 | - print_checkbox("enable_content_dupcheck", $enable_content_dupcheck); |
|
| 66 | - print " " . __("Enable additional duplicate checking") . "</label>"; |
|
| 67 | - print "</fieldset>"; |
|
| 63 | + print "<fieldset class='narrow'>"; |
|
| 64 | + print "<label class='checkbox'>"; |
|
| 65 | + print_checkbox("enable_content_dupcheck", $enable_content_dupcheck); |
|
| 66 | + print " " . __("Enable additional duplicate checking") . "</label>"; |
|
| 67 | + print "</fieldset>"; |
|
| 68 | 68 | |
| 69 | - print_button("submit", __("Save"), 'class="alt-primary"'); |
|
| 70 | - print "</form>"; |
|
| 69 | + print_button("submit", __("Save"), 'class="alt-primary"'); |
|
| 70 | + print "</form>"; |
|
| 71 | 71 | |
| 72 | - print "</div>"; |
|
| 73 | - } |
|
| 72 | + print "</div>"; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - public function save() { |
|
| 76 | - $enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]); |
|
| 77 | - $enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]); |
|
| 75 | + public function save() { |
|
| 76 | + $enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]); |
|
| 77 | + $enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]); |
|
| 78 | 78 | |
| 79 | - $this->host->set($this, "enable_readability", $enable_readability, false); |
|
| 80 | - $this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck); |
|
| 79 | + $this->host->set($this, "enable_readability", $enable_readability, false); |
|
| 80 | + $this->host->set($this, "enable_content_dupcheck", $enable_content_dupcheck); |
|
| 81 | 81 | |
| 82 | - echo __("Configuration saved"); |
|
| 83 | - } |
|
| 82 | + echo __("Configuration saved"); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 87 | - */ |
|
| 88 | - private function inline_stuff($article, &$doc, $xpath) { |
|
| 85 | + /** |
|
| 86 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 87 | + */ |
|
| 88 | + private function inline_stuff($article, &$doc, $xpath) { |
|
| 89 | 89 | |
| 90 | - $entries = $xpath->query('(//a[@href]|//img[@src])'); |
|
| 91 | - $img_entries = $xpath->query("(//img[@src])"); |
|
| 90 | + $entries = $xpath->query('(//a[@href]|//img[@src])'); |
|
| 91 | + $img_entries = $xpath->query("(//img[@src])"); |
|
| 92 | 92 | |
| 93 | - $found = false; |
|
| 94 | - //$debug = 1; |
|
| 93 | + $found = false; |
|
| 94 | + //$debug = 1; |
|
| 95 | 95 | |
| 96 | - foreach ($entries as $entry) { |
|
| 97 | - if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) { |
|
| 96 | + foreach ($entries as $entry) { |
|
| 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 | - $matches = array(); |
|
| 101 | + $matches = array(); |
|
| 102 | 102 | |
| 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); |
|
| 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); |
|
| 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 | - if ($oembed_result) { |
|
| 109 | - $oembed_result = json_decode($oembed_result, true); |
|
| 108 | + if ($oembed_result) { |
|
| 109 | + $oembed_result = json_decode($oembed_result, true); |
|
| 110 | 110 | |
| 111 | - if ($oembed_result && isset($oembed_result["html"])) { |
|
| 111 | + if ($oembed_result && isset($oembed_result["html"])) { |
|
| 112 | 112 | |
| 113 | - $tmp = new DOMDocument(); |
|
| 114 | - if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) { |
|
| 115 | - $p = $doc->createElement("p"); |
|
| 113 | + $tmp = new DOMDocument(); |
|
| 114 | + if ($tmp->loadHTML('<?xml encoding="utf-8" ?>' . $oembed_result["html"])) { |
|
| 115 | + $p = $doc->createElement("p"); |
|
| 116 | 116 | |
| 117 | - $p->appendChild($doc->importNode( |
|
| 118 | - $tmp->getElementsByTagName("blockquote")->item(0), true)); |
|
| 117 | + $p->appendChild($doc->importNode( |
|
| 118 | + $tmp->getElementsByTagName("blockquote")->item(0), true)); |
|
| 119 | 119 | |
| 120 | - $br = $doc->createElement('br'); |
|
| 121 | - $entry->parentNode->insertBefore($p, $entry); |
|
| 122 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 120 | + $br = $doc->createElement('br'); |
|
| 121 | + $entry->parentNode->insertBefore($p, $entry); |
|
| 122 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 123 | 123 | |
| 124 | - $found = 1; |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - } |
|
| 124 | + $found = 1; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 131 | - $entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]); |
|
| 132 | - } |
|
| 130 | + if (!$found && preg_match("/\.gfycat.com\/([a-z]+)?(\.[a-z]+)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 131 | + $entry->setAttribute("href", "http://www.gfycat.com/".$matches[1]); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 134 | + if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 135 | 135 | |
| 136 | - Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE); |
|
| 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 | - $content_type = $this->get_content_type($source_stream); |
|
| 141 | + $content_type = $this->get_content_type($source_stream); |
|
| 142 | 142 | |
| 143 | - if (strpos($content_type, "video/") !== false) { |
|
| 144 | - $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 145 | - $found = 1; |
|
| 146 | - } |
|
| 147 | - } |
|
| 143 | + if (strpos($content_type, "video/") !== false) { |
|
| 144 | + $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 145 | + $found = 1; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 149 | + if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) { |
|
| 150 | 150 | |
| 151 | - Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE); |
|
| 151 | + Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE); |
|
| 152 | 152 | |
| 153 | - $img = $img_entries->item(0); |
|
| 153 | + $img = $img_entries->item(0); |
|
| 154 | 154 | |
| 155 | - if ($img) { |
|
| 156 | - $poster_url = $img->getAttribute("src"); |
|
| 157 | - } else { |
|
| 158 | - $poster_url = false; |
|
| 159 | - } |
|
| 155 | + if ($img) { |
|
| 156 | + $poster_url = $img->getAttribute("src"); |
|
| 157 | + } else { |
|
| 158 | + $poster_url = false; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - // Get original article URL from v.redd.it redirects |
|
| 162 | - $source_article_url = $this->get_location($matches[0]); |
|
| 163 | - Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE); |
|
| 164 | - |
|
| 165 | - $source_stream = false; |
|
| 166 | - |
|
| 167 | - if ($source_article_url) { |
|
| 168 | - $j = json_decode(fetch_file_contents($source_article_url.".json"), true); |
|
| 169 | - |
|
| 170 | - if ($j) { |
|
| 171 | - foreach ($j as $listing) { |
|
| 172 | - foreach ($listing["data"]["children"] as $child) { |
|
| 173 | - if ($child["data"]["url"] == $matches[0]) { |
|
| 174 | - try { |
|
| 175 | - $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"]; |
|
| 176 | - } |
|
| 177 | - catch (Exception $e) { |
|
| 178 | - } |
|
| 179 | - break 2; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 161 | + // Get original article URL from v.redd.it redirects |
|
| 162 | + $source_article_url = $this->get_location($matches[0]); |
|
| 163 | + Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE); |
|
| 164 | + |
|
| 165 | + $source_stream = false; |
|
| 166 | + |
|
| 167 | + if ($source_article_url) { |
|
| 168 | + $j = json_decode(fetch_file_contents($source_article_url.".json"), true); |
|
| 169 | + |
|
| 170 | + if ($j) { |
|
| 171 | + foreach ($j as $listing) { |
|
| 172 | + foreach ($listing["data"]["children"] as $child) { |
|
| 173 | + if ($child["data"]["url"] == $matches[0]) { |
|
| 174 | + try { |
|
| 175 | + $source_stream = $child["data"]["media"]["reddit_video"]["fallback_url"]; |
|
| 176 | + } |
|
| 177 | + catch (Exception $e) { |
|
| 178 | + } |
|
| 179 | + break 2; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - if (!$source_stream) { |
|
| 187 | - $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K"; |
|
| 188 | - } |
|
| 186 | + if (!$source_stream) { |
|
| 187 | + $source_stream = "https://v.redd.it/" . $matches[1] . "/DASH_600_K"; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 191 | - $found = 1; |
|
| 192 | - } |
|
| 190 | + $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 191 | + $found = 1; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) { |
|
| 194 | + if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) { |
|
| 195 | 195 | |
| 196 | - Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE); |
|
| 196 | + Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE); |
|
| 197 | 197 | |
| 198 | - $tmp = fetch_file_contents($entry->getAttribute("href")); |
|
| 198 | + $tmp = fetch_file_contents($entry->getAttribute("href")); |
|
| 199 | 199 | |
| 200 | - if ($tmp) { |
|
| 201 | - $tmpdoc = new DOMDocument(); |
|
| 200 | + if ($tmp) { |
|
| 201 | + $tmpdoc = new DOMDocument(); |
|
| 202 | 202 | |
| 203 | - if (@$tmpdoc->loadHTML($tmp)) { |
|
| 204 | - $tmpxpath = new DOMXPath($tmpdoc); |
|
| 203 | + if (@$tmpdoc->loadHTML($tmp)) { |
|
| 204 | + $tmpxpath = new DOMXPath($tmpdoc); |
|
| 205 | 205 | |
| 206 | - $source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0); |
|
| 207 | - $poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0); |
|
| 206 | + $source_node = $tmpxpath->query("//video[contains(@class,'video-player-tag')]//source[contains(@src, '.mp4')]")->item(0); |
|
| 207 | + $poster_node = $tmpxpath->query("//video[contains(@class,'video-player-tag') and @poster]")->item(0); |
|
| 208 | 208 | |
| 209 | - if ($source_node && $poster_node) { |
|
| 210 | - $source_stream = $source_node->getAttribute("src"); |
|
| 211 | - $poster_url = $poster_node->getAttribute("poster"); |
|
| 209 | + if ($source_node && $poster_node) { |
|
| 210 | + $source_stream = $source_node->getAttribute("src"); |
|
| 211 | + $poster_url = $poster_node->getAttribute("poster"); |
|
| 212 | 212 | |
| 213 | - $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 214 | - $found = 1; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - } |
|
| 213 | + $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 214 | + $found = 1; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - // imgur .gif -> .gifv |
|
| 221 | - if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) { |
|
| 222 | - Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE); |
|
| 220 | + // imgur .gif -> .gifv |
|
| 221 | + if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) { |
|
| 222 | + Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE); |
|
| 223 | 223 | |
| 224 | - $entry->setAttribute("href", |
|
| 225 | - str_replace(".gif", ".gifv", $entry->getAttribute("href"))); |
|
| 226 | - } |
|
| 224 | + $entry->setAttribute("href", |
|
| 225 | + str_replace(".gif", ".gifv", $entry->getAttribute("href"))); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) { |
|
| 229 | - Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE); |
|
| 228 | + if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) { |
|
| 229 | + Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE); |
|
| 230 | 230 | |
| 231 | - $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href")); |
|
| 231 | + $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href")); |
|
| 232 | 232 | |
| 233 | - if (strpos($source_stream, "imgur.com") !== false) |
|
| 234 | - $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
| 233 | + if (strpos($source_stream, "imgur.com") !== false) |
|
| 234 | + $poster_url = str_replace(".mp4", "h.jpg", $source_stream); |
|
| 235 | 235 | |
| 236 | - $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 236 | + $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 237 | 237 | |
| 238 | - $found = true; |
|
| 239 | - } |
|
| 238 | + $found = true; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - $matches = array(); |
|
| 242 | - if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 243 | - preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 244 | - preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 245 | - preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) { |
|
| 241 | + $matches = array(); |
|
| 242 | + if (!$found && preg_match("/youtube\.com\/v\/([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 243 | + preg_match("/youtube\.com\/.*?[\&\?]v=([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 244 | + preg_match("/youtube\.com\/watch\?v=([\w-]+)/", $entry->getAttribute("href"), $matches) || |
|
| 245 | + preg_match("/\/\/youtu.be\/([\w-]+)/", $entry->getAttribute("href"), $matches)) { |
|
| 246 | 246 | |
| 247 | - $vid_id = $matches[1]; |
|
| 247 | + $vid_id = $matches[1]; |
|
| 248 | 248 | |
| 249 | - Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE); |
|
| 249 | + Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE); |
|
| 250 | 250 | |
| 251 | - $iframe = $doc->createElement("iframe"); |
|
| 252 | - $iframe->setAttribute("class", "youtube-player"); |
|
| 253 | - $iframe->setAttribute("type", "text/html"); |
|
| 254 | - $iframe->setAttribute("width", "640"); |
|
| 255 | - $iframe->setAttribute("height", "385"); |
|
| 256 | - $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id"); |
|
| 257 | - $iframe->setAttribute("allowfullscreen", "1"); |
|
| 258 | - $iframe->setAttribute("frameborder", "0"); |
|
| 251 | + $iframe = $doc->createElement("iframe"); |
|
| 252 | + $iframe->setAttribute("class", "youtube-player"); |
|
| 253 | + $iframe->setAttribute("type", "text/html"); |
|
| 254 | + $iframe->setAttribute("width", "640"); |
|
| 255 | + $iframe->setAttribute("height", "385"); |
|
| 256 | + $iframe->setAttribute("src", "https://www.youtube.com/embed/$vid_id"); |
|
| 257 | + $iframe->setAttribute("allowfullscreen", "1"); |
|
| 258 | + $iframe->setAttribute("frameborder", "0"); |
|
| 259 | 259 | |
| 260 | - $br = $doc->createElement('br'); |
|
| 261 | - $entry->parentNode->insertBefore($iframe, $entry); |
|
| 262 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 260 | + $br = $doc->createElement('br'); |
|
| 261 | + $entry->parentNode->insertBefore($iframe, $entry); |
|
| 262 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 263 | 263 | |
| 264 | - $found = true; |
|
| 265 | - } |
|
| 264 | + $found = true; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) || |
|
| 268 | - mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false || |
|
| 269 | - mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false) { |
|
| 267 | + if (!$found && preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?$/i", $entry->getAttribute("href")) || |
|
| 268 | + mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false || |
|
| 269 | + mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false) { |
|
| 270 | 270 | |
| 271 | - Debug::log("Handling as a picture", Debug::$LOG_VERBOSE); |
|
| 271 | + Debug::log("Handling as a picture", Debug::$LOG_VERBOSE); |
|
| 272 | 272 | |
| 273 | - $img = $doc->createElement('img'); |
|
| 274 | - $img->setAttribute("src", $entry->getAttribute("href")); |
|
| 273 | + $img = $doc->createElement('img'); |
|
| 274 | + $img->setAttribute("src", $entry->getAttribute("href")); |
|
| 275 | 275 | |
| 276 | - $br = $doc->createElement('br'); |
|
| 277 | - $entry->parentNode->insertBefore($img, $entry); |
|
| 278 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 276 | + $br = $doc->createElement('br'); |
|
| 277 | + $entry->parentNode->insertBefore($img, $entry); |
|
| 278 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 279 | 279 | |
| 280 | - $found = true; |
|
| 281 | - } |
|
| 280 | + $found = true; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | // imgur via link rel="image_src" href="..." |
| 284 | 284 | if (!$found && preg_match("/imgur/", $entry->getAttribute("href"))) { |
@@ -311,109 +311,109 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - // wtf is this even |
|
| 315 | - if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) { |
|
| 316 | - $img_id = $matches[1]; |
|
| 314 | + // wtf is this even |
|
| 315 | + if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) { |
|
| 316 | + $img_id = $matches[1]; |
|
| 317 | 317 | |
| 318 | - Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE); |
|
| 318 | + Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE); |
|
| 319 | 319 | |
| 320 | - $img = $doc->createElement('img'); |
|
| 321 | - $img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg"); |
|
| 320 | + $img = $doc->createElement('img'); |
|
| 321 | + $img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg"); |
|
| 322 | 322 | |
| 323 | - $br = $doc->createElement('br'); |
|
| 324 | - $entry->parentNode->insertBefore($img, $entry); |
|
| 325 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 323 | + $br = $doc->createElement('br'); |
|
| 324 | + $entry->parentNode->insertBefore($img, $entry); |
|
| 325 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 326 | 326 | |
| 327 | - $found = true; |
|
| 328 | - } |
|
| 327 | + $found = true; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - // let's try meta properties |
|
| 331 | - if (!$found) { |
|
| 332 | - Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE); |
|
| 330 | + // let's try meta properties |
|
| 331 | + if (!$found) { |
|
| 332 | + Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE); |
|
| 333 | 333 | |
| 334 | - $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
| 335 | - "http_accept" => "text/*"]); |
|
| 334 | + $content = fetch_file_contents(["url" => $entry->getAttribute("href"), |
|
| 335 | + "http_accept" => "text/*"]); |
|
| 336 | 336 | |
| 337 | - if ($content) { |
|
| 338 | - $cdoc = new DOMDocument(); |
|
| 337 | + if ($content) { |
|
| 338 | + $cdoc = new DOMDocument(); |
|
| 339 | 339 | |
| 340 | - if (@$cdoc->loadHTML($content)) { |
|
| 341 | - $cxpath = new DOMXPath($cdoc); |
|
| 340 | + if (@$cdoc->loadHTML($content)) { |
|
| 341 | + $cxpath = new DOMXPath($cdoc); |
|
| 342 | 342 | |
| 343 | - $og_image = $cxpath->query("//meta[@property='og:image']")->item(0); |
|
| 344 | - $og_video = $cxpath->query("//meta[@property='og:video']")->item(0); |
|
| 343 | + $og_image = $cxpath->query("//meta[@property='og:image']")->item(0); |
|
| 344 | + $og_video = $cxpath->query("//meta[@property='og:video']")->item(0); |
|
| 345 | 345 | |
| 346 | - if ($og_video) { |
|
| 346 | + if ($og_video) { |
|
| 347 | 347 | |
| 348 | - $source_stream = $og_video->getAttribute("content"); |
|
| 348 | + $source_stream = $og_video->getAttribute("content"); |
|
| 349 | 349 | |
| 350 | - if ($source_stream) { |
|
| 350 | + if ($source_stream) { |
|
| 351 | 351 | |
| 352 | - if ($og_image) { |
|
| 353 | - $poster_url = $og_image->getAttribute("content"); |
|
| 354 | - } else { |
|
| 355 | - $poster_url = false; |
|
| 356 | - } |
|
| 352 | + if ($og_image) { |
|
| 353 | + $poster_url = $og_image->getAttribute("content"); |
|
| 354 | + } else { |
|
| 355 | + $poster_url = false; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | - $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 359 | - $found = true; |
|
| 360 | - } |
|
| 358 | + $this->handle_as_video($doc, $entry, $source_stream, $poster_url); |
|
| 359 | + $found = true; |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - } else if ($og_image) { |
|
| 362 | + } else if ($og_image) { |
|
| 363 | 363 | |
| 364 | - $og_src = $og_image->getAttribute("content"); |
|
| 364 | + $og_src = $og_image->getAttribute("content"); |
|
| 365 | 365 | |
| 366 | - if ($og_src) { |
|
| 367 | - $img = $doc->createElement('img'); |
|
| 368 | - $img->setAttribute("src", $og_src); |
|
| 366 | + if ($og_src) { |
|
| 367 | + $img = $doc->createElement('img'); |
|
| 368 | + $img->setAttribute("src", $og_src); |
|
| 369 | 369 | |
| 370 | - $br = $doc->createElement('br'); |
|
| 371 | - $entry->parentNode->insertBefore($img, $entry); |
|
| 372 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 370 | + $br = $doc->createElement('br'); |
|
| 371 | + $entry->parentNode->insertBefore($img, $entry); |
|
| 372 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 373 | 373 | |
| 374 | - $found = true; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - } |
|
| 374 | + $found = true; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - // remove tiny thumbnails |
|
| 384 | - if ($entry->hasAttribute("src")) { |
|
| 385 | - if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
| 386 | - $entry->parentNode->parentNode->removeChild($entry->parentNode); |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - } |
|
| 383 | + // remove tiny thumbnails |
|
| 384 | + if ($entry->hasAttribute("src")) { |
|
| 385 | + if ($entry->parentNode && $entry->parentNode->parentNode) { |
|
| 386 | + $entry->parentNode->parentNode->removeChild($entry->parentNode); |
|
| 387 | + } |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - return $found; |
|
| 392 | - } |
|
| 391 | + return $found; |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | - public function hook_article_filter($article) { |
|
| 394 | + public function hook_article_filter($article) { |
|
| 395 | 395 | |
| 396 | - if (strpos($article["link"], "reddit.com/r/") !== false) { |
|
| 397 | - $doc = new DOMDocument(); |
|
| 398 | - @$doc->loadHTML($article["content"]); |
|
| 399 | - $xpath = new DOMXPath($doc); |
|
| 396 | + if (strpos($article["link"], "reddit.com/r/") !== false) { |
|
| 397 | + $doc = new DOMDocument(); |
|
| 398 | + @$doc->loadHTML($article["content"]); |
|
| 399 | + $xpath = new DOMXPath($doc); |
|
| 400 | 400 | |
| 401 | - $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0); |
|
| 401 | + $content_link = $xpath->query("(//a[contains(., '[link]')])")->item(0); |
|
| 402 | 402 | |
| 403 | - if ($this->host->get($this, "enable_content_dupcheck")) { |
|
| 403 | + if ($this->host->get($this, "enable_content_dupcheck")) { |
|
| 404 | 404 | |
| 405 | - if ($content_link) { |
|
| 406 | - $content_href = $content_link->getAttribute("href"); |
|
| 407 | - $entry_guid = $article["guid_hashed"]; |
|
| 408 | - $owner_uid = $article["owner_uid"]; |
|
| 405 | + if ($content_link) { |
|
| 406 | + $content_href = $content_link->getAttribute("href"); |
|
| 407 | + $entry_guid = $article["guid_hashed"]; |
|
| 408 | + $owner_uid = $article["owner_uid"]; |
|
| 409 | 409 | |
| 410 | - if (DB_TYPE == "pgsql") { |
|
| 411 | - $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'"; |
|
| 412 | - } else { |
|
| 413 | - $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)"; |
|
| 414 | - } |
|
| 410 | + if (DB_TYPE == "pgsql") { |
|
| 411 | + $interval_qpart = "date_entered < NOW() - INTERVAL '1 day'"; |
|
| 412 | + } else { |
|
| 413 | + $interval_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY)"; |
|
| 414 | + } |
|
| 415 | 415 | |
| 416 | - $sth = $this->pdo->prepare("SELECT COUNT(id) AS cid |
|
| 416 | + $sth = $this->pdo->prepare("SELECT COUNT(id) AS cid |
|
| 417 | 417 | FROM ttrss_entries, ttrss_user_entries WHERE |
| 418 | 418 | ref_id = id AND |
| 419 | 419 | $interval_qpart AND |
@@ -421,149 +421,149 @@ discard block |
||
| 421 | 421 | owner_uid = ? AND |
| 422 | 422 | content LIKE ?"); |
| 423 | 423 | |
| 424 | - $sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]); |
|
| 424 | + $sth->execute([$entry_guid, $owner_uid, "%href=\"$content_href\">[link]%"]); |
|
| 425 | 425 | |
| 426 | - if ($row = $sth->fetch()) { |
|
| 427 | - $num_found = $row['cid']; |
|
| 426 | + if ($row = $sth->fetch()) { |
|
| 427 | + $num_found = $row['cid']; |
|
| 428 | 428 | |
| 429 | - if ($num_found > 0) $article["force_catchup"] = true; |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 429 | + if ($num_found > 0) $article["force_catchup"] = true; |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | 433 | |
| 434 | - $found = $this->inline_stuff($article, $doc, $xpath); |
|
| 434 | + $found = $this->inline_stuff($article, $doc, $xpath); |
|
| 435 | 435 | |
| 436 | - $node = $doc->getElementsByTagName('body')->item(0); |
|
| 436 | + $node = $doc->getElementsByTagName('body')->item(0); |
|
| 437 | 437 | |
| 438 | - if ($node && $found) { |
|
| 439 | - $article["content"] = $doc->saveHTML($node); |
|
| 440 | - } else if ($content_link) { |
|
| 441 | - $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath); |
|
| 442 | - } |
|
| 443 | - } |
|
| 438 | + if ($node && $found) { |
|
| 439 | + $article["content"] = $doc->saveHTML($node); |
|
| 440 | + } else if ($content_link) { |
|
| 441 | + $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | - return $article; |
|
| 446 | - } |
|
| 445 | + return $article; |
|
| 446 | + } |
|
| 447 | 447 | |
| 448 | - public function api_version() { |
|
| 449 | - return 2; |
|
| 450 | - } |
|
| 448 | + public function api_version() { |
|
| 449 | + return 2; |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) { |
|
| 452 | + private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) { |
|
| 453 | 453 | |
| 454 | - Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE); |
|
| 454 | + Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE); |
|
| 455 | 455 | |
| 456 | - $video = $doc->createElement('video'); |
|
| 457 | - $video->setAttribute("autoplay", "1"); |
|
| 458 | - $video->setAttribute("controls", "1"); |
|
| 459 | - $video->setAttribute("loop", "1"); |
|
| 456 | + $video = $doc->createElement('video'); |
|
| 457 | + $video->setAttribute("autoplay", "1"); |
|
| 458 | + $video->setAttribute("controls", "1"); |
|
| 459 | + $video->setAttribute("loop", "1"); |
|
| 460 | 460 | |
| 461 | - if ($poster_url) $video->setAttribute("poster", $poster_url); |
|
| 461 | + if ($poster_url) $video->setAttribute("poster", $poster_url); |
|
| 462 | 462 | |
| 463 | - $source = $doc->createElement('source'); |
|
| 464 | - $source->setAttribute("src", $source_stream); |
|
| 465 | - $source->setAttribute("type", "video/mp4"); |
|
| 463 | + $source = $doc->createElement('source'); |
|
| 464 | + $source->setAttribute("src", $source_stream); |
|
| 465 | + $source->setAttribute("type", "video/mp4"); |
|
| 466 | 466 | |
| 467 | - $video->appendChild($source); |
|
| 467 | + $video->appendChild($source); |
|
| 468 | 468 | |
| 469 | - $br = $doc->createElement('br'); |
|
| 470 | - $entry->parentNode->insertBefore($video, $entry); |
|
| 471 | - $entry->parentNode->insertBefore($br, $entry); |
|
| 469 | + $br = $doc->createElement('br'); |
|
| 470 | + $entry->parentNode->insertBefore($video, $entry); |
|
| 471 | + $entry->parentNode->insertBefore($br, $entry); |
|
| 472 | 472 | |
| 473 | - $img = $doc->createElement('img'); |
|
| 474 | - $img->setAttribute("src", |
|
| 475 | - "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D"); |
|
| 473 | + $img = $doc->createElement('img'); |
|
| 474 | + $img->setAttribute("src", |
|
| 475 | + "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D"); |
|
| 476 | 476 | |
| 477 | - $entry->parentNode->insertBefore($img, $entry); |
|
| 478 | - } |
|
| 477 | + $entry->parentNode->insertBefore($img, $entry); |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - public function testurl() { |
|
| 481 | - $url = htmlspecialchars($_REQUEST["url"]); |
|
| 480 | + public function testurl() { |
|
| 481 | + $url = htmlspecialchars($_REQUEST["url"]); |
|
| 482 | 482 | |
| 483 | - header("Content-type: text/plain"); |
|
| 483 | + header("Content-type: text/plain"); |
|
| 484 | 484 | |
| 485 | - print "URL: $url\n"; |
|
| 485 | + print "URL: $url\n"; |
|
| 486 | 486 | |
| 487 | - $doc = new DOMDocument(); |
|
| 488 | - @$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>"); |
|
| 489 | - $xpath = new DOMXPath($doc); |
|
| 487 | + $doc = new DOMDocument(); |
|
| 488 | + @$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>"); |
|
| 489 | + $xpath = new DOMXPath($doc); |
|
| 490 | 490 | |
| 491 | - $found = $this->inline_stuff([], $doc, $xpath); |
|
| 491 | + $found = $this->inline_stuff([], $doc, $xpath); |
|
| 492 | 492 | |
| 493 | - print "Inline result: $found\n"; |
|
| 493 | + print "Inline result: $found\n"; |
|
| 494 | 494 | |
| 495 | - if (!$found) { |
|
| 496 | - print "\nReadability result:\n"; |
|
| 495 | + if (!$found) { |
|
| 496 | + print "\nReadability result:\n"; |
|
| 497 | 497 | |
| 498 | - $article = $this->readability([], $url, $doc, $xpath); |
|
| 498 | + $article = $this->readability([], $url, $doc, $xpath); |
|
| 499 | 499 | |
| 500 | - print_r($article); |
|
| 501 | - } else { |
|
| 502 | - print "\nResulting HTML:\n"; |
|
| 500 | + print_r($article); |
|
| 501 | + } else { |
|
| 502 | + print "\nResulting HTML:\n"; |
|
| 503 | 503 | |
| 504 | - print $doc->saveHTML(); |
|
| 505 | - } |
|
| 506 | - } |
|
| 504 | + print $doc->saveHTML(); |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | 507 | |
| 508 | - private function get_header($url, $useragent = SELF_USER_AGENT, $header) { |
|
| 509 | - $ret = false; |
|
| 508 | + private function get_header($url, $useragent = SELF_USER_AGENT, $header) { |
|
| 509 | + $ret = false; |
|
| 510 | 510 | |
| 511 | - if (function_exists("curl_init") && !defined("NO_CURL")) { |
|
| 512 | - $ch = curl_init($url); |
|
| 513 | - curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 514 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 515 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 516 | - curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 517 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir")); |
|
| 518 | - curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
|
| 511 | + if (function_exists("curl_init") && !defined("NO_CURL")) { |
|
| 512 | + $ch = curl_init($url); |
|
| 513 | + curl_setopt($ch, CURLOPT_TIMEOUT, 5); |
|
| 514 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 515 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
| 516 | + curl_setopt($ch, CURLOPT_NOBODY, true); |
|
| 517 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir")); |
|
| 518 | + curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
|
| 519 | 519 | |
| 520 | - @curl_exec($ch); |
|
| 521 | - $ret = curl_getinfo($ch, $header); |
|
| 522 | - } |
|
| 520 | + @curl_exec($ch); |
|
| 521 | + $ret = curl_getinfo($ch, $header); |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - return $ret; |
|
| 525 | - } |
|
| 524 | + return $ret; |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - private function get_content_type($url, $useragent = SELF_USER_AGENT) { |
|
| 528 | - return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE); |
|
| 529 | - } |
|
| 527 | + private function get_content_type($url, $useragent = SELF_USER_AGENT) { |
|
| 528 | + return $this->get_header($url, $useragent, CURLINFO_CONTENT_TYPE); |
|
| 529 | + } |
|
| 530 | 530 | |
| 531 | - private function get_location($url, $useragent = SELF_USER_AGENT) { |
|
| 532 | - return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL); |
|
| 533 | - } |
|
| 531 | + private function get_location($url, $useragent = SELF_USER_AGENT) { |
|
| 532 | + return $this->get_header($url, $useragent, CURLINFO_EFFECTIVE_URL); |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 537 | - */ |
|
| 538 | - private function readability($article, $url, $doc, $xpath, $debug = false) { |
|
| 535 | + /** |
|
| 536 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
|
| 537 | + */ |
|
| 538 | + private function readability($article, $url, $doc, $xpath, $debug = false) { |
|
| 539 | 539 | |
| 540 | - if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") && |
|
| 541 | - mb_strlen(strip_tags($article["content"])) <= 150) { |
|
| 540 | + if (!defined('NO_CURL') && function_exists("curl_init") && $this->host->get($this, "enable_readability") && |
|
| 541 | + mb_strlen(strip_tags($article["content"])) <= 150) { |
|
| 542 | 542 | |
| 543 | - // do not try to embed posts linking back to other reddit posts |
|
| 544 | - // readability.php requires PHP 5.6 |
|
| 545 | - if ($url && strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) { |
|
| 543 | + // do not try to embed posts linking back to other reddit posts |
|
| 544 | + // readability.php requires PHP 5.6 |
|
| 545 | + if ($url && strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) { |
|
| 546 | 546 | |
| 547 | - /* link may lead to a huge video file or whatever, we need to check content type before trying to |
|
| 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 */ |
| 549 | 549 | |
| 550 | - $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; |
|
| 551 | - $content_type = $this->get_content_type($url, $useragent_compat); |
|
| 550 | + $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; |
|
| 551 | + $content_type = $this->get_content_type($url, $useragent_compat); |
|
| 552 | 552 | |
| 553 | - if ($content_type && strpos($content_type, "text/html") !== false) { |
|
| 553 | + if ($content_type && strpos($content_type, "text/html") !== false) { |
|
| 554 | 554 | |
| 555 | - foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) { |
|
| 556 | - $extracted_content = $p->hook_get_full_text($url); |
|
| 555 | + foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) { |
|
| 556 | + $extracted_content = $p->hook_get_full_text($url); |
|
| 557 | 557 | |
| 558 | - if ($extracted_content) { |
|
| 559 | - $article["content"] = $extracted_content; |
|
| 560 | - break; |
|
| 561 | - } |
|
| 562 | - } |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - } |
|
| 558 | + if ($extracted_content) { |
|
| 559 | + $article["content"] = $extracted_content; |
|
| 560 | + break; |
|
| 561 | + } |
|
| 562 | + } |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - return $article; |
|
| 568 | - } |
|
| 567 | + return $article; |
|
| 568 | + } |
|
| 569 | 569 | } |
@@ -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); |