diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php index b0bb8090f266bc8e62d79c91a890602c9689ea2e..9fafb6ebf70cc8a7895d036a39114481065166f6 100644 --- a/interface/web/dashboard/dashboard.php +++ b/interface/web/dashboard/dashboard.php @@ -157,7 +157,7 @@ while ($file = @readdir ($handle)) { /* Which dashlets in which column */ /******************************************************************************/ -$leftcol_dashlets = array('modules','invoices'); +$leftcol_dashlets = array('modules','invoices','quota'); $rightcol_dashlets = array('limits'); /******************************************************************************/ diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php new file mode 100644 index 0000000000000000000000000000000000000000..bfbfe73fbac000e9be4beb6d0854dfcc794f8945 --- /dev/null +++ b/interface/web/dashboard/dashlets/quota.php @@ -0,0 +1,116 @@ +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); + $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']))); + } + } + //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'".$sql_where); + //print_r($sites); + if(is_array($sites) && !empty($sites)){ + for($i=0;$i $sites[$i]['used'][1]){ + $sites[$i]['used'] = $sites[$i]['used'][0]; + } else { + $sites[$i]['used'] = $sites[$i]['used'][1]; + } + } + 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){ + $used_ratio = $sites[$i]['used']/$sites[$i]['soft']; + } else { + $used_ratio = 0; + } + 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'; + } else { + if ($sites[$i]['used'] != '') $sites[$i]['used'] .= ' KB'; + } + + if($sites[$i]['soft'] > 1024) { + $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'; + } 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); + + return $tpl->grab(); + + + } +} + + + + + + + + +?> \ No newline at end of file diff --git a/interface/web/dashboard/dashlets/templates/quota.htm b/interface/web/dashboard/dashlets/templates/quota.htm new file mode 100644 index 0000000000000000000000000000000000000000..3cf40e73e272759046cab8e7fa7551718f931660 --- /dev/null +++ b/interface/web/dashboard/dashlets/templates/quota.htm @@ -0,0 +1,29 @@ +
+

{tmpl_var name='quota_txt'}

+
+ + + + + + + + + + + + + + + + + + + + + + + +
{tmpl_var name='domain_txt'}{tmpl_var name='used_txt'}{tmpl_var name='soft_txt'}{tmpl_var name='hard_txt'}
{tmpl_var name='domain'}{tmpl_var name='used'}{tmpl_var name='soft'}{tmpl_var name='hard'}
{tmpl_var name='no_sites_txt'}
+
+
\ No newline at end of file diff --git a/interface/web/dashboard/lib/lang/de_dashlet_quota.lng b/interface/web/dashboard/lib/lang/de_dashlet_quota.lng new file mode 100644 index 0000000000000000000000000000000000000000..6050e105f264272faf2eb27cfdbfa281867e176c --- /dev/null +++ b/interface/web/dashboard/lib/lang/de_dashlet_quota.lng @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/interface/web/dashboard/lib/lang/en_dashlet_quota.lng b/interface/web/dashboard/lib/lang/en_dashlet_quota.lng new file mode 100644 index 0000000000000000000000000000000000000000..8b2e3d43d00117f0bb31345990c2a13fd386721a --- /dev/null +++ b/interface/web/dashboard/lib/lang/en_dashlet_quota.lng @@ -0,0 +1,8 @@ + \ No newline at end of file