1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- require_once __DIR__ . '/include/config.php';
- if (
- !isset($_GET['dest'])
- || !(
- strpos($_GET['dest'], 'i.pximg.net/') === 0
- || strpos($_GET['dest'], 's.pximg.net/') === 0
- )
- ) {
- http_response_code(400);
- die('Illegal request');
- }
- $stream_context = [
- 'http' => [
- 'header' =>
- "User-Agent: Mozilla/5.0" . PHP_EOL .
- 'Referer: https://www.pixiv.net/'
- ]
- ];
- if (HTTP_PROXY) {
- $stream_context['http']['proxy'] = 'tcp://' . HTTP_PROXY;
- }
- $response = file_get_contents('https://' . $_GET['dest'], false, stream_context_create($stream_context));
- if (!$response) {
- http_response_code(500);
- die('Proxy failed');
- }
- foreach ($http_response_header as $header) {
- if (strpos($header, 'Content-Type: ') === 0) {
- header($header);
- break;
- }
- }
- $path = explode('/', $_GET['dest']);
- header('Content-Disposition: filename="' . $path[count($path) - 1] . '"');
- echo $response;
|