From 9b6127c9abc625e1db80c70162fb154228848ef6 Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Tue, 2 Apr 2024 17:01:17 -0500 Subject: [PATCH] remove storage functions from eqsl and use new helper instead --- application/controllers/Eqsl.php | 48 ++------------------------------ 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php index beae3f1c..15258867 100644 --- a/application/controllers/Eqsl.php +++ b/application/controllers/Eqsl.php @@ -12,8 +12,9 @@ class eqsl extends CI_Controller { public function index() { $this->lang->load('qslcard'); + $this->load->helper('storage'); $folder_name = "images/eqsl_card_images"; - $data['storage_used'] = $this->sizeFormat($this->folderSize($folder_name)); + $data['storage_used'] = sizeFormat(folderSize($folder_name)); // Render Page @@ -749,49 +750,4 @@ class eqsl extends CI_Controller { $status = $this->uploadQso($adif, $qsl); } } - -// Functions for storage, these need shifted to a libary to use across Cloudlog - function folderSize($dir){ - $count_size = 0; - $count = 0; - $dir_array = scandir($dir); - foreach($dir_array as $key=>$filename){ - if($filename!=".." && $filename!="."){ - if(is_dir($dir."/".$filename)){ - $new_foldersize = $this->foldersize($dir."/".$filename); - $count_size = $count_size+ $new_foldersize; - }else if(is_file($dir."/".$filename)){ - $count_size = $count_size + filesize($dir."/".$filename); - $count++; - } - } - } - return $count_size; - } - - function sizeFormat($bytes){ - $kb = 1024; - $mb = $kb * 1024; - $gb = $mb * 1024; - $tb = $gb * 1024; - - if (($bytes >= 0) && ($bytes < $kb)) { - return $bytes . ' B'; - - } elseif (($bytes >= $kb) && ($bytes < $mb)) { - return ceil($bytes / $kb) . ' KB'; - - } elseif (($bytes >= $mb) && ($bytes < $gb)) { - return ceil($bytes / $mb) . ' MB'; - - } elseif (($bytes >= $gb) && ($bytes < $tb)) { - return ceil($bytes / $gb) . ' GB'; - - } elseif ($bytes >= $tb) { - return ceil($bytes / $tb) . ' TB'; - } else { - return $bytes . ' B'; - } - } - } // end class