From 29dc1043cf707c2a4223cbcff5c28eab9afee21c Mon Sep 17 00:00:00 2001 From: David Drapeau Date: Thu, 26 Nov 2020 14:00:14 +0100 Subject: [PATCH] [ADD] proxies --- images/proxy.php | 43 +++++++++++++++++++++++++++++++++++++++++++ proxy.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 images/proxy.php create mode 100644 proxy.php diff --git a/images/proxy.php b/images/proxy.php new file mode 100644 index 0000000..1dcb13e --- /dev/null +++ b/images/proxy.php @@ -0,0 +1,43 @@ +getURLRoot())); + +$custom_file = $oConf->getPathCustom($file_path); +$native_file = $oConf->getPathRoot($file_path); + +if(file_exists($custom_file)){ + $file = $custom_file; +} elseif(file_exists($native_file)) { + $file = $native_file; +} else { + header('HTTP/1.1 404 Not found', true); + exit(0); +} + +$is_css = preg_match('/\.css$/', $file); +$is_js = preg_match('/\.js$/', $file); +$is_php = preg_match('/\.php$/', $file); + +if($is_php){ + include($file); + exit(0); +} else if($is_css){ + $type = 'text/css'; +} else if($is_js){ + $type = 'text/javascript'; +} else { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $type = finfo_file($finfo, $file); + finfo_close($finfo); +} + +header('Content-Type: ' . $type, true); + +echo file_get_contents($file); diff --git a/proxy.php b/proxy.php new file mode 100644 index 0000000..1dcb13e --- /dev/null +++ b/proxy.php @@ -0,0 +1,43 @@ +getURLRoot())); + +$custom_file = $oConf->getPathCustom($file_path); +$native_file = $oConf->getPathRoot($file_path); + +if(file_exists($custom_file)){ + $file = $custom_file; +} elseif(file_exists($native_file)) { + $file = $native_file; +} else { + header('HTTP/1.1 404 Not found', true); + exit(0); +} + +$is_css = preg_match('/\.css$/', $file); +$is_js = preg_match('/\.js$/', $file); +$is_php = preg_match('/\.php$/', $file); + +if($is_php){ + include($file); + exit(0); +} else if($is_css){ + $type = 'text/css'; +} else if($is_js){ + $type = 'text/javascript'; +} else { + $finfo = finfo_open(FILEINFO_MIME_TYPE); + $type = finfo_file($finfo, $file); + finfo_close($finfo); +} + +header('Content-Type: ' . $type, true); + +echo file_get_contents($file);