3 define(
'DIRECTORY_BASE', str_replace(
'_src/_api' , NULL , dirname( __FILE__ ) ) );
12 # $ttl = 60 * 60 * 24 * ; // cache timeout in seconds 14 $x = intval($_GET[
'x']);
15 $y = intval($_GET[
'y']);
16 $z = intval($_GET[
'z']);
17 # $r = strip_tags($_GET['r']); 19 appendToFile(
'richiesta tela ' .
$z .
'/' .
$x .
'/' .
$y . PHP_EOL,
'var/log/osm/cache.' . date(
'Ymd' ) .
'.log' );
34 appendToFile(
'file: ' .
$file . PHP_EOL,
'var/log/osm/cache.' . date(
'Ymd' ) .
'.log' );
38 if (!is_file(
$file) || filemtime(
$file)<time()-(86400*30) || filesize(
$file)==0)
44 $server[] =
'a.tile.openstreetmap.org';
45 $server[] =
'b.tile.openstreetmap.org';
46 $server[] =
'c.tile.openstreetmap.org';
48 $url =
'https://'.$server[array_rand($server)];
49 $url .=
"/".$z.
"/".
$x.
"/".
$y.
".png";
54 $server[] =
'a.tah.openstreetmap.org';
55 $server[] =
'b.tah.openstreetmap.org';
56 $server[] =
'c.tah.openstreetmap.org';
58 $url =
'https://'.$server[array_rand($server)].
'/Tiles/tile.php';
59 $url .=
"/".$z.
"/".
$x.
"/".
$y.
".png";
62 $ch = curl_init($url);
63 $fp = fopen(
$file,
"wb");
64 #1 curl_setopt($ch, CURLOPT_FILE, $fp); 65 #1 curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); 66 #1 curl_setopt($ch, CURLOPT_HEADER, 0); 67 #1 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 68 #1 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 69 #1 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); 70 #1 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 71 curl_setopt(
$ch, CURLOPT_VERBOSE, 1);
72 curl_setopt(
$ch, CURLOPT_RETURNTRANSFER, 1);
73 #curl_setopt($ch, CURLOPT_AUTOREFERER, false); 74 #curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); 75 #curl_setopt($ch, CURLOPT_HEADER, 0); 76 curl_setopt(
$ch, CURLOPT_SSL_VERIFYPEER, 0);
77 curl_setopt(
$ch, CURLOPT_SSL_VERIFYHOST, 0);
78 curl_setopt(
$ch, CURLOPT_USERAGENT,
'GlisWeb/2020.1 contact produzione@istricesrl.it');
80 if(
$e ===
false ) {
appendToFile(
'errore: ' . curl_error(
$ch ) . PHP_EOL,
'var/log/osm/cache.' . date(
'Ymd' ) .
'.log' ); }
85 appendToFile(
'url chiamato: ' . $url . PHP_EOL,
'var/log/osm/cache.' . date(
'Ymd' ) .
'.log' );
91 #error_reporting(E_ALL); 96 # header("Cache-Control: pre-check=" . $ttl * 60, FALSE); 97 # header ('Content-Type: image/png'); 98 # header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); 100 # header('Content-Length: ' . filesize($file)); 106 #$handle = fopen($file, "rb"); 107 #$contents = fread($handle, filesize($file)); 115 header(
'Last-Modified: ' .
$mod_gmt);
116 header(
'Cache-Control: public, max-age=' .
$ttl * 60);
117 header(
'Content-Type: image/png');
118 #header('Content-Length: ' . filesize($file) ); 124 #$im = imagecreatefromjpeg($file); 125 #header('Content-Type: image/jpeg');
if(!is_file($file)||filemtime($file)< time() -(86400 *30)||filesize($file)==0 $exp_gmt)