[QSL Cards] Added notification on storage usage to /qsl
这个提交包含在:
父节点
0d5b15847e
当前提交
219c11d4d5
共有 2 个文件被更改,包括 57 次插入 和 0 次删除
|
|
@ -13,7 +13,12 @@ class Qsl extends CI_Controller {
|
||||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default view when loading controller.
|
||||||
public function index() {
|
public function index() {
|
||||||
|
|
||||||
|
$folder_name = "assets/qslcard";
|
||||||
|
$data['storage_used'] = sizeFormat(folderSize($folder_name));
|
||||||
|
|
||||||
// Render Page
|
// Render Page
|
||||||
$data['page_title'] = "QSL Cards";
|
$data['page_title'] = "QSL Cards";
|
||||||
|
|
||||||
|
|
@ -33,6 +38,7 @@ class Qsl extends CI_Controller {
|
||||||
$this->load->view('interface_assets/footer');
|
$this->load->view('interface_assets/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deletes QSL Card
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->load->model('user_model');
|
$this->load->model('user_model');
|
||||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
|
|
@ -137,4 +143,50 @@ class Qsl extends CI_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 = 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';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2><?php echo $page_title; ?></h2>
|
<h2><?php echo $page_title; ?></h2>
|
||||||
|
|
||||||
|
<div class="alert alert-info" role="alert">
|
||||||
|
You are using <?php echo $storage_used; ?> of disk space to store QSL Card assets.
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (is_array($qslarray->result())) {
|
if (is_array($qslarray->result())) {
|
||||||
echo '<table style="width:100%" class="qsltable table table-sm table-bordered table-hover table-striped table-condensed">
|
echo '<table style="width:100%" class="qsltable table table-sm table-bordered table-hover table-striped table-condensed">
|
||||||
|
|
@ -25,4 +29,5 @@
|
||||||
echo '</tbody></table>';
|
echo '</tbody></table>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
正在加载…
在新工单中引用