root/trunk/gui/reseller/domain_details.php

Revision 1327, 8.6 kB (checked in by rats, 4 months ago)

* Fixed: --scan-knownbad-files and --check-deleted are no longer supported by rkhunter
* Fixed #1471: chkrootkit should be in lenny / hardy
* Updated Chinese (simplified)
* Updated German
* Fixed #1475: typo on installation (ispcp-setup)
* Fixed: default user for rkhunter.log

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @version     SVN: $Id$
8  * @link         http://isp-control.net
9  * @author         ispCP Team
10  *
11  * @license
12  *   This program is free software; you can redistribute it and/or modify it under
13  *   the terms of the MPL General Public License as published by the Free Software
14  *   Foundation; either version 1.1 of the License, or (at your option) any later
15  *   version.
16  *   You should have received a copy of the MPL Mozilla Public License along with
17  *   this program; if not, write to the Open Source Initiative (OSI)
18  *   http://opensource.org | osi@opensource.org
19  */
20
21 require '../include/ispcp-lib.php';
22
23 check_login(__FILE__);
24
25 $tpl = new pTemplate();
26 $tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/domain_details.tpl');
27 $tpl->define_dynamic('logged_from', 'page');
28
29 $theme_color = Config::get('USER_INITIAL_THEME');
30
31 $tpl->assign(
32         array(
33             'TR_DETAILS_DOMAIN_PAGE_TITLE' => tr('ispCP - Domain/Details'),
34             'THEME_COLOR_PATH' => "../themes/$theme_color",
35             'THEME_CHARSET' => tr('encoding'),
36             'ISP_LOGO' => get_logo($_SESSION['user_id'])
37             )
38     );
39
40 /*
41  *
42  * static page messages.
43  *
44  */
45 $tpl->assign(
46         array(
47             'TR_DOMAIN_DETAILS' => tr('Domain details'),
48             'TR_DOMAIN_NAME' => tr('Domain name'),
49             'TR_DOMAIN_IP' => tr('Domain IP'),
50             'TR_STATUS' => tr('Status'),
51             'TR_PHP_SUPP' => tr('PHP support'),
52             'TR_CGI_SUPP' => tr('CGI support'),
53             'TR_MYSQL_SUPP' => tr('MySQL support'),
54             'TR_TRAFFIC' => tr('Traffic in MB'),
55             'TR_DISK' => tr('Disk in MB'),
56             'TR_FEATURE' => tr('Feature'),
57             'TR_USED' => tr('Used'),
58             'TR_LIMIT' => tr('Limit'),
59             'TR_MAIL_ACCOUNTS' => tr('Mail accounts'),
60             'TR_FTP_ACCOUNTS' => tr('FTP accounts'),
61             'TR_SQL_DB_ACCOUNTS' => tr('SQL databases'),
62             'TR_SQL_USER_ACCOUNTS' => tr('SQL users'),
63             'TR_SUBDOM_ACCOUNTS' => tr('Subdomains'),
64             'TR_DOMALIAS_ACCOUNTS' => tr('Domain aliases'),
65             'TR_UPDATE_DATA' => tr('Submit changes'),
66             'TR_BACK' => tr('Back'),
67             'TR_EDIT' => tr('Edit'),
68             )
69     );
70
71 if (Config::exists('HOSTING_PLANS_LEVEL') && Config::get('HOSTING_PLANS_LEVEL') === 'admin') {
72     $tpl->assign('EDIT_OPTION', '');
73 }
74
75 gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_users_manage.tpl');
76 gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_users_manage.tpl');
77
78 gen_logged_from($tpl);
79
80 gen_page_message($tpl);
81 // Get user id that come for manage domain
82 if (!isset($_GET['domain_id'])) {
83     header('Location: users.php');
84     die();
85 }
86
87 $editid = $_GET['domain_id'];
88 gen_detaildom_page($tpl, $_SESSION['user_id'], $editid);
89
90 $tpl->parse('PAGE', 'page');
91
92 $tpl->prnt();
93
94 if (Config::get('DUMP_GUI_DEBUG')) dump_gui_debug();
95
96 unset_messages();
97
98 // Begin function block
99
100 function gen_detaildom_page(&$tpl, $user_id, $domain_id) {
101     $sql = Database::getInstance();
102     // Get domain data
103     $query = <<<SQL_QUERY
104         select
105             *,
106             IFNULL(domain_disk_usage, 0) as domain_disk_usage
107         from
108             domain
109         where
110             domain_id = ?
111 SQL_QUERY;
112
113     $res = exec_query($sql, $query, array($domain_id));
114
115     $data = $res->FetchRow();
116
117     if ($res->RecordCount() <= 0) {
118         header('Location: users.php');
119         die();
120     }
121     // Get admin data
122     $created_by = $_SESSION['user_id'];
123     $res1 = exec_query($sql,
124         "select admin_name from admin where admin_id=? and created_by=?",
125         array($data['domain_admin_id'], $created_by));
126     $data1 = $res1->FetchRow();
127     if ($res1->RecordCount() <= 0) {
128         header('Location: users.php');
129         die();
130     }
131     // Get IP-info
132     $ipres = exec_query($sql, "select * from server_ips where ip_id=?", array($data['domain_ip_id']));
133     $ipdat = $ipres->FetchRow();
134     // Get staus name
135     $dstatus = translate_dmn_status($data['domain_status']);
136
137     // Traffic diagram
138     $fdofmnth = mktime(0, 0, 0, date("m"), 1, date("Y"));
139     $ldofmnth = mktime(1, 0, 0, date("m") + 1, 0, date("Y"));
140     $res7 = exec_query($sql,
141         "select IFNULL(sum(dtraff_web),0) as dtraff_web, IFNULL(sum(dtraff_ftp), 0) as dtraff_ftp, IFNULL(sum(dtraff_mail), 0) as dtraff_mail, IFNULL(sum(dtraff_pop),0) as dtraff_pop " . "from domain_traffic where domain_id=? and dtraff_time>? and dtraff_time<?",
142         array($data['domain_id'], $fdofmnth, $ldofmnth));
143     $dtraff = $res7->FetchRow();
144
145     $sumtraff = $dtraff['dtraff_web'] + $dtraff['dtraff_ftp'] + $dtraff['dtraff_mail'] + $dtraff['dtraff_pop'];
146     $dtraffmb = sprintf("%.1f", ($sumtraff / 1024) / 1024);
147
148     $month = date("m");
149     $year = date("Y");
150
151     $res8 = exec_query($sql, "select * from server_ips where ip_id=?", array($data['domain_ip_id']));
152     $ipdat = $res8->FetchRow();
153
154     $domain_traffic_limit = $data['domain_traffic_limit'];
155     $domain_all_traffic = $sumtraff; //$dtraff['traffic'];
156
157     $traff = ($domain_all_traffic / 1024) / 1024;
158     $mtraff = sprintf("%.2f", $traff);
159
160     if ($domain_traffic_limit == 0) {
161         $pr = 0;
162     } else {
163         $pr = ($traff / $domain_traffic_limit) * 100;
164         $pr = sprintf("%.2f", $pr);
165     }
166
167     $indx = (int)$pr;
168
169     list($traffic_percent, $indx, $a) = make_usage_vals($domain_all_traffic, $domain_traffic_limit * 1024 * 1024);
170     // Get disk status
171     $domdu = $data['domain_disk_usage'];
172     $domdl = $data['domain_disk_limit'];
173
174     $tmp = ($domdu / 1024) / 1024;
175
176     if ($domdu == 0) {
177         $dpr = 0;
178     } else if ($domdl == 0) {
179         $dpr = 0;
180     } else {
181         $dpr = ($tmp / $domdl) * 100;
182         $dpr = sprintf("%.2f", $dpr);
183     }
184
185     $dindx = (int) $dpr;
186     $domduh = sizeit($domdu);
187
188     list($disk_percent, $dindx, $b) = make_usage_vals($domdu, $domdl * 1024 * 1024);
189     // Get current mail count
190     $res6 = exec_query($sql, "SELECT COUNT(mail_id) AS mcnt FROM mail_users WHERE domain_id = ? AND mail_type NOT RLIKE '_catchall'", array($data['domain_id']));
191     $dat3 = $res6->FetchRow();
192     $mail_limit = translate_limit_value($data['domain_mailacc_limit']);
193     // FTP stat
194     $res4 = exec_query($sql, "select gid from ftp_group where groupname=?", array($data['domain_name']));
195     $ftp_gnum = $res4->RowCount();
196     if ($ftp_gnum == 0) {
197         $used_ftp_acc = 0;
198     } else {
199         $dat1 = $res4->FetchRow();
200         $res5 = exec_query($sql, "select count(uid) as ftp_cnt from ftp_users where gid=?", array($dat1['gid']));
201         $dat2 = $res5->FetchRow();
202
203         $used_ftp_acc = $dat2['ftp_cnt'];
204     }
205     $ftp_limit = translate_limit_value($data['domain_ftpacc_limit']);
206     // Get sql database count
207     $res = exec_query($sql, "select count(sqld_id) as dnum from sql_database where domain_id=?", array($data['domain_id']));
208     $dat5 = $res->FetchRow();
209     $sql_db = translate_limit_value($data['domain_sqld_limit']);
210     // Get sql users count
211     $res = exec_query($sql,
212         "select count(u.sqlu_id) as ucnt from sql_user u,sql_database d where u.sqld_id=d.sqld_id and d.domain_id=?",
213         array($data['domain_id']));
214     $dat6 = $res->FetchRow();
215     $sql_users = translate_limit_value($data['domain_sqlu_limit']);
216     // Get sub domain
217     $res1 = exec_query($sql, "select count(subdomain_id) as sub_num from subdomain where domain_id=?", array($domain_id));
218     $sub_num_data = $res1->FetchRow();
219     $sub_dom = translate_limit_value($data['domain_subd_limit']);
220     // Get domain aliases
221     $res1 = exec_query($sql, "select count(alias_id) as alias_num from domain_aliasses where domain_id=?", array($domain_id));
222     $alias_num_data = $res1->FetchRow();
223
224     $dom_alias = translate_limit_value($data['domain_alias_limit']);
225     // Fill in the fileds
226     $tpl->assign(
227             array(
228                 'DOMAIN_ID' => $data['domain_id'],
229                 'VL_DOMAIN_NAME' => decode_idna($data['domain_name']),
230                 'VL_DOMAIN_IP' => $ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')',
231                 'VL_STATUS' => $dstatus,
232
233                 'VL_PHP_SUPP' => ($data['domain_php'] == 'yes')?
234                                 tr('Enabled') : tr('Disabled'),
235                 'VL_CGI_SUPP' => ($data['domain_cgi'] == 'yes')?
236                                 tr('Enabled') : tr('Disabled'),
237                 'VL_MYSQL_SUPP' => ($data['domain_sqld_limit'] >= 0)?
238                                 tr('Enabled') : tr('Disabled'),
239
240                 'VL_TRAFFIC_PERCENT' => $traffic_percent,
241                 'VL_TRAFFIC_USED' => sizeit($domain_all_traffic),
242                 'VL_TRAFFIC_LIMIT' => sizeit($domain_traffic_limit, 'MB'),
243                 'VL_DISK_PERCENT' => $disk_percent,
244                 'VL_DISK_USED' => $domduh,
245                 'VL_DISK_LIMIT' => sizeit($data['domain_disk_limit'], 'MB'),
246                 'VL_MAIL_ACCOUNTS_USED' => $dat3['mcnt'],
247                 'VL_MAIL_ACCOUNTS_LIIT' => $mail_limit,
248                 'VL_FTP_ACCOUNTS_USED' => $used_ftp_acc,
249                 'VL_FTP_ACCOUNTS_LIIT' => $ftp_limit,
250                 'VL_SQL_DB_ACCOUNTS_USED' => $dat5['dnum'],
251                 'VL_SQL_DB_ACCOUNTS_LIIT' => $sql_db,
252                 'VL_SQL_USER_ACCOUNTS_USED' => $dat6['ucnt'],
253                 'VL_SQL_USER_ACCOUNTS_LIIT' => $sql_users,
254                 'VL_SUBDOM_ACCOUNTS_USED' => $sub_num_data['sub_num'],
255                 'VL_SUBDOM_ACCOUNTS_LIIT' => $sub_dom,
256                 'VL_DOMALIAS_ACCOUNTS_USED' => $alias_num_data['alias_num'],
257                 'VL_DOMALIAS_ACCOUNTS_LIIT' => $dom_alias
258             )
259         );
260 } //End of load_user_data();
261
262 ?>
Note: See TracBrowser for help on using the browser.