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'); 13*1faa1ff0SAndreas Gohrrequire_once(DOKU_INC.'inc/pluginutils.php'); 1427bbde00SAndreas Gohrrequire_once(DOKU_INC.'inc/auth.php'); 1527bbde00SAndreas Gohrsession_write_close(); 1627bbde00SAndreas Gohr 17*1faa1ff0SAndreas Gohr // load plugin 18*1faa1ff0SAndreas Gohr $pl =& plugin_load('syntax','panoview'); 19*1faa1ff0SAndreas 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'); 29*1faa1ff0SAndreas 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*1faa1ff0SAndreas Gohr if($data['inv'] < 1.0) $pl->gfx_error('maxzoom'); 3827bbde00SAndreas Gohr 3927bbde00SAndreas Gohr // calculate tile boundaries 4027bbde00SAndreas Gohr $data['tlx'] = (int) ($data['col'] * $data['ts'] * $data['inv']); 4127bbde00SAndreas Gohr $data['tly'] = (int) ($data['row'] * $data['ts'] * $data['inv']); 4227bbde00SAndreas Gohr $data['brx'] = (int) ($data['tlx'] + ($data['ts'] * $data['inv'])); 4327bbde00SAndreas Gohr $data['bry'] = (int) ($data['tly'] + ($data['ts'] * $data['inv'])); 44*1faa1ff0SAndreas Gohr if($data['tlx'] > $data['width'] || $data['tly'] > $data['height']) $pl->gfx_error('blank'); 4527bbde00SAndreas Gohr 4627bbde00SAndreas Gohr // cache times 4727bbde00SAndreas Gohr $data['cache'] = getCacheName($data['file'],'.pv.'.$data['zoom'].'-'.$data['col'].'-'.$data['row'].'.jpg'); 4827bbde00SAndreas Gohr $data['cachet'] = @filemtime($data['cache']); 4927bbde00SAndreas Gohr 5027bbde00SAndreas Gohr // (re)generate 51c131b324SAndreas Gohr if($data['cachet'] < $data['mtime']){ 52*1faa1ff0SAndreas Gohr $pl->tile_lock($data); 53dc838624SAndreas Gohr if($conf['im_convert']){ 54*1faa1ff0SAndreas Gohr $pl->tile_im($data); 55dc838624SAndreas Gohr }else{ 56*1faa1ff0SAndreas Gohr $pl->tile_gd($data); 5727bbde00SAndreas Gohr } 58*1faa1ff0SAndreas Gohr $pl->tile_unlock($data); 59dc838624SAndreas Gohr } 6027bbde00SAndreas Gohr 6127bbde00SAndreas Gohr // send 6227bbde00SAndreas Gohr header('Content-type: image/jpeg'); 6327bbde00SAndreas Gohr http_conditionalRequest(max($data['mtime'],$data['selft'])); 6427bbde00SAndreas Gohr http_sendfile($data['cache']); 6527bbde00SAndreas Gohr readfile($data['cache']); 6627bbde00SAndreas Gohr 6727bbde00SAndreas Gohr 6827bbde00SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 69