diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php index 005c364aa5cd644dd04ca87482f54c1b7e846e80..d8adccd15eb9ba3e82783411a499084ebbf5f474 100644 --- a/interface/web/dashboard/dashboard.php +++ b/interface/web/dashboard/dashboard.php @@ -160,10 +160,14 @@ $dashlet_list = array(); $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); while ($file = @readdir($handle)) { if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) { - $dashlet_name = substr($file, 0, -4); - $dashlet_class = 'dashlet_'.$dashlet_name; - include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; - $dashlet_list[$dashlet_name] = new $dashlet_class; + $splitfilename = explode('.', $file); + $file_extension = pathinfo($file)['extension']; + if ($file_extension === 'php') { // only allow .php files + $dashlet_name = substr($file, 0, -4); + $dashlet_class = 'dashlet_'.$dashlet_name; + include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; + $dashlet_list[$dashlet_name] = new $dashlet_class; + } } } diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index 62cd2db358c7bf923bc065bcef137320fdbe7dde..a299bbcaf35f891766ca930ed38e96451aaed649 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -1,217 +1,221 @@ 'limit_mailquota', - 'db_table' => 'mail_user', - 'db_where' => 'quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ - 'q_type' => 'quota'); - - $limits[] = array('field' => 'limit_maildomain', - 'db_table' => 'mail_domain', - 'db_where' => ''); - - $limits[] = array('field' => 'limit_mailmailinglist', - 'db_table' => 'mail_mailinglist', - 'db_where' => ''); - - $limits[] = array('field' => 'limit_mailbox', - 'db_table' => 'mail_user', - 'db_where' => ''); - - $limits[] = array('field' => 'limit_mailalias', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'alias'"); - - $limits[] = array('field' => 'limit_mailaliasdomain', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'aliasdomain'"); - - $limits[] = array('field' => 'limit_mailforward', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'forward'"); - - $limits[] = array('field' => 'limit_mailcatchall', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'catchall'"); - - $limits[] = array('field' => 'limit_mailrouting', - 'db_table' => 'mail_transport', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_mailfilter', - 'db_table' => 'mail_user_filter', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_fetchmail', - 'db_table' => 'mail_get', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_spamfilter_wblist', - 'db_table' => 'spamfilter_wblist', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_spamfilter_user', - 'db_table' => 'spamfilter_users', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_spamfilter_policy', - 'db_table' => 'spamfilter_policy', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_web_quota', - 'db_table' => 'web_domain', - 'db_where' => 'hd_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ - 'q_type' => 'hd_quota'); - - $limits[] = array('field' => 'limit_web_domain', - 'db_table' => 'web_domain', - 'db_where' => "type = 'vhost'"); - - $limits[] = array('field' => 'limit_web_subdomain', - 'db_table' => 'web_domain', - 'db_where' => "(type = 'subdomain' OR type = 'vhostsubdomain')"); - - $limits[] = array('field' => 'limit_web_aliasdomain', - 'db_table' => 'web_domain', - 'db_where' => "(type = 'alias' OR type = 'vhostalias')"); - - $limits[] = array('field' => 'limit_ftp_user', - 'db_table' => 'ftp_user', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_shell_user', - 'db_table' => 'shell_user', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_dns_zone', - 'db_table' => 'dns_soa', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_dns_slave_zone', - 'db_table' => 'dns_slave', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_dns_record', - 'db_table' => 'dns_rr', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_database_quota', - 'db_table' => 'web_database', - 'db_where' => 'database_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ - 'q_type' => 'database_quota'); - - $limits[] = array('field' => 'limit_database', - 'db_table' => 'web_database', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_cron', - 'db_table' => 'cron', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_client', - 'db_table' => 'client', - 'db_where' => ""); - - $limits[] = array('field' => 'limit_domain', - 'db_table' => 'domain', - 'db_where' => ""); - - - //* Loading Template - $app->uses('tpl,tform'); - - $tpl = new tpl; - $tpl->newTemplate("dashlets/templates/limits.htm"); - - $wb = array(); - $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_limits.lng'; - if(is_file($lng_file)) include $lng_file; - $tpl->setVar($wb); - - if($app->auth->is_admin()) { - $user_is_admin = true; - } else { - $user_is_admin = false; - } - $tpl->setVar('is_admin', $user_is_admin); - - if($user_is_admin == false) { - $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); - } - - $rows = array(); - foreach($limits as $limit) { - $field = $limit['field']; - if($user_is_admin) { - $value = $wb['unlimited_txt']; - } else { - $value = $client[$field]; - } - if($value != 0 || $value == $wb['unlimited_txt']) { - $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; - if($limit['q_type']!=''){ - $usage = $this->_get_assigned_quota($limit) . " MB"; - $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB"; - } - else $usage = $this->_get_limit_usage($limit); - $percentage = ($value == '-1' || $value == 0 ? 0 : round(100 * $usage / $value)); - $rows[] = array('field' => $field, - 'field_txt' => $wb[$field.'_txt'], - 'value' => $value_formatted, - 'value_raw' => $value, - 'usage' => $usage, - 'usage_raw' => $usage, - 'percentage' => $percentage); - } - } - $rows = $app->functions->htmlentities($rows); - $tpl->setLoop('rows', $rows); - - - return $tpl->grab(); - - } - - function _get_limit_usage($limit) { - global $app; - - $sql = "SELECT count(sys_userid) as number FROM ?? WHERE "; - if($limit['db_where'] != '') $sql .= $limit['db_where']." AND "; - $sql .= $app->tform->getAuthSQL('r'); - $rec = $app->db->queryOneRecord($sql, $limit['db_table']); - return $rec['number']; - - } - - function _get_assigned_quota($limit) { - global $app; - - $sql = "SELECT sum(??) as number FROM ?? WHERE "; - if($limit['db_where'] != '') $sql .= $limit['db_where']." AND "; - $sql .= $app->tform->getAuthSQL('r'); - $rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']); - if($limit['db_table']=='mail_user') $quotaMB = $rec['number'] / 1048576; // Mail quota is in bytes, must be converted to MB - else $quotaMB = $rec['number']; - return $quotaMB; - - } - +class dashlet_limits +{ + public function show() + { + global $app, $conf; + + $limits = array(); + + /* Limits to be shown*/ + + $limits[] = array('field' => 'limit_mailquota', + 'db_table' => 'mail_user', + 'db_where' => 'quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ + 'q_type' => 'quota'); + + $limits[] = array('field' => 'limit_maildomain', + 'db_table' => 'mail_domain', + 'db_where' => ''); + + $limits[] = array('field' => 'limit_mailmailinglist', + 'db_table' => 'mail_mailinglist', + 'db_where' => ''); + + $limits[] = array('field' => 'limit_mailbox', + 'db_table' => 'mail_user', + 'db_where' => ''); + + $limits[] = array('field' => 'limit_mailalias', + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'alias'"); + + $limits[] = array('field' => 'limit_mailaliasdomain', + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'aliasdomain'"); + + $limits[] = array('field' => 'limit_mailforward', + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'forward'"); + + $limits[] = array('field' => 'limit_mailcatchall', + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'catchall'"); + + $limits[] = array('field' => 'limit_mailrouting', + 'db_table' => 'mail_transport', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_mailfilter', + 'db_table' => 'mail_user_filter', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_fetchmail', + 'db_table' => 'mail_get', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_spamfilter_wblist', + 'db_table' => 'spamfilter_wblist', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_spamfilter_user', + 'db_table' => 'spamfilter_users', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_spamfilter_policy', + 'db_table' => 'spamfilter_policy', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_web_quota', + 'db_table' => 'web_domain', + 'db_where' => 'hd_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ + 'q_type' => 'hd_quota'); + + $limits[] = array('field' => 'limit_web_domain', + 'db_table' => 'web_domain', + 'db_where' => "type = 'vhost'"); + + $limits[] = array('field' => 'limit_web_subdomain', + 'db_table' => 'web_domain', + 'db_where' => "(type = 'subdomain' OR type = 'vhostsubdomain')"); + + $limits[] = array('field' => 'limit_web_aliasdomain', + 'db_table' => 'web_domain', + 'db_where' => "(type = 'alias' OR type = 'vhostalias')"); + + $limits[] = array('field' => 'limit_ftp_user', + 'db_table' => 'ftp_user', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_shell_user', + 'db_table' => 'shell_user', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_dns_zone', + 'db_table' => 'dns_soa', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_dns_slave_zone', + 'db_table' => 'dns_slave', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_dns_record', + 'db_table' => 'dns_rr', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_database_quota', + 'db_table' => 'web_database', + 'db_where' => 'database_quota > 0', /* Count only posive value of quota, negative value -1 is unlimited */ + 'q_type' => 'database_quota'); + + $limits[] = array('field' => 'limit_database', + 'db_table' => 'web_database', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_cron', + 'db_table' => 'cron', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_client', + 'db_table' => 'client', + 'db_where' => ""); + + $limits[] = array('field' => 'limit_domain', + 'db_table' => 'domain', + 'db_where' => ""); + + + //* Loading Template + $app->uses('tpl,tform'); + + $tpl = new tpl; + $tpl->newTemplate("dashlets/templates/limits.htm"); + + $wb = array(); + $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_limits.lng'; + if (is_file($lng_file)) { + include $lng_file; + } + $tpl->setVar($wb); + + if ($app->auth->is_admin()) { + $user_is_admin = true; + } else { + $user_is_admin = false; + } + $tpl->setVar('is_admin', $user_is_admin); + + if ($user_is_admin == false) { + $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); + $client = $app->db->queryOneRecord("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + } + + $rows = array(); + foreach ($limits as $limit) { + $field = $limit['field']; + if ($user_is_admin) { + $value = $wb['unlimited_txt']; + } else { + $value = $client[$field]; + } + if ($value != 0 || $value == $wb['unlimited_txt']) { + $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; + if ($limit['q_type']!='') { + $usage = $this->_get_assigned_quota($limit) . " MB"; + $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value . " MB"; + } else { + $usage = $this->_get_limit_usage($limit); + } + $percentage = ($value == '-1' || $value == 0 ? -1 : round(100 * $usage / $value)); + $progressbar = $percentage > 100 ? 100 : $percentage; + $rows[] = array('field' => $field, + 'field_txt' => $wb[$field.'_txt'], + 'value' => $value_formatted, + 'value_raw' => $value, + 'usage' => $usage, + 'usage_raw' => $usage, + 'percentage' => $percentage, + 'progressbar' => $progressbar + ); + } + } + $rows = $app->functions->htmlentities($rows); + $tpl->setLoop('rows', $rows); + + + return $tpl->grab(); + } + + public function _get_limit_usage($limit) + { + global $app; + + $sql = "SELECT count(sys_userid) as number FROM ?? WHERE "; + if ($limit['db_where'] != '') { + $sql .= $limit['db_where']." AND "; + } + $sql .= $app->tform->getAuthSQL('r'); + $rec = $app->db->queryOneRecord($sql, $limit['db_table']); + return $rec['number']; + } + + public function _get_assigned_quota($limit) + { + global $app; + + $sql = "SELECT sum(??) as number FROM ?? WHERE "; + if ($limit['db_where'] != '') { + $sql .= $limit['db_where']." AND "; + } + $sql .= $app->tform->getAuthSQL('r'); + $rec = $app->db->queryOneRecord($sql, $limit['q_type'], $limit['db_table']); + if ($limit['db_table']=='mail_user') { + $quotaMB = $rec['number'] / 1048576; + } // Mail quota is in bytes, must be converted to MB + else { + $quotaMB = $rec['number']; + } + return $quotaMB; + } } - - - - - - - - -?> diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index f1c46051d1082649fe3a73971eb719cae905b703..d0b1be998f7e44f304a4bae9a7aa6b2c296740a7 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -31,6 +31,7 @@ class dashlet_quota { if(is_array($sites) && !empty($sites)){ foreach($sites as &$site) { $site['domain'] = $app->functions->idn_decode($site['domain']); + $site['progressbar'] = $site['hd_quota']; } unset($site); diff --git a/interface/web/dashboard/dashlets/templates/databasequota.htm b/interface/web/dashboard/dashlets/templates/databasequota.htm index 46db3cc6b818282f7b18c0755b4480f696099b3f..7cfd10b095a627c5e3cda2084788143ad01c8331 100644 --- a/interface/web/dashboard/dashlets/templates/databasequota.htm +++ b/interface/web/dashboard/dashlets/templates/databasequota.htm @@ -1,28 +1,28 @@ -
{tmpl_var name='database_txt'} | +{tmpl_var name='used_txt'} | +{tmpl_var name='quota_txt'} | +||||||
---|---|---|---|---|---|---|---|---|
{tmpl_var name='database_txt'} | -{tmpl_var name='used_txt'} | -{tmpl_var name='quota_txt'} | +{tmpl_var name='database_name'} | +{tmpl_var name='used'} | +{tmpl_var name='database_quota'} | + {tmpl_if name="database_quota" op="!=" value="unlimited"}
+
+
+
+ | {/tmpl_if} | |
{tmpl_var name='database_name'} | -{tmpl_var name='used'} | -{tmpl_var name='database_quota'} | -
-
-
-
- |
-
- | - | ||||
---|---|---|---|---|---|
{tmpl_var name='field_txt'} | -{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'} | -
-
-
-
- |
+ + | + | |
{tmpl_var name='field_txt'} | +{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'} | + {tmpl_if name="progressbar" op="!=" value="-1"}
+
+
+
+ |
+ {/tmpl_if} + |
{tmpl_var name='email_txt'} | +{tmpl_var name='name_txt'} | +{tmpl_var name='used_txt'} | +{tmpl_var name='quota_txt'} | +|||||||
---|---|---|---|---|---|---|---|---|---|---|
{tmpl_var name='email_txt'} | -{tmpl_var name='name_txt'} | -{tmpl_var name='used_txt'} | -{tmpl_var name='quota_txt'} | +{tmpl_var name='email'} | +{tmpl_var name='name'} | +{tmpl_var name='used'} | +{tmpl_var name='quota'} | + {tmpl_if name="quota" op="!=" value="unlimited"}
+
+
+
+ | {tmpl_else}{/tmpl_if} | |
{tmpl_var name='email'} | -{tmpl_var name='name'} | -{tmpl_var name='used'} | -{tmpl_var name='quota'} | -
-
-
-
- |
-
{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='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_if name="progressbar" op="!=" value="-1"}
+
+
+
+ | {tmpl_else}{/tmpl_if} + |
{tmpl_var name='search_limit'} | -|||||
---|---|---|---|---|---|
- | - | - | - | - | - - | -
{tmpl_var name="email"} | -{tmpl_var name="name"} | -{tmpl_var name="used"} | -{tmpl_var name="quota"} | -{tmpl_var name="percentage"} | -- |
{tmpl_var name='globalsearch_noresults_text_txt'} | -|||||
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ {tmpl_var name='search_limit'} | +
---|---|---|---|---|---|
+ | + | ++ | + | + | + + | +
{tmpl_var + name="email"} | +{tmpl_var + name="name"} | +{tmpl_var + name="used"} | +{tmpl_var + name="quota"} | +
+ {tmpl_if name="progressbar" op="!=" value="-1"}
+ {/tmpl_if}
+
+ |
+
+ |
{tmpl_var name='globalsearch_noresults_text_txt'} | +|||||
+ |
+
{tmpl_var name='search_limit'} | |||||||||
---|---|---|---|---|---|---|---|---|---|
+ | @@ -31,13 +33,16 @@ | ||||||||
{tmpl_var name="domain"} | +{tmpl_var name="domain"} | {tmpl_var name="system_user"} | {tmpl_var name="used"} | {tmpl_var name="soft"} | {tmpl_var name="hard"} | {tmpl_var name="files"} | -+ | {tmpl_if name="progressbar" op="!=" value="-1"}
+ {/tmpl_if}
+ |
+