root/trunk/gui/admin/domain_details.php

Revision 1327, 9.3 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('ADMIN_TEMPLATE_PATH') . '/domain_details.tpl');
27 $tpl->define_dynamic('logged_from', 'page');
28 $tpl->define_dynamic('custom_buttons', 'page');
29
30 $theme_color = Config::get('USER_INITIAL_THEME');
31
32 $tpl->assign(
33         array(
34             'TR_DETAILS_DOMAIN_PAGE_TITLE' => tr('ispCP - Domain/Details'),
35             'THEME_COLOR_PATH' => "../themes/$theme_color",
36             'THEME_CHARSET' => tr('encoding'),
37             'ISP_LOGO' => get_logo($_SESSION['user_id']),
38             )
39     );
40
41 /*
42  *
43  * static page messages.
44  *
45  */
46
47 $tpl->assign(
48         array(
49             'TR_DOMAIN_DETAILS' => tr('Domain details'),
50             'TR_DOMAIN_NAME' => tr('Domain name'),
51             'TR_DOMAIN_IP' => tr('Domain IP'),
52             'TR_STATUS' => tr('Status'),
53             'TR_PHP_SUPP' => tr('PHP support'),
54             'TR_CGI_SUPP' => tr('CGI support'),
55             'TR_MYSQL_SUPP' => tr('MySQL support'),
56             'TR_TRAFFIC' => tr('Traffic in MB'),
57             'TR_DISK' => tr('Disk in MB'),
58             'TR_FEATURE' => tr('Feature'),
59             'TR_USED' => tr('Used'),
60             'TR_LIMIT' => tr('Limit'),
61             'TR_MAIL_ACCOUNTS' => tr('Mail accounts'),
62             'TR_FTP_ACCOUNTS' => tr('FTP accounts'),
63             'TR_SQL_DB_ACCOUNTS' => tr('SQL databases'),
64             'TR_SQL_USER_ACCOUNTS' => tr('SQL users'),
65             'TR_SUBDOM_ACCOUNTS' => tr('Subdomains'),
66             'TR_DOMALIAS_ACCOUNTS' => tr('Domain aliases'),
67             'TR_UPDATE_DATA' => tr('Submit changes'),
68             'TR_BACK' => tr('Back'),
69             )
70     );
71
72 gen_admin_mainmenu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/main_menu_users_manage.tpl');
73 gen_admin_menu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/menu_users_manage.tpl');
74
75 gen_page_message($tpl);
76 // Get user id that come for manage domain
77 if (!isset($_GET['domain_id'])) {
78     header('Location: manage_users.php');
79     die();
80 }
81
82 $editid = $_GET['domain_id'];
83 gen_detaildom_page($tpl, $_SESSION['user_id'], $editid);
84
85 $tpl->parse('PAGE', 'page');
86
87 $tpl->prnt();
88
89 if (Config::get('DUMP_GUI_DEBUG')) dump_gui_debug();
90
91 unset_messages();
92
93 // Begin function block
94
95 function gen_detaildom_page(&$tpl, $user_id, $domain_id) {
96     $sql = Database::getInstance();
97     // Get domain data
98     $query = <<<SQL_QUERY
99       select
100           *,
101           IFNULL(domain_disk_usage, 0) as domain_disk_usage
102       from
103           domain
104       where
105           domain_id = ?;
106 SQL_QUERY;
107
108     $res = exec_query($sql, $query, array($domain_id));
109     $data = $res->FetchRow();
110
111     if ($res->RecordCount() <= 0) {
112         header('Location: manage_users.php');
113         die();
114     }
115     // Get admin data
116     $query = "select admin_name from admin where admin_id = ?";
117     $res1 = exec_query($sql, $query, array($data['domain_admin_id']));
118     $data1 = $res1->FetchRow();
119     if ($res1->RecordCount() <= 0) {
120         header('Location: manage_users.php');
121         die();
122     }
123     // Get IP-info
124     $query = "select * from server_ips where ip_id = ?";
125     $ipres = exec_query($sql, $query, array($data['domain_ip_id']));
126     $ipdat = $ipres->FetchRow();
127     // Get staus name
128     $dstatus = $data['domain_status'];
129
130     if ($dstatus == Config::get('ITEM_OK_STATUS') || $dstatus == Config::get('ITEM_DISABLED_STATUS') || $dstatus == Config::get('ITEM_DELETE_STATUS') || $dstatus == Config::get('ITEM_ADD_STATUS') || $dstatus == Config::get('ITEM_RESTORE_STATUS') || $dstatus == Config::get('ITEM_CHANGE_STATUS') || $dstatus == Config::get('ITEM_TOENABLE_STATUS') || $dstatus == Config::get('ITEM_TODISABLED_STATUS')) {
131         $dstatus = translate_dmn_status($data['domain_status']);
132     } else {
133         $dstatus = "<b><font size=\"3\" color=red>" . $data['domain_status'] . "</font></b>";
134     }
135
136     // Traffic diagram
137     $fdofmnth = mktime(0, 0, 0, date("m"), 1, date("Y"));
138     $ldofmnth = mktime(1, 0, 0, date("m") + 1, 0, date("Y"));
139     $query = <<<SQL_QUERY
140         select
141             IFNULL(sum(dtraff_web),0) as dtraff_web,
142             IFNULL(sum(dtraff_ftp), 0) as dtraff_ftp,
143             IFNULL(sum(dtraff_mail), 0) as dtraff_mail,
144             IFNULL(sum(dtraff_pop),0) as dtraff_pop
145         from
146             domain_traffic
147         where
148             domain_id = ?
149           and
150             dtraff_time > ?
151           and
152             dtraff_time < ?
153 SQL_QUERY;
154
155     $res7 = exec_query($sql, $query, array($data['domain_id'], $fdofmnth, $ldofmnth));
156     $dtraff = $res7->FetchRow();
157     $sumtraff = $dtraff['dtraff_web'] + $dtraff['dtraff_ftp'] + $dtraff['dtraff_mail'] + $dtraff['dtraff_pop'];
158     $dtraffmb = sprintf("%.1f", ($sumtraff / 1024) / 1024);
159
160     $month = date("m");
161     $year = date("Y");
162
163     $query = "select * from server_ips where ip_id=?";
164     $res8 = exec_query($sql, $query, array($data['domain_ip_id']));
165     $ipdat = $res8->FetchRow();
166
167     $domain_traffic_limit = $data['domain_traffic_limit'];
168     $domain_all_traffic = $sumtraff; //$dtraff['traffic'];
169
170     $traff = ($domain_all_traffic / 1024) / 1024;
171     $mtraff = sprintf("%.2f", $traff);
172
173     if ($domain_traffic_limit == 0) {
174         $pr = 0;
175     } else {
176         $pr = ($traff / $domain_traffic_limit) * 100;
177         $pr = sprintf("%.2f", $pr);
178     }
179
180     $indx = (int)$pr;
181
182     list($traffic_percent, $indx, $a) = make_usage_vals($domain_all_traffic, $domain_traffic_limit * 1024 * 1024);
183     // Get disk status
184     $domdu = $data['domain_disk_usage'];
185     $domdl = $data['domain_disk_limit'];
186
187     $tmp = ($domdu / 1024) / 1024;
188
189     if ($domdu == 0) {
190         $dpr = 0;
191     } else if ($domdl == 0) {
192         $dpr = 0;
193     } else {
194         $dpr = ($tmp / $domdl) * 100;
195         $dpr = sprintf("%.2f", $dpr);
196     }
197
198     $dindx = (int) $dpr;
199     $domduh = sizeit($domdu);
200
201     list($disk_percent, $dindx, $b) = make_usage_vals($domdu, $domdl * 1024 * 1024);
202     // Get current mail count
203     $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']));
204     $dat3 = $res6->FetchRow();
205     $mail_limit = translate_limit_value($data['domain_mailacc_limit']);
206     // FTP stat
207     $query = "select gid from ftp_group where groupname = ?";
208     $res4 = exec_query($sql, $query, array($data['domain_name']));
209     $ftp_gnum = $res4->RowCount();
210     if ($ftp_gnum == 0) {
211         $used_ftp_acc = 0;
212     } else {
213         $dat1 = $res4->FetchRow();
214         $query = "select count(uid) as ftp_cnt from ftp_users where gid=?";
215         $res5 = exec_query($sql, $query, array($dat1['gid']));
216         $dat2 = $res5->FetchRow();
217
218         $used_ftp_acc = $dat2['ftp_cnt'];
219     }
220     $ftp_limit = translate_limit_value($data['domain_ftpacc_limit']);
221     // Get sql database count
222     $query = "select count(sqld_id) as dnum from sql_database where domain_id=?";
223     $res = exec_query($sql, $query, array($data['domain_id']));
224     $dat5 = $res->FetchRow();
225     $sql_db = translate_limit_value($data['domain_sqld_limit']);
226     // Get sql users count
227     $query = "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=?";
228     $res = exec_query($sql, $query, array($data['domain_id']));
229     $dat6 = $res->FetchRow();
230     $sql_users = translate_limit_value($data['domain_sqlu_limit']);
231     // Get sub domain
232     $query = "select count(subdomain_id) as sub_num from subdomain where domain_id=?";
233     $res1 = exec_query($sql, $query, array($data['domain_id']));
234     $sub_num_data = $res1->FetchRow();
235     $sub_dom = translate_limit_value($data['domain_subd_limit']);
236     // Get domain aliases
237     $query = "select count(alias_id) as alias_num from domain_aliasses where domain_id=?";
238     $res1 = exec_query($sql, $query, array($data['domain_id']));
239     $alias_num_data = $res1->FetchRow();
240
241     $dom_alias = translate_limit_value($data['domain_alias_limit']);
242     // Fill in the fileds
243     $tpl->assign(
244             array(
245                 'DOMAIN_ID' => $data['domain_id'],
246                 'VL_DOMAIN_NAME' => decode_idna($data['domain_name']),
247                 'VL_DOMAIN_IP' => $ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')',
248                 'VL_STATUS' => $dstatus,
249
250                 'VL_PHP_SUPP' => ($data['domain_php'] == 'yes')?
251                                 tr('Enabled') : tr('Disabled'),
252                 'VL_CGI_SUPP' => ($data['domain_cgi'] == 'yes')?
253                                 tr('Enabled') : tr('Disabled'),
254                 'VL_MYSQL_SUPP' => ($data['domain_sqld_limit'] >= 0)?
255                                 tr('Enabled') : tr('Disabled'),
256
257                 'VL_TRAFFIC_PERCENT' => $traffic_percent,
258                 'VL_TRAFFIC_USED' => sizeit($domain_all_traffic),
259                 'VL_TRAFFIC_LIMIT' => sizeit($domain_traffic_limit, 'MB'),
260                 'VL_DISK_PERCENT' => $disk_percent,
261                 'VL_DISK_USED' => $domduh,
262                 'VL_DISK_LIMIT' => sizeit($data['domain_disk_limit'], 'MB'),
263                 'VL_MAIL_ACCOUNTS_USED' => $dat3['mcnt'],
264                 'VL_MAIL_ACCOUNTS_LIIT' => $mail_limit,
265                 'VL_FTP_ACCOUNTS_USED' => $used_ftp_acc,
266                 'VL_FTP_ACCOUNTS_LIIT' => $ftp_limit,
267                 'VL_SQL_DB_ACCOUNTS_USED' => $dat5['dnum'],
268                 'VL_SQL_DB_ACCOUNTS_LIIT' => $sql_db,
269                 'VL_SQL_USER_ACCOUNTS_USED' => $dat6['ucnt'],
270                 'VL_SQL_USER_ACCOUNTS_LIIT' => $sql_users,
271                 'VL_SUBDOM_ACCOUNTS_USED' => $sub_num_data['sub_num'],
272                 'VL_SUBDOM_ACCOUNTS_LIIT' => $sub_dom,
273                 'VL_DOMALIAS_ACCOUNTS_USED' => $alias_num_data['alias_num'],
274                 'VL_DOMALIAS_ACCOUNTS_LIIT' => $dom_alias
275                 )
276         );
277 } //End of load_user_data();
278
279 ?>
Note: See TracBrowser for help on using the browser.