| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - UploadImage-plugin for htmlArea * 4 * http://www.eGroupWare.org * 5 * Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> * 6 * Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> * 7 * -------------------------------------------- * 8 * This program is free software; you can redistribute it and/or modify it * 9 * under the terms of the GNU General Public License as published by the * 10 * Free Software Foundation; version 2 of the License. * 11 * -------------------------------------------- * 12 * Title.........: Thumbnail generator, with cache. * 13 * Version.......: 1.01 * 14 * Author........: Xiang Wei ZHUO <wei@zhuo.org> * 15 * Notes.........: Configuration in config.inc.php * 16 * * 17 * Functions * 18 * - if the thumbnail does not exists or the source file is newer, create a * 19 * new thumbnail. * 20 \**************************************************************************/ 21 22 /* $id */ 23 24 require_once 'config.inc.php'; 25 require_once 'std_functions.inc.php'; 26 require_once '../ImageEditor/Transform.php'; 27 28 $img = $BASE_DIR.urldecode($_GET['img']); 29 30 if(is_file($img)) { 31 make_thumbs(urldecode($_GET['img'])); 32 } 33 34 function make_thumbs($img) 35 { 36 global $BASE_DIR, $BASE_URL; 37 38 $path_info = pathinfo($img); 39 $path = $path_info['dirname']."/"; 40 $img_file = $path_info['basename']; 41 42 $thumb = $path.'.'.$img_file; 43 44 $img_info = getimagesize($BASE_DIR.$path.$img_file); 45 $w = $img_info[0]; $h = $img_info[1]; 46 47 $nw = 96; $nh = 96; 48 49 if($w <= $nw && $h <= $nh) { 50 header('Location: '.$BASE_URL.$path.$img_file); 51 exit(); 52 } 53 54 if(is_file($BASE_DIR.$thumb)) { 55 56 $t_mtime = filemtime($BASE_DIR.$thumb); 57 $o_mtime = filemtime($BASE_DIR.$img); 58 59 if($t_mtime > $o_mtime) { 60 //echo $BASE_URL.$path.'.'.$img_file; 61 header('Location: '.$BASE_URL.$path.'.'.$img_file); 62 exit(); 63 } 64 } 65 66 $img_thumbs = Image_Transform::factory(IMAGE_CLASS); 67 $img_thumbs->load($BASE_DIR.$path.$img_file); 68 69 if ($w > $h) 70 $nh = unpercent(percent($nw, $w), $h); 71 else if ($h > $w) 72 $nw = unpercent(percent($nh, $h), $w); 73 74 $img_thumbs->resize($nw, $nh); 75 76 $img_thumbs->save($BASE_DIR.$thumb); 77 $img_thumbs->free(); 78 79 chmod($BASE_DIR.$thumb, 0666); 80 81 if(is_file($BASE_DIR.$thumb)) { 82 header('Location: '.$BASE_URL.$path.'.'.$img_file); 83 exit(); 84 } 85 } 86 87 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |