Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
73813a 1 <?php
MC 2
3 /*
4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /******************************************
32 * Begin Form configuration
33 ******************************************/
34
35 $list_def_file = "list/web_vhost_domain.list.php";
36 $tform_def_file = "form/web_vhost_domain.tform.php";
37
38 /******************************************
39 * End Form configuration
40 ******************************************/
41
42 require_once '../../lib/config.inc.php';
43 require_once '../../lib/app.inc.php';
44
45 //* Check permissions for module
46 $app->auth->check_module_permissions('sites');
47
48 $app->uses('tpl,tform,tform_actions');
49 $app->load('tform_actions');
50
51 //* Get and set the vhost domain type - store in session
52 $show_type = 'domain';
53 if(isset($_GET['type']) && $_GET['type'] == 'subdomain') {
54     $show_type = 'subdomain';
55 } elseif(isset($_GET['type']) && $_GET['type'] == 'aliasdomain') {
56     $show_type = 'aliasdomain';
57 } elseif(!isset($_GET['type']) && isset($_SESSION['s']['var']['vhostdomain_type']) && $_SESSION['s']['var']['vhostdomain_type'] == 'subdomain') {
58     $show_type = 'subdomain';
59 } elseif(!isset($_GET['type']) && isset($_SESSION['s']['var']['vhostdomain_type']) && $_SESSION['s']['var']['vhostdomain_type'] == 'aliasdomain') {
60     $show_type = 'aliasdomain';
61 }
62
63 $_SESSION['s']['var']['vhostdomain_type'] = $show_type;
64
65
66 class page_action extends tform_actions {
67
68     function onBeforeDelete() {
69         global $app; $conf;
70
71         if($_SESSION['s']['var']['vhostdomain_type'] == 'domain') {
72             if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission'));
73
74             //* Delete all records that belong to this web.
2af58c 75             $records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE parent_domain_id = ? AND type != 'vhost'", $this->id);
73813a 76             foreach($records as $rec) {
MC 77                 $app->db->datalogDelete('web_domain', 'domain_id', $rec['domain_id']);
78             }
79
80             //* Delete all records that belong to this web.
2af58c 81             $records = $app->db->queryAllRecords("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = ?", $this->id);
73813a 82             foreach($records as $rec) {
MC 83                 $app->db->datalogDelete('ftp_user', 'ftp_user_id', $rec['ftp_user_id']);
84             }
85
86             //* Delete all records that belong to this web.
2af58c 87             $records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = ?", $this->id);
73813a 88             foreach($records as $rec) {
MC 89                 $app->db->datalogDelete('shell_user', 'shell_user_id', $rec['shell_user_id']);
90             }
91
92             //* Delete all records that belong to this web.
2af58c 93             $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = ?", $this->id);
73813a 94             foreach($records as $rec) {
MC 95                 $app->db->datalogDelete('cron', 'id', $rec['id']);
96             }
97
98             //* Delete all records that belong to this web
2af58c 99             $records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = ?", $this->id);
73813a 100             foreach($records as $rec) {
MC 101                 $app->db->datalogDelete('webdav_user', 'webdav_user_id', $rec['webdav_user_id']);
102             }
103
104             //* Delete all records that belong to this web
2af58c 105             $records = $app->db->queryAllRecords("SELECT backup_id FROM web_backup WHERE parent_domain_id = ?", $this->id);
73813a 106             foreach($records as $rec) {
MC 107                 $app->db->datalogDelete('web_backup', 'backup_id', $rec['backup_id']);
108             }
109
110             //* Delete all records that belog to this web.
2af58c 111             $web_domain = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $this->id);
73813a 112             if($web_domain['domain'] != ''){
2af58c 113                 $aps_instances = $app->db->queryAllRecords("SELECT instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = ?", $web_domain['domain']);
73813a 114                 if(is_array($aps_instances) && !empty($aps_instances)){
MC 115                     foreach($aps_instances as $aps_instance){
116                         if($aps_instance['instance_id'] > 0){
117                             $app->db->datalogDelete('aps_instances_settings', 'instance_id', $aps_instance['instance_id']);
118                             $app->db->datalogDelete('aps_instances', 'id', $aps_instance['instance_id']);
119                         }
120                     }
121                 }
122             }
123         }
124
125         //* Delete all web folders
2af58c 126         $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = ?", $this->id);
73813a 127         foreach($records as $rec) {
MC 128             //* Delete all web folder users
2af58c 129             $records2 = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = ?", $rec['web_folder_id']);
73813a 130             foreach($records2 as $rec2) {
MC 131                 $app->db->datalogDelete('web_folder_user', 'web_folder_user_id', $rec2['web_folder_user_id']);
132             }
133             $app->db->datalogDelete('web_folder', 'web_folder_id', $rec['web_folder_id']);
134         }
135     }
136
137 }
138
139 $page = new page_action;
140 $page->onDelete();
141
142 ?>