root/trunk/gui/reseller/domain_delete.php

Revision 1327, 5.2 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 $reseller = $_SESSION['user_id'];
26
27 $theme_color = Config::get('USER_INITIAL_THEME');
28
29 if (isset($_GET['domain_id']))
30     $del_id = $_GET['domain_id'];
31 else {
32     set_page_message(tr('Wrong domain ID!'));
33     Header("Location: users.php");
34     die();
35 }
36
37 /* check for domain owns */
38 $query = "SELECT domain_id FROM domain WHERE domain_id=? AND domain_created_id=?";
39 $res = exec_query($sql, $query, array($del_id, $reseller));
40 $data = $res->FetchRow();
41 if ($data['domain_id'] == 0) {
42     set_page_message(tr('Wrong domain ID!'));
43     header("Location: users.php");
44     die();
45 }
46
47 /* check for mail acc in MAIN domain */
48 $query = "SELECT COUNT(mail_id) AS mailnum FROM mail_users WHERE domain_id=?";
49 $res = exec_query($sql, $query, array($del_id));
50 $data = $res->FetchRow();
51 if ($data['mailnum'] > 0) {
52     /* ERR - we have mail acc in this domain */
53     set_page_message(tr('Domain you are trying to remove has email accounts !<br> first remove them !'));
54     header("Location: users.php");
55     die();
56 }
57
58 /* check for ftp acc in MAIN domain */
59 $query = "SELECT COUNT(fg.gid) AS ftpnum FROM ftp_group fg,domain d WHERE d.domain_id=? AND fg.groupname=d.domain_name";
60 $res = exec_query($sql, $query, array($del_id));
61 $data = $res->FetchRow();
62 if ($data['ftpnum'] > 0) {
63     /* ERR -  we have ftp acc in this domain */
64     set_page_message(tr('Domain you are trying to remove has FTP accounts !<br> first remove them !'));
65     header("Location: users.php");
66     die();
67 }
68
69 /* check for alias domains */
70 $query = "SELECT COUNT(alias_id) AS aliasnum FROM domain_aliasses WHERE domain_id=?";
71 $res = exec_query($sql, $query, array($del_id));
72 $data = $res->FetchRow();
73 if ($data['aliasnum'] > 0) {
74     /* ERR -  we have domain aliases for this domain */
75     set_page_message(tr('Domain you are trying to remove has domain alias!<br> first remove them !'));
76     header("Location: users.php");
77     die();
78 }
79
80 /* check for subdomains */
81 $query = "SELECT COUNT(subdomain_id) AS subnum FROM subdomain WHERE domain_id = ?";
82 $res = exec_query($sql, $query, array($del_id));
83 $data = $res->FetchRow();
84 if ($data['subnum'] > 0) {
85     /* ERR - we have subdomain for this domain */
86     set_page_message(tr('Domain you are trying to remove has subdomains accounts !<br> first remove them !'));
87     header("Location: users.php");
88     die();
89 }
90
91 substract_from_reseller_props($_SESSION['user_id'], $del_id);
92
93 $query = "UPDATE domain SET domain_status='delete' WHERE domain_id = ?";
94 $res = exec_query($sql, $query, array($del_id));
95 send_request();
96
97 /* delete admin of this domain */
98 $query = "SELECT domain_admin_id,domain_name FROM domain WHERE domain_id = ?";
99 $res = exec_query($sql, $query, array($del_id));
100 $dat = $res->FetchRow();
101
102 $query = "DELETE FROM admin WHERE admin_id = ?";
103 $res = exec_query($sql, $query, array($dat['domain_admin_id']));
104
105 /* delete the quota section */
106 $query = "DELETE FROM quotalimits WHERE name = ?";
107 $res = exec_query($sql, $query, array($dat['domain_admin_id']));
108
109
110 write_log($_SESSION['user_logged'] .": deletes domain " . $dat['domain_name']);
111
112 $_SESSION['ddel'] = '_yes_';
113 header("Location: users.php");
114 die();
115
116 // Function declaration
117
118 function substract_from_reseller_props($reseller_id, $domain_id) {
119     list ($rdmn_current, $rdmn_max,
120         $rsub_current, $rsub_max,
121         $rals_current, $rals_max,
122         $rmail_current, $rmail_max,
123         $rftp_current, $rftp_max,
124         $rsql_db_current, $rsql_db_max,
125         $rsql_user_current, $rsql_user_max,
126         $rtraff_current, $rtraff_max,
127         $rdisk_current, $rdisk_max
128         ) = generate_reseller_props($reseller_id);
129
130     list ($sub_current, $sub_max,
131         $als_current, $als_max,
132         $mail_current, $mail_max,
133         $ftp_current, $ftp_max,
134         $sql_db_current, $sql_db_max,
135         $sql_user_current, $sql_user_max,
136         $traff_max, $disk_max
137         ) = generate_user_props($domain_id);
138
139     $rdmn_current -= 1;
140
141     if ($sub_max != -1) {
142         $rsub_current -= $sub_max;
143     }
144
145     if ($als_max != -1) {
146         $rals_current -= $als_max;
147     }
148
149     $rmail_current -= $mail_max;
150
151     $rftp_current -= $ftp_max;
152
153     if ($sql_db_max != -1) {
154         $rsql_db_current -= $sql_db_max;
155     }
156
157     if ($sql_user_max != -1) {
158         $rsql_user_current -= $sql_user_max;
159     }
160
161     $rtraff_current -= $traff_max;
162
163     $rdisk_current -= $disk_max;
164
165     $rprops  = "$rdmn_current;$rdmn_max;";
166     $rprops .= "$rsub_current;$rsub_max;";
167     $rprops .= "$rals_current;$rals_max;";
168     $rprops .= "$rmail_current;$rmail_max;";
169     $rprops .= "$rftp_current;$rftp_max;";
170     $rprops .= "$rsql_db_current;$rsql_db_max;";
171     $rprops .= "$rsql_user_current;$rsql_user_max;";
172     $rprops .= "$rtraff_current;$rtraff_max;";
173     $rprops .= "$rdisk_current;$rdisk_max;";
174
175     update_reseller_props($reseller_id, $rprops);
176 }
177
178 ?>
Note: See TracBrowser for help on using the browser.