@@ -41,12 +41,14 @@ function prepareDataRow($rec)
4141 $ tmp_year = date ('Y ' );
4242 $ tmp_month = date ('m ' );
4343 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT SUM(in_bytes) AS ftp_in, SUM(out_bytes) AS ftp_out FROM ftp_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? AND MONTH(traffic_date) = ? " , $ rec ['domain ' ], $ tmp_year , $ tmp_month );
44+ $ rec ['this_month_sort ' ] = $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
4445 $ rec ['this_month_in ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_in ' ]);
4546 $ rec ['this_month_out ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_out ' ]);
4647 $ this ->sum_this_month += $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
4748
4849 //** Traffic of the current year
4950 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT SUM(in_bytes) AS ftp_in, SUM(out_bytes) AS ftp_out FROM ftp_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? " , $ rec ['domain ' ], $ tmp_year );
51+ $ rec ['this_year_sort ' ] = $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
5052 $ rec ['this_year_in ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_in ' ]);
5153 $ rec ['this_year_out ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_out ' ]);
5254 $ this ->sum_this_year += $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
@@ -55,13 +57,15 @@ function prepareDataRow($rec)
5557 $ tmp_year = date ('Y ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
5658 $ tmp_month = date ('m ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
5759 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT SUM(in_bytes) AS ftp_in, SUM(out_bytes) AS ftp_out FROM ftp_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? AND MONTH(traffic_date) = ? " , $ rec ['domain ' ], $ tmp_year , $ tmp_month );
60+ $ rec ['last_month_sort ' ] = $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
5861 $ rec ['last_month_in ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_in ' ]);
5962 $ rec ['last_month_out ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_out ' ]);
6063 $ this ->sum_last_month += $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
6164
6265 //** Traffic of the last year
6366 $ tmp_year = date ('Y ' , mktime (0 , 0 , 0 , date ("m " ), date ("d " ), date ("Y " )-1 ));
6467 $ tmp_rec = $ app ->db ->queryOneRecord ("SELECT SUM(in_bytes) AS ftp_in, SUM(out_bytes) AS ftp_out FROM ftp_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? " , $ rec ['domain ' ], $ tmp_year );
68+ $ rec ['last_year_sort ' ] = $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
6569 $ rec ['last_year_in ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_in ' ]);
6670 $ rec ['last_year_out ' ] = $ app ->functions ->formatBytes ($ tmp_rec ['ftp_out ' ]);
6771 $ this ->sum_last_year += $ tmp_rec ['ftp_in ' ]+$ tmp_rec ['ftp_out ' ];
@@ -77,105 +81,24 @@ function onShowEnd()
7781 global $ app ;
7882
7983 $ app ->tpl ->setVar ('sum_this_month ' , $ app ->functions ->formatBytes ($ this ->sum_this_month ));
84+ if ($ app ->tpl ->getVar ('sum_this_month ' ) == 'NAN ' ) $ app ->tpl ->setVar ('sum_this_month ' ,'0 KB ' );
8085 $ app ->tpl ->setVar ('sum_this_year ' , $ app ->functions ->formatBytes ($ this ->sum_this_year ));
86+ if ($ app ->tpl ->getVar ('sum_this_year ' ) == 'NAN ' ) $ app ->tpl ->setVar ('sum_this_year ' ,'0 KB ' );
8187 $ app ->tpl ->setVar ('sum_last_month ' , $ app ->functions ->formatBytes ($ this ->sum_last_month ));
88+ if ($ app ->tpl ->getVar ('sum_last_month ' ) == 'NAN ' ) $ app ->tpl ->setVar ('sum_last_month ' ,'0 KB ' );
8289 $ app ->tpl ->setVar ('sum_last_year ' , $ app ->functions ->formatBytes ($ this ->sum_last_year ));
90+ if ($ app ->tpl ->getVar ('sum_last_year ' ) == 'NAN ' ) $ app ->tpl ->setVar ('sum_last_year ' ,'0 KB ' );
8391 $ app ->tpl ->setVar ('sum_txt ' , $ app ->listform ->lng ('sum_txt ' ));
8492
8593 $ app ->tpl_defaults ();
8694 $ app ->tpl ->pparse ();
8795 }
8896
89- function getQueryString ($ no_limit = false ) {
90- global $ app ;
91- $ sql_where = '' ;
92-
93- //* Generate the search sql
94- if ($ app ->listform ->listDef ['auth ' ] != 'no ' ) {
95- if ($ _SESSION ['s ' ]['user ' ]['typ ' ] == "admin " ) {
96- $ sql_where = '' ;
97- } else {
98- $ sql_where = $ app ->tform ->getAuthSQL ('r ' , $ app ->listform ->listDef ['table ' ]).' and ' ;
99- //$sql_where = $app->tform->getAuthSQL('r').' and';
100- }
101- }
102- if ($ this ->SQLExtWhere != '' ) {
103- $ sql_where .= ' ' .$ this ->SQLExtWhere .' and ' ;
104- }
105-
106- $ sql_where = $ app ->listform ->getSearchSQL ($ sql_where );
107- if ($ app ->listform ->listDef ['join_sql ' ]) $ sql_where .= ' AND ' .$ app ->listform ->listDef ['join_sql ' ];
108- $ app ->tpl ->setVar ($ app ->listform ->searchValues );
109-
110- $ order_by_sql = $ this ->SQLOrderBy ;
111-
112- //* Generate SQL for paging
113- $ limit_sql = $ app ->listform ->getPagingSQL ($ sql_where );
114- $ app ->tpl ->setVar ('paging ' , $ app ->listform ->pagingHTML );
115-
116- $ extselect = '' ;
117- $ join = '' ;
118-
119- if (!empty ($ _SESSION ['search ' ][$ _SESSION ['s ' ]['module ' ]['name ' ].$ app ->listform ->listDef ["name " ].$ app ->listform ->listDef ['table ' ]]['order ' ])){
120- $ order = str_replace (' DESC ' , '' , $ _SESSION ['search ' ][$ _SESSION ['s ' ]['module ' ]['name ' ].$ app ->listform ->listDef ["name " ].$ app ->listform ->listDef ['table ' ]]['order ' ]);
121- list ($ tmp_table , $ order ) = explode ('. ' , $ order );
122- if ($ order == 'ftp_traffic_last_month ' ){
123- $ tmp_year = date ('Y ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
124- $ tmp_month = date ('m ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
125- $ extselect .= ', SUM(ft.in_bytes+out_bytes) as calctraffic ' ;
126- $ join .= ' INNER JOIN ftp_traffic as ft ON ' .$ app ->listform ->listDef ['table ' ].'.domain = ft.hostname ' ;
127- $ sql_where .= " AND YEAR(ft.traffic_date) = ' $ tmp_year' AND MONTH(ft.traffic_date) = ' $ tmp_month' " ;
128- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.ftp_traffic_last_month ' , 'calctraffic ' , $ order_by_sql );
129- $ order_by_sql = "GROUP BY domain " .$ order_by_sql ;
130- } elseif ($ order == 'ftp_traffic_this_month ' ){
131- $ tmp_year = date ('Y ' );
132- $ tmp_month = date ('m ' );
133- $ extselect .= ', SUM(ft.in_bytes+out_bytes) as calctraffic ' ;
134- $ join .= ' INNER JOIN ftp_traffic as ft ON ' .$ app ->listform ->listDef ['table ' ].'.domain = ft.hostname ' ;
135- $ sql_where .= " AND YEAR(ft.traffic_date) = ' $ tmp_year' AND MONTH(ft.traffic_date) = ' $ tmp_month' " ;
136- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.ftp_traffic_this_month ' , 'calctraffic ' , $ order_by_sql );
137- $ order_by_sql = "GROUP BY domain " .$ order_by_sql ;
138- } elseif ($ order == 'ftp_traffic_last_year ' ){
139- $ tmp_year = date ('Y ' , mktime (0 , 0 , 0 , date ("m " )-1 , date ("d " ), date ("Y " )));
140- $ extselect .= ', SUM(ft.in_bytes+out_bytes) as calctraffic ' ;
141- $ join .= ' INNER JOIN ftp_traffic as ft ON ' .$ app ->listform ->listDef ['table ' ].'.domain = ft.hostname ' ;
142- $ sql_where .= " AND YEAR(ft.traffic_date) = ' $ tmp_year' " ;
143- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.ftp_traffic_last_year ' , 'calctraffic ' , $ order_by_sql );
144- $ order_by_sql = "GROUP BY domain " .$ order_by_sql ;
145- } elseif ($ order == 'ftp_traffic_this_year ' ){
146- $ tmp_year = date ('Y ' );
147- $ extselect .= ', SUM(ft.in_bytes+out_bytes) as calctraffic ' ;
148- $ join .= ' INNER JOIN ftp_traffic as ft ON ' .$ app ->listform ->listDef ['table ' ].'.domain = ft.hostname ' ;
149- $ sql_where .= " AND YEAR(ft.traffic_date) = ' $ tmp_year' " ;
150- $ order_by_sql = str_replace ($ app ->listform ->listDef ['table ' ].'.ftp_traffic_this_year ' , 'calctraffic ' , $ order_by_sql );
151- $ order_by_sql = "GROUP BY domain " .$ order_by_sql ;
152- }
153- }
154-
155- if ($ this ->SQLExtSelect != '' ) {
156- if (substr ($ this ->SQLExtSelect , 0 , 1 ) != ', ' ) $ this ->SQLExtSelect = ', ' .$ this ->SQLExtSelect ;
157- $ extselect .= $ this ->SQLExtSelect ;
158- }
159-
160- $ table_selects = array ();
161- $ table_selects [] = trim ($ app ->listform ->listDef ['table ' ]).'.* ' ;
162- $ app ->listform ->listDef ['additional_tables ' ] = trim ($ app ->listform ->listDef ['additional_tables ' ]);
163- if ($ app ->listform ->listDef ['additional_tables ' ] != '' ){
164- $ additional_tables = explode (', ' , $ app ->listform ->listDef ['additional_tables ' ]);
165- foreach ($ additional_tables as $ additional_table ){
166- $ table_selects [] = trim ($ additional_table ).'.* ' ;
167- }
168- }
169- $ select = implode (', ' , $ table_selects );
170-
171- $ sql = 'SELECT ' .$ select .$ extselect .' FROM ' .$ app ->listform ->listDef ['table ' ].($ app ->listform ->listDef ['additional_tables ' ] != '' ? ', ' .$ app ->listform ->listDef ['additional_tables ' ] : '' )."$ join WHERE $ sql_where $ order_by_sql $ limit_sql " ;
172- return $ sql ;
173- }
17497}
17598
17699$ list = new list_action ;
177100$ list ->SQLExtWhere = "(web_domain.type = 'vhost' or web_domain.type = 'vhostsubdomain') " ;
178101$ list ->SQLOrderBy = 'ORDER BY web_domain.domain ' ;
179102$ list ->onLoad ();
180103
181- ?>
104+ ?>
0 commit comments