remove storage functions from eqsl and use new helper instead

pull/3047/head
Patrick Burns 2024-04-02 17:01:17 -05:00
rodzic e345364bfa
commit 9b6127c9ab
1 zmienionych plików z 2 dodań i 46 usunięć

Wyświetl plik

@ -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