]> 91.132.146.200 Git - insipid.git/commitdiff
some code recovery from backup
authorBanana <banana@mirage>
Tue, 24 Dec 2019 23:10:02 +0000 (00:10 +0100)
committerBanana <banana@mirage>
Tue, 24 Dec 2019 23:10:02 +0000 (00:10 +0100)
TODO
webroot/lib/management.class.php
webroot/lib/summoner.class.php
webroot/view/stats.inc.php
webroot/view/stats.php

diff --git a/TODO b/TODO
index 962b2a66c202179170d595f0099a1bdae12745b9..e0d988b06b92c18b4ca4bf373f25043fea52a214 100755 (executable)
--- a/TODO
+++ b/TODO
@@ -1,9 +1,9 @@
 TODO / Feature list
 ==========================================================================
-+ delete of a link
 + stats, storage usage. With stats and valid auth display moderation
 + email import auto reply check
 + flush local storage of images
++ delete single local storage of a link
 + sorting
 + snapshots
 + bookmark js snippet
index 1076ac601973faf413091d5da20b97697b3ca6d6..42f08b024eff85c2234dfa7a7de775a05aaa2579 100644 (file)
@@ -511,6 +511,18 @@ class Management {
                return $ret;
        }
 
+       public function storageAmount() {
+               $ret = 0;
+
+               $_storageFolder = ABSOLUTE_PATH.'/'.LOCAL_STORAGE;
+
+               if(file_exists($_storageFolder) && is_readable($_storageFolder)) {
+                       $ret = Summoner::folderSize();
+               }
+
+               return $ret;
+       }
+
 
        /**
         * Load link by given hash. Do not use Link class directly.
index e04b8f92620cbfa7e2ba90a0ceb24996cc5421cd..df42deab6f76ec1ccffec5cd979f0ee6f7c3f538 100644 (file)
@@ -464,4 +464,26 @@ class Summoner {
 
                return $ret;
        }
+
+       static function folderSize($folder) {
+               $ret = 0;
+
+               if(file_exists($folder) && is_readable($folder)) {
+                       foreach (glob(rtrim($folder, '/') . '/*', GLOB_NOSORT) as $each) {
+                               $ret += is_file($each) ? filesize($each) : self::folderSize($each);
+                       }
+               }
+
+               return $ret;
+       }
+
+       static function  humanFileSize($size,$unit="") {
+         if( (!$unit && $size >= 1<<30) || $unit == "GB")
+               return number_format($size/(1<<30),2)."GB";
+         if( (!$unit && $size >= 1<<20) || $unit == "MB")
+               return number_format($size/(1<<20),2)."MB";
+         if( (!$unit && $size >= 1<<10) || $unit == "KB")
+               return number_format($size/(1<<10),2)."KB";
+         return number_format($size)." bytes";
+       }
 }
index e72953a39594c7d48a19d5ae60518fdc613a6987..041ff412ea9d6d880716e17f529bb11365a43dee 100644 (file)
@@ -34,4 +34,5 @@ if(Summoner::simpleAuthCheck() === true) {
 $linkAmount = $Management->linkAmount();
 $tagAmount = $Management->tagAmount();
 $categoryAmount = $Management->categoryAmount();
+$localStorageAmount = $Management->storageAmount();
 
index 0a4ddd30dc1fc3b4e126befea30eba72091a17c6..f62b99ce6f41f236a285fff5e320ced8afd736f1 100644 (file)
@@ -75,7 +75,7 @@
                </div>
                <div class="column is-one-quarter">
                        <h3 class="is-size-3">Local image storage</h3>
-                       <p># Moderation needed: <?php echo $moderationAmount; ?></p>
+                       <p>Diskspace used: <?php echo $moderationAmount; ?></p>
                        <p><a href="index.php?p=overview&m=category">Delete all</a></p>
                </div>
                <?php } ?>