Changeset 12908 for trunk/i.php
- Timestamp:
- Jan 17, 2012, 7:09:32 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/i.php
r12865 r12908 29 29 defined('PWG_DERIVATIVE_DIR') or define('PWG_DERIVATIVE_DIR', $conf['data_location'].'i/'); 30 30 31 function get_moment() 32 { 33 $t1 = explode( ' ', microtime() ); 34 $t2 = explode( '.', $t1[0] ); 35 $t2 = $t1[1].'.'.$t2[1]; 36 return $t2; 37 } 31 38 function trigger_action() {} 32 39 function get_extension( $filename ) … … 64 71 // end fast bootstrap 65 72 73 function ilog() 74 { 75 global $conf, $ilogfh; 76 if (!$conf['enable_i_log']) return; 77 if(!$ilogfh) 78 { 79 $dir=PHPWG_ROOT_PATH.$conf['data_location'].'tmp/'; 80 if (!mkgetdir($dir) or ! ($ilogfh=fopen($dir.'i.log', 'a')) ) 81 return; 82 } 83 fwrite($ilogfh, date("c") ); 84 foreach( func_get_args() as $arg) 85 { 86 fwrite($ilogfh, ' ' ); 87 if (is_array($arg)) 88 { 89 fwrite($ilogfh, implode(' ', $arg) ); 90 } 91 else 92 { 93 fwrite($ilogfh, $arg); 94 } 95 } 96 fwrite($ilogfh, "\n"); 97 } 66 98 67 99 function ierror($msg, $code) … … 93 125 } 94 126 127 function time_step( &$step ) 128 { 129 $tmp = $step; 130 $step = get_moment(); 131 return intval(1000*($step - $tmp)); 132 } 95 133 96 134 function parse_request() … … 160 198 } 161 199 array_shift($deriv); 162 163 200 $page['coi'] = ''; 164 201 if (count($deriv) && $deriv[0][0]=='c' && $deriv[0][1]=='i') 165 202 { 166 203 $page['coi'] = substr(array_shift($deriv), 2); 167 preg_match('#^[a-z ]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400);204 preg_match('#^[a-zA-Z]{4}$#', $page['coi']) or ierror('Invalid center of interest', 400); 168 205 } 169 206 … … 188 225 } 189 226 190 if ($req[0]!='g' && $req[0]!='u') 227 if (!is_file(PHPWG_ROOT_PATH.$req.$ext) and 228 is_file(PHPWG_ROOT_PATH.'../'.$req.$ext) ) 191 229 $req = '../'.$req; 192 230 … … 226 264 227 265 $page=array(); 266 $begin = $step = get_moment(); 267 $timing=array(); 268 foreach( explode(',','load,rotate,crop,scale,sharpen,watermark,save,send') as $k ) 269 { 270 $timing[$k] = ''; 271 } 228 272 229 273 include_once( PHPWG_ROOT_PATH .'/include/derivative_params.inc.php'); … … 288 332 289 333 $image = new pwg_image($page['src_path']); 334 $timing['load'] = time_step($step); 290 335 291 336 $changes = 0; … … 300 345 $changes++; 301 346 $image->crop( $crop_rect->width(), $crop_rect->height(), $crop_rect->l, $crop_rect->t); 347 $timing['crop'] = time_step($step); 302 348 } 303 349 … … 307 353 $image->resize( $scaled_size[0], $scaled_size[1] ); 308 354 $d_size = $scaled_size; 355 $timing['scale'] = time_step($step); 309 356 } 310 357 … … 312 359 { 313 360 $changes += $image->sharpen( $params->sharpen ); 361 $timing['sharpen'] = time_step($step); 314 362 } 315 363 … … 346 394 } 347 395 $wm_image->destroy(); 396 $timing['watermark'] = time_step($step); 348 397 } 349 398 … … 358 407 $image->write( $page['derivative_path'] ); 359 408 $image->destroy(); 409 $timing['save'] = time_step($step); 360 410 361 411 send_derivative($expires); 412 $timing['send'] = time_step($step); 413 414 ilog('perf', 415 basename($page['src_path']), $o_size, $o_size[0]*$o_size[1], 416 basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1], 417 time_step($begin), 418 $timing); 362 419 ?>
Note: See TracChangeset
for help on using the changeset viewer.