From 76ba1df76e9ce3733c990e1d953706b691ee7b14 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Jul 2016 15:46:54 +0300 Subject: af_redditimgur: use browser UA for readability requests --- plugins/af_redditimgur/init.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'plugins/af_redditimgur') diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index f32578450..1068ec548 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -349,24 +349,27 @@ class Af_RedditImgur extends Plugin { /* link may lead to a huge video file or whatever, we need to check content type before trying to parse it which p much requires curl */ + $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; + $ch = curl_init($content_link->getAttribute("href")); 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, !ini_get("open_basedir")); - curl_setopt($ch, CURLOPT_USERAGENT, SELF_USER_AGENT); + curl_setopt($ch, CURLOPT_USERAGENT, $useragent_compat); @$result = curl_exec($ch); $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); if ($content_type && strpos($content_type, "text/html") !== FALSE) { - $tmp = fetch_file_contents($content_link->getAttribute("href")); + $tmp = fetch_file_contents(array("url" => $content_link->getAttribute("href"), + "useragent" => $useragent_compat)); //_debug("tmplen: " . mb_strlen($tmp)); - if ($tmp && mb_strlen($tmp) < 65535 * 4) { + if ($tmp && mb_strlen($tmp) < 1024 * 250) { $r = new Readability($tmp, $content_link->getAttribute("href")); -- cgit v1.2.3