[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] SF.net SVN: squirrelmail:[14861] trunk/squirrelmail
From: pdontthink--- via squirrelmail-cvs <squirrelmail-cvs () lists ! sourceforge ! net>
Date: 2020-05-23 19:29:27
Message-ID: 1590262167.563777.27112 () sfp-scm-1 ! v30 ! lw ! sourceforge ! com
[Download RAW message or body]
Revision: 14861
http://sourceforge.net/p/squirrelmail/code/14861
Author: pdontthink
Date: 2020-05-23 19:29:27 +0000 (Sat, 23 May 2020)
Log Message:
-----------
Uploaded file sizes seem to be reported differently by PHP filesize(); changing \
divisor from 1024 to 1000 in this case. You can set $upload_filesize_divisor in \
config/config_local.php to 1024 if this breaks things for you. Feedback appreciated \
for this one.
Modified Paths:
--------------
trunk/squirrelmail/config/config_local.example.php
trunk/squirrelmail/functions/strings.php
trunk/squirrelmail/functions/template/general_util.php
trunk/squirrelmail/src/compose.php
trunk/squirrelmail/templates/default/compose_attachments.tpl
Modified: trunk/squirrelmail/config/config_local.example.php
===================================================================
--- trunk/squirrelmail/config/config_local.example.php 2020-05-23 18:54:31 UTC (rev \
14860)
+++ trunk/squirrelmail/config/config_local.example.php 2020-05-23 19:29:27 UTC (rev \
14861) @@ -193,4 +193,11 @@
* traffic from a proxy so the normal $PHP_SELF does not resolve
* to what it should be for the real client.
*
+ * $upload_filesize_divisor allows the administrator to specify
+ * the divisor used when converting the size of an uploaded file
+ * as given by PHP's filesize() and converted to human-digestable
+ * form. By default, 1000 is used, but 1024 may be necessary in
+ * some environments.
+ * $upload_filesize_divisor = 1024;
+ *
*/
Modified: trunk/squirrelmail/functions/strings.php
===================================================================
--- trunk/squirrelmail/functions/strings.php 2020-05-23 18:54:31 UTC (rev 14860)
+++ trunk/squirrelmail/functions/strings.php 2020-05-23 19:29:27 UTC (rev 14861)
@@ -654,6 +654,7 @@
* a more easily digested (readable) format
*
* @param int $bytes the size in bytes
+ * @param int $filesize_divisor the divisor we'll use (OPTIONAL; default 1024)
*
* @return string The size in human readable format
*
@@ -660,12 +661,12 @@
* @since 1.0
*
*/
-function show_readable_size($bytes) {
- $bytes /= 1024;
+function show_readable_size($bytes, $filesize_divisor) {
+ $bytes /= $filesize_divisor;
$type = _("KiB");
- if ($bytes / 1024 > 1) {
- $bytes /= 1024;
+ if ($bytes / $filesize_divisor > 1) {
+ $bytes /= $filesize_divisor;
$type = _("MiB");
}
Modified: trunk/squirrelmail/functions/template/general_util.php
===================================================================
--- trunk/squirrelmail/functions/template/general_util.php 2020-05-23 18:54:31 UTC \
(rev 14860)
+++ trunk/squirrelmail/functions/template/general_util.php 2020-05-23 19:29:27 UTC \
(rev 14861) @@ -169,9 +169,10 @@
//FIXME: I think this is needless since there is no reason templates cannot just \
call directly to show_readable_size
*
* @param int size to be converted to human-readable
+ * @param int filesize_divisor the divisor we'll use (OPTIONAL; default 1024)
* @return string human-readable form
* @since 1.5.2
**/
-function humanReadableSize ($size) {
- return show_readable_size($size);
+function humanReadableSize ($size, $filesize_divisor=1024) {
+ return show_readable_size($size, $filesize_divisor);
}
Modified: trunk/squirrelmail/src/compose.php
===================================================================
--- trunk/squirrelmail/src/compose.php 2020-05-23 18:54:31 UTC (rev 14860)
+++ trunk/squirrelmail/src/compose.php 2020-05-23 19:29:27 UTC (rev 14861)
@@ -1484,7 +1484,9 @@
}
$attach = array();
- global $username, $attachment_dir;
+ global $username, $attachment_dir, $upload_filesize_divisor;
+ if (empty($upload_filesize_divisor))
+ $upload_filesize_divisor = 1000; // *not* 1024 -- does this break for \
some users?
$hashed_attachment_dir = getHashedDir($username, $attachment_dir);
if (!empty($attach_array)) {
foreach ($attach_array as $key => $attachment) {
@@ -1507,6 +1509,7 @@
$max = min($sizes);
$oTemplate->assign('max_file_size', empty($max) ? -1 : $max);
$oTemplate->assign('attachments', $attach);
+ $oTemplate->assign('upload_filesize_divisor', $upload_filesize_divisor);
// access keys...
//
Modified: trunk/squirrelmail/templates/default/compose_attachments.tpl
===================================================================
--- trunk/squirrelmail/templates/default/compose_attachments.tpl 2020-05-23 18:54:31 \
UTC (rev 14860)
+++ trunk/squirrelmail/templates/default/compose_attachments.tpl 2020-05-23 19:29:27 \
UTC (rev 14861) @@ -55,7 +55,7 @@
<input type="checkbox" name="delete[]" id="delete<?php echo $attachment_count; \
?>" accesskey="<?php echo ($attachment_count % 10); ?>" value="<?php echo \
$attach['Key']; ?>" /> </td>
<td class="fieldValue"><label for="delete<?php echo $attachment_count; ?>">
- <?php echo $attach['FileName']; ?> - <?php echo $attach['ContentType']; ?> (<?php \
echo humanReadableSize($attach['Size']); ?>) + <?php echo $attach['FileName']; ?> - \
<?php echo $attach['ContentType']; ?> (<?php echo humanReadableSize($attach['Size'], \
$upload_filesize_divisor); ?>) </label></td>
</tr>
<?php
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic