- Change to megs if over 1024 k
- if x < 10, show first digit after decimal point
Created new function (in strings.php) in case sizes should be shown elsewhere.
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@790
7612ce4b-ef26-0410-bec9-
ea0150e637f0
fputs ($imap_stream, "a003 FETCH $id RFC822.SIZE\r\n");
$read = sqimap_read_data($imap_stream, "a003", true, $r, $m);
preg_match("/([0-9]+)\)\s*$/i", $read[0], $regs);
- $size = $regs[1] / 1024;
- settype($size, "integer");
+ $size = $regs[1];
$header = new small_header;
if ($sent == true)
else echo " <td bgcolor=$hlt_color width=1%> </td>\n";
break;
case 6: # size
- echo " <td bgcolor=$hlt_color width=1%>$bold".$msg["SIZE"]."k$bold_end</td>\n";
+ echo " <td bgcolor=$hlt_color width=1%>$bold".show_readable_size($msg['SIZE'])."$bold_end</td>\n";
break;
}
}
$body .= '<TR><TD> </TD><TD>';
$body .= "<A HREF=\"$DefaultLink\">$display_filename</A> </TD>";
- $size = $message->header->size / 1024;
- settype($size, "integer");
- $body .= "<TD><SMALL><b>" . $size . "k</b> </small></TD>";
+ $body .= '<TD><SMALL><b>' . show_readable_size($message->header->size) .
+ '</b> </small></TD>';
$body .= "<TD><SMALL>[ $type0/$type1 ] </SMALL></TD>";
$body .= '<TD><SMALL>';
if ($message->header->description)
if (count($words) > 1) {
while ($i < count($words)) {
// Force one word to be on a line (minimum)
- $line .= $words[$i] . ' ';
+ $line .= $words[$i];
$line_len = strlen($beginning_spaces) + strlen($words[$i]) +
strlen($words[$i + 1]) + 2;
$i ++;
// Add more words (as long as they fit)
while ($line_len < $wrap && $i < count($words)) {
- $line .= $words[$i] . ' ';
+ $line .= ' ' . $words[$i];
$i++;
$line_len += strlen($words[$i]) + 1;
}
return true;
}
+
+ /* Returns a string showing the size of the message/attachment */
+ function show_readable_size($bytes)
+ {
+ $bytes /= 1024;
+ $type = 'k';
+
+ if ($bytes / 1024 > 1)
+ {
+ $bytes /= 1024;
+ $type = 'm';
+ }
+
+ if ($bytes < 10)
+ {
+ $bytes *= 10;
+ settype($bytes, "integer");
+ $bytes /= 10;
+ }
+ else
+ settype($bytes, "integer");
+
+ return $bytes . '<small> ' . $type . '</small>';
+ }
?>