From 7fe908c50c8dbc5cc05f571dbe11d66141caacd4 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Thu, 14 Nov 2013 09:01:22 -0500 Subject: [PATCH] Cleaning up code to match coding guidelines --- interface/web/dashboard/dashlets/quota.php | 55 ++++++++++++++++++++++++++++--------------------------- 1 files changed, 28 insertions(+), 27 deletions(-) diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index 29d1d3b..1cb5671 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -1,33 +1,33 @@ <?php class dashlet_quota { - + function show() { global $app, $conf; - + //* Loading Template $app->uses('tpl'); - + $tpl = new tpl; $tpl->newTemplate("dashlets/templates/quota.htm"); - + $wb = array(); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_quota.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - + $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC"); $monitor_data = array(); if(is_array($tmp_rec)) { foreach ($tmp_rec as $tmp_mon) { - $monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data']))); + $monitor_data = array_merge_recursive($monitor_data, unserialize($app->db->unquote($tmp_mon['data']))); } } //print_r($monitor_data); if($_SESSION["s"]["user"]["typ"] != 'admin'){ $sql_where = " AND sys_groupid = ".$_SESSION['s']['user']['default_group']; } - + $has_quota = false; // select websites belonging to client $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".$sql_where); @@ -39,7 +39,7 @@ $sites[$i]['soft'] = $monitor_data['user'][$username]['soft']; $sites[$i]['hard'] = $monitor_data['user'][$username]['hard']; $sites[$i]['files'] = $monitor_data['user'][$username]['files']; - + if (!is_numeric($sites[$i]['used'])){ if ($sites[$i]['used'][0] > $sites[$i]['used'][1]){ $sites[$i]['used'] = $sites[$i]['used'][0]; @@ -50,7 +50,7 @@ if (!is_numeric($sites[$i]['soft'])) $sites[$i]['soft']=$sites[$i]['soft'][1]; if (!is_numeric($sites[$i]['hard'])) $sites[$i]['hard']=$sites[$i]['hard'][1]; if (!is_numeric($sites[$i]['files'])) $sites[$i]['files']=$sites[$i]['files'][1]; - + // colours $sites[$i]['display_colour'] = '#000000'; if($sites[$i]['soft'] > 0){ @@ -60,50 +60,51 @@ } if($used_ratio >= 0.8) $sites[$i]['display_colour'] = '#fd934f'; if($used_ratio >= 1) $sites[$i]['display_colour'] = '#cc0000'; - + if($sites[$i]['used'] > 1024) { - $sites[$i]['used'] = round($sites[$i]['used'] / 1024,2).' MB'; + $sites[$i]['used'] = round($sites[$i]['used'] / 1024, 2).' MB'; } else { if ($sites[$i]['used'] != '') $sites[$i]['used'] .= ' KB'; } - + if($sites[$i]['soft'] > 1024) { - $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024,2).' MB'; + $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024, 2).' MB'; } else { $sites[$i]['soft'] .= ' KB'; } - + if($sites[$i]['hard'] > 1024) { - $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024,2).' MB'; + $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024, 2).' MB'; } else { $sites[$i]['hard'] .= ' KB'; } - + if($sites[$i]['soft'] == " KB") $sites[$i]['soft'] = $app->lng('unlimited'); if($sites[$i]['hard'] == " KB") $sites[$i]['hard'] = $app->lng('unlimited'); - - + + /* if(!strstr($sites[$i]['used'],'M') && !strstr($sites[$i]['used'],'K')) $sites[$i]['used'].= ' B'; if(!strstr($sites[$i]['soft'],'M') && !strstr($sites[$i]['soft'],'K')) $sites[$i]['soft'].= ' B'; if(!strstr($sites[$i]['hard'],'M') && !strstr($sites[$i]['hard'],'K')) $sites[$i]['hard'].= ' B'; */ - + if($sites[$i]['soft'] == '0 B' || $sites[$i]['soft'] == '0 KB' || $sites[$i]['soft'] == '0') $sites[$i]['soft'] = $app->lng('unlimited'); if($sites[$i]['hard'] == '0 B' || $sites[$i]['hard'] == '0 KB' || $sites[$i]['hard'] == '0') $sites[$i]['hard'] = $app->lng('unlimited'); - + } $has_quota = true; $tpl->setloop('quota', $sites); } //print_r($sites); - - $tpl->setVar('has_quota',$has_quota); - + + $tpl->setVar('has_quota', $has_quota); + return $tpl->grab(); - - + + } + } @@ -113,4 +114,4 @@ -?> \ No newline at end of file +?> -- Gitblit v1.9.1