Florian Schaal
2013-12-27 91c842be76f7f7ac693577f61fb579728ad2e5d8
changed hard-coded conversion to formatBytes for web-traffic stats
2 files modified
37 ■■■■■ changed files
interface/web/sites/templates/web_sites_stats_list.htm 10 ●●●● patch | view | raw | blame | history
interface/web/sites/web_sites_stats.php 27 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_sites_stats_list.htm
@@ -30,10 +30,10 @@
                <tmpl_loop name="records">
                    <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
                        <td class="tbl_col_domain"><a target="_blank" href="http://{tmpl_var name="domain"}/stats">{tmpl_var name="domain"}</a></td>
                        <td class="tbl_col_this_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"} MB</a></td>
                        <td class="tbl_col_last_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"} MB</a></td>
                        <td class="tbl_col_this_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"} MB</a></td>
                        <td class="tbl_col_last_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"} MB</a></td>
                        <td class="tbl_col_this_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_month"}</a></td>
                        <td class="tbl_col_last_month"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_month"}</a></td>
                        <td class="tbl_col_this_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="this_year"}</a></td>
                        <td class="tbl_col_last_year"><a href="#" onclick="loadContent('sites/web_<tmpl_if name='type' op='==' value='vhostsubdomain'>vhost_sub</tmpl_if>domain_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="last_year"}</a></td>
                        <td class="tbl_col_buttons"></td>
                    </tr>
                </tmpl_loop>
@@ -60,4 +60,4 @@
        </fieldset>
    </div>
</div>
</div>
interface/web/sites/web_sites_stats.php
@@ -15,6 +15,8 @@
//* Check permissions for module
$app->auth->check_module_permissions('sites');
$app->uses('functions');
$app->load('listform_actions');
class list_action extends listform_actions {
@@ -39,26 +41,35 @@
        $tmp_year = date('Y');
        $tmp_month = date('m');
        $tmp_rec = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
        $rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
        $this->sum_this_month += ($tmp_rec['t']/1024/1024);
//        $rec['this_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
//        $this->sum_this_month += ($tmp_rec['t']/1024/1024);
        $rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
        $this->sum_this_month += $app->functions->formatBytes($tmp_rec['t']);
        //** Traffic of the current year
        $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year'");
        $rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
        $this->sum_this_year += ($tmp_rec['t']/1024/1024);
//        $rec['this_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
//        $this->sum_this_year += ($tmp_rec['t']/1024/1024);
        $rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
        $this->sum_this_year += $app->functions->formatBytes($tmp_rec['t']);
        //** Traffic of the last month
        $tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
        $tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
        $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year' AND MONTH(traffic_date) = '$tmp_month'");
        $rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
        $this->sum_last_month += ($tmp_rec['t']/1024/1024);
//        $rec['last_month'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
//        $this->sum_last_month += ($tmp_rec['t']/1024/1024);
        $rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
        $this->sum_last_month += $app->functions->formatBytes($tmp_rec['t']);
        //** Traffic of the last year
        $tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
        $tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."' AND YEAR(traffic_date) = '$tmp_year'");
        $rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
        $this->sum_last_year += ($tmp_rec['t']/1024/1024);
//        $rec['last_year'] = number_format($tmp_rec['t']/1024/1024, 0, '.', ' ');
//        $this->sum_last_year += ($tmp_rec['t']/1024/1024);
        $rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
        $this->sum_last_year += $app->functions->formatBytes($tmp_rec['t']);
        //* The variable "id" contains always the index variable
        $rec['id'] = $rec[$this->idx_key];