root/trunk/gui/client/mail_delete.php

Revision 1412, 4.0 kB (checked in by scitech, 8 hours ago)

Fixed #1518: Virtual mail problem. Add support for alias subdomain mail (part I)

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     global $delete_id;
27     $delete_id = $_GET['id'];
28 } else {
29     user_goto('mail_accounts.php');
30 }
31
32 /* do we have a proper delete_id ? */
33 if (!isset($delete_id)) {
34     header("Location: mail_accounts.php");
35     die();
36 }
37
38 if (!is_numeric($delete_id)) {
39     header("Location: mail_accounts.php");
40     die();
41 }
42
43 $dmn_name = $_SESSION['user_logged'];
44
45 $query = "
46     SELECT
47         t1.mail_id, t2.domain_id, t2.domain_name
48     FROM
49         mail_users AS t1,
50         domain AS t2
51     WHERE
52         t1.mail_id = ?
53     AND
54         t1.domain_id = t2.domain_id
55     AND
56         t2.domain_name = ?
57 ";
58
59 $rs = exec_query($sql, $query, array($delete_id, $dmn_name));
60 if ($rs->RecordCount() == 0) {
61     user_goto('mail_accounts.php');
62 }
63
64 /* check for catchall assigment !! */
65 $query = "SELECT mail_acc, domain_id, sub_id, mail_type FROM mail_users WHERE mail_id=?";
66 $res = exec_query($sql, $query, array($delete_id));
67 $data = $res->FetchRow();
68
69 if (preg_match("/".MT_NORMAL_MAIL."/", $data['mail_type']) || preg_match("/".MT_NORMAL_FORWARD."/", $data['mail_type'])) {
70     /* mail to normal domain */
71     // global $domain_name;
72     $mail_name = $data['mail_acc'] . '@' . $_SESSION['user_logged']; //$domain_name;
73 } else if (preg_match("/".MT_ALIAS_MAIL."/", $data['mail_type']) || preg_match("/".MT_ALIAS_FORWARD."/", $data['mail_type'])) {
74     /* mail to domain alias*/
75     $res_tmp = exec_query($sql, "SELECT alias_name FROM domain_aliasses WHERE alias_id=?", array($data['sub_id']));
76     $dat_tmp = $res_tmp->FetchRow();
77     $mail_name = $data['mail_acc'] . '@' . $dat_tmp['alias_name'];
78 } else if (preg_match("/".MT_SUBDOM_MAIL."/", $data['mail_type']) || preg_match("/".MT_SUBDOM_FORWARD."/", $data['mail_type'])) {
79     /* mail to subdomain*/
80     $res_tmp = exec_query($sql, "SELECT subdomain_name FROM subdomain WHERE subdomain_id=?", array($data['sub_id']));
81     $dat_tmp = $res_tmp->FetchRow();
82     $mail_name = $data['mail_acc'] . '@' . $dat_tmp['subdomain_name'].'.'.$dmn_name;
83 } else if (preg_match("/".MT_ALSSUB_MAIL."/", $data['mail_type']) || preg_match("/".MT_ALSSUB_FORWARD."/", $data['mail_type'])) {
84     /* mail to subdomain*/
85     $res_tmp = exec_query($sql, "SELECT subdomain_alias_name, alias_name FROM subdomain_alias AS t1, domain_aliasses AS t2 WHERE t1.alias_id=t2.alias_id AND subdomain_alias_id=?", array($data['sub_id']));
86     $dat_tmp = $res_tmp->FetchRow();
87     $mail_name = $data['mail_acc'] . '@' . $dat_tmp['subdomain_alias_name'].'.'.$dat_tmp['alias_name'];
88 }
89
90 $query = "SELECT `mail_id` FROM `mail_users` WHERE `mail_acc`=? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ? OR `mail_acc` LIKE ?";
91 $res_tmp = exec_query($sql, $query, array($mail_name, "$mail_name,%", "%,$mail_name,%", "%,$mail_name"));
92 $num = $res_tmp->RowCount();
93 if ($num > 0) {
94     $catchall_assigned = 1;
95     set_page_message(tr('Please delete first CatchAll account for this email!'));
96     session_register("catchall_assigned");
97     header("Location: mail_accounts.php");
98     die();
99 }
100 /* if we are locket wait to unlock */
101 check_for_lock_file();
102
103 $query = "UPDATE mail_users SET status='" . Config::get('ITEM_DELETE_STATUS') . "' WHERE mail_id = ?";
104 exec_query($sql, $query, array($delete_id));
105
106 send_request();
107 $admin_login = decode_idna($_SESSION['user_logged']);
108 write_log("$admin_login: deletes mail account: " . $mail_name);
109 $maildel = 1;
110 session_register("maildel");
111 header("Location: mail_accounts.php");
112 die();
113
114 ?>
Note: See TracBrowser for help on using the browser.