Changeset 29124 for trunk/admin/include/functions_upload.inc.php
- Timestamp:
- Jul 30, 2014, 3:48:35 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r28714 r29124 220 220 221 221 list($width, $height, $type) = getimagesize($source_filepath); 222 222 223 if (IMAGETYPE_PNG == $type) 223 224 { … … 233 234 $file_path.= 'tif'; 234 235 } 236 elseif (IMAGETYPE_JPEG == $type) 237 { 238 $file_path.= 'jpg'; 239 } 240 elseif (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) 241 { 242 $original_extension = strtolower(get_extension($original_filename)); 243 244 if (in_array($original_extension, $conf['file_ext'])) 245 { 246 $file_path.= $original_extension; 247 } 248 else 249 { 250 die('unexpected file type'); 251 } 252 } 235 253 else 236 254 { 237 $file_path.= 'jpg';255 die('forbidden file type'); 238 256 } 239 257 … … 295 313 } 296 314 315 // 316 // generate pwg_representative in case of video 317 // 318 $ffmpeg_video_exts = array( // extensions tested with FFmpeg 319 'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg', 320 'avi','rm', 321 ); 322 323 if (isset($original_extension) and in_array($original_extension, $ffmpeg_video_exts)) 324 { 325 $representative_file_path = dirname($file_path).'/pwg_representative/'; 326 $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; 327 328 $representative_ext = 'jpg'; 329 $representative_file_path.= $representative_ext; 330 331 prepare_directory(dirname($representative_file_path)); 332 333 $second = 1; 334 335 $ffmpeg = $conf['ffmpeg_dir'].'ffmpeg'; 336 $ffmpeg.= ' -i "'.$file_path.'"'; 337 $ffmpeg.= ' -an -ss '.$second; 338 $ffmpeg.= ' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg'; 339 $ffmpeg.= ' "'.$representative_file_path.'"'; 340 341 // file_put_contents('/tmp/ffmpeg.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.$ffmpeg."\n", FILE_APPEND); 342 343 @exec($ffmpeg); 344 345 if (!file_exists($representative_file_path)) 346 { 347 $representative_ext = null; 348 } 349 } 350 351 if (isset($original_extension) and 'pdf' == $original_extension and pwg_image::get_library() == 'ext_imagick') 352 { 353 $representative_file_path = dirname($file_path).'/pwg_representative/'; 354 $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; 355 356 $representative_ext = 'jpg'; 357 $representative_file_path.= $representative_ext; 358 359 prepare_directory(dirname($representative_file_path)); 360 361 $exec = $conf['ext_imagick_dir'].'convert'; 362 $exec.= ' -quality 98'; 363 $exec.= ' "'.realpath($file_path).'"[0]'; 364 365 $dest = pathinfo($representative_file_path); 366 $exec.= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; 367 $exec.= ' 2>&1'; 368 @exec($exec, $returnarray); 369 } 370 297 371 if (pwg_image::get_library() != 'gd') 298 372 { … … 477 551 function is_valid_image_extension($extension) 478 552 { 479 return in_array(strtolower($extension), array('jpg', 'jpeg', 'png', 'gif')); 553 global $conf; 554 555 if (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) 556 { 557 $extensions = $conf['file_ext']; 558 } 559 else 560 { 561 $extensions = $conf['picture_ext']; 562 } 563 564 return array_unique(array_map('strtolower', $extensions)); 480 565 } 481 566
Note: See TracChangeset
for help on using the changeset viewer.