Changeset 12917 for trunk/admin/include/functions_upload.inc.php
- Timestamp:
- Jan 17, 2012, 10:02:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r12907 r12917 3 3 // | Piwigo - a PHP based photo gallery | 4 4 // +-----------------------------------------------------------------------+ 5 // | Copyright(C) 2008-201 1Piwigo Team http://piwigo.org |5 // | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org | 6 6 // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | 7 7 // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | … … 37 37 'can_be_null' => false, 38 38 ), 39 39 40 40 'original_resize_maxwidth' => array( 41 41 'default' => 2000, … … 46 46 'error_message' => l10n('The original maximum width must be a number between %d and %d'), 47 47 ), 48 48 49 49 'original_resize_maxheight' => array( 50 50 'default' => 2000, … … 55 55 'error_message' => l10n('The original maximum height must be a number between %d and %d'), 56 56 ), 57 57 58 58 'original_resize_quality' => array( 59 59 'default' => 95, … … 113 113 $max = $upload_form_config[$field]['max']; 114 114 $pattern = $upload_form_config[$field]['pattern']; 115 115 116 116 if (preg_match($pattern, $value) and $value >= $min and $value <= $max) 117 117 { … … 158 158 // 159 159 // 3) register in database 160 160 161 161 // TODO 162 162 // * check md5sum (already exists?) 163 163 164 164 global $conf, $user; 165 165 … … 172 172 $md5sum = md5_file($source_filepath); 173 173 } 174 174 175 175 $file_path = null; 176 176 177 177 if (isset($image_id)) 178 178 { … … 189 189 $file_path = $row['path']; 190 190 } 191 191 192 192 if (!isset($file_path)) 193 193 { … … 201 201 { 202 202 // this photo is new 203 203 204 204 // current date 205 205 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); 206 206 list($year, $month, $day) = preg_split('/[^\d]/', $dbnow, 4); 207 207 208 208 // upload directory hierarchy 209 209 $upload_dir = sprintf( … … 251 251 { 252 252 $need_resize = need_resize($file_path, $conf['original_resize_maxwidth'], $conf['original_resize_maxheight']); 253 253 254 254 if ($need_resize) 255 255 { 256 256 $img = new pwg_image($file_path); 257 257 258 258 $img->pwg_resize( 259 259 $file_path, … … 264 264 false 265 265 ); 266 266 267 267 $img->destroy(); 268 268 } … … 271 271 272 272 $file_infos = pwg_image_infos($file_path); 273 273 274 274 if (isset($image_id)) 275 275 { … … 282 282 'added_by' => $user['id'], 283 283 ); 284 284 285 285 if (isset($level)) 286 286 { … … 293 293 array('id' => $image_id) 294 294 ); 295 296 delete_element_derivatives($image_id);297 295 } 298 296 else … … 309 307 'added_by' => $user['id'], 310 308 ); 311 309 312 310 if (isset($level)) 313 311 { … … 316 314 317 315 single_insert(IMAGES_TABLE, $insert); 318 316 319 317 $image_id = pwg_db_insert_id(IMAGES_TABLE); 320 318 } … … 327 325 ); 328 326 } 329 327 330 328 // update metadata from the uploaded file (exif/iptc) 331 329 if ($conf['use_exif'] and !function_exists('read_exif_data')) … … 375 373 // invert width and height. 376 374 list($width, $height) = getimagesize($image_filepath); 377 375 378 376 if ($width > $max_width or $height > $max_height) 379 377 { … … 388 386 list($width, $height) = getimagesize($path); 389 387 $filesize = floor(filesize($path)/1024); 390 388 391 389 return array( 392 390 'width' => $width, … … 434 432 $size = convert_shorthand_notation_to_bytes($size); 435 433 } 436 434 437 435 return $size; 438 436 } … … 442 440 $suffix = substr($value, -1); 443 441 $multiply_by = null; 444 442 445 443 if ('K' == $suffix) 446 444 { … … 455 453 $multiply_by = 1024*1024*1024; 456 454 } 457 455 458 456 if (isset($multiply_by)) 459 457 { … … 500 498 { 501 499 @chmod($conf['upload_dir'], 0777); 502 500 503 501 if (!is_writable($conf['upload_dir'])) 504 502 {
Note: See TracChangeset
for help on using the changeset viewer.