127bbde00SAndreas Gohr<?php 227bbde00SAndreas Gohr/** 327bbde00SAndreas Gohr * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 427bbde00SAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 527bbde00SAndreas Gohr */ 627bbde00SAndreas Gohr 727bbde00SAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 827bbde00SAndreas Gohrdefine('DOKU_DISABLE_GZIP_OUTPUT', 1); 927bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/init.php'); 1027bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/common.php'); 1127bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/pageutils.php'); 1227bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/httputils.php'); 131faa1ff0SAndreas Gohrrequire_once(DOKU_INC.'inc/pluginutils.php'); 1427bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/auth.php'); 1527bbde00SAndreas Gohrsession_write_close(); 1627bbde00SAndreas Gohr 171faa1ff0SAndreas Gohr // load plugin 181faa1ff0SAndreas Gohr $pl =& plugin_load('syntax','panoview'); 191faa1ff0SAndreas Gohr 2027bbde00SAndreas Gohr $data = array(); 2127bbde00SAndreas Gohr // get parameters 2227bbde00SAndreas Gohr list($data['zoom'],$data['col'],$data['row']) = explode('-',$_GET['tile']); 2327bbde00SAndreas Gohr $data['id'] = cleanID($_GET['image']); 2427bbde00SAndreas Gohr $data['file'] = mediaFN($data['id']); 2527bbde00SAndreas Gohr $data['mtime'] = @filemtime($data['file']); 2627bbde00SAndreas Gohr 2727bbde00SAndreas Gohr // check auth and existance 2827bbde00SAndreas Gohr if(auth_quickaclcheck(getNS($data['id']).':X') < AUTH_READ) gfx_error('noauth'); 291faa1ff0SAndreas Gohr if(!$data['mtime']) $pl->gfx_error('notfound'); 3027bbde00SAndreas Gohr 3127bbde00SAndreas Gohr // calculate zoom level scaling 3227bbde00SAndreas Gohr $data['ts'] = 256; 3327bbde00SAndreas Gohr list($data['width'],$data['height']) = getimagesize($data['file']); 3427bbde00SAndreas Gohr $data['scale'] = (int)pow(2,$data['zoom']); 3527bbde00SAndreas Gohr $data['max'] = max($data['width'],$data['height']); 3627bbde00SAndreas Gohr $data['inv'] = $data['max'] / ($data['ts'] * $data['scale']); 37*359cb25cSAndreas Gohr 38*359cb25cSAndreas Gohr 39*359cb25cSAndreas Gohr if($data['inv'] < 0.5) $pl->gfx_error('maxzoom'); 40*359cb25cSAndreas Gohr if($data['inv'] < 1.0) $data['inv'] = 1.0; // original size, no upscaling 4127bbde00SAndreas Gohr 4227bbde00SAndreas Gohr // calculate tile boundaries 4327bbde00SAndreas Gohr $data['tlx'] = (int) ($data['col'] * $data['ts'] * $data['inv']); 4427bbde00SAndreas Gohr $data['tly'] = (int) ($data['row'] * $data['ts'] * $data['inv']); 4527bbde00SAndreas Gohr $data['brx'] = (int) ($data['tlx'] + ($data['ts'] * $data['inv'])); 4627bbde00SAndreas Gohr $data['bry'] = (int) ($data['tly'] + ($data['ts'] * $data['inv'])); 471faa1ff0SAndreas Gohr if($data['tlx'] > $data['width'] || $data['tly'] > $data['height']) $pl->gfx_error('blank'); 4827bbde00SAndreas Gohr 4927bbde00SAndreas Gohr // cache times 5027bbde00SAndreas Gohr $data['cache'] = getCacheName($data['file'],'.pv.'.$data['zoom'].'-'.$data['col'].'-'.$data['row'].'.jpg'); 5127bbde00SAndreas Gohr $data['cachet'] = @filemtime($data['cache']); 5227bbde00SAndreas Gohr 5327bbde00SAndreas Gohr // (re)generate 54c131b324SAndreas Gohr if($data['cachet'] < $data['mtime']){ 551faa1ff0SAndreas Gohr $pl->tile_lock($data); 56dc838624SAndreas Gohr if($conf['im_convert']){ 571faa1ff0SAndreas Gohr $pl->tile_im($data); 58dc838624SAndreas Gohr }else{ 591faa1ff0SAndreas Gohr $pl->tile_gd($data); 6027bbde00SAndreas Gohr } 611faa1ff0SAndreas Gohr $pl->tile_unlock($data); 62dc838624SAndreas Gohr } 6327bbde00SAndreas Gohr 6427bbde00SAndreas Gohr // send 6527bbde00SAndreas Gohr header('Content-type: image/jpeg'); 6627bbde00SAndreas Gohr http_conditionalRequest(max($data['mtime'],$data['selft'])); 6727bbde00SAndreas Gohr http_sendfile($data['cache']); 6827bbde00SAndreas Gohr readfile($data['cache']); 6927bbde00SAndreas Gohr 7027bbde00SAndreas Gohr 7127bbde00SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 72