aboutsummaryrefslogtreecommitdiffstats
path: root/proxy.php
diff options
context:
space:
mode:
authorlolcat <will@lolcat.ca>2025-04-17 19:54:34 -0400
committerlolcat <will@lolcat.ca>2025-04-17 19:54:34 -0400
commitff8b1addf7059a8289049e937475c289e1ba407d (patch)
tree3769d42e374d659f951440c25b522ff0099914d9 /proxy.php
parent3e2c3fc5d90a0b0f859358d1c5b2614ab26905a4 (diff)
fixed bing images failing to load, added flickr
Diffstat (limited to 'proxy.php')
-rw-r--r--proxy.php56
1 files changed, 41 insertions, 15 deletions
diff --git a/proxy.php b/proxy.php
index e4e8541..14c0efa 100644
--- a/proxy.php
+++ b/proxy.php
@@ -34,36 +34,62 @@ try{
)
){
- if(
- !isset($image["query"]) ||
- !isset($image["path"]) ||
- $image["path"] != "/th"
- ){
+ if(!isset($image["path"])){
- header("X-Error: Invalid bing image path");
+ header("X-Error: Missing bing image path");
$proxy->do404();
die();
}
- parse_str($image["query"], $str);
+ //
+ // get image ID
+ // formations:
+ // https://tse2.mm.bing.net/th/id/OIP.3yLBkUPn8EXA1wlhWP2BHwHaE3
+ // https://tse2.mm.bing.net/th?id=OIP.3yLBkUPn8EXA1wlhWP2BHwHaE3
+ //
+ $id = null;
+ if(isset($image["query"])){
+
+ parse_str($image["query"], $str);
+
+ if(isset($str["id"])){
+
+ $id = $str["id"];
+ }
+ }
+
+ if($id === null){
+
+ // fallback to getting ID from path
+ $id = explode("/", $image["path"]);
+
+ for($i=count($id) - 1; $i>0; $i--){
+
+ if(trim($id[$i]) != ""){
+
+ $id = $id[$i];
+ break;
+ }
+ }
+ }
- if(!isset($str["id"])){
+ if(is_array($id)){
- header("X-Error: Missing bing ID");
+ header("X-Error: Missing bing id parameter");
$proxy->do404();
die();
}
switch($_GET["s"]){
- case "portrait": $req = "&w=50&h=90&p=0&qlt=90"; break;
- case "landscape": $req = "&w=160&h=90&p=0&qlt=90"; break;
- case "square": $req = "&w=90&h=90&p=0&qlt=90"; break;
- case "thumb": $req = "&w=236&h=180&p=0&qlt=90"; break;
- case "cover": $req = "&w=207&h=270&p=0&qlt=90"; break;
+ case "portrait": $req = "?w=50&h=90&p=0&qlt=90"; break;
+ case "landscape": $req = "?w=160&h=90&p=0&qlt=90"; break;
+ case "square": $req = "?w=90&h=90&p=0&qlt=90"; break;
+ case "thumb": $req = "?w=236&h=180&p=0&qlt=90"; break;
+ case "cover": $req = "?w=207&h=270&p=0&qlt=90"; break;
}
- $proxy->stream_linear_image("https://" . $image["host"] . "/th?id=" . urlencode($str["id"]) . $req, "https://www.bing.com");
+ $proxy->stream_linear_image("https://" . $image["host"] . "/th/id/" . urlencode($id) . $req, "https://www.bing.com");
die();
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage