root/trunk/gui/client/alias_delete.php

Revision 1397, 3.0 kB (checked in by scitech, 2 weeks ago)

small fixes

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 if (isset($_GET['id']) && $_GET['id'] !== '') {
26     $als_id = $_GET['id'];
27     $dmn_id = get_user_domain_id($sql, $_SESSION['user_id']);
28
29     $query = "
30         SELECT
31             `alias_id`
32             `alias_name`
33         FROM
34             `domain_aliasses`
35         WHERE
36             `domain_id` = ?
37         AND
38             `alias_id` = ?
39     ";
40
41     $rs = exec_query($sql, $query, array($dmn_id, $als_id));
42     $alias_name = $rs->fields['alias_name'];
43
44     if ($rs -> RecordCount() == 0) {
45         user_goto('domains_manage.php');
46     }
47
48     // check for subdomains
49     $query = "
50         SELECT
51             count(`subdomain_alias_id`) as `count`
52         FROM
53             `subdomain_alias`
54         WHERE
55             `alias_id` = ?
56     ";
57
58     $rs = exec_query($sql, $query, array($als_id));
59     if ($rs -> fields['count'] > 0 ) {
60         set_page_message(tr('Domain alias you are trying to remove has subdomains!<br>First remove them!'));
61         header('Location: domains_manage.php');
62         exit(0);
63     }
64
65     // check for mail accounts
66     $query = "
67         SELECT
68             count(`mail_id`) as `cnt`
69         FROM
70             `mail_users`
71         WHERE
72             `sub_id` = ?
73         AND
74             `mail_type` LIKE '%alias_%'
75     ";
76
77     $rs = exec_query($sql, $query, array($als_id));
78
79     if ($rs -> fields['cnt'] > 0 ) {
80         set_page_message(tr('Domain alias you are trying to remove has email accounts !<br>First remove them!'));
81         header('Location: domains_manage.php');
82         exit(0);
83     }
84
85     // check for ftp accounts
86     $query = "
87         SELECT
88             count(`fg`.`gid`) as `ftpnum`
89         FROM
90             `ftp_group` `fg`,
91             `domain` `dmn`,
92             `domain_aliasses` `d`
93         WHERE
94             `d`.`alias_id` = ?
95         AND
96             `fg`.`groupname` = `dmn`.`domain_name`
97         AND
98             `fg`.`members` RLIKE `d`.`alias_name`
99         AND
100             `d`.`domain_id` = `dmn`.`domain_id`
101     ";
102
103     $rs = exec_query($sql, $query, array($als_id));
104     if ($rs -> fields['ftpnum'] > 0 ) {
105         set_page_message(tr('Domain alias you are trying to remove has FTP accounts!<br>First remove them!'));
106         header('Location: domains_manage.php');
107         exit(0);
108     }
109
110     check_for_lock_file();
111
112     $query = "
113         UPDATE
114             `domain_aliasses`
115         SET
116             `alias_status` = 'delete'
117         WHERE
118             `alias_id` = ?
119     ";
120
121     $rs = exec_query($sql, $query, array($als_id));
122
123     send_request();
124     write_log($_SESSION['user_logged'].": delete alias ".$alias_name."!");
125     set_page_message(tr('Alias scheduled for deletion!'));
126     header('Location: domains_manage.php');
127     exit(0);
128 } else {
129     header('Location: domains_manage.php');
130     exit(0);
131 }
132
133 ?>
Note: See TracBrowser for help on using the browser.