diff --git a/upload/admin/admin_attach_cp.php b/upload/admin/admin_attach_cp.php index 10fed9d8b..05eab88f3 100644 --- a/upload/admin/admin_attach_cp.php +++ b/upload/admin/admin_attach_cp.php @@ -263,18 +263,7 @@ if ($view == 'stats') { $upload_dir_size = get_formatted_dirsize(); - if ($attach_config['attachment_quota'] >= 1048576) - { - $attachment_quota = round($attach_config['attachment_quota'] / 1048576 * 100) / 100 . ' ' . $lang['MB']; - } - else if ($attach_config['attachment_quota'] >= 1024) - { - $attachment_quota = round($attach_config['attachment_quota'] / 1024 * 100) / 100 . ' ' . $lang['KB']; - } - else - { - $attachment_quota = $attach_config['attachment_quota'] . ' ' . $lang['BYTES']; - } + $attachment_quota = humn_size($attach_config['attachment_quota']); // number_of_attachments $row = DB()->fetch_row(" diff --git a/upload/admin/index.php b/upload/admin/index.php index 39944bd9e..7f4953c17 100644 --- a/upload/admin/index.php +++ b/upload/admin/index.php @@ -91,19 +91,7 @@ else if( isset($_GET['pane']) && $_GET['pane'] == 'right' ) @closedir($avatar_dir); - if($avatar_dir_size >= 1048576) - { - $avatar_dir_size = round($avatar_dir_size / 1048576 * 100) / 100 .' '. $lang['MB']; - } - else if($avatar_dir_size >= 1024) - { - $avatar_dir_size = round($avatar_dir_size / 1024 * 100) / 100 .' '. $lang['KB']; - } - else - { - $avatar_dir_size = $avatar_dir_size .' '. $lang['BYTES']; - } - + $avatar_dir_size = humn_size($avatar_dir_size); } else { diff --git a/upload/attach_mod/displaying.php b/upload/attach_mod/displaying.php index ed7974129..15746500a 100644 --- a/upload/attach_mod/displaying.php +++ b/upload/attach_mod/displaying.php @@ -217,16 +217,7 @@ function display_attachments($post_id) $upload_image = ''; } - $filesize = $attachments['_' . $post_id][$i]['filesize']; - $size_lang = ($filesize >= 1048576) ? $lang['MB'] : ( ($filesize >= 1024) ? $lang['KB'] : $lang['BYTES'] ); - if ($filesize >= 1048576) - { - $filesize = (round((round($filesize / 1048576 * 100) / 100), 2)); - } - else if ($filesize >= 1024) - { - $filesize = (round((round($filesize / 1024 * 100) / 100), 2)); - } + $filesize = humn_size($attachments['_' . $post_id][$i]['filesize']); $display_name = htmlspecialchars($attachments['_' . $post_id][$i]['real_filename']); $comment = htmlspecialchars($attachments['_' . $post_id][$i]['comment']); @@ -333,7 +324,6 @@ function display_attachments($post_id) 'IMG_SRC' => $img_source, 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, )); @@ -384,7 +374,6 @@ function display_attachments($post_id) 'IMG_SRC' => append_sid(BB_ROOT . 'download.php?id=' . $attachments['_' . $post_id][$i]['attach_id']), 'IMG_THUMB_SRC' => $thumb_source, 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, )); } @@ -398,7 +387,6 @@ function display_attachments($post_id) 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count'])) ); @@ -425,7 +413,6 @@ function display_attachments($post_id) 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'DOWNLOAD_COUNT' => sprintf($lang['DOWNLOAD_NUMBER'], $attachments['_' . $post_id][$i]['download_count']), 'WIDTH' => $width, @@ -460,7 +447,6 @@ function display_attachments($post_id) 'DOWNLOAD_NAME' => $display_name, 'FILESIZE' => $filesize, - 'SIZE_VAR' => $size_lang, 'COMMENT' => $comment, 'TARGET_BLANK' => $target_blank, diff --git a/upload/attach_mod/includes/functions_admin.php b/upload/attach_mod/includes/functions_admin.php index 55ceb5cee..3922ccc67 100644 --- a/upload/attach_mod/includes/functions_admin.php +++ b/upload/attach_mod/includes/functions_admin.php @@ -224,20 +224,7 @@ function get_formatted_dirsize() @ftp_quit($conn_id); } - if ($upload_dir_size >= 1048576) - { - $upload_dir_size = round($upload_dir_size / 1048576 * 100) / 100 . ' ' . $lang['MB']; - } - else if ($upload_dir_size >= 1024) - { - $upload_dir_size = round($upload_dir_size / 1024 * 100) / 100 . ' ' . $lang['KB']; - } - else - { - $upload_dir_size = $upload_dir_size . ' ' . $lang['BYTES']; - } - - return $upload_dir_size; + return humn_size($upload_dir_size); } /* diff --git a/upload/attach_mod/posting_attachments.php b/upload/attach_mod/posting_attachments.php index 5749a6d18..9532d189f 100644 --- a/upload/attach_mod/posting_attachments.php +++ b/upload/attach_mod/posting_attachments.php @@ -1103,23 +1103,14 @@ class attach_parent // check Filesize if (!$error && $allowed_filesize != 0 && $this->filesize > $allowed_filesize && !(IS_ADMIN || IS_MOD || IS_GROUP_MEMBER)) { - $size_lang = ($allowed_filesize >= 1048576) ? $lang['MB'] : ( ($allowed_filesize >= 1024) ? $lang['KB'] : $lang['BYTES'] ); - - if ($allowed_filesize >= 1048576) - { - $allowed_filesize = round($allowed_filesize / 1048576 * 100) / 100; - } - else if($allowed_filesize >= 1024) - { - $allowed_filesize = round($allowed_filesize / 1024 * 100) / 100; - } + $allowed_filesize = humn_size($allowed_filesize); $error = TRUE; if(!empty($error_msg)) { $error_msg .= '
'; } - $error_msg .= sprintf($lang['ATTACHMENT_TOO_BIG'], $allowed_filesize, $size_lang); + $error_msg .= sprintf($lang['ATTACHMENT_TOO_BIG'], $allowed_filesize); } // Check our complete quota diff --git a/upload/config.php b/upload/config.php index 998d9e90b..e31115f46 100644 --- a/upload/config.php +++ b/upload/config.php @@ -63,7 +63,7 @@ $bb_cfg = $tr_cfg = $page_cfg = array(); // Increase number of revision after update $bb_cfg['tp_version'] = '2.4 (beta)'; -$bb_cfg['tp_release_state'] = 'R349'; +$bb_cfg['tp_release_state'] = 'R350'; $bb_cfg['tp_release_date'] = '02-02-2012'; // Database diff --git a/upload/language/lang_english/lang_main.php b/upload/language/lang_english/lang_main.php index ce3d8681e..f634f29ea 100644 --- a/upload/language/lang_english/lang_main.php +++ b/upload/language/lang_english/lang_main.php @@ -1108,7 +1108,7 @@ $lang['ATTACHMENT_PHP_SIZE_NA'] = 'The Attachment is too big.
Couldn\'t get $lang['ATTACHMENT_PHP_SIZE_OVERRUN'] = 'The Attachment is too big.
Maximum Upload Size: %d MB.
Please note that this Size is defined in php.ini, this means it\'s set by PHP and the Attachment Mod can not override this value.'; // replace %d with ini_get('upload_max_filesize') $lang['DISALLOWED_EXTENSION'] = 'The Extension %s is not allowed'; // replace %s with extension (e.g. .php) $lang['DISALLOWED_EXTENSION_WITHIN_FORUM'] = 'You are not allowed to post Files with the Extension %s within this Forum'; // replace %s with the Extension -$lang['ATTACHMENT_TOO_BIG'] = 'The Attachment is too big.
Max Size: %d %s'; // replace %d with maximum file size, %s with size var +$lang['ATTACHMENT_TOO_BIG'] = 'The Attachment is too big.
Max Size: %d'; // replace %d with maximum file size, %s with size var $lang['ATTACH_QUOTA_REACHED'] = 'Sorry, but the maximum filesize for all Attachments is reached. Please contact the Board Administrator if you have questions.'; $lang['TOO_MANY_ATTACHMENTS'] = 'Attachment cannot be added, since the max. number of %d Attachments in this post was achieved'; // replace %d with maximum number of attachments $lang['ERROR_IMAGESIZE'] = 'The Attachment/Image must be less than %d pixels wide and %d pixels high'; diff --git a/upload/language/lang_russian/lang_main.php b/upload/language/lang_russian/lang_main.php index 005cf586e..5e711afd0 100644 --- a/upload/language/lang_russian/lang_main.php +++ b/upload/language/lang_russian/lang_main.php @@ -1115,7 +1115,7 @@ $lang['ATTACHMENT_PHP_SIZE_NA'] = 'Вложение слишком велико. $lang['ATTACHMENT_PHP_SIZE_OVERRUN'] = 'Вложение слишком велико.
Максимальный размер закачиваемого файла: %d MB.
Отметьте, что эта величина определена в php.ini и Attachment Mod не может изменить это значение в большую сторону.'; // replace %d with ini_get('upload_max_filesize') $lang['DISALLOWED_EXTENSION'] = 'Расширение %s запрещено администратором'; // replace %s with extension (e.g. .php) $lang['DISALLOWED_EXTENSION_WITHIN_FORUM'] = 'Вы не можете публиковать файлы с расширением %s в этом форуме'; // replace %s with the Extension -$lang['ATTACHMENT_TOO_BIG'] = 'Вложение слишком велико.
Максимальный размер: %d %s'; // replace %d with maximum file size, %s with size var +$lang['ATTACHMENT_TOO_BIG'] = 'Вложение слишком велико.
Максимальный размер: %d'; // replace %d with maximum file size, %s with size var $lang['ATTACH_QUOTA_REACHED'] = 'Достигнут максимальный общий размер ваших вложений. Пожалуйста, обратитесь к администратору по этому вопросу.'; $lang['TOO_MANY_ATTACHMENTS'] = 'Вложение невозможно, так как максимальное количество (%d) вложений в этом сообщении достигнуто.'; // replace %d with maximum number of attachments $lang['ERROR_IMAGESIZE'] = 'Изображение должно быть меньше, чем %d пикселей в ширину и %d пикселей в высоту.'; diff --git a/upload/misc.php b/upload/misc.php index 8ef20c2d6..a5b0b1e9c 100644 --- a/upload/misc.php +++ b/upload/misc.php @@ -55,18 +55,8 @@ if ($do == 'attach_rules') $group_name = $rows[$i]['group_name']; $f_size = intval(trim($rows[$i]['max_filesize'])); $det_filesize = (!$f_size) ? $_max_filesize : $f_size; - $size_lang = ($det_filesize >= 1048576) ? $lang['MB'] : (($det_filesize >= 1024) ? $lang['KB'] : $lang['BYTES']); - if ($det_filesize >= 1048576) - { - $det_filesize = round($det_filesize / 1048576 * 100) / 100; - } - else if($det_filesize >= 1024) - { - $det_filesize = round($det_filesize / 1024 * 100) / 100; - } - - $max_filesize = ($det_filesize == 0) ? $lang['UNLIMITED'] : $det_filesize . ' ' . $size_lang; + $max_filesize = (!$det_filesize) ? $lang['UNLIMITED'] : humn_size($det_filesize); $template->assign_block_vars('group_row', array( 'GROUP_RULE_HEADER' => sprintf($lang['GROUP_RULE_HEADER'], $group_name, $max_filesize)) diff --git a/upload/templates/default/viewtopic_attach.tpl b/upload/templates/default/viewtopic_attach.tpl index 48d7ff3e0..d43eaa12d 100644 --- a/upload/templates/default/viewtopic_attach.tpl +++ b/upload/templates/default/viewtopic_attach.tpl @@ -29,7 +29,7 @@  {L_FILESIZE}: -  {postrow.attach.cat_stream.FILESIZE} {postrow.attach.cat_stream.SIZE_VAR} +  {postrow.attach.cat_stream.FILESIZE}  {L_VIEWED}: @@ -73,7 +73,7 @@  {L_FILESIZE}: -  {postrow.attach.cat_swf.FILESIZE} {postrow.attach.cat_swf.SIZE_VAR} +  {postrow.attach.cat_swf.FILESIZE}  {L_VIEWED}: @@ -98,7 +98,7 @@
-{ATTACHMENT_ICON} {L_ATTACHMENT} ({postrow.attach.cat_images.FILESIZE} {postrow.attach.cat_images.SIZE_VAR}) +{ATTACHMENT_ICON} {L_ATTACHMENT} ({postrow.attach.cat_images.FILESIZE})

img

@@ -120,7 +120,7 @@

@@ -137,7 +137,7 @@ {postrow.attach.attachrow.S_UPLOAD_IMAGE} {L_ATTACHMENT}