From 35b6a881467800d554e3cd548c120ad58d2e9bf7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2021 13:36:24 +0300 Subject: RIP af_tumblr_1280 --- plugins/af_tumblr_1280/init.php | 91 ----------------------------------------- 1 file changed, 91 deletions(-) delete mode 100755 plugins/af_tumblr_1280/init.php diff --git a/plugins/af_tumblr_1280/init.php b/plugins/af_tumblr_1280/init.php deleted file mode 100755 index 5d7f366a4..000000000 --- a/plugins/af_tumblr_1280/init.php +++ /dev/null @@ -1,91 +0,0 @@ - true); - } - - function init($host) { - $this->host = $host; - - if (function_exists("curl_init")) { - $host->add_hook($host::HOOK_ARTICLE_FILTER, $this); - } - } - - function hook_article_filter($article) { - - if (!function_exists("curl_init") || ini_get("open_basedir")) - return $article; - - $doc = new DOMDocument(); - $doc->loadHTML('' . $article["content"]); - - $found = false; - - if ($doc) { - $xpath = new DOMXpath($doc); - - $images = $xpath->query('(//img[contains(@src, \'media.tumblr.com\')])'); - - foreach ($images as $img) { - $src = $img->getAttribute("src"); - - $test_src = preg_replace("/_\d{3}.(jpg|gif|png)/", "_1280.$1", $src); - - if ($src != $test_src) { - - $ch = curl_init($test_src); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); - - @$result = curl_exec($ch); - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - - if ($result && $http_code == 200) { - $img->setAttribute("src", $test_src); - $found = true; - } - } - } - - $video_sources = $xpath->query('//video/source[contains(@src, \'.tumblr.com/video_file\')]'); - - foreach ($video_sources as $source) { - $src = $source->getAttribute("src"); - - $new_src = preg_replace("/\/\d{3}$/", "", $src); - - if ($src != $new_src) { - $source->setAttribute("src", $new_src); - $found = true; - } - } - - if ($found) { - $doc->removeChild($doc->firstChild); //remove doctype - $article["content"] = $doc->saveHTML(); - } - } - - return $article; - - } - - - function api_version() { - return 2; - } - -} -- cgit v1.2.3