]> git.mxchange.org Git - friendica.git/commitdiff
show maximagesize warning in a human readable format
authorrabuzarus <>
Mon, 29 Jun 2015 00:39:08 +0000 (02:39 +0200)
committerrabuzarus <>
Mon, 29 Jun 2015 00:39:08 +0000 (02:39 +0200)
include/Photo.php
mod/photos.php
mod/profile_photo.php
mod/wall_attach.php
mod/wall_upload.php

index e36fd46ca036b5e101f5d19dbf8353dfebd4a261..0adc55258bac8a0d2f2ce5eedf9d72105d72d3e4 100644 (file)
@@ -1013,3 +1013,15 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
 
        return($image);
 }
+
+function formatBytes($bytes, $precision = 2) { 
+        $units = array('B', 'KB', 'MB', 'GB', 'TB'); 
+
+       $bytes = max($bytes, 0); 
+       $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); 
+       $pow = min($pow, count($units) - 1); 
+
+       $bytes /= pow(1024, $pow);
+
+       return round($bytes, $precision) . ' ' . $units[$pow]; 
+} 
index ca770d95aac6fb1517e715dc8c25e1bcec190b25..3ed8e9984c315f0e20deb4a42ff5b04fcb637db4 100644 (file)
@@ -785,7 +785,7 @@ function photos_post(&$a) {
        $maximagesize = get_config('system','maximagesize');
 
        if(($maximagesize) && ($filesize > $maximagesize)) {
-               notice( t('Image exceeds size limit of ') . $maximagesize . EOL);
+               notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
                @unlink($src);
                $foo = 0;
                call_hooks('photo_post_end',$foo);
index 6ca7c4b6d4fbda6084c854d0b801897d30d5953e..6607eebd0c1e1685f8d312b37c3adf7d65278760 100644 (file)
@@ -141,7 +141,7 @@ function profile_photo_post(&$a) {
        $maximagesize = get_config('system','maximagesize');
 
        if(($maximagesize) && ($filesize > $maximagesize)) {
-               notice( sprintf(t('Image exceeds size limit of %d'), $maximagesize) . EOL);
+               notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
                @unlink($src);
                return;
        }
index 646a776a4ab6d73e7c6aeea3fb1728fc684fae10..80b679012c88caec7566f7cb9a1f946605c8c68c 100644 (file)
@@ -78,9 +78,9 @@ function wall_attach_post(&$a) {
        }
 
        if(($maxfilesize) && ($filesize > $maxfilesize)) {
-               notice( sprintf(t('File exceeds size limit of %d'), $maxfilesize) . EOL);
+               echo sprintf(t('File exceeds size limit of %s'), formatBytes($maxfilesize)) . EOL;
                @unlink($src);
-               return;
+               killme();
        }
 
        $r = q("select sum(octet_length(data)) as total from attach where uid = %d ",
index 291307b8ec3d22efcf14e2b6295c1fb686f9aa00..44cfa015678d77d33a78516da2a867e0de687a3d 100644 (file)
@@ -119,7 +119,7 @@ function wall_upload_post(&$a, $desktopmode = true) {
        $maximagesize = get_config('system','maximagesize');
 
        if(($maximagesize) && ($filesize > $maximagesize)) {
-               echo  sprintf( t('Image exceeds size limit of %d'), $maximagesize) . EOL;
+               echo  sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL;
                @unlink($src);
                killme();
        }