commit | author | age
|
d02193
|
1 |
<?php |
T |
2 |
/* |
|
3 |
Copyright (c) 2012, Till Brehm, projektfarm Gmbh, ISPConfig UG |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
require_once('../../lib/config.inc.php'); |
|
31 |
require_once('../../lib/app.inc.php'); |
|
32 |
|
|
33 |
//* Check permissions for module |
|
34 |
$app->auth->check_module_permissions('admin'); |
|
35 |
|
|
36 |
//* This is only allowed for administrators |
|
37 |
if(!$app->auth->is_admin()) die('only allowed for administrators.'); |
|
38 |
|
|
39 |
$app->uses('tpl,validate_dns'); |
|
40 |
|
|
41 |
$app->tpl->newTemplate('form.tpl.htm'); |
|
42 |
$app->tpl->setInclude('content_tpl', 'templates/resync.htm'); |
|
43 |
$msg = ''; |
|
44 |
$error = ''; |
|
45 |
|
|
46 |
//* load language file |
|
47 |
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_resync.lng'; |
|
48 |
include($lng_file); |
|
49 |
$app->tpl->setVar($wb); |
|
50 |
|
|
51 |
//* Resyncing websites |
|
52 |
if(isset($_POST['resync_sites']) && $_POST['resync_sites'] == 1) { |
|
53 |
$db_table = 'web_domain'; |
|
54 |
$index_field = 'domain_id'; |
|
55 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
56 |
$records = $app->db->queryAllRecords($sql); |
|
57 |
if(is_array($records)) { |
|
58 |
foreach($records as $rec) { |
|
59 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
60 |
$msg .= "Resynced Website: ".$rec['domain'].'<br />'; |
|
61 |
} |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
//* Resyncing ftp |
|
66 |
if(isset($_POST['resync_ftp']) && $_POST['resync_ftp'] == 1) { |
|
67 |
$db_table = 'ftp_user'; |
|
68 |
$index_field = 'ftp_user_id'; |
|
69 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
70 |
$records = $app->db->queryAllRecords($sql); |
|
71 |
if(is_array($records)) { |
|
72 |
foreach($records as $rec) { |
|
73 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
74 |
$msg .= "Resynced FTP user: ".$rec['username'].'<br />'; |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
//* Resyncing shell |
|
80 |
if(isset($_POST['resync_shell']) && $_POST['resync_shell'] == 1) { |
|
81 |
$db_table = 'shell_user'; |
|
82 |
$index_field = 'shell_user_id'; |
|
83 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
84 |
$records = $app->db->queryAllRecords($sql); |
|
85 |
if(is_array($records)) { |
|
86 |
foreach($records as $rec) { |
|
87 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
88 |
$msg .= "Resynced Shell user: ".$rec['username'].'<br />'; |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
93 |
//* Resyncing Cronjobs |
|
94 |
if(isset($_POST['resync_cron']) && $_POST['resync_cron'] == 1) { |
|
95 |
$db_table = 'cron'; |
|
96 |
$index_field = 'id'; |
|
97 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
98 |
$records = $app->db->queryAllRecords($sql); |
|
99 |
if(is_array($records)) { |
|
100 |
foreach($records as $rec) { |
|
101 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
102 |
$msg .= "Resynced Cron: ".$rec['id'].'<br />'; |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
//* Resyncing Databases |
|
108 |
if(isset($_POST['resync_db']) && $_POST['resync_db'] == 1) { |
|
109 |
$db_table = 'web_database'; |
|
110 |
$index_field = 'database_id'; |
|
111 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
112 |
$records = $app->db->queryAllRecords($sql); |
|
113 |
if(is_array($records)) { |
|
114 |
foreach($records as $rec) { |
|
115 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
116 |
$msg .= "Resynced Database: ".$rec['database_name'].'<br />'; |
|
117 |
} |
|
118 |
} |
|
119 |
} |
|
120 |
|
3285d2
|
121 |
//* Resyncing Mailbox Domains |
T |
122 |
if(isset($_POST['resync_mailbox']) && $_POST['resync_mailbox'] == 1) { |
|
123 |
$db_table = 'mail_domain'; |
|
124 |
$index_field = 'domain_id'; |
|
125 |
$sql = "SELECT * FROM ".$db_table." WHERE active = 'y'"; |
|
126 |
$records = $app->db->queryAllRecords($sql); |
|
127 |
if(is_array($records)) { |
|
128 |
foreach($records as $rec) { |
|
129 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
130 |
$msg .= "Resynced Mail Domain: ".$rec['domain'].'<br />'; |
|
131 |
} |
|
132 |
} |
|
133 |
} |
|
134 |
|
d02193
|
135 |
//* Resyncing Mailboxes |
T |
136 |
if(isset($_POST['resync_mailbox']) && $_POST['resync_mailbox'] == 1) { |
|
137 |
$db_table = 'mail_user'; |
|
138 |
$index_field = 'mailuser_id'; |
af9f25
|
139 |
$sql = "SELECT * FROM ".$db_table; |
d02193
|
140 |
$records = $app->db->queryAllRecords($sql); |
T |
141 |
if(is_array($records)) { |
|
142 |
foreach($records as $rec) { |
|
143 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
144 |
$msg .= "Resynced Mailbox: ".$rec['email'].'<br />'; |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
//* Resyncing dns zones |
|
150 |
if(isset($_POST['resync_dns']) && $_POST['resync_dns'] == 1) { |
|
151 |
$zones = $app->db->queryAllRecords("SELECT id,origin,serial FROM dns_soa WHERE active = 'Y'"); |
|
152 |
if(is_array($zones) && !empty($zones)) { |
|
153 |
foreach($zones as $zone) { |
|
154 |
$records = $app->db->queryAllRecords("SELECT id,serial FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'"); |
|
155 |
if(is_array($records)) { |
|
156 |
foreach($records as $rec) { |
|
157 |
$new_serial = $app->validate_dns->increase_serial($rec["serial"]); |
|
158 |
$app->db->datalogUpdate('dns_rr', "serial = '".$new_serial."'", 'id', $rec['id']); |
|
159 |
|
|
160 |
} |
|
161 |
} |
|
162 |
$new_serial = $app->validate_dns->increase_serial($zone["serial"]); |
|
163 |
$app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone['id']); |
|
164 |
$msg .= "Resynced DNS zone: ".$zone['origin'].'<br />'; |
|
165 |
} |
|
166 |
} else { |
|
167 |
$error .= "No zones found to sync.<br />"; |
|
168 |
} |
|
169 |
|
|
170 |
} |
|
171 |
|
|
172 |
$app->tpl->setVar('msg',$msg); |
|
173 |
$app->tpl->setVar('error',$error); |
|
174 |
|
|
175 |
$app->tpl_defaults(); |
|
176 |
$app->tpl->pparse(); |
|
177 |
|
|
178 |
|
|
179 |
?> |