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