commit | author | age
|
25907a
|
1 |
<?php |
FS |
2 |
/* |
|
3 |
Copyright (c) 2014, Florian Schaal, info@schaal-24.de |
|
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 |
|
|
31 |
/****************************************** |
|
32 |
* Begin Form configuration |
|
33 |
******************************************/ |
|
34 |
|
|
35 |
$tform_def_file = 'form/resync.tform.php'; |
|
36 |
|
|
37 |
/****************************************** |
|
38 |
* End Form configuration |
|
39 |
******************************************/ |
|
40 |
|
|
41 |
require_once '../../lib/config.inc.php'; |
|
42 |
require_once '../../lib/app.inc.php'; |
|
43 |
|
|
44 |
//* Check permissions for module |
|
45 |
$app->auth->check_module_permissions('admin'); |
|
46 |
|
|
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
|
52 |
|
|
53 |
//* called during onShowEnd |
|
54 |
private function create_list($server_rec, $server_type, $search) { |
|
55 |
|
|
56 |
$server_count = 0; |
|
57 |
|
|
58 |
//* we allow multiple search-pattern - convert string to array |
|
59 |
if (!is_array($search)) { |
|
60 |
$_search = $search; |
|
61 |
$search=array(); |
|
62 |
$search[]=$_search; |
|
63 |
} |
|
64 |
|
|
65 |
foreach ($server_rec as $server) { |
|
66 |
//* check the database for existing records |
|
67 |
$server_data = $this->server_has_data($server_type, $server['server_id']); |
|
68 |
foreach ($search as $needle) |
|
69 |
if (in_array($needle, $server_data) && strpos($options_servers, $server['server_name']) === false) { |
|
70 |
$options_servers .= "<option value='$server[server_id]'>$server[server_name]</option>"; |
|
71 |
$server_count++; |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
return array($options_servers, $server_count); |
|
76 |
} |
|
77 |
|
|
78 |
//* called from create_list |
|
79 |
private function server_has_data($type, $server) { |
|
80 |
|
|
81 |
global $app; |
|
82 |
|
|
83 |
$server_id = $app->functions->intval($server); |
|
84 |
|
|
85 |
if($type == 'mail') { |
|
86 |
$server_data = array ( |
|
87 |
'mail_domain' => array ( |
|
88 |
'index_field' => 'domain_id', |
|
89 |
'server_type' => 'mail', |
5a990b
|
90 |
'server_id' => $server_id, |
25907a
|
91 |
), |
FS |
92 |
'mail_mailinglist' => array ( |
|
93 |
'index_field' => 'mailinglist_id', |
|
94 |
'server_type' => 'mail', |
5a990b
|
95 |
'server_id' => $server_id, |
25907a
|
96 |
), |
FS |
97 |
'mail_user' => array ( |
|
98 |
'index_field' => 'mailuser_id', |
|
99 |
'server_type' => 'mail', |
5a990b
|
100 |
'server_id' => $server_id, |
25907a
|
101 |
), |
FS |
102 |
); |
|
103 |
} |
|
104 |
if($type == 'mail_filter') { |
|
105 |
$server_data = array ( |
|
106 |
'mail_access' => array ( |
|
107 |
'index_field' => 'access_id', |
|
108 |
'server_type' => 'mail', |
5a990b
|
109 |
'server_id' => $server_id, |
25907a
|
110 |
), |
FS |
111 |
'mail_content_filter' => array ( |
|
112 |
'index_field' => 'content_filter_id', |
|
113 |
'server_type' => 'mail', |
|
114 |
), |
|
115 |
'mail_user_filter' => array ( |
|
116 |
'index_field' => 'filter_id', |
|
117 |
'server_type' => 'mail', |
|
118 |
), |
|
119 |
); |
|
120 |
} |
|
121 |
if($type == 'web' ) { |
|
122 |
$server_data = array ( |
|
123 |
'web_domain' => array ( |
|
124 |
'index_field' => 'domain_id', |
|
125 |
'server_type' => 'web', |
5a990b
|
126 |
'server_id' => $server_id, |
25907a
|
127 |
), |
FS |
128 |
'shell_user' => array ( |
|
129 |
'index_field' => 'shell_user_id', |
|
130 |
'server_type' => 'web', |
5a990b
|
131 |
'server_id' => $server_id, |
25907a
|
132 |
), |
FS |
133 |
'cron' => array ( |
|
134 |
'index_field' => 'id', |
|
135 |
'server_type' => 'cron', |
5a990b
|
136 |
'server_id' => $server_id, |
25907a
|
137 |
), |
FS |
138 |
'ftp_user' => array ( |
|
139 |
'index_field' => 'ftp_user_id', |
|
140 |
'server_type' => 'web', |
5a990b
|
141 |
'server_id' => $server_id, |
25907a
|
142 |
), |
FS |
143 |
); |
|
144 |
} |
|
145 |
if($type == 'dns' ) { |
|
146 |
$server_data = array ( |
|
147 |
'dns_soa' => array ( |
|
148 |
'index_field' => 'id', |
|
149 |
'server_type' => 'dns', |
5a990b
|
150 |
'server_id' => $server_id, |
25907a
|
151 |
), |
FS |
152 |
); |
|
153 |
} |
|
154 |
if($type == 'file' ) { |
|
155 |
$server_data = array ( |
|
156 |
'webdav_user' => array ( |
|
157 |
'index_field' => 'webdav_user_id', |
|
158 |
'server_type' => 'file', |
5a990b
|
159 |
'server_id' => $server_id, |
25907a
|
160 |
), |
FS |
161 |
); |
|
162 |
} |
|
163 |
if($type == 'db' ) { |
|
164 |
$server_data = array ( |
|
165 |
'web_database' => array ( |
|
166 |
'index_field' => 'web_database_id', |
|
167 |
'server_type' => 'db', |
5a990b
|
168 |
'server_id' => $server_id, |
25907a
|
169 |
), |
FS |
170 |
); |
|
171 |
} |
|
172 |
if($type == 'vserver' ) { |
|
173 |
$server_data = array ( |
|
174 |
'openvz_vm' => array ( |
|
175 |
'index_field' => 'vm_id', |
|
176 |
'server_type' => 'vserver', |
5a990b
|
177 |
'server_id' => $server_id, |
25907a
|
178 |
), |
FS |
179 |
); |
|
180 |
} |
|
181 |
//* proxy |
|
182 |
//* firewall |
|
183 |
$array_out = array(); |
|
184 |
foreach($server_data as $db_table => $data) { |
cc7a82
|
185 |
$sql = @(isset($data['server_id']))?"SELECT * FROM ?? WHERE server_id = ":"SELECT * FROM ??"; |
MC |
186 |
$records = $app->db->queryAllRecords($sql, $db_table, $server_id); |
25907a
|
187 |
if (!empty($records)) array_push($array_out, $db_table); |
FS |
188 |
} |
|
189 |
|
|
190 |
return $array_out; |
|
191 |
} |
|
192 |
|
|
193 |
function onShowEnd() { |
|
194 |
global $app; |
|
195 |
|
|
196 |
//* fetch all-server |
|
197 |
$server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
198 |
$server_count = 0; |
|
199 |
foreach ($server_rec as $server) { |
|
200 |
$options_servers .= "<option value='$server[server_id]'>$server[server_name]</option>"; |
|
201 |
$server_count++; |
|
202 |
} |
|
203 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_txt']."</option>" . $options_servers; |
|
204 |
$app->tpl->setVar('all_server_id', $options_servers); |
|
205 |
unset($options_servers); |
|
206 |
|
|
207 |
//* fetch mail-server |
|
208 |
$mail_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE mail_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
209 |
if (!empty($mail_server_rec)) { |
|
210 |
$app->tpl->setVar('mail_server_found', 1); |
|
211 |
|
|
212 |
//* mail-domain |
|
213 |
$server_list = $this->create_list($mail_server_rec, 'mail', 'mail_domain'); |
|
214 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
215 |
unset($server_list); |
|
216 |
if (isset($options_servers)) { //* server with data found |
|
217 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_mail_txt']."</option>" . $options_servers; |
|
218 |
$app->tpl->setVar('mail_server_id', $options_servers); |
|
219 |
$app->tpl->setVar('mail_domain_found', 1); |
|
220 |
unset($options_servers); |
|
221 |
} |
|
222 |
|
|
223 |
//* mailbox |
|
224 |
$server_list = $this->create_list($mail_server_rec, 'mail', 'mail_user'); |
|
225 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
226 |
unset($server_list); |
|
227 |
if (isset($options_servers)) { //* server with data found |
|
228 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_mail_txt']."</option>" . $options_servers; |
|
229 |
$app->tpl->setVar('mailbox_server_id', $options_servers); |
|
230 |
$app->tpl->setVar('mail_user_found', 1); |
|
231 |
unset($options_servers); |
|
232 |
} |
|
233 |
|
|
234 |
//* mailfilter |
|
235 |
$server_list = $this->create_list($mail_server_rec, 'mail_filter', array('mail_access', 'mail_content_filter', 'mail_user_filter')); |
|
236 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
237 |
unset($server_list); |
|
238 |
if (isset($options_servers)) { //* server with data found |
|
239 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_mail_txt']."</option>" . $options_servers; |
|
240 |
$app->tpl->setVar('mailfilter_server_id', $options_servers); |
|
241 |
$app->tpl->setVar('mail_filter_found', 1); |
|
242 |
unset($options_servers); |
|
243 |
} |
|
244 |
|
|
245 |
//* mailinglist |
|
246 |
$server_list = $this->create_list($mail_server_rec, 'mail', 'mail_mailinglist'); |
|
247 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
248 |
unset($server_list); |
|
249 |
if (isset($options_servers)) { //* server with data found |
|
250 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_mail_txt']."</option>" . $options_servers; |
|
251 |
$app->tpl->setVar('mailinglist_server_id', $options_servers); |
|
252 |
$app->tpl->setVar('mailinglist_found', 1); |
|
253 |
unset($options_servers); |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
//* fetch web-server |
|
258 |
$web_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE web_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
259 |
if (!empty($web_server_rec)) { |
|
260 |
$app->tpl->setVar('web_server_found', 1); |
|
261 |
|
|
262 |
//* web-domain |
|
263 |
$server_list = $this->create_list($web_server_rec, 'web', 'web_domain'); |
|
264 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
265 |
unset($server_list); |
|
266 |
if (isset($options_servers)) { //* server with data found |
|
267 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_web_txt']."</option>" . $options_servers; |
|
268 |
$app->tpl->setVar('web_server_id', $options_servers); |
|
269 |
$app->tpl->setVar('web_domain_found', 1); |
|
270 |
unset($options_servers); |
|
271 |
} |
|
272 |
|
|
273 |
//* ftp-user |
|
274 |
$server_list = $this->create_list($web_server_rec, 'web', 'ftp_user'); |
|
275 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
276 |
unset($server_list); |
|
277 |
if (isset($options_servers)) { //* server with data found |
|
278 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_web_txt']."</option>" . $options_servers; |
|
279 |
$app->tpl->setVar('ftp_server_id', $options_servers); |
|
280 |
$app->tpl->setVar('ftp_user_found', 1); |
|
281 |
unset($options_servers); |
|
282 |
} |
|
283 |
|
|
284 |
//* shell-user |
|
285 |
$server_list = $this->create_list($web_server_rec, 'web', 'shell_user'); |
|
286 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
287 |
unset($server_list); |
|
288 |
if (isset($options_servers)) { //* server with data found |
|
289 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_web_txt']."</option>" . $options_servers; |
|
290 |
$app->tpl->setVar('shell_server_id', $options_servers); |
|
291 |
$app->tpl->setVar('shell_user_found', 1); |
|
292 |
unset($options_servers); |
|
293 |
} |
|
294 |
|
|
295 |
//* cron |
|
296 |
$server_list = $this->create_list($web_server_rec, 'web', 'cron'); |
|
297 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
298 |
unset($server_list); |
|
299 |
if (isset($options_servers)) { //* server with data found |
|
300 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_web_txt']."</option>" . $options_servers; |
|
301 |
$app->tpl->setVar('cron_server_id', $options_servers); |
|
302 |
$app->tpl->setVar('cron_found', 1); |
|
303 |
unset($options_servers); |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
//* fetch dns-server |
|
308 |
$dns_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE dns_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
309 |
if (!empty($dns_server_rec)) { |
|
310 |
$app->tpl->setVar('dns_server_found', 1); |
|
311 |
|
|
312 |
$server_list = $this->create_list($dns_server_rec, 'dns', 'dns_soa'); |
|
313 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
314 |
unset($server_list); |
|
315 |
if (isset($options_servers)) { //* server with data found |
|
316 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_dns_txt']."</option>" . $options_servers; |
|
317 |
$app->tpl->setVar('dns_server_id', $options_servers); |
|
318 |
$app->tpl->setVar('dns_soa_found', 1); |
|
319 |
unset($options_servers); |
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
//* fetch webdav-user |
|
324 |
$file_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE file_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
325 |
if (!empty($file_server_rec)) { |
|
326 |
$app->tpl->setVar('file_server_found', 1); |
|
327 |
|
|
328 |
$server_list = $this->create_list($file_server_rec, 'file', 'webdav_user'); |
|
329 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
330 |
unset($server_list); |
|
331 |
if (isset($options_servers)) { //* server with data found |
|
332 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_file_txt']."</option>" . $options_servers; |
|
333 |
$app->tpl->setVar('file_server_id', $options_servers); |
|
334 |
$app->tpl->setVar('webdav_user_found', 1); |
|
335 |
unset($options_servers); |
|
336 |
} |
|
337 |
} |
|
338 |
|
|
339 |
//* fetch database-server |
|
340 |
$db_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE db_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
341 |
if (!empty($db_server_rec)) { |
|
342 |
$app->tpl->setVar('db_server_found', 1); |
|
343 |
|
|
344 |
$server_list = $this->create_list($db_server_rec, 'db', 'web_database'); |
|
345 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
346 |
unset($server_list); |
|
347 |
if (isset($options_servers)) { //* server with data found |
|
348 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_db_txt']."</option>" . $options_servers; |
|
349 |
$app->tpl->setVar('db_server_id', $options_servers); |
|
350 |
$app->tpl->setVar('client_db_found', 1); |
|
351 |
unset($options_servers); |
|
352 |
} |
|
353 |
} |
|
354 |
|
|
355 |
//* fetch vserver |
|
356 |
$v_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE vserver_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); |
|
357 |
if (!empty($db_server_rec)) { |
|
358 |
$app->tpl->setVar('vserver_server_found', 1); |
|
359 |
|
|
360 |
$server_list = $this->create_list($v_server_rec, 'vserver', 'openvz_vm'); |
|
361 |
$options_servers = $server_list[0];$server_count = $server_list[1]; |
|
362 |
unset($server_list); |
|
363 |
if (isset($options_servers)) { //* server with data found |
|
364 |
if ($server_count > 1) $options_servers = "<option value='0'>".$app->tform->wordbook['all_active_vserver_txt']."</option>" . $options_servers; |
|
365 |
$app->tpl->setVar('vserver_server_id', $options_servers); |
|
366 |
$app->tpl->setVar('vserver_found', 1); |
|
367 |
unset($options_servers); |
|
368 |
} |
|
369 |
} |
|
370 |
|
|
371 |
parent::onShowEnd(); |
|
372 |
} |
|
373 |
|
|
374 |
//* fetch values during do_resync |
5a990b
|
375 |
private function query_server($db_table, $server_id, $server_type, $active=true, $opt='') { |
25907a
|
376 |
global $app; |
FS |
377 |
|
|
378 |
$server_name = array(); |
|
379 |
if ( $server_id == 0 ) { //* resync multiple server |
cc7a82
|
380 |
$temp = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE ?? = 1 AND active = 1 AND mirror_server_id = 0", $server_type."_server"); |
25907a
|
381 |
foreach ($temp as $server) { |
FS |
382 |
$temp_id .= $server['server_id'].','; |
|
383 |
$server_name[$server['server_id']] = $server['server_name']; |
|
384 |
} |
|
385 |
} else { |
|
386 |
$temp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $server_id); |
|
387 |
$server_name[$server_id] = $temp['server_name']; |
|
388 |
} |
|
389 |
unset($temp); |
|
390 |
|
|
391 |
if ( isset($temp_id) ) $server_id = rtrim($temp_id,','); |
cc7a82
|
392 |
$sql = "SELECT * FROM ??"; |
c93956
|
393 |
if ($db_table != "mail_user_filter") $sql .= " WHERE server_id IN (".$server_id.") "; |
FS |
394 |
$sql .= $opt; |
25907a
|
395 |
if ($active) $sql .= " AND active = 'y'"; |
cc7a82
|
396 |
$records = $app->db->queryAllRecords($sql, $db_table); |
25907a
|
397 |
|
FS |
398 |
return array($records, $server_name); |
|
399 |
} |
|
400 |
|
|
401 |
private function do_resync($db_table, $index_field, $server_type, $server_id, $msg_field, $wordbook, $active=true) { |
|
402 |
global $app; |
|
403 |
|
|
404 |
$server_id = $app->functions->intval($server_id); |
|
405 |
$rec = $this->query_server($db_table, $server_id, $server_type, $active); |
|
406 |
$records = $rec[0]; |
|
407 |
$server_name = $rec[1]; |
|
408 |
$msg = '<b>'.$wordbook.'</b><br>'; |
|
409 |
if(!empty($records)) |
|
410 |
foreach($records as $rec) { |
|
411 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
c93956
|
412 |
if(!empty($rec[$msg_field])) $msg .= '['.$server_name[$rec['server_id']].'] '.$rec[$msg_field].'<br>'; |
25907a
|
413 |
} |
FS |
414 |
else $msg .= $app->tform->wordbook['no_results_txt'].'<br>'; |
|
415 |
|
|
416 |
return $msg.'<br>'; |
|
417 |
} |
|
418 |
|
|
419 |
function onSubmit() { |
|
420 |
global $app; |
|
421 |
|
|
422 |
//* all services |
|
423 |
if($this->dataRecord['resync_all'] == 1) { |
|
424 |
$this->dataRecord['resync_sites'] = 1; |
|
425 |
$this->dataRecord['resync_ftp'] = 1; |
|
426 |
$this->dataRecord['resync_webdav'] = 1; |
|
427 |
$this->dataRecord['resync_shell'] = 1; |
|
428 |
$this->dataRecord['resync_cron'] = 1; |
|
429 |
$this->dataRecord['resync_db'] = 1; |
|
430 |
$this->dataRecord['resync_mail'] = 1; |
|
431 |
$this->dataRecord['resync_mailbox'] = 1; |
|
432 |
$this->dataRecord['resync_mailfilter'] = 1; |
|
433 |
$this->dataRecord['resync_mailinglist'] = 1; |
|
434 |
$this->dataRecord['resync_vserver'] = 1; |
|
435 |
$this->dataRecord['resync_dns'] = 1; |
|
436 |
$this->dataRecord['resync_client'] = 1; |
|
437 |
$this->dataRecord['web_server_id'] = $this->dataRecord['all_server_id']; |
|
438 |
$this->dataRecord['ftp_server_id'] = $this->dataRecord['all_server_id']; |
|
439 |
$this->dataRecord['webdav_server_id'] = $this->dataRecord['all_server_id']; |
|
440 |
$this->dataRecord['shell_server_id'] = $this->dataRecord['all_server_id']; |
|
441 |
$this->dataRecord['cron_server_id'] = $this->dataRecord['all_server_id']; |
|
442 |
$this->dataRecord['db_server_id'] = $this->dataRecord['all_server_id']; |
|
443 |
$this->dataRecord['mail_server_id'] = $this->dataRecord['all_server_id']; |
|
444 |
$this->dataRecord['mailbox_server_id'] = $this->dataRecord['all_server_id']; |
|
445 |
$this->dataRecord['verserver_server_id'] = $this->dataRecord['all_server_id']; |
|
446 |
$this->dataRecord['dns_server_id'] = $this->dataRecord['all_server_id']; |
|
447 |
} |
|
448 |
|
|
449 |
//* websites |
|
450 |
if($this->dataRecord['resync_sites'] == 1) |
|
451 |
$msg .= $this->do_resync('web_domain', 'domain_id', 'web', $this->dataRecord['web_server_id'], 'domain', $app->tform->wordbook['do_sites_txt']); |
|
452 |
|
|
453 |
//* ftp |
|
454 |
if($this->dataRecord['resync_ftp'] == 1) |
|
455 |
$msg .= $this->do_resync('ftp_user', 'ftp_user_id', 'web', $this->dataRecord['ftp_server_id'], 'username', $app->tform->wordbook['do_ftp_txt']); |
|
456 |
|
|
457 |
//* webdav |
|
458 |
if($this->dataRecord['resync_webdav'] == 1) |
|
459 |
$msg .= $this->do_resync('webdav_user', 'webdav_user_id', 'file', $this->dataRecord['webdav_server_id'], 'username', $app->tform->wordbook['do_webdav_txt']); |
|
460 |
|
|
461 |
//* shell |
|
462 |
if($this->dataRecord['resync_shell'] == 1) |
|
463 |
$msg .= $this->do_resync('shell_user', 'shell_user_id', 'web', $this->dataRecord['shell_server_id'], 'username', $app->tform->wordbook['do_shell_txt']); |
|
464 |
|
|
465 |
//* cron |
|
466 |
if($this->dataRecord['resync_cron'] == 1) |
|
467 |
$msg .= $this->do_resync('cron', 'id', 'web', $this->dataRecord['cron_server_id'], 'command', $app->tform->wordbook['do_cron_txt']); |
|
468 |
|
|
469 |
//* database |
|
470 |
if(isset($this->dataRecord['resync_db']) && $this->dataRecord['resync_db'] == 1) { |
e5ac71
|
471 |
$msg .= $this->do_resync('web_database_user', 'database_user_id', 'db', $this->dataRecord['db_server_id'], 'database_user', $app->tform->wordbook['do_db_user_txt'], false); |
25907a
|
472 |
$msg .= $this->do_resync('web_database', 'database_id', 'db', $this->dataRecord['db_server_id'], 'database_name', $app->tform->wordbook['do_db_txt']); |
FS |
473 |
} |
|
474 |
|
|
475 |
//* maildomains |
|
476 |
if($this->dataRecord['resync_mail'] == 1) |
|
477 |
$msg .= $this->do_resync('mail_domain', 'domain_id', 'mail', $this->dataRecord['mail_server_id'], 'domain', $app->tform->wordbook['do_mail_txt']); |
|
478 |
|
|
479 |
//* mailbox |
|
480 |
if($this->dataRecord['resync_mailbox'] == 1) { |
|
481 |
$msg .= $this->do_resync('mail_user', 'mailuser_id', 'mail', $this->dataRecord['mailbox_server_id'], 'email', $app->tform->wordbook['do_mailbox_txt'], false); |
|
482 |
$msg .= $this->do_resync('mail_forwarding', 'forwarding_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_alias_txt']); |
|
483 |
} |
|
484 |
|
|
485 |
//* mailfilter |
|
486 |
if($this->dataRecord['resync_mailfilter'] == 1) { |
|
487 |
$msg .= $this->do_resync('mail_access', 'access_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_access_txt']); |
|
488 |
$msg .= $this->do_resync('mail_content_filter', 'content_filter_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_contentfilter_txt']); |
|
489 |
$msg .= $this->do_resync('mail_user_filter', 'filter_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_userfilter_txt'], false); |
|
490 |
} |
|
491 |
|
|
492 |
//* mailinglists |
|
493 |
if($this->dataRecord['resync_mailinglist'] == 1) |
|
494 |
$msg .= $this->do_resync('mail_mailinglist', 'mailinglist_id', 'mail', $this->dataRecord['mail_server_id'], 'listname', $app->tform->wordbook['do_mailinglist_txt'], false); |
|
495 |
|
|
496 |
//* vserver |
|
497 |
if($this->dataRecord['resync_vserver'] == 1) |
|
498 |
$msg .= $this->do_resync('openvz_vm', 'vm_id', 'vserver', $this->dataRecord['verserver_server_id'], 'hostname', $app->tform->wordbook['do_vserver_txt']); |
|
499 |
|
|
500 |
//* dns |
|
501 |
if($this->dataRecord['resync_dns'] == 1) { |
|
502 |
$rec=$this->query_server('dns_soa', $this->dataRecord['dns_server_id'], 'dns'); |
|
503 |
$soa_records = $rec[0]; |
|
504 |
$server_name = $rec[1]; |
|
505 |
unset($rec); |
|
506 |
$msg .= '<b>'.$app->tform->wordbook['do_dns_txt'].'</b><br>'; |
|
507 |
if(is_array($soa_records) && !empty($soa_records)) |
|
508 |
foreach($soa_records as $soa_rec) { |
5a990b
|
509 |
$temp = $this->query_server('dns_rr', $soa_rec['server_id'], 'dns', true, "AND zone = ".$app->functions->intval($soa_rec['id'])); |
25907a
|
510 |
$rr_records = $temp[0]; |
FS |
511 |
if(!empty($rr_records)) { |
|
512 |
foreach($rr_records as $rec) { |
|
513 |
$new_serial = $app->validate_dns->increase_serial($rec['serial']); |
3a11d2
|
514 |
$app->db->datalogUpdate('dns_rr', array("serial" => $new_serial), 'id', $rec['id']); |
25907a
|
515 |
} |
FS |
516 |
} else { |
|
517 |
$msg .= $app->tform->wordbook['no_results_txt'].'<br>'; |
|
518 |
} |
|
519 |
$new_serial = $app->validate_dns->increase_serial($soa_rec['serial']); |
3a11d2
|
520 |
$app->db->datalogUpdate('dns_soa', array("serial" => $new_serial), 'id', $soa_rec['id']); |
5a990b
|
521 |
$msg .= '['.$server_name[$soa_rec['server_id']].'] '.$soa_rec['origin'].' ('.count($rr_records).')<br>'; |
25907a
|
522 |
} |
FS |
523 |
else $msg .= $app->tform->wordbook['no_results_txt'].'<br>'; |
|
524 |
|
|
525 |
$msg .= '<br>'; |
|
526 |
} |
|
527 |
|
|
528 |
//* clients |
|
529 |
if($this->dataRecord['resync_client'] == 1) { |
|
530 |
$db_table = 'client'; |
|
531 |
$index_field = 'client_id'; |
cc7a82
|
532 |
$records = $app->db->queryAllRecords("SELECT * FROM ??", $db_table); |
25907a
|
533 |
$msg .= '<b>'.$app->tform->wordbook['do_clients_txt'].'</b><br>'; |
FS |
534 |
if(!empty($records)) { |
|
535 |
$tform_def_file = '../client/form/client.tform.php'; |
|
536 |
$app->uses('tpl,tform,tform_actions'); |
|
537 |
$app->load('tform_actions'); |
|
538 |
foreach($records as $rec) { |
|
539 |
$app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); |
|
540 |
$tmp = new tform_actions; |
|
541 |
$tmp->id = $rec[$index_field]; |
|
542 |
$tmp->dataRecord = $rec; |
|
543 |
$tmp->oldDataRecord = $rec; |
|
544 |
$app->plugin->raiseEvent('client:client:on_after_update', $tmp); |
|
545 |
$msg .= $rec['contact_name'].'<br>'; |
|
546 |
unset($tmp); |
|
547 |
} |
|
548 |
} else { |
|
549 |
$msg .= $app->tform->wordbook['no_results_txt'].'<br>'; |
|
550 |
} |
|
551 |
$msg .= '<br>'; |
|
552 |
} |
|
553 |
|
|
554 |
echo $msg; |
|
555 |
} //* end onSumbmit |
|
556 |
|
|
557 |
} |
|
558 |
|
|
559 |
$page = new page_action; |
|
560 |
$page->onLoad(); |
|
561 |
?> |