summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-15 08:02:28 +0300
committerAndrew Dolgov <[email protected]>2020-09-15 08:02:28 +0300
commit79f102c25d8125f7ff145269627d8146d66b951c (patch)
tree2eb24d762a71a7aadaf4b068694561f5e189e339
parent1ee458b5c1cdaf254dccadee77bb77b421b0fd45 (diff)
af_proxy_http: never print received data directly, always redirect to cached_url
cache/getUrl: basename() passed filename just in case
-rw-r--r--classes/diskcache.php2
-rw-r--r--plugins/af_proxy_http/init.php19
2 files changed, 4 insertions, 17 deletions
diff --git a/classes/diskcache.php b/classes/diskcache.php
index 74415189c..da7722bf0 100644
--- a/classes/diskcache.php
+++ b/classes/diskcache.php
@@ -273,7 +273,7 @@ class DiskCache {
}
public function getUrl($filename) {
- return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename;
+ return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . basename($filename);
}
// check for locally cached (media) URLs and rewrite to local versions
diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php
index 936942387..1d518c9c2 100644
--- a/plugins/af_proxy_http/init.php
+++ b/plugins/af_proxy_http/init.php
@@ -62,17 +62,10 @@ class Af_Proxy_Http extends Plugin {
$data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
if ($data) {
-
- $disable_cache = $this->host->get($this, "disable_cache");
-
- if (!$disable_cache) {
- if ($this->cache->put($local_filename, $data)) {
- header("Location: " . $this->cache->getUrl($local_filename));
- return;
- }
+ if ($this->cache->put($local_filename, $data)) {
+ header("Location: " . $this->cache->getUrl($local_filename));
+ return;
}
-
- print $data;
} else {
global $fetch_last_error;
global $fetch_last_error_code;
@@ -232,10 +225,6 @@ class Af_Proxy_Http extends Plugin {
print_checkbox("proxy_all", $proxy_all);
print "&nbsp;<label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>";
- $disable_cache = $this->host->get($this, "disable_cache");
- print_checkbox("disable_cache", $disable_cache);
- print "&nbsp;<label for=\"disable_cache\">" . __("Don't cache files locally.") . "</label>";
-
print "<p>"; print_button("submit", __("Save"));
print "</form>";
@@ -245,10 +234,8 @@ class Af_Proxy_Http extends Plugin {
function save() {
$proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]);
- $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]);
$this->host->set($this, "proxy_all", $proxy_all, false);
- $this->host->set($this, "disable_cache", $disable_cache);
echo __("Configuration saved");
}