-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproxy.php
More file actions
72 lines (55 loc) · 1.9 KB
/
Copy pathproxy.php
File metadata and controls
72 lines (55 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/* This file is part of BooruSurfer.
BooruSurfer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BooruSurfer is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BooruSurfer. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "lib/Booru.php";
$site = new Booru( $_GET['site'] );
$post = $site->post( $_GET['id'] );
$site_url = $site->get_api()->get_refferer();
//TODO: emulate it better ;P
//Get image
$type = $_GET['type'];
switch( $type ){
case 'thumb':
case 'preview':
case 'reduced':
break;
case 'original':
$type = '';
break;
default:
die( "Unknown image type!" );
}
$img = $post->get_image( $type );
$url = $img['real_url'];
//Fix caching
header( "Cache-Control: max-age=" . 60*60*24*365 );
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_REFERER, $site_url );
curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false );
//Enable HTTPS
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
//Forward content lenght
curl_setopt( $ch, CURLOPT_HEADERFUNCTION, function( $ch, $header ){
if( strpos( $header, 'Content-Length:' ) !== false )
header( $header );
if( strpos( $header, 'Content-Type:' ) !== false )
header( $header );
return strlen( $header );
} );
//Enable redirection-following
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec( $ch );
curl_close( $ch );
?>