forked from Cacti/plugin_mactrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mactrack_view_dot1x.php
731 lines (659 loc) · 28.3 KB
/
mactrack_view_dot1x.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
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2017 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/ |
+-------------------------------------------------------------------------+
*/
$guest_account = true;
chdir('../../');
include('./include/auth.php');
include_once('./include/global_arrays.php');
include_once('./plugins/mactrack/lib/mactrack_functions.php');
$title = __('Device Tracking - 802.1x View', 'mactrack');
set_default_action();
if (isset_request_var('export')) {
mactrack_view_export_dot1x();
}else{
mactrack_redirect();
general_header();
mactrack_view_dot1x_validate_request_vars();
if (isset_request_var('scan_date')) {
mactrack_view_dot1x();
}else{
}
bottom_footer();
}
function mactrack_view_dot1x_validate_request_vars() {
/* ================= input validation and session storage ================= */
$filters = array(
'rows' => array(
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
),
'page' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'site_id' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
),
'device_id' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
),
'status' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '0'
),
'mac_filter_type_id' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'port_name_filter_type_id' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'ip_filter_type_id' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
),
'domain' => array(
'filter' => FILTER_VALIDATE_INT,
'default' => '-1',
'pageset' => true
),
'filter' => array(
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'ip_filter' => array(
'filter' => FILTER_CALLBACK,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'mac_filter' => array(
'filter' => FILTER_CALLBACK,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'port_name_filter' => array(
'filter' => FILTER_CALLBACK,
'default' => '',
'options' => array('options' => 'sanitize_search_string')
),
'scan_date' => array(
'filter' => FILTER_CALLBACK,
'default' => '2',
'options' => array('options' => 'sanitize_search_string')
),
'sort_column' => array(
'filter' => FILTER_CALLBACK,
'default' => 'device_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_mtv_dot1x');
/* ================= input validation ================= */
}
function mactrack_view_export_dot1x() {
mactrack_view_dot1x_validate_request_vars();
$sql_where = '';
$port_results = mactrack_view_get_dot1x_records($sql_where, 0, FALSE);
$xport_array = array();
array_push($xport_array, '"site_name","hostname","device_name",' .
'"domain","status","mac_address",' .
'"ip_address","dns_hostname","port_number","ifName","username","scan_date"');
if (sizeof($port_results)) {
foreach($port_results as $port_result) {
if (get_request_var('scan_date') == 1) {
$scan_date = $port_result['scan_date'];
}else{
$scan_date = $port_result['max_scan_date'];
}
array_push($xport_array,'"' . $port_result['site_name'] . '","' .
$port_result['hostname'] . '","' . $port_result['device_name'] . '","' .
$port_result['domain'] . '","' . $port_result['status'] . '","' .
$port_result['mac_address'] . '","' . $port_result['ip_address'] . '","' .
$port_result['dns_hostname'] . '","' . $port_result['port_number'] . '","' .
$port_result['ifName'] . '","' . $port_result['username'] . '","' .
$scan_date . '"');
}
}
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=mactrack_dot1x_xport.csv');
foreach($xport_array as $xport_line) {
print $xport_line . "\n";
}
}
function mactrack_view_get_dot1x_records(&$sql_where, $apply_limits = TRUE, $rows) {
/* status sql where */
if (get_request_var('status') == '0') { // Any Status
/* do nothing all records */
} elseif (get_request_var('status') == '1') { // Idle
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=1)";
} elseif (get_request_var('status') == '2') { // Running
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=2)";
} elseif (get_request_var('status') == '3') { // No Method
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=3)";
} elseif (get_request_var('status') == '4') { // Authentication Success
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=4)";
} elseif (get_request_var('status') == '5') { // Authentication Failed
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=5)";
} elseif (get_request_var('status') == '6') { // Authorization Success
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=6)";
} elseif (get_request_var('status') == '7') { // Authorization Failed
$sql_where .= (strlen($sql_where) ? ' AND ' : 'WHERE ') . "(mtd.status=7)";
} else {
}
/* form the 'where' clause for our main sql query */
if (get_request_var('mac_filter') != '') {
switch (get_request_var('mac_filter_type_id')) {
case '1': /* do not filter */
break;
case '2': /* matches */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.mac_address='" . get_request_var('mac_filter') . "'";
break;
case '3': /* contains */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.mac_address LIKE '%" . get_request_var('mac_filter') . "%'";
break;
case '4': /* begins with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.mac_address LIKE '" . get_request_var('mac_filter') . "%'";
break;
case '5': /* does not contain */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.mac_address NOT LIKE '%" . get_request_var('mac_filter') . "%'";
break;
case '6': /* does not begin with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.mac_address NOT LIKE '" . get_request_var('mac_filter') . "%'";
}
}
if ((get_request_var('ip_filter') != '') || (get_request_var('ip_filter_type_id') > 6)) {
switch (get_request_var('ip_filter_type_id')) {
case '1': /* do not filter */
break;
case '2': /* matches */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address='" . get_request_var('ip_filter') . "'";
break;
case '3': /* contains */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address LIKE '%" . get_request_var('ip_filter') . "%'";
break;
case '4': /* begins with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address LIKE '" . get_request_var('ip_filter') . "%'";
break;
case '5': /* does not contain */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address NOT LIKE '%" . get_request_var('ip_filter') . "%'";
break;
case '6': /* does not begin with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address NOT LIKE '" . get_request_var('ip_filter') . "%'";
break;
case '7': /* is null */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address = ''";
break;
case '8': /* is not null */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.ip_address != ''";
}
}
if ((get_request_var('port_name_filter') != '') || (get_request_var('port_name_filter_type_id') > 6)) {
switch (get_request_var('port_name_filter_type_id')) {
case '1': /* do not filter */
break;
case '2': /* matches */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName='" . get_request_var('port_name_filter') . "'";
break;
case '3': /* contains */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName LIKE '%" . get_request_var('port_name_filter') . "%'";
break;
case '4': /* begins with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName LIKE '" . get_request_var('port_name_filter') . "%'";
break;
case '5': /* does not contain */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName NOT LIKE '%" . get_request_var('port_name_filter') . "%'";
break;
case '6': /* does not begin with */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName NOT LIKE '" . get_request_var('port_name_filter') . "%'";
break;
case '7': /* is null */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName = ''";
break;
case '8': /* is not null */
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mti.ifName != ''";
}
}
if (get_request_var('filter') != '') {
if (strlen(read_config_option('mt_reverse_dns'))) {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') .
" (mtd.dns_hostname LIKE '%" . get_request_var('filter') . "%' OR " .
"mtd.device_name LIKE '%" . get_request_var('filter') . "%' OR " .
"mtd.hostname LIKE '%" . get_request_var('filter') . "%' OR " .
"mtd.status LIKE '%" . get_request_var('filter') . "%')";
}else{
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') .
" (mtd.device_name LIKE '%" . get_request_var('filter') . "%' OR " .
"mtd.hostname LIKE '%" . get_request_var('filter') . "%' OR " .
"mtd.status LIKE '%" . get_request_var('filter') . "%')";
}
}
if (get_request_var('domain') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' mtd.domain=' . get_request_var('domain');
}
if (get_request_var('site_id') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' mtd.site_id=' . get_request_var('site_id');
}
if (get_request_var('status') != '0') {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' mtd.status=' . get_request_var('status');
}
if (get_request_var('device_id') != '-1') {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . ' mtd.device_id=' . get_request_var('device_id');
}
if ((get_request_var('scan_date') != '1') && (get_request_var('scan_date') != '2')) {
$sql_where .= (strlen($sql_where) ? ' AND':'WHERE') . " mtd.scan_date='" . get_request_var('scan_date') . "'";
}
/* prevent table scans, either a device or site must be selected */
if (get_request_var('site_id') == -1 && get_request_var('device_id') == -1) {
if (!strlen($sql_where)) return array();
}
$sql_order = get_order_string();
if ($apply_limits && $rows != 999999) {
$sql_limit = ' LIMIT ' . ($rows*(get_request_var('page')-1)) . ',' . $rows;
}else{
$sql_limit = '';
}
if ((get_request_var('scan_date') != 2)) {
$query_string = "SELECT mts.site_name, mtd.device_id, mtd.device_name, mtd.hostname,
mtd.mac_address, mtd.username, mtd.ip_address, mtd.dns_hostname, mtd.port_number,
mti.ifName, mtd.domain, mtd.status, mtd.scan_date
FROM mac_track_dot1x mtd
LEFT JOIN mac_track_sites mts
ON (mtd.site_id = mts.site_id)
LEFT JOIN mac_track_interfaces mti
ON (mtd.port_number = mti.ifIndex AND mtd.device_id=mti.device_id)
$sql_where
$sql_order
$sql_limit";
}else{
$query_string = "SELECT mts.site_name, mtd.device_id, mtd.device_name, mtd.hostname,
mtd.mac_address, mtd.username, mtd.ip_address, mtd.dns_hostname, mtd.port_number,
mti.ifName, mtd.domain, mtd.status, MAX(mtd.scan_date) AS scan_date
FROM mac_track_dot1x mtd
LEFT JOIN mac_track_sites mts
ON (mtd.site_id = mts.site_id)
LEFT JOIN mac_track_interfaces mti
ON (mtd.port_number = mti.ifIndex AND mtd.device_id=mti.device_id)
$sql_where
GROUP BY device_id, mac_address, port_number, ip_address
$sql_order
$sql_limit";
}
if (strlen($sql_where) == 0) {
return array();
}else{
return db_fetch_assoc($query_string);
}
}
function mactrack_view_dot1x() {
global $title, $report, $mactrack_search_types, $rows_selector, $config;
global $item_rows;
mactrack_tabs();
html_start_box($title, '100%', '', '3', 'center', '');
mactrack_dot1x_filter();
html_end_box();
$sql_where = '';
if (get_request_var('rows') == -1) {
$rows = read_config_option('num_rows_table');
}elseif (get_request_var('rows') == -2) {
$rows = 999999;
}else{
$rows = get_request_var('rows');
}
$port_results = mactrack_view_get_dot1x_records($sql_where, TRUE, $rows);
/* prevent table scans, either a device or site must be selected */
if (!strlen($sql_where)) {
$total_rows = 0;
}elseif (get_request_var('scan_date') != 3) {
$rows_query_string = "SELECT
COUNT(mtd.device_id)
FROM mac_track_dot1x mtd
LEFT JOIN mac_track_sites mts ON (mtd.site_id = mts.site_id)
$sql_where";
$total_rows = db_fetch_cell($rows_query_string);
}else{
$rows_query_string = "SELECT
COUNT(DISTINCT device_id, mac_address, port_number, ip_address)
FROM mac_track_dot1x mtd
LEFT JOIN mac_track_sites mts ON (mtd.site_id = mts.site_id)
$sql_where";
$total_rows = db_fetch_cell($rows_query_string);
}
if (read_config_option('mt_reverse_dns') != '') {
$display_text = array(
'nosort' => array(__('Actions', 'mactrack'), ''),
'device_name' => array(__('Switch Name', 'mactrack'), 'ASC'),
'hostname' => array(__('Switch Hostname', 'mactrack'), 'ASC'),
'username' => array(__('Username', 'mactrack'), 'ASC'),
'ip_address' => array(__('ED IP Address', 'mactrack'), 'ASC'),
'dns_hostname' => array(__('ED DNS Hostname', 'mactrack'), 'ASC'),
'mac_address' => array(__('ED MAC Address', 'mactrack'), 'ASC'),
'port_number' => array(__('Port Number', 'mactrack'), 'DESC'),
'ifName' => array(__('Port Name', 'mactrack'), 'ASC'),
'domain' => array(__('Domain', 'mactrack'), 'DESC'),
'status' => array(__('Status', 'mactrack'), 'ASC'),
'scan_date' => array(__('Last Scan Date', 'mactrack'), 'DESC')
);
}else{
$display_text = array(
'nosort' => array(__('Actions', 'mactrack'), ''),
'device_name' => array(__('Switch Name', 'mactrack'), 'ASC'),
'hostname' => array(__('Switch Hostname', 'mactrack'), 'ASC'),
'username' => array(__('Username', 'mactrack'), 'ASC'),
'ip_address' => array(__('ED IP Address', 'mactrack'), 'ASC'),
'mac_address' => array(__('ED MAC Address', 'mactrack'), 'ASC'),
'port_number' => array(__('Port Number', 'mactrack'), 'DESC'),
'ifName' => array(__('Port Name', 'mactrack'), 'ASC'),
'domain' => array(__('Domain', 'mactrack'), 'DESC'),
'status' => array(__('Status', 'mactrack'), 'ASC'),
'scan_date' => array(__('Last Scan Date', 'mactrack'), 'DESC')
);
}
if (mactrack_check_user_realm(2122)) {
$columns = sizeof($display_text) + 1;
}else{
$columns = sizeof($display_text);
}
$nav = html_nav_bar('mactrack_view_dot1x.php?report=dot1x', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, $columns, __('802.1x Sessions', 'mactrack'), 'page', 'main');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
if (mactrack_check_user_realm(2122)) {
html_header_sort_checkbox($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
}else{
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
}
$i = 0;
if (sizeof($port_results)) {
foreach ($port_results as $port_result) {
/* find the background color and enclose it */
$class = mactrack_dot1x_row_class($port_result);
if ($class) {
print "<tr id='row_" . $port_result['device_id'] . '_' . $port_result['port_number'] . "' class='$class'>\n"; $i++;
}else{
if (($i % 2) == 1) {
$class = 'odd';
}else{
$class = 'even';
}
print "<tr id='row_" . $port_result['device_id'] . "' class='$class'>\n"; $i++;
}
print mactrack_format_dot1x_row($port_result);
}
}else{
print '<tr><td colspan="7"><em>' . __('No Device Tracking 802.1x Sessions Found', 'mactrack') . '</em></td></tr>';
}
html_end_box(false);
if (sizeof($port_results)) {
print $nav;
}
print '<div class="center" style="position:fixed;left:0;bottom:0;display:table;margin-left:auto;margin-right:auto;width:100%;">';
html_start_box('', '100%', '', '3', 'center', '');
print '<tr>';
mactrack_legend_row('authn_success', __('Authorization Success', 'mactrack'));
mactrack_legend_row('auth_success', __('Authentication Success', 'mactrack'));
mactrack_legend_row('authn_failed', __('Authorization Failed', 'mactrack'));
mactrack_legend_row('auth_failed', __('Authentication Failed', 'mactrack'));
mactrack_legend_row('running', __('Running', 'mactrack'));
mactrack_legend_row('idle', __('Idle', 'mactrack'));
print '</tr>';
html_end_box(false);
print '</div>';
print '<div id="response"></div>';
bottom_footer();
}
function mactrack_dot1x_filter() {
global $item_rows, $rows_selector, $mactrack_search_types;
?>
<tr class='even'>
<td>
<form id='mactrack'>
<table class='filterTable'>
<tr>
<td>
<?php print __('Search', 'mactrack');?>
</td>
<td>
<input type='text' id='filter' size='25' value='<?php print get_request_var('filter');?>'>
</td>
<td>
<?php print __('Site', 'mactrack');?>
</td>
<td>
<select id='site_id' onChange='applyFilter()'>
<option value='-1'<?php if (get_request_var('site_id') == '-1') {?> selected<?php }?>><?php print __('N/A', 'mactrack');?></option>
<?php
$sites = db_fetch_assoc('select site_id,site_name from mac_track_sites order by site_name');
if (sizeof($sites)) {
foreach ($sites as $site) {
print '<option value="' . $site['site_id'] .'"'; if (get_request_var('site_id') == $site['site_id']) { print ' selected'; } print '>' . $site['site_name'] . '</option>';
}
}
?>
</select>
</td>
<td>
<?php print __('Device', 'mactrack');?>
</td>
<td>
<select id='device_id' onChange='applyFilter()'>
<option value='-1'<?php if (get_request_var('device_id') == '-1') {?> selected<?php }?>><?php print __('All', 'mactrack');?></option>
<?php
if (get_request_var('site_id') == -1) {
$filter_devices = db_fetch_assoc('SELECT DISTINCT device_id, device_name, hostname
FROM mac_track_devices
WHERE device_type_id
IN (SELECT device_type_id from mac_track_device_types
WHERE dot1x_scanning_function="get_cisco_dot1x_table")
ORDER BY device_name');
}else{
$filter_devices = db_fetch_assoc_prepared('SELECT device_id, device_name, hostname
FROM mac_track_devices
WHERE (site_id = ? )
AND (device_type_id IN
(SELECT device_type_id from mac_track_device_types
WHERE dot1x_scanning_function="get_cisco_dot1x_table"))
ORDER BY device_name',
array(get_request_var('site_id')));
}
if (sizeof($filter_devices)) {
foreach ($filter_devices as $filter_device) {
print '<option value=" ' . $filter_device['device_id'] . '"'; if (get_request_var('device_id') == $filter_device['device_id']) { print ' selected'; } print '>' . $filter_device['device_name'] . '(' . $filter_device['hostname'] . ')' . '</option>';
}
}
?>
</select>
</td>
<td>
<?php print __('Sessions', 'mactrack');?>
</td>
<td>
<select id='rows' onChange='applyFilter()'>
<?php
if (sizeof($rows_selector)) {
foreach ($rows_selector as $key => $value) {
print '<option value="' . $key . '"'; if (get_request_var('rows') == $key) { print ' selected'; } print '>' . $value . '</option>\n';
}
}
?>
</select>
</td>
<td>
<span class='nowrap'>
<input type='submit' id='go' value='<?php print __esc('Go', 'mactrack');?>'>
<input type='button' id='clear' value='<?php print __esc('Clear', 'mactrack');?>'>
<input type='button' id='export' value='<?php print __esc('Export', 'mactrack');?>'>
</span>
</td>
</tr>
</table>
<table class='filterTable'>
<tr>
<td>
<?php print __('IP', 'mactrack');?>
</td>
<td>
<select id='ip_filter_type_id'>
<?php
for($i=1;$i<=sizeof($mactrack_search_types);$i++) {
print "<option value='" . $i . "'"; if (get_request_var('ip_filter_type_id') == $i) { print ' selected'; } print '>' . $mactrack_search_types[$i] . '</option>';
}
?>
</select>
</td>
<td>
<input type='text' id='ip_filter' size='25' value='<?php print get_request_var('ip_filter');?>'>
</td>
<td>
<?php print __('Status', 'mactrack');?>
</td>
<td>
<select id='status' onChange='applyFilter()'>
<option value='0'<?php if (get_request_var('status') == '0') {?> selected<?php }?>><?php print __('Any Status', 'mactrack');?></option>
<option value='1'<?php if (get_request_var('status') == '1') {?> selected<?php }?>><?php print __('Idle', 'mactrack');?></option>
<option value='2'<?php if (get_request_var('status') == '2') {?> selected<?php }?>><?php print __('Running', 'mactrack');?></option>
<option value='3'<?php if (get_request_var('status') == '3') {?> selected<?php }?>><?php print __('No method', 'mactrack');?></option>
<option value='4'<?php if (get_request_var('status') == '4') {?> selected<?php }?>><?php print __('Authentication Success', 'mactrack');?></option>
<option value='5'<?php if (get_request_var('status') == '5') {?> selected<?php }?>><?php print __('Authentication Failed', 'mactrack');?></option>
<option value='6'<?php if (get_request_var('status') == '6') {?> selected<?php }?>><?php print __('Authorization Succcess', 'mactrack');?></option>
<option value='7'<?php if (get_request_var('status') == '7') {?> selected<?php }?>><?php print __('Authorization Failed', 'mactrack');?></option>
</select>
</td>
<td>
<?php print __('Show', 'mactrack');?>
</td>
<td>
<select id='scan_date' onChange='applyFilter()'>
<option value='1'<?php if (get_request_var('scan_date') == '1') {?> selected<?php }?>><?php print __('All', 'mactrack');?></option>
<option value='2'<?php if (get_request_var('scan_date') == '2') {?> selected<?php }?>><?php print __('Most Recent', 'mactrack');?></option>
<?php
$scan_dates = db_fetch_assoc('SELECT DISTINCT scan_date FROM mac_track_dot1x ORDER BY scan_date DESC LIMIT 10');
if (sizeof($scan_dates)) {
foreach ($scan_dates as $scan_date) {
print '<option value="' . $scan_date['scan_date'] . '"'; if (get_request_var('scan_date') == $scan_date['scan_date']) { print ' selected'; } print '>' . $scan_date['scan_date'] . '</option>';
}
}
?>
</select>
</td>
</tr>
<tr>
<td>
<?php print __('MAC', 'mactrack');?>
</td>
<td>
<select id='mac_filter_type_id'>
<?php
for($i=1;$i<=sizeof($mactrack_search_types)-2;$i++) {
print "<option value='" . $i . "'"; if (get_request_var('mac_filter_type_id') == $i) { print ' selected'; } print '>' . $mactrack_search_types[$i] . '</option>';
}
?>
</select>
</td>
<td>
<input type='text' id='mac_filter' size='25' value='<?php print get_request_var('mac_filter');?>'>
</td>
<td>
<?php print __('Domain', 'mactrack');?>
</td>
<td>
<select id='domain' onChange='applyFilter()'>
<option value='-1'<?php if (get_request_var('domain') == '-1') {?> selected<?php }?>><?php print __('All', 'mactrack');?></option>
<option value='2'<?php if (get_request_var('domain') == '2') {?> selected<?php }?>><?php print __('DATA', 'mactrack');?></option>
<option value='3'<?php if (get_request_var('domain') == '3') {?> selected<?php }?>><?php print __('VOICE', 'mactrack');?></option>
</select>
</td>
</tr>
<tr>
<td>
<?php print __('Portname', 'mactrack');?>
</td>
<td>
<select id='port_name_filter_type_id'>
<?php
for($i=1;$i<=sizeof($mactrack_search_types);$i++) {
print "<option value='" . $i . "'"; if (get_request_var('port_name_filter_type_id') == $i) { print ' selected'; } print '>' . $mactrack_search_types[$i] . '</option>';
}
?>
</select>
</td>
<td>
<input type='text' id='port_name_filter' size='25' value='<?php print get_request_var('port_name_filter');?>'>
</td>
<td colspan='2'>
</td>
</tr>
</table>
</form>
<script type='text/javascript'>
function applyFilter() {
strURL = urlPath+'plugins/mactrack/mactrack_view_dot1x.php?report=dot1x&header=false';
strURL += '&site_id=' + $('#site_id').val();
strURL += '&device_id=' + $('#device_id').val();
strURL += '&rows=' + $('#rows').val();
strURL += '&mac_filter_type_id=' + $('#mac_filter_type_id').val();
strURL += '&mac_filter=' + $('#mac_filter').val();
strURL += '&filter=' + $('#filter').val();
strURL += '&ip_filter_type_id=' + $('#ip_filter_type_id').val();
strURL += '&ip_filter=' + $('#ip_filter').val();
strURL += '&port_name_filter_type_id=' + $('#port_name_filter_type_id').val();
strURL += '&port_name_filter=' + $('#port_name_filter').val();
strURL += '&scan_date=' + $('#scan_date').val();
strURL += '&domain=' + $('#domain').val();
strURL += '&status=' + $('#status').val();
loadPageNoHeader(strURL);
}
function clearFilter() {
strURL = urlPath+'plugins/mactrack/mactrack_view_dot1x.php?report=dot1x&header=false&clear=true';
loadPageNoHeader(strURL);
}
function exportRows() {
strURL = urlPath+'plugins/mactrack/mactrack_view_dot1x.php?report=dot1x&export=true';
document.location = strURL;
}
$(function() {
$('#mactrack').submit(function(event) {
event.preventDefault();
applyFilter();
});
$('#clear').click(function() {
clearFilter();
});
$('#export').click(function() {
exportRows();
});
});
</script>
</td>
</tr>
<?php
}