summaryrefslogtreecommitdiff
path: root/proxy.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2024-04-21 19:31:56 -0400
committerlolcat <will@lolcat.ca>2024-04-21 19:31:56 -0400
commit130358a9e0504a55cf3f86b2d7035feb7f4e84de (patch)
tree81f59790f7ead0b393a0e0b25caa082216245fcd /proxy.php
parent9e18327df69542e07fad2ef471a3ebdbe9b08ae8 (diff)
v8
Diffstat (limited to 'proxy.php')
-rw-r--r--proxy.php29
1 files changed, 26 insertions, 3 deletions
diff --git a/proxy.php b/proxy.php
index 563f378..e4e8541 100644
--- a/proxy.php
+++ b/proxy.php
@@ -24,13 +24,36 @@ try{
}
// bing request, ask bing to resize and stream to browser
+ $image = parse_url($_GET["i"]);
+
if(
+ isset($image["host"]) &&
preg_match(
- '/bing.net$/',
- parse_url($_GET["i"], PHP_URL_HOST)
+ '/^[A-z0-9.]*bing\.(net|com)$/i',
+ $image["host"]
)
){
+ if(
+ !isset($image["query"]) ||
+ !isset($image["path"]) ||
+ $image["path"] != "/th"
+ ){
+
+ header("X-Error: Invalid bing image path");
+ $proxy->do404();
+ die();
+ }
+
+ parse_str($image["query"], $str);
+
+ if(!isset($str["id"])){
+
+ header("X-Error: Missing bing ID");
+ $proxy->do404();
+ die();
+ }
+
switch($_GET["s"]){
case "portrait": $req = "&w=50&h=90&p=0&qlt=90"; break;
@@ -40,7 +63,7 @@ try{
case "cover": $req = "&w=207&h=270&p=0&qlt=90"; break;
}
- $proxy->stream_linear_image($_GET["i"] . $req, "https://bing.net");
+ $proxy->stream_linear_image("https://" . $image["host"] . "/th?id=" . urlencode($str["id"]) . $req, "https://www.bing.com");
die();
}