1
0

proxy.php 732 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once("../config.php");
  3. $url = htmlspecialchars($_GET["url"]);
  4. if (explode("/", $url)[0] != "i.pximg.net" && explode("/", $url)[0] != "s.pximg.net") die("不正なURL");
  5. // ファイル類
  6. $ext = explode(".", $url);
  7. $ext = $ext[array_key_last($ext)];
  8. if ($ext == "jpg") $ext = "jpeg";
  9. // ファイル名
  10. $fname = explode("/", $url);
  11. $fname = $fname[array_key_last($fname)];
  12. header("Content-type: image/".$ext);
  13. header("Content-Disposition: filename=\"".$fname."\"");
  14. $ch = curl_init();
  15. curl_setopt($ch, CURLOPT_URL, "https://".$url);
  16. curl_setopt($ch, CURLOPT_REFERER, "https://www.pixiv.net/");
  17. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  18. curl_exec($ch);
  19. curl_close($ch);
  20. ?>