mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-10-15 21:11:14 +02:00
af_zz_imgproxy: rewrite to absolute url; add on-parse article filter hook to handle redirect situation in case frontend has open_basedir (disabled currently)
This commit is contained in:
parent
b73bf7e2d8
commit
c55fb22bcd
@ -18,6 +18,7 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
|
$host->add_hook($host::HOOK_RENDER_ARTICLE, $this);
|
||||||
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
|
$host->add_hook($host::HOOK_RENDER_ARTICLE_CDM, $this);
|
||||||
$host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
|
$host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this);
|
||||||
|
//$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
|
||||||
|
|
||||||
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
$host->add_hook($host::HOOK_PREFS_TAB, $this);
|
||||||
}
|
}
|
||||||
@ -32,6 +33,10 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
return $enc;
|
return $enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hook_article_filter($article) {
|
||||||
|
return $this->hook_render_article_cdm($article);
|
||||||
|
}
|
||||||
|
|
||||||
function hook_render_article($article) {
|
function hook_render_article($article) {
|
||||||
return $this->hook_render_article_cdm($article);
|
return $this->hook_render_article_cdm($article);
|
||||||
}
|
}
|
||||||
@ -63,7 +68,7 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
|
|
||||||
readfile($local_filename);
|
readfile($local_filename);
|
||||||
} else {
|
} else {
|
||||||
$data = fetch_file_contents(array("url" => $url, "useragent" => "Mozilla/5.0"));
|
$data = fetch_file_contents(array("url" => $url));
|
||||||
|
|
||||||
if ($data) {
|
if ($data) {
|
||||||
if (file_put_contents($local_filename, $data)) {
|
if (file_put_contents($local_filename, $data)) {
|
||||||
@ -77,7 +82,7 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
global $fetch_last_error_code;
|
global $fetch_last_error_code;
|
||||||
global $fetch_last_error_content;
|
global $fetch_last_error_content;
|
||||||
|
|
||||||
if (function_exists("imagecreate")) {
|
if (function_exists("imagecreate") && !isset($_REQUEST["text"])) {
|
||||||
$img = imagecreate(450, 75);
|
$img = imagecreate(450, 75);
|
||||||
|
|
||||||
$bg = imagecolorallocate($img, 255, 255, 255);
|
$bg = imagecolorallocate($img, 255, 255, 255);
|
||||||
@ -121,7 +126,7 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
|
|
||||||
if (($scheme != 'https' && $scheme != "") || $is_remote) {
|
if (($scheme != 'https' && $scheme != "") || $is_remote) {
|
||||||
if (strpos($url, "data:") !== 0) {
|
if (strpos($url, "data:") !== 0) {
|
||||||
$url = "public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&kind=$kind&url=" .
|
$url = get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&kind=$kind&url=" .
|
||||||
urlencode($url);
|
urlencode($url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,6 +149,7 @@ class Af_Zz_ImgProxy extends Plugin {
|
|||||||
|
|
||||||
if ($new_src != $img->getAttribute("src")) {
|
if ($new_src != $img->getAttribute("src")) {
|
||||||
$img->setAttribute("src", $new_src);
|
$img->setAttribute("src", $new_src);
|
||||||
|
$img->removeAttribute("srcset");
|
||||||
|
|
||||||
$need_saving = true;
|
$need_saving = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user