00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00052
00053
00054
00055 error_reporting (E_ALL ^ E_NOTICE);
00056
00057
00058
00059
00060
00061 define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
00062 define('TYPO3_MODE','FE');
00063 define('PATH_thisScript',str_replace('
00064
00065 define('PATH_site', dirname(PATH_thisScript).'/');
00066 define('PATH_t3lib', PATH_site.'t3lib/');
00067 define('PATH_tslib', PATH_site.'tslib/');
00068 define('PATH_typo3conf', PATH_site.'typo3conf/');
00069 define('TYPO3_mainDir', 'typo3/');
00070
00071 require_once(PATH_t3lib.'class.t3lib_div.php');
00072 require_once(PATH_t3lib.'class.t3lib_extmgm.php');
00073
00074
00075
00076
00077 require_once(PATH_t3lib.'config_default.php');
00078 if (!defined ('TYPO3_db')) die ('The configuration file was not included.');
00079
00080 require_once(PATH_t3lib.'class.t3lib_db.php');
00081 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
00082
00083 require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
00084
00085
00086
00087
00088
00097 class SC_tslib_showpic {
00098 var $content;
00099
00100
00101 var $file;
00102 var $width;
00103 var $height;
00104 var $sample;
00105 var $alternativeTempPath;
00106 var $effects;
00107 var $frame;
00108 var $bodyTag;
00109 var $title;
00110 var $wrap;
00111 var $md5;
00112
00118 function init() {
00119
00120 $this->file = t3lib_div::_GP('file');
00121 $this->width = t3lib_div::_GP('width');
00122 $this->height = t3lib_div::_GP('height');
00123 $this->sample = t3lib_div::_GP('sample');
00124 $this->alternativeTempPath = t3lib_div::_GP('alternativeTempPath');
00125 $this->effects = t3lib_div::_GP('effects');
00126 $this->frame = t3lib_div::_GP('frame');
00127 $this->bodyTag = t3lib_div::_GP('bodyTag');
00128 $this->title = t3lib_div::_GP('title');
00129 $this->wrap = t3lib_div::_GP('wrap');
00130 $this->md5 = t3lib_div::_GP('md5');
00131
00132
00133
00134
00135
00136 if (!$this->file) {
00137 die('Parameter Error: No file given.');
00138 }
00139
00140
00141 $md5_value = md5($this->file.'|'.$this->width.'|'.$this->height.'|'.$this->effects.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
00142 if ($md5_value!=$this->md5) {
00143 die('Parameter Error: Wrong parameters sent.');
00144 }
00145
00146
00147
00148
00149
00150
00151 $test_file=PATH_site.$this->file;
00152 if (!t3lib_div::validPathStr($test_file)) {
00153 die('Parameter Error: No valid filepath');
00154 }
00155 if (!@is_file($test_file)) {
00156 die('The given file was not found');
00157 }
00158 }
00159
00166 function main() {
00167
00168
00169 $img = t3lib_div::makeInstance('t3lib_stdGraphic');
00170 $img->mayScaleUp = 0;
00171 $img->init();
00172 if ($this->sample) {$img->scalecmd = '-sample';}
00173 if ($this->alternativeTempPath && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'],$this->alternativeTempPath)) {
00174 $img->tempPath = $this->alternativeTempPath;
00175 }
00176
00177 #if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['enable_typo3temp_db_tracking']) {
00178
00179 $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password);
00180 #}
00181
00182 if (strstr($this->width.$this->height, 'm')) {$max='m';} else {$max='';}
00183
00184 $this->height = t3lib_div::intInRange($this->height,0,1000);
00185 $this->width = t3lib_div::intInRange($this->width,0,1000);
00186 if ($this->frame) {$this->frame = intval($this->frame);}
00187 $imgInfo = $img->imageMagickConvert($this->file,'web',$this->width.$max,$this->height,$img->IMparams($this->effects),$this->frame,'');
00188
00189
00190
00191 $this->content='';
00192 $this->content.='
00193 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
00194
00195 <html>
00196 <head>
00197 <title>'.htmlspecialchars($this->title ? $this->title : "Image").'</title>
00198 </head>
00199 '.($this->bodyTag ? $this->bodyTag : '<body>');
00200
00201 if (is_array($imgInfo)) {
00202 $wrapParts = explode('|',$this->wrap);
00203 $this->content.=trim($wrapParts[0]).$img->imgTag($imgInfo).trim($wrapParts[1]);
00204 }
00205 $this->content.='
00206 </body>
00207 </html>';
00208 }
00209
00215 function printContent() {
00216 echo $this->content;
00217 }
00218 }
00219
00220
00221 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/showpic.php']) {
00222 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/showpic.php']);
00223 }
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 $SOBE = t3lib_div::makeInstance('SC_tslib_showpic');
00238 $SOBE->init();
00239 $SOBE->main();
00240 $SOBE->printContent();
00241 ?>