- Timestamp:
- Jun 29, 2010, 8:42:11 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r6622 r6625 300 300 return in_array(strtolower($extension), array('jpg', 'jpeg', 'png')); 301 301 } 302 303 function file_upload_error_message($error_code) 304 { 305 switch ($error_code) { 306 case UPLOAD_ERR_INI_SIZE: 307 return sprintf( 308 l10n('The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'), 309 get_ini_size('upload_max_filesize', false) 310 ); 311 case UPLOAD_ERR_FORM_SIZE: 312 return l10n('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'); 313 case UPLOAD_ERR_PARTIAL: 314 return l10n('The uploaded file was only partially uploaded'); 315 case UPLOAD_ERR_NO_FILE: 316 return l10n('No file was uploaded'); 317 case UPLOAD_ERR_NO_TMP_DIR: 318 return l10n('Missing a temporary folder'); 319 case UPLOAD_ERR_CANT_WRITE: 320 return l10n('Failed to write file to disk'); 321 case UPLOAD_ERR_EXTENSION: 322 return l10n('File upload stopped by extension'); 323 default: 324 return l10n('Unknown upload error'); 325 } 326 } 327 328 function get_ini_size($ini_key, $in_bytes=true) 329 { 330 $size = ini_get($ini_key); 331 332 if ($in_bytes) 333 { 334 $size = convert_shortand_notation_to_bytes($size); 335 } 336 337 return $size; 338 } 339 340 function convert_shortand_notation_to_bytes($value) 341 { 342 $suffix = substr($value, -1); 343 $multiply_by = null; 344 345 if ('K' == $suffix) 346 { 347 $multiply_by = 1024; 348 } 349 else if ('M' == $suffix) 350 { 351 $multiply_by = 1024*1024; 352 } 353 else if ('G' == $suffix) 354 { 355 $multiply_by = 1024*1024*1024; 356 } 357 358 if (isset($multiply_by)) 359 { 360 $value = substr($value, 0, -1); 361 $value*= $multiply_by; 362 } 363 364 return $value; 365 } 366 367 function add_upload_error($upload_id, $error_message) 368 { 369 if (!isset($_SESSION['uploads_error'])) 370 { 371 $_SESSION['uploads_error'] = array(); 372 } 373 if (!isset($_SESSION['uploads_error'][$upload_id])) 374 { 375 $_SESSION['uploads_error'][$upload_id] = array(); 376 } 377 378 array_push($_SESSION['uploads_error'][$upload_id], $error_message); 379 } 302 380 ?> -
trunk/admin/include/uploadify/uploadify.php
r6054 r6625 12 12 13 13 ob_start(); 14 echo '$_FILES'."\n"; 14 15 print_r($_FILES); 16 echo '$_POST'."\n"; 15 17 print_r($_POST); 18 echo '$user'."\n"; 16 19 print_r($user); 17 20 $tmp = ob_get_contents(); 18 21 ob_end_clean(); 19 22 // error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log"); 23 24 if ($_FILES['Filedata']['error'] !== UPLOAD_ERR_OK) 25 { 26 $error_message = file_upload_error_message($_FILES['Filedata']['error']); 27 28 add_upload_error( 29 $_POST['upload_id'], 30 sprintf( 31 l10n('Error on file "%s" : %s'), 32 $_FILES['Filedata']['name'], 33 $error_message 34 ) 35 ); 36 37 echo "File Size Error"; 38 exit(); 39 } 40 41 ob_start(); 20 42 21 43 $image_id = add_uploaded_file( … … 41 63 ); 42 64 65 $output = ob_get_contents(); 66 ob_end_clean(); 67 if (!empty($output)) 68 { 69 add_upload_error($_POST['upload_id'], $output); 70 } 71 43 72 echo "1"; 44 73 ?> -
trunk/admin/photos_add_direct.php
r6622 r6625 63 63 // +-----------------------------------------------------------------------+ 64 64 65 if (isset($_ POST['submit_upload']))65 if (isset($_GET['processed'])) 66 66 { 67 67 // echo '<pre>POST'."\n"; print_r($_POST); echo '</pre>'; … … 69 69 // echo '<pre>SESSION'."\n"; print_r($_SESSION); echo '</pre>'; 70 70 // exit(); 71 72 // sometimes, you have submitted the form but you have nothing in $_POST 73 // and $_FILES. This may happen when you have an HTML upload and you 74 // exceeded the post_max_size (but not the upload_max_size) 75 if (!isset($_POST['submit_upload'])) 76 { 77 array_push( 78 $page['errors'], 79 sprintf( 80 l10n('The uploaded files exceed the post_max_size directive in php.ini: %sB'), 81 ini_get('post_max_size') 82 ) 83 ); 84 } 71 85 72 86 $category_id = null; 73 if ('existing' == $_POST['category_type']) 87 if (!isset($_POST['category_type'])) 88 { 89 // nothing to do, we certainly have the post_max_size issue 90 } 91 elseif ('existing' == $_POST['category_type']) 74 92 { 75 93 $category_id = $_POST['category']; … … 194 212 } 195 213 } 214 else 215 { 216 $error_message = file_upload_error_message($error); 217 218 array_push( 219 $page['errors'], 220 sprintf( 221 l10n('Error on file "%s" : %s'), 222 $_FILES['image_upload']['name'][$idx], 223 $error_message 224 ) 225 ); 226 } 196 227 } 197 228 … … 205 236 { 206 237 // we're on a multiple upload, with uploadify and so on 207 $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ]; 208 209 associate_images_to_categories( 210 $image_ids, 211 array($category_id) 212 ); 213 214 $query = ' 238 if (isset($_SESSION['uploads_error'][ $_POST['upload_id'] ])) 239 { 240 foreach ($_SESSION['uploads_error'][ $_POST['upload_id'] ] as $error) 241 { 242 array_push($page['errors'], $error); 243 } 244 } 245 246 if (isset($_SESSION['uploads'][ $_POST['upload_id'] ])) 247 { 248 $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ]; 249 250 associate_images_to_categories( 251 $image_ids, 252 array($category_id) 253 ); 254 255 $query = ' 215 256 UPDATE '.IMAGES_TABLE.' 216 257 SET level = '.$_POST['level'].' 217 258 WHERE id IN ('.implode(', ', $image_ids).') 218 259 ;'; 219 pwg_query($query);260 pwg_query($query); 220 261 221 invalidate_user_cache(); 262 invalidate_user_cache(); 263 } 222 264 } 223 265 … … 326 368 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, 327 369 'uploadify_path' => $uploadify_path, 370 'upload_max_filesize' => min( 371 get_ini_size('upload_max_filesize'), 372 get_ini_size('post_max_size') 373 ), 328 374 ) 329 375 ); … … 346 392 array( 347 393 'upload_mode' => $upload_mode, 394 'form_action' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode.'&processed=1', 348 395 'switch_url' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_switch, 349 396 'upload_id' => md5(rand()), 350 397 'session_id' => session_id(), 351 398 'pwg_token' => get_pwg_token(), 399 'another_upload_link' => PHOTOS_ADD_BASE_URL.'&upload_mode='.$upload_mode, 352 400 ) 353 401 ); … … 465 513 } 466 514 515 if (get_ini_size('upload_max_filesize') > get_ini_size('post_max_size')) 516 { 517 array_push( 518 $setup_warnings, 519 sprintf( 520 l10n('In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'), 521 get_ini_size('upload_max_filesize', false), 522 get_ini_size('post_max_size', false) 523 ) 524 ); 525 } 526 467 527 $template->assign( 468 528 array( -
trunk/admin/themes/default/template/photos_add_direct.tpl
r6622 r6625 50 50 } 51 51 52 function humanReadableFileSize(bytes) { 53 var byteSize = Math.round(bytes / 1024 * 100) * .01; 54 var suffix = 'KB'; 55 56 if (byteSize > 1000) { 57 byteSize = Math.round(byteSize *.001 * 100) * .01; 58 suffix = 'MB'; 59 } 60 61 var sizeParts = byteSize.toString().split('.'); 62 if (sizeParts.length > 1) { 63 byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2); 64 } 65 else { 66 byteSize = sizeParts[0]; 67 } 68 69 return byteSize+suffix; 70 } 71 52 72 if ($("select[name=category] option").length == 0) { 53 73 $('input[name=category_type][value=existing]').attr('disabled', true); … … 91 111 var pwg_token = '{$pwg_token}'; 92 112 var buttonText = 'Browse'; 113 var sizeLimit = {$upload_max_filesize}; 93 114 94 115 {literal} … … 109 130 'fileDesc' : 'Photo files (*.jpg,*.jpeg,*.png)', 110 131 'fileExt' : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG', 132 'sizeLimit' : sizeLimit, 111 133 'onAllComplete' : function(event, data) { 112 134 if (data.errors) { … … 119 141 onError: function (event, queueID ,fileObj, errorObj) { 120 142 var msg; 121 if (errorObj.status == 404) { 122 alert('Could not find upload script.'); 123 msg = 'Could not find upload script.'; 124 } 125 else if (errorObj.type === "HTTP") { 126 msg = errorObj.type+": "+errorObj.status; 143 144 if (errorObj.type === "HTTP") { 145 if (errorObj.info === 404) { 146 alert('Could not find upload script.'); 147 msg = 'Could not find upload script.'; 148 } 149 else { 150 msg = errorObj.type+": "+errorObj.info; 151 } 127 152 } 128 153 else if (errorObj.type ==="File Size") { 129 msg = fileObj.name+'<br>'+errorObj.type+' Limit: '+Math.round(errorObj.sizeLimit/1024)+'KB'; 154 msg = "File too big"; 155 msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size); 156 msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit); 130 157 } 131 158 else { 132 msg = errorObj.type+": "+errorObj. text;159 msg = errorObj.type+": "+errorObj.info; 133 160 } 134 161 … … 240 267 <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p> 241 268 </fieldset> 242 <p><a href=" ">{'Add another set of photos'|@translate}</a></p>269 <p><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p> 243 270 {else} 244 271 … … 251 278 </div> 252 279 253 <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$ F_ACTION}" class="properties">280 <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties"> 254 281 <fieldset> 255 282 <legend>{'Drop into category'|@translate}</legend> -
trunk/language/en_UK/admin.lang.php
r6419 r6625 758 758 $lang['This theme was not designed to be directly activated'] = 'This theme was not designed to be directly activated'; 759 759 $lang['Pending Comments'] = 'Pending Comments'; 760 $lang['In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'] = 'In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'; 761 $lang['Exif extension not available, admin should disable exif use'] = 'Exif extension not available, admin should disable exif use'; 762 $lang['The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'; 763 $lang['The uploaded files exceed the post_max_size directive in php.ini: %sB'] = 'The uploaded files exceed the post_max_size directive in php.ini: %sB'; 764 $lang['The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; 765 $lang['The uploaded file was only partially uploaded'] = 'The uploaded file was only partially uploaded'; 766 $lang['No file was uploaded'] = 'No file was uploaded'; 767 $lang['Missing a temporary folder'] = 'Missing a temporary folder'; 768 $lang['Failed to write file to disk'] = 'Failed to write file to disk'; 769 $lang['File upload stopped by extension'] = 'File upload stopped by extension'; 770 $lang['Unknown upload error'] = 'Unknown upload error'; 771 $lang['Error on file "%s" : %s'] = 'Error on file "%s" : %s'; 760 772 ?> -
trunk/language/fr_FR/admin.lang.php
r6421 r6625 763 763 $lang['This theme was not designed to be directly activated'] = 'Ce thème n\'est pas conçu pour être activé directement'; 764 764 $lang['Pending Comments'] = 'Commentaires en attente'; 765 $lang['In your php.ini file, the upload_max_filesize (%sB) is bigger than post_max_size (%sB), you should change this setting'] = 'Dans votre fichier php.ini, la variable upload_max_filesize (%sB) est plus grande que post_max_size (%sB), vous devriez modifier ce paramétrage'; 766 $lang['Exif extension not available, admin should disable exif use'] = 'L\'extension Exif n\'est pas disponible, un administrateur devrait désactiver l\'utilisation des métadonnées Exif'; 767 $lang['The uploaded file exceeds the upload_max_filesize directive in php.ini: %sB'] = 'Le poids du fichier transféré dépasse la valeur de upload_max_filesize définie dans votre fichier php.ini: %sB'; 768 $lang['The uploaded files exceed the post_max_size directive in php.ini: %sB'] = 'Le poids total des fichiers transférés dépasse la valeur de post_max_size dans votre fichier php.ini: %sB'; 769 $lang['The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'] = 'Le poids du fichier transféré dépasse la valeur de MAX_FILE_SIZE définie dans le formulaire HTML'; 770 $lang['The uploaded file was only partially uploaded'] = 'Le fichier n\é até que partiellement transféré'; 771 $lang['No file was uploaded'] = 'Aucun fichier n\'a été transféré'; 772 $lang['Missing a temporary folder'] = 'Impossible de trouver le répertoire temporaire'; 773 $lang['Failed to write file to disk'] = 'Échec à l\'écriture du fichier sur le serveur'; 774 $lang['File upload stopped by extension'] = 'Le transfert du fichier a été arrêté par une extension'; 775 $lang['Unknown upload error'] = 'Erreur inconnue survenue lors du transfert'; 776 $lang['Error on file "%s" : %s'] = 'Erreur sur le fichier "%s" : %s'; 765 777 ?>
Note: See TracChangeset
for help on using the changeset viewer.