forked from Cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_domains.php
742 lines (649 loc) · 26 KB
/
user_domains.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2016 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
include('./include/auth.php');
include_once('./lib/utility.php');
$actions = array(
1 => 'Delete',
2 => 'Disable',
3 => 'Enable',
4 => 'Default'
);
/* set default action */
set_default_action();
switch (get_request_var('action')) {
case 'save':
form_save();
break;
case 'actions':
form_actions();
break;
case 'edit':
top_header();
domain_edit();
bottom_footer();
break;
default:
top_header();
domains();
bottom_footer();
break;
}
/* --------------------------
The Save Function
-------------------------- */
function form_save() {
global $registered_cacti_names;
if (isset_request_var('save_component_domain_ldap')) {
/* ================= input validation ================= */
get_filter_request_var('domain_id');
get_filter_request_var('type');
get_filter_request_var('user_id');
/* ==================================================== */
$save['domain_id'] = get_nfilter_request_var('domain_id');
$save['type'] = get_nfilter_request_var('type');
$save['user_id'] = get_nfilter_request_var('user_id');
$save['domain_name'] = form_input_validate(get_nfilter_request_var('domain_name'), 'domain_name', '', false, 3);
$save['enabled'] = (isset_request_var('enabled') ? form_input_validate(get_nfilter_request_var('enabled'), 'enabled', '', true, 3):'');
if (!is_error_message()) {
$domain_id = sql_save($save, 'user_domains', 'domain_id');
if ($domain_id) {
raise_message(1);
}else{
raise_message(2);
}
if (!is_error_message()) {
/* ================= input validation ================= */
get_filter_request_var('domain_id');
get_filter_request_var('port');
get_filter_request_var('port_ssl');
get_filter_request_var('proto_version');
get_filter_request_var('encryption');
get_filter_request_var('referrals');
get_filter_request_var('mode');
get_filter_request_var('group_member_type');
/* ==================================================== */
$save = array();
$save['domain_id'] = $domain_id;
$save['server'] = form_input_validate(get_nfilter_request_var('server'), 'server', '', false, 3);
$save['port'] = get_nfilter_request_var('port');
$save['port_ssl'] = get_nfilter_request_var('port_ssl');
$save['proto_version'] = get_nfilter_request_var('proto_version');
$save['encryption'] = get_nfilter_request_var('encryption');
$save['referrals'] = get_nfilter_request_var('referrals');
$save['mode'] = get_nfilter_request_var('mode');
$save['group_member_type'] = get_nfilter_request_var('group_member_type');
$save['dn'] = form_input_validate(get_nfilter_request_var('dn'), 'dn', '', true, 3);
$save['group_require'] = isset_request_var('group_require') ? 'on':'';
$save['group_dn'] = form_input_validate(get_nfilter_request_var('group_dn'), 'group_dn', '', true, 3);
$save['group_attrib'] = form_input_validate(get_nfilter_request_var('group_attrib'), 'group_attrib', '', true, 3);
$save['search_base'] = form_input_validate(get_nfilter_request_var('search_base'), 'search_base', '', true, 3);
$save['search_filter'] = form_input_validate(get_nfilter_request_var('search_filter'), 'search_filter', '', true, 3);
$save['specific_dn'] = form_input_validate(get_nfilter_request_var('specific_dn'), 'specific_dn', '', true, 3);
$save['specific_password'] = form_input_validate(get_nfilter_request_var('specific_password'), 'specific_password', '', true, 3);
if (!is_error_message()) {
$insert_id = sql_save($save, 'user_domains_ldap', 'domain_id', false);
if ($insert_id) {
raise_message(1);
}else{
raise_message(2);
}
}
}
}
}elseif (isset_request_var('save_component_domain')) {
/* ================= input validation ================= */
get_filter_request_var('domain_id');
get_filter_request_var('type');
get_filter_request_var('user_id');
/* ==================================================== */
$save['domain_id'] = get_nfilter_request_var('domain_id');
$save['domain_name'] = form_input_validate(get_nfilter_request_var('domain_name'), 'domain_name', '', false, 3);
$save['type'] = get_nfilter_request_var('type');
$save['user_id'] = get_nfilter_request_var('user_id');
$save['enabled'] = (isset_request_var('enabled') ? form_input_validate(get_nfilter_request_var('enabled'), 'enabled', '', true, 3):'');
if (!is_error_message()) {
$domain_id = sql_save($save, 'user_domains', 'domain_id');
if ($domain_id) {
raise_message(1);
}else{
raise_message(2);
}
}
}
header('Location: user_domains.php?header=false&action=edit&domain_id=' . (empty($domain_id) ? get_nfilter_request_var('domain_id') : $domain_id));
}
function form_actions() {
global $actions;
/* if we are to save this form, instead of display it */
if (isset_request_var('selected_items')) {
$selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
if ($selected_items != false) {
if (get_nfilter_request_var('drp_action') == '1') { /* delete */
for ($i=0;($i<count($selected_items));$i++) {
domain_remove($selected_items[$i]);
}
}elseif (get_nfilter_request_var('drp_action') == '2') { /* disable */
for ($i=0;($i<count($selected_items));$i++) {
domain_disable($selected_items[$i]);
}
}elseif (get_nfilter_request_var('drp_action') == '3') { /* enable */
for ($i=0;($i<count($selected_items));$i++) {
domain_enable($selected_items[$i]);
}
}elseif (get_nfilter_request_var('drp_action') == '4') { /* default */
if (sizeof($selected_items) > 1) {
/* error message */
}else{
for ($i=0;($i<count($selected_items));$i++) {
domain_default($selected_items[$i]);
}
}
}
}
header('Location: user_domains.php?header=false');
exit;
}
/* setup some variables */
$d_list = ''; $d_array = array();
/* loop through each of the data queries and process them */
while (list($var,$val) = each($_POST)) {
if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
/* ================= input validation ================= */
input_validate_input_number($matches[1]);
/* ==================================================== */
$d_list .= '<li>' . db_fetch_cell_prepared('SELECT domain_name FROM user_domains WHERE domain_id = ?', array($matches[1])) . '</li>';
$d_array[] = $matches[1];
}
}
top_header();
form_start('user_domains.php');
html_start_box($actions{get_nfilter_request_var('drp_action')}, '60%', '', '3', 'center', '');
if (isset($d_array) && sizeof($d_array)) {
if (get_nfilter_request_var('drp_action') == '1') { /* delete */
print "<tr>
<td class='textArea'>
<p>Click 'Continue' to delete the following User Domain(s).</p>
<p><ul>$d_list</ul></p>
</td>
</tr>\n";
$save_html = "<input type='button' value='Cancel' onClick='cactiReturnTo()'> <input type='submit' value='Continue' title='Delete User Domain(s)'>";
}else if (get_nfilter_request_var('drp_action') == '2') { /* disable */
print "<tr>
<td class='textArea'>
<p>Click 'Continue' to disable the following User Domain(s).</p>
<p><ul>$d_list</ul></p>
</td>
</tr>\n";
$save_html = "<input type='button' value='Cancel' onClick='cactiReturnTo()'> <input type='submit' value='Continue' title='Disable User Domain(s)'>";
}else if (get_nfilter_request_var('drp_action') == '3') { /* enable */
print "<tr>
<td class='textArea'>
<p>Click 'Continue' to enable the following User Domain(s).</p>
<p><ul>$d_list</ul></p>
</td>
</tr>\n";
$save_html = "<input type='button' value='Cancel' onClick='cactiReturnTo()'> <input type='submit' value='Continue' title='Enabled User Domain(s)'>";
}else if (get_nfilter_request_var('drp_action') == '4') { /* default */
print "<tr>
<td class='textArea'>
<p>Click 'Continue' to make the following the following User Domain the default one.</p>
<p><ul>$d_list</ul></p>
</td>
</tr>\n";
$save_html = "<input type='button' value='Cancel' onClick='cactiReturnTo()'> <input type='submit' value='Continue' title='Make Selected Domain Default'>";
}
}else{
print "<tr><td class='even'><span class='textError'>You must select at least one data input method.</span></td></tr>\n";
$save_html = "<input type='button' value='Return' onClick='cactiReturnTo()'>";
}
print "<tr>
<td class='saveRow'>
<input type='hidden' name='action' value='actions'>
<input type='hidden' name='selected_items' value='" . (isset($d_array) ? serialize($d_array) : '') . "'>
<input type='hidden' name='drp_action' value='" . get_nfilter_request_var('drp_action') . "'>
$save_html
</td>
</tr>\n";
html_end_box();
form_end();
bottom_footer();
}
/* -----------------------
Domain Functions
----------------------- */
function domain_remove($domain_id) {
db_execute_prepared('DELETE FROM user_domains WHERE domain_id = ?', array($domain_id));
db_execute_prepared('DELETE FROM user_domains_ldap WHERE domain_id = ?', array($domain_id));
}
function domain_disable($domain_id) {
db_execute_prepared('UPDATE user_domains SET enabled = "" WHERE domain_id = ?', array($domain_id));
}
function domain_enable($domain_id) {
db_execute_prepared('UPDATE user_domains SET enabled = "on" WHERE domain_id = ?', array($domain_id));
}
function domain_default($domain_id) {
db_execute('UPDATE user_domains SET defdomain = 0');
db_execute_prepared('UPDATE user_domains SET defdomain = 1 WHERE domain_id = ?', array($domain_id));
}
function domain_edit() {
global $ldap_versions, $ldap_encryption, $ldap_modes, $domain_types;
/* ================= input validation ================= */
get_filter_request_var('domain_id');
/* ==================================================== */
if (!isempty_request_var('domain_id')) {
$domain = db_fetch_row_prepared('SELECT * FROM user_domains WHERE domain_id = ?', array(get_request_var('domain_id')));
$header_label = '[edit: ' . $domain['domain_name'] . ']';
}else{
$header_label = '[new]';
}
/* file: data_input.php, action: edit */
$fields_domain_edit = array(
'domain_name' => array(
'method' => 'textbox',
'friendly_name' => 'Name',
'description' => 'Enter a meaningful name for this domain. This will be the name that appears
in the Login Realm during login.',
'value' => '|arg1:domain_name|',
'max_length' => '255',
),
'type' => array(
'method' => 'drop_array',
'friendly_name' => 'Domains Type',
'description' => 'Choose what type of domain this is.',
'value' => '|arg1:type|',
'array' => $domain_types,
'default' => '2'
),
'user_id' => array(
'friendly_name' => 'User Template',
'description' => 'The name of the user that Cacti will use as a template for new user accounts.',
'method' => 'drop_sql',
'value' => '|arg1:user_id|',
'none_value' => 'No User',
'sql' => 'SELECT id AS id, username AS name FROM user_auth WHERE realm=0 ORDER BY username',
'default' => '0'
),
'enabled' => array(
'method' => 'checkbox',
'friendly_name' => 'Enabled',
'description' => 'If this checkbox is checked, users will be able to login using this domain.',
'value' => '|arg1:enabled|',
'default' => '',
),
'domain_id' => array(
'method' => 'hidden_zero',
'value' => '|arg1:domain_id|'
),
'save_component_domain' => array(
'method' => 'hidden',
'value' => '1'
)
);
$fields_domain_ldap_edit = array(
'server' => array(
'friendly_name' => 'Server',
'description' => 'The dns hostname or ip address of the server.',
'method' => 'textbox',
'value' => '|arg1:server|',
'default' => read_config_option('ldap_server'),
'max_length' => '255'
),
'port' => array(
'friendly_name' => 'Port Standard',
'description' => 'TCP/UDP port for Non SSL communications.',
'method' => 'textbox',
'max_length' => '5',
'value' => '|arg1:port|',
'default' => read_config_option('ldap_port'),
'size' => '5'
),
'port_ssl' => array(
'friendly_name' => 'Port SSL',
'description' => 'TCP/UDP port for SSL communications.',
'method' => 'textbox',
'max_length' => '5',
'value' => '|arg1:port_ssl|',
'default' => read_config_option('ldap_port_ssl'),
'size' => '5'
),
'proto_version' => array(
'friendly_name' => 'Protocol Version',
'description' => 'Protocol Version that the server supports.',
'method' => 'drop_array',
'value' => '|arg1:proto_version|',
'array' => $ldap_versions
),
'encryption' => array(
'friendly_name' => 'Encryption',
'description' => 'Encryption that the server supports. TLS is only supported by Protocol Version 3.',
'method' => 'drop_array',
'value' => '|arg1:encryption|',
'array' => $ldap_encryption
),
'referrals' => array(
'friendly_name' => 'Referrals',
'description' => 'Enable or Disable LDAP referrals. If disabled, it may increase the speed of searches.',
'method' => 'drop_array',
'value' => '|arg1:referrals|',
'array' => array( '0' => 'Disabled', '1' => 'Enable')
),
'mode' => array(
'friendly_name' => 'Mode',
'description' => 'Mode which cacti will attempt to authenticate against the LDAP server.<blockquote><i>No Searching</i> - No Distinguished Name (DN) searching occurs, just attempt to bind with the provided Distinguished Name (DN) format.<br><br><i>Anonymous Searching</i> - Attempts to search for username against LDAP directory via anonymous binding to locate the users Distinguished Name (DN).<br><br><i>Specific Searching</i> - Attempts search for username against LDAP directory via Specific Distinguished Name (DN) and Specific Password for binding to locate the users Distinguished Name (DN).',
'method' => 'drop_array',
'value' => '|arg1:mode|',
'array' => $ldap_modes
),
'dn' => array(
'friendly_name' => 'Distinguished Name (DN)',
'description' => 'Distinguished Name syntax, such as for windows: <i>"<username>@win2kdomain.local"</i> or for OpenLDAP: <i>"uid=<username>,ou=people,dc=domain,dc=local"</i>. "<username>" is replaced with the username that was supplied at the login prompt. This is only used when in "No Searching" mode.',
'method' => 'textbox',
'value' => '|arg1:dn|',
'max_length' => '255'
),
'group_require' => array(
'friendly_name' => 'Require Group Membership',
'description' => 'Require user to be member of group to authenticate. Group settings must be set for this to work, enabling without proper group settings will cause authenication failure.',
'value' => '|arg1:group_require|',
'method' => 'checkbox'
),
'group_header' => array(
'friendly_name' => 'LDAP Group Settings',
'method' => 'spacer'
),
'group_dn' => array(
'friendly_name' => 'Group Distingished Name (DN)',
'description' => 'Distingished Name of the group that user must have membership.',
'method' => 'textbox',
'value' => '|arg1:group_dn|',
'max_length' => '255'
),
'group_attrib' => array(
'friendly_name' => 'Group Member Attribute',
'description' => 'Name of the attribute that contains the usernames of the members.',
'method' => 'textbox',
'value' => '|arg1:group_attrib|',
'max_length' => '255'
),
'group_member_type' => array(
'friendly_name' => 'Group Member Type',
'description' => 'Defines if users use full Distingished Name or just Username in the defined Group Member Attribute.',
'method' => 'drop_array',
'value' => '|arg1:group_member_type|',
'array' => array( 1 => 'Distingished Name', 2 => 'Username' )
),
'search_base_header' => array(
'friendly_name' => 'LDAP Specific Search Settings',
'method' => 'spacer'
),
'search_base' => array(
'friendly_name' => 'Search Base',
'description' => 'Search base for searching the LDAP directory, such as <i>"dc=win2kdomain,dc=local"</i> or <i>"ou=people,dc=domain,dc=local"</i>.',
'method' => 'textbox',
'value' => '|arg1:search_base|',
'max_length' => '255'
),
'search_filter' => array(
'friendly_name' => 'Search Filter',
'description' => 'Search filter to use to locate the user in the LDAP directory, such as for windows: <i>"(&(objectclass=user)(objectcategory=user)(userPrincipalName=<username>*))"</i> or for OpenLDAP: <i>"(&(objectClass=account)(uid=<username>))"</i>. "<username>" is replaced with the username that was supplied at the login prompt. ',
'method' => 'textbox',
'value' => '|arg1:search_filter|',
'max_length' => '255'
),
'specific_dn' => array(
'friendly_name' => 'Search Distingished Name (DN)',
'description' => 'Distinguished Name for Specific Searching binding to the LDAP directory.',
'method' => 'textbox',
'value' => '|arg1:specific_dn|',
'max_length' => '255'
),
'specific_password' => array(
'friendly_name' => 'Search Password',
'description' => 'Password for Specific Searching binding to the LDAP directory.',
'method' => 'textbox_password',
'value' => '|arg1:specific_password|',
'max_length' => '255'
),
'save_component_domain_ldap' => array(
'method' => 'hidden',
'value' => '1'
)
);
form_start('user_domains.php');
html_start_box("User Domain $header_label", '100%', '', '3', 'center', '');
draw_edit_form(array(
'config' => array(),
'fields' => inject_form_variables($fields_domain_edit, (isset($domain) ? $domain : array()))
));
html_end_box();
if (!isempty_request_var('domain_id')) {
$domain = db_fetch_row_prepared('SELECT * FROM user_domains_ldap WHERE domain_id = ?', array(get_request_var('domain_id')));
html_start_box('Domain Properties', '100%', '', '3', 'center', '');
draw_edit_form(array(
'config' => array(),
'fields' => inject_form_variables($fields_domain_ldap_edit, (isset($domain) ? $domain : array()))
));
html_end_box();
}
?>
<script type='text/javascript'>
function initGroupMember() {
if ($('#group_require').is(':checked')) {
$('#row_group_header').show();
$('#row_group_dn').show();
$('#row_group_attrib').show();
$('#row_group_member_type').show();
}else{
$('#row_group_header').hide();
$('#row_group_dn').hide();
$('#row_group_attrib').hide();
$('#row_group_member_type').hide();
}
}
function initSearch() {
switch($('#mode').val()) {
case "0":
$('#row_search_base_header').hide();
$('#row_search_base').hide();
$('#row_search_filter').hide();
$('#row_specific_dn').hide();
$('#row_specific_password').hide();
break;
case "1":
$('#row_search_base_header').show();
$('#row_search_base').show();
$('#row_search_filter').show();
$('#row_specific_dn').hide();
$('#row_specific_password').hide();
break;
case "2":
$('#row_search_base_header').show();
$('#row_search_base').show();
$('#row_search_filter').show();
$('#row_specific_dn').show();
$('#row_specific_password').show();
break;
}
}
$(function(data) {
initSearch();
initGroupMember();
$('#mode').change(function() {
initSearch();
});
$('#group_require').change(function() {
initGroupMember();
});
});
</script>
<?php
form_save_button('user_domains.php', 'return', 'domain_id');
}
function domains() {
global $domain_types, $actions, $item_rows;
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => read_config_option('num_rows_table')
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'filter' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'domain_name',
'options' => array('options' => 'sanitize_search_string')
),
'sort_direction' => array(
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => array('options' => 'sanitize_search_string')
)
);
validate_store_request_vars($filters, 'sess_domains');
/* ================= input validation ================= */
html_start_box('User Domains', '100%', '', '3', 'center', 'user_domains.php?action=edit');
?>
<tr class='even' class='noprint'>
<td class='noprint'>
<form id='form_domains' method='get' action='user_domains.php'>
<table class='filterTable'>
<tr class='noprint'>
<td>
Search
</td>
<td>
<input id='filter' type='text' name='filter' size='25' value='<?php print get_request_var('filter');?>'>
</td>
<td>
Domains
</td>
<td>
<select id='rows' name="rows" onChange="applyFilter()">
<?php
if (sizeof($item_rows) > 0) {
foreach ($item_rows as $key => $value) {
print "<option value='" . $key . "'"; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . htmlspecialchars($value) . "</option>\n";
}
}
?>
</select>
</td>
<td>
<input id='refresh' type='button' value='Go' title='Set/Refresh Filters'>
</td>
<td>
<input id='clear' type='button' value='Clear' title='Clear Filters'>
</td>
</tr>
</table>
<input type='hidden' id='page' value='<?php print get_request_var('page');?>'>
</form>
<script type='text/javascript'>
function applyFilter() {
strURL = 'user_domains.php?rows=' + $('#rows').val();
strURL += '&filter=' + $('#filter').val();
strURL += '&page=' + $('#page').val();
strURL += '&header=false';
loadPageNoHeader(strURL);
}
function clearFilter() {
strURL = 'user_domains.php?clear=1&header=false';
loadPageNoHeader(strURL);
}
$(function(data) {
$('#refresh').click(function() {
applyFilter();
});
$('#clear').click(function() {
clearFilter();
});
$('#form_domains').submit(function(event) {
event.preventDefault();
applyFilter();
});
});
</script>
</td>
</tr>
<?php
html_end_box();
form_start('user_domains.php', 'chk');
html_start_box('', '100%', '', '3', 'center', '');
/* form the 'where' clause for our main sql query */
if (get_request_var('filter') != '') {
$sql_where = "WHERE (domain_name LIKE '%%" . get_request_var('filter') . "%%') ||
(type LIKE '%%" . get_request_var('filter') . "%%')";
}else{
$sql_where = '';
}
$total_rows = db_fetch_cell("SELECT
count(*)
FROM user_domains
$sql_where");
$domains = db_fetch_assoc("SELECT *
FROM user_domains
$sql_where
ORDER BY " . get_request_var('sort_column') . ' ' . get_request_var('sort_direction') . '
LIMIT ' . (get_request_var('rows')*(get_request_var('page')-1)) . ',' . get_request_var('rows'));
$nav = html_nav_bar('user_user_domains.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), get_request_var('rows'), $total_rows, 6, 'User Domains', 'page', 'main');
print $nav;
$display_text = array(
'domain_name' => array('Domain Name', 'ASC'),
'type' => array('Domain Type', 'ASC'),
'defdomain' => array('Default', 'ASC'),
'user_id' => array('Effective User', 'ASC'),
'enabled' => array('Enabled', 'ASC'));
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), false);
$i = 0;
if (sizeof($domains) > 0) {
foreach ($domains as $domain) {
/* hide system types */
form_alternate_row('line' . $domain['domain_id'], true);
form_selectable_cell("<a class='linkEditMain' href='" . htmlspecialchars('user_domains.php?action=edit&domain_id=' . $domain['domain_id']) . "'>" . (strlen(get_request_var('filter')) ? preg_replace('/(' . preg_quote(get_request_var('filter')) . ')/i', "<span class='filteredValue>\\1</span>", htmlspecialchars($domain['domain_name'])) : htmlspecialchars($domain['domain_name'])) . '</a>', $domain['domain_id']);
form_selectable_cell($domain_types{$domain['type']}, $domain['domain_id']);
form_selectable_cell(($domain['defdomain'] == '0' ? '--':'Yes'), $domain['domain_id']);
form_selectable_cell(($domain['user_id'] == '0' ? 'None Selected': db_fetch_cell_prepared('SELECT username FROM user_auth WHERE id = ?', array($domain['user_id']))), $domain['domain_id']);
form_selectable_cell(($domain['enabled'] == 'on' ? 'Yes':'No'), $domain['domain_id']);
form_checkbox_cell($domain['domain_name'], $domain['domain_id']);
form_end_row();
}
print $nav;
}else{
print '<tr><td><em>No User Domains Defined</em></td></tr>';
}
html_end_box(false);
/* draw the dropdown containing a list of available actions for this form */
draw_actions_dropdown($actions);
form_end();
}