root/trunk/gui/admin/ispcp_debugger.php

Revision 1327, 13.8 kB (checked in by rats, 4 months ago)

* Fixed: --scan-knownbad-files and --check-deleted are no longer supported by rkhunter
* Fixed #1471: chkrootkit should be in lenny / hardy
* Updated Chinese (simplified)
* Updated German
* Fixed #1475: typo on installation (ispcp-setup)
* Fixed: default user for rkhunter.log

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 function count_requests(&$sql, $id_name, $table){
26     $query = "select `$id_name` FROM `$table` WHERE `$id_name` NOT IN (?, ?, ?)";
27     $rs = exec_query($sql, $query, array(Config::get('ITEM_OK_STATUS'), Config::get('ITEM_DISABLED_STATUS'), Config::get('ITEM_ORDERED_STATUS')));
28     $count = $rs->RecordCount();
29     return $count;
30 }
31
32 function get_error_domains(&$sql, &$tpl) {
33     $ok_status = Config::get('ITEM_OK_STATUS');
34     $disabled_status = Config::get('ITEM_DISABLED_STATUS');
35     $delete_status = Config::get('ITEM_DELETE_STATUS');
36     $add_status = Config::get('ITEM_ADD_STATUS');
37     $restore_status = Config::get('ITEM_RESTORE_STATUS');
38     $change_status = Config::get('ITEM_CHANGE_STATUS');
39     $toenable_status = Config::get('ITEM_TOENABLE_STATUS');
40     $todisable_status = Config::get('ITEM_TODISABLED_STATUS');
41
42     $dmn_query = <<<SQL_QUERY
43         select
44             domain_name, domain_status, domain_id
45         from
46             domain
47         where
48             (domain_status != ?
49           and
50             domain_status != ?
51           and
52             domain_status != ?
53           and
54             domain_status != ?
55           and
56             domain_status != ?
57           and
58             domain_status != ?
59           and
60             domain_status != ?
61           and
62             domain_status != ?)
63 SQL_QUERY;
64
65     $rs = exec_query($sql, $dmn_query, array($ok_status, $disabled_status, $delete_status, $add_status,
66             $restore_status, $change_status, $toenable_status, $todisable_status));
67
68     if ($rs->RecordCount() == 0) {
69         $tpl->assign(
70                 array(
71                     'DOMAIN_LIST' => '',
72                     'TR_DOMAIN_MESSAGE' => tr('No domain system errors'),
73                     )
74             );
75
76         $tpl->parse('DOMAIN_MESSAGE', 'domain_message');
77     } else {
78         $i = 1;
79         while (!$rs->EOF) {
80             if ($i % 2 == 0) {
81                 $tpl->assign(
82                         array(
83                             'CONTENT' => 'content2',
84                             )
85                     );
86             } else {
87                 $tpl->assign(
88                         array(
89                             'CONTENT' => 'content1',
90                             )
91                     );
92             }
93
94             $tpl->assign(
95                     array(
96                         'DOMAIN_MESSAGE' => '',
97                         'TR_DOMAIN_NAME' => $rs->fields['domain_name'],
98                         'TR_DOMAIN_ERROR' => $rs->fields['domain_status'],
99                         'CHANGE_ID' => $rs->fields['domain_id'],
100                         'CHANGE_TYPE' => 'domain',
101                         )
102                 );
103
104             $tpl->parse('DOMAIN_LIST', '.domain_list');
105
106             $i++;
107             $rs->MoveNext();
108         }
109     }
110 }
111
112 function get_error_aliases(&$sql, &$tpl) {
113     $ok_status = Config::get('ITEM_OK_STATUS');
114     $disabled_status = Config::get('ITEM_DISABLED_STATUS');
115     $delete_status = Config::get('ITEM_DELETE_STATUS');
116     $add_status = Config::get('ITEM_ADD_STATUS');
117     $restore_status = Config::get('ITEM_RESTORE_STATUS');
118     $change_status = Config::get('ITEM_CHANGE_STATUS');
119     $toenable_status = Config::get('ITEM_TOENABLE_STATUS');
120     $todisable_status = Config::get('ITEM_TODISABLED_STATUS');
121     $ordered_status = Config::get('ITEM_ORDERED_STATUS');
122
123     $dmn_query = <<<SQL_QUERY
124         select
125             alias_name, alias_status, alias_id
126         from
127             domain_aliasses
128         where
129             (alias_status != ?
130           and
131             alias_status != ?
132           and
133             alias_status != ?
134           and
135             alias_status != ?
136           and
137             alias_status != ?
138           and
139             alias_status != ?
140           and
141             alias_status != ?
142           and
143             alias_status != ?
144           and
145             alias_status != ?)
146 SQL_QUERY;
147
148     $rs = exec_query($sql, $dmn_query, array(
149                                             $ok_status,
150                                             $disabled_status,
151                                             $delete_status,
152                                             $add_status,
153                                             $restore_status,
154                                             $change_status,
155                                             $toenable_status,
156                                             $todisable_status,
157                                             $ordered_status));
158
159     if ($rs->RecordCount() == 0) {
160         $tpl->assign(
161                 array(
162                     'ALIAS_LIST' => '',
163                     'TR_ALIAS_MESSAGE' => tr('No domain alias system errors'),
164                     )
165             );
166
167         $tpl->parse('ALIAS_MESSAGE', 'alias_message');
168     } else {
169         $i = 1;
170         while (!$rs->EOF) {
171             if ($i % 2 == 0) {
172                 $tpl->assign(
173                         array(
174                             'CONTENT' => 'content',
175                             )
176                     );
177             } else {
178                 $tpl->assign(
179                         array(
180                             'CONTENT' => 'content2',
181                             )
182                     );
183             }
184
185             $tpl->assign(
186                     array(
187                         'ALIAS_MESSAGE' => '',
188                         'TR_ALIAS_NAME' => $rs->fields['alias_name'],
189                         'TR_ALIAS_ERROR' => $rs->fields['alias_status'],
190                         'CHANGE_ID' => $rs->fields['alias_id'],
191                         'CHANGE_TYPE' => 'alias',
192                         )
193                 );
194
195             $tpl->parse('ALIAS_LIST', '.alias_list');
196
197             $i ++;
198             $rs->MoveNext();
199         }
200     }
201 }
202
203 function get_error_subdomains(&$sql, &$tpl) {
204     $ok_status = Config::get('ITEM_OK_STATUS');
205     $disabled_status = Config::get('ITEM_DISABLED_STATUS');
206     $delete_status = Config::get('ITEM_DELETE_STATUS');
207     $add_status = Config::get('ITEM_ADD_STATUS');
208     $restore_status = Config::get('ITEM_RESTORE_STATUS');
209     $change_status = Config::get('ITEM_CHANGE_STATUS');
210     $toenable_status = Config::get('ITEM_TOENABLE_STATUS');
211     $todisable_status = Config::get('ITEM_TODISABLED_STATUS');
212
213     $dmn_query = <<<SQL_QUERY
214       select
215           subdomain_name, subdomain_status, subdomain_id
216       from
217           subdomain
218       where
219           (subdomain_status != ?
220         and
221           subdomain_status != ?
222         and
223           subdomain_status != ?
224         and
225           subdomain_status != ?
226         and
227           subdomain_status != ?
228         and
229           subdomain_status != ?
230         and
231           subdomain_status != ?
232         and
233           subdomain_status != ?)
234 SQL_QUERY;
235
236     $rs = exec_query($sql, $dmn_query, array(
237                                             $ok_status,
238                                             $disabled_status,
239                                             $delete_status,
240                                             $add_status,
241                                             $restore_status,
242                                             $change_status,
243                                             $toenable_status,
244                                             $todisable_status));
245
246     if ($rs->RecordCount() == 0) {
247         $tpl->assign(
248                 array(
249                     'SUBDOMAIN_LIST' => '',
250                     'TR_SUBDOMAIN_MESSAGE' => tr('No subdomain system errors'),
251                     )
252             );
253
254         $tpl->parse('SUBDOMAIN_MESSAGE', 'subdomain_message');
255     } else {
256         $i = 1;
257         while (!$rs->EOF) {
258             if ($i % 2 == 0) {
259                 $tpl->assign(array('CONTENT' => 'content'));
260             } else {
261                 $tpl->assign(array('CONTENT' => 'content2'));
262             }
263
264             $tpl->assign(
265                     array(
266                         'SUBDOMAIN_MESSAGE' => '',
267                         'TR_SUBDOMAIN_NAME' => $rs->fields['subdomain_name'],
268                         'TR_SUBDOMAIN_ERROR' => $rs->fields['subdomain_status'],
269                         'CHANGE_ID' => $rs->fields['subdomain_id'],
270                         'CHANGE_TYPE' => 'subdomain'
271                         )
272                 );
273
274             $tpl->parse('SUBDOMAIN_LIST', '.subdomain_list');
275
276             $i ++;
277             $rs->MoveNext();
278         }
279     }
280 }
281
282 function get_error_mails(&$sql, &$tpl) {
283     $ok_status = Config::get('ITEM_OK_STATUS');
284     $disabled_status = Config::get('ITEM_DISABLED_STATUS');
285     $delete_status = Config::get('ITEM_DELETE_STATUS');
286     $add_status = Config::get('ITEM_ADD_STATUS');
287     $restore_status = Config::get('ITEM_RESTORE_STATUS');
288     $change_status = Config::get('ITEM_CHANGE_STATUS');
289     $toenable_status = Config::get('ITEM_TOENABLE_STATUS');
290     $todisable_status = Config::get('ITEM_TODISABLED_STATUS');
291     $ordered_status = Config::get('ITEM_ORDERED_STATUS');
292
293     $dmn_query = <<<SQL_QUERY
294         select
295             mail_acc, domain_id, mail_type, status, mail_id
296         from
297             mail_users
298         where
299             (status != ?
300               and
301             status != ?
302               and
303             status != ?
304               and
305             status != ?
306               and
307             status != ?
308               and
309             status != ?
310               and
311             status != ?
312               and
313             status != ?
314               and
315             status != ?)
316 SQL_QUERY;
317
318     $rs = exec_query($sql, $dmn_query, array(
319                                             $ok_status,
320                                             $disabled_status,
321                                             $delete_status,
322                                             $add_status,
323                                             $restore_status,
324                                             $change_status,
325                                             $toenable_status,
326                                             $todisable_status,
327                                             $ordered_status));
328
329     if ($rs->RecordCount() == 0) {
330         $tpl->assign(
331                 array(
332                     'MAIL_LIST' => '',
333                     'TR_MAIL_MESSAGE' => tr('No email account system errors'),
334                     )
335             );
336
337         $tpl->parse('MAIL_MESSAGE', 'mail_message');
338     } else {
339         $i = 1;
340         while (!$rs->EOF) {
341             $searched_id = $rs->fields['domain_id'];
342             $query = '';
343
344             if ($rs->fields['mail_type'] == 'normal_mail' || $rs->fields['mail_type'] == 'normal_forward') {
345                 $query = <<<SQL_QUERY
346             select
347                  domain_name as domain_name
348             from
349                   domain
350             where
351                   domain_id = ?
352 SQL_QUERY;
353             } else if ($rs->fields['mail_type'] == 'subdom_mail' || $rs->fields['mail_type'] == 'subdom_forward') {
354                 $query = <<<SQL_QUERY
355             select
356                 subdomain_name as domain_name
357             from
358                 subdomain
359             where
360                 subdomain_id = ?
361 SQL_QUERY;
362             } else if ($rs->fields['mail_type'] == 'alias_mail' || $rs->fields['mail_type'] == 'alias_forward') {
363                 $query = <<<SQL_QUERY
364             select
365                 alias_name as domain_name
366             from
367                 domain_aliasses
368             where
369                 alias_id  = ?
370 SQL_QUERY;
371             } else {
372                 write_log(sprintf('FIXME: %s:%d' . "\n" . 'Unknown mail type %s',__FILE__, __LINE__, $rs->fields['mail_type']));
373                 die('FIXME: ' . __FILE__ . ':' . __LINE__);
374             }
375
376             $sr = exec_query($sql, $query, array($searched_id));
377             $domain_name = $sr->fields['domain_name'];
378
379             if ($i % 2 == 0) {
380                 $tpl->assign(
381                         array(
382                             'CONTENT' => 'content',
383                             )
384                     );
385             } else {
386                 $tpl->assign(
387                         array(
388                             'CONTENT' => 'content2',
389                             )
390                     );
391             }
392
393             $tpl->assign(
394                     array(
395                         'MAIL_MESSAGE' => '',
396                         'TR_MAIL_NAME' => $rs->fields['mail_acc'] . "@" . $domain_name,
397                         'TR_MAIL_ERROR' => $rs->fields['status'],
398                         'CHANGE_ID' => $rs->fields['mail_id'],
399                         'CHANGE_TYPE' => 'mail',
400                         )
401                 );
402
403             $tpl->parse('MAIL_LIST', '.mail_list');
404
405             $i ++;
406             $rs->MoveNext();
407         }
408     }
409 }
410
411 $exec_count = count_requests($sql, 'domain_status', 'domain');
412 $exec_count = $exec_count + count_requests($sql, 'alias_status', 'domain_aliasses');
413 $exec_count = $exec_count + count_requests($sql, 'subdomain_status', 'subdomain');
414 $exec_count = $exec_count + count_requests($sql, 'status', 'mail_users');
415 $exec_count = $exec_count + count_requests($sql, 'status', 'htaccess');
416 $exec_count = $exec_count + count_requests($sql, 'status', 'htaccess_groups');
417 $exec_count = $exec_count + count_requests($sql, 'status', 'htaccess_users');
418
419 $tpl = new pTemplate();
420
421 $tpl->define_dynamic('page', Config::get('ADMIN_TEMPLATE_PATH') . '/ispcp_debugger.tpl');
422 $tpl->define_dynamic('page_message', 'page');
423 $tpl->define_dynamic('hosting_plans', 'page');
424 $tpl->define_dynamic('domain_message', 'page');
425 $tpl->define_dynamic('alias_message', 'page');
426 $tpl->define_dynamic('subdomain_message', 'page');
427 $tpl->define_dynamic('mail_message', 'page');
428 $tpl->define_dynamic('domain_list', 'page');
429 $tpl->define_dynamic('alias_list', 'page');
430 $tpl->define_dynamic('subdomain_list', 'page');
431 $tpl->define_dynamic('mail_list', 'page');
432
433 $theme_color = Config::get('USER_INITIAL_THEME');
434
435 $tpl->assign(
436         array(
437             'TR_ADMIN_ISPCP_DEBUGGER_PAGE_TITLE' => tr('ispCP - Virtual Hosting Control System'),
438             'THEME_COLOR_PATH' => "../themes/$theme_color",
439             'THEME_CHARSET' => tr('encoding'),
440             'ISP_LOGO' => get_logo($_SESSION['user_id'])
441             )
442     );
443
444 /*
445  *
446  * static page messages.
447  *
448  */
449 gen_admin_mainmenu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/main_menu_system_tools.tpl');
450 gen_admin_menu($tpl, Config::get('ADMIN_TEMPLATE_PATH') . '/menu_system_tools.tpl');
451
452 $tpl->assign(
453         array(
454             'TR_DEBUGGER_TITLE' => tr('ispCP debugger'),
455             'TR_DOMAIN_ERRORS' => tr('Domain errors'),
456             'TR_ALIAS_ERRORS' => tr('Domain alias errors'),
457             'TR_SUBDOMAIN_ERRORS' => tr('Subdomain errors'),
458             'TR_MAIL_ERRORS' => tr('Mail account errors'),
459             'TR_DAEMON_TOOLS' => tr('ispCP Daemon tools'),
460             'TR_EXEC_REQUESTS' => tr('Execute requests'),
461             'TR_CHANGE_STATUS' => tr('Set status to "change"'),
462             'EXEC_COUNT' => $exec_count,
463             )
464     );
465
466 if (isset($_GET['action']) && $exec_count > 0) {
467     if ($_GET['action'] == 'run_engine') {
468         check_for_lock_file();
469         $c = send_request();
470         set_page_message(tr('Daemon returned %d as status code', $c));
471     } else if ($_GET['action'] == 'change_status' && (
472             isset($_GET['id']) && isset($_GET['type']))) {
473         switch ($_GET['type']) {
474             case 'domain':
475                 $query = 'UPDATE domain SET domain_status = "change" WHERE domain_id = ?';
476                 break;
477             case 'alias':
478                 $query = 'UPDATE domain_aliasses SET alias_status = "change" WHERE alias_id = ?';
479                 break;
480             case 'subdomain':
481                 $query = 'UPDATE subdomain SET subdomain_status = "change" WHERE subdomain_id = ?';
482                 break;
483             case 'mail':
484                 $query = 'UPDATE mail_users SET status = "change" WHERE mail_id = ?';
485                 break;
486             default:
487                 set_page_message(tr('Unknown type!'));
488                 user_goto('ispcp_debugger.php');
489                 break;
490         }
49