mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 03:15:56 +00:00
move all $fetch globals to UrlHelper
This commit is contained in:
@@ -8,17 +8,14 @@ class Af_Comics_Cad extends Af_ComicFilter {
|
||||
function process(&$article) {
|
||||
if (strpos($article["link"], "cad-comic.com") !== false) {
|
||||
if (strpos($article["title"], "News:") === false) {
|
||||
|
||||
global $fetch_last_error_content;
|
||||
|
||||
$doc = new DOMDocument();
|
||||
|
||||
$res = UrlHelper::fetch($article["link"], false, false, false,
|
||||
false, false, 0,
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
|
||||
|
||||
if (!$res && $fetch_last_error_content)
|
||||
$res = $fetch_last_error_content;
|
||||
if (!$res && UrlHelper::$fetch_last_error_content)
|
||||
$res = UrlHelper::$fetch_last_error_content;
|
||||
|
||||
if (@$doc->loadHTML($res)) {
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
@@ -13,10 +13,8 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
|
||||
false, false, 0,
|
||||
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
|
||||
|
||||
global $fetch_last_error_content;
|
||||
|
||||
if (!$res && $fetch_last_error_content)
|
||||
$res = $fetch_last_error_content;
|
||||
if (!$res && UrlHelper::$fetch_last_error_content)
|
||||
$res = UrlHelper::$fetch_last_error_content;
|
||||
|
||||
$doc = new DOMDocument();
|
||||
|
||||
|
||||
@@ -14,10 +14,8 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
|
||||
false, false, 0,
|
||||
"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
|
||||
|
||||
global $fetch_last_error_content;
|
||||
|
||||
if (!$res && $fetch_last_error_content)
|
||||
$res = $fetch_last_error_content;
|
||||
if (!$res && UrlHelper::$fetch_last_error_content)
|
||||
$res = UrlHelper::$fetch_last_error_content;
|
||||
|
||||
$doc = new DOMDocument();
|
||||
|
||||
|
||||
@@ -12,10 +12,8 @@ class Af_Comics_Whomp extends Af_ComicFilter {
|
||||
false, false, 0,
|
||||
"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
|
||||
|
||||
global $fetch_last_error_content;
|
||||
|
||||
if (!$res && $fetch_last_error_content)
|
||||
$res = $fetch_last_error_content;
|
||||
if (!$res && UrlHelper::$fetch_last_error_content)
|
||||
$res = UrlHelper::$fetch_last_error_content;
|
||||
|
||||
$doc = new DOMDocument();
|
||||
|
||||
|
||||
@@ -76,10 +76,6 @@ class Af_Proxy_Http extends Plugin {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
global $fetch_last_error;
|
||||
global $fetch_last_error_code;
|
||||
global $fetch_last_error_content;
|
||||
|
||||
if (function_exists("imagecreate") && !isset($_REQUEST["text"])) {
|
||||
$img = imagecreate(450, 75);
|
||||
|
||||
@@ -90,7 +86,7 @@ class Af_Proxy_Http extends Plugin {
|
||||
|
||||
imagestring($img, 5, 5, 5, "Proxy request failed", $textcolor);
|
||||
imagestring($img, 5, 5, 30, truncate_middle($url, 46, "..."), $textcolor);
|
||||
imagestring($img, 5, 5, 55, "HTTP Code: $fetch_last_error_code", $textcolor);
|
||||
imagestring($img, 5, 5, 55, "HTTP Code: ".UrlHelper::$fetch_last_error_code, $textcolor);
|
||||
|
||||
header("Content-type: image/png");
|
||||
print imagepng($img);
|
||||
@@ -102,7 +98,7 @@ class Af_Proxy_Http extends Plugin {
|
||||
http_response_code(400);
|
||||
|
||||
print "Proxy request failed.\n".
|
||||
"Fetch error $fetch_last_error ($fetch_last_error_code)\n".
|
||||
"Fetch error ".UrlHelper::$fetch_last_error." (".UrlHelper::$fetch_last_error_code.")\n".
|
||||
"Requested URL: $url";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,8 +190,6 @@ class Af_Readability extends Plugin {
|
||||
|
||||
public function extract_content($url) {
|
||||
|
||||
global $fetch_effective_url;
|
||||
|
||||
$tmp = UrlHelper::fetch([
|
||||
"url" => $url,
|
||||
"http_accept" => "text/*",
|
||||
@@ -224,13 +222,13 @@ class Af_Readability extends Plugin {
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry->hasAttribute("href")) {
|
||||
$entry->setAttribute("href",
|
||||
rewrite_relative_url($fetch_effective_url, $entry->getAttribute("href")));
|
||||
rewrite_relative_url(UrlHelper::$fetch_effective_url, $entry->getAttribute("href")));
|
||||
|
||||
}
|
||||
|
||||
if ($entry->hasAttribute("src")) {
|
||||
$entry->setAttribute("src",
|
||||
rewrite_relative_url($fetch_effective_url, $entry->getAttribute("src")));
|
||||
rewrite_relative_url(UrlHelper::$fetch_effective_url, $entry->getAttribute("src")));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,8 +276,7 @@ class Af_RedditImgur extends Plugin {
|
||||
}
|
||||
} else {
|
||||
if (!$tmp) {
|
||||
global $fetch_last_error;
|
||||
Debug::log("JSON: failed to fetch post:" . $fetch_last_error, Debug::$LOG_EXTENDED);
|
||||
Debug::log("JSON: failed to fetch post:" . UrlHelper::$fetch_last_error, Debug::$LOG_EXTENDED);
|
||||
}
|
||||
}
|
||||
} else if (!$anchor) {
|
||||
|
||||
Reference in New Issue
Block a user