Repository navigation
Expand file tree
/
Copy pathmactrack_view_arp.php
More file actions
725 lines (635 loc) · 23.3 KB
/
Copy pathmactrack_view_arp.php
File metadata and controls
725 lines (635 loc) · 23.3 KB
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
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 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('../../');
require('./include/auth.php');
require_once('./plugins/mactrack/lib/mactrack_functions.php');
$title = __('Mactrack - ARP/IP View', 'mactrack');
set_default_action();
if (isset_request_var('export')) {
mactrack_view_export_ips();
} else {
general_header();
mactrack_view_ips();
bottom_footer();
}
/* ------------------------
The 'actions' function
------------------------ */
/**
* Validates and stores this view's filter request variables (rows,
* page, site id, device id, MAC/IP filter type and text, sort
* column/direction, scan date) into the session for the ARP/IP list
* view.
*
* @return void
*/
function mactrack_view_ips_validate_request_vars(): void {
// ================= input validation and session storage =================
$filters = [
'rows' => [
'filter' => FILTER_VALIDATE_INT,
'pageset' => true,
'default' => '-1'
],
'page' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
],
'site_id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
],
'device_id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '-1'
],
'mac_filter_type_id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
],
'ip_filter_type_id' => [
'filter' => FILTER_VALIDATE_INT,
'default' => '1'
],
'filter' => [
'filter' => FILTER_CALLBACK,
'pageset' => true,
'default' => '',
'options' => ['options' => 'sanitize_search_string']
],
'ip_filter' => [
'filter' => FILTER_CALLBACK,
'default' => '',
'options' => ['options' => 'sanitize_search_string']
],
'mac_filter' => [
'filter' => FILTER_CALLBACK,
'default' => '',
'options' => ['options' => 'sanitize_search_string']
],
'sort_column' => [
'filter' => FILTER_CALLBACK,
'default' => 'device_name',
'options' => ['options' => 'sanitize_search_string']
],
'sort_direction' => [
'filter' => FILTER_CALLBACK,
'default' => 'ASC',
'options' => ['options' => 'sanitize_search_string']
],
'scan_date' => [
'filter' => FILTER_CALLBACK,
'default' => '2',
'options' => ['options' => 'sanitize_search_string']
]
];
validate_store_request_vars($filters, 'sess_mtv_arp');
// ================= input validation =================
}
/**
* Exports the current filtered ARP/IP results (site, hostname, device,
* MAC, vendor, IP, DNS hostname, port, interface, scan date) as a
* downloaded CSV file. Called from this script's main dispatch when
* the export request variable is set.
*
* @return void
*/
function mactrack_view_export_ips(): void {
mactrack_view_ips_validate_request_vars();
$sql_where = '';
$port_results = mactrack_view_get_ip_records($sql_where, 0, false);
$xport_array = [];
array_push($xport_array, '"site_name","hostname","device_name",' .
'"mac_address","vendor_name",' .
'"ip_address","dns_hostname","port_number","ifName","scan_date"');
if (cacti_sizeof($port_results)) {
foreach ($port_results as $port_result) {
$scan_date = $port_result['scan_date'];
array_push($xport_array,'"' . $port_result['site_name'] . '","' .
$port_result['hostname'] . '","' . $port_result['device_name'] . '","' .
mactrack_format_mac($port_result['mac_address']) . '","' . $port_result['vendor_name'] . '","' .
$port_result['ip_address'] . '","' . $port_result['dns_hostname'] . '","' .
$port_result['port_number'] . '","' . $port_result['ifName'] . '","' .
$scan_date . '"');
}
}
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename=cacti_port_ipaddresses_xport.csv');
foreach ($xport_array as $xport_line) {
print $xport_line . "\n";
}
}
/**
* Builds and executes the SQL query for the ARP/IP list view, applying
* the current MAC filter, IP filter, text filter, site, device, and
* scan date request variables (defaulting to the most recent scan
* date), sort order, and optional row limits. Requires a site or
* device filter (or a non-empty WHERE clause) to avoid a full table
* scan; returns an empty result set otherwise.
*
* @param string &$sql_where Receives the generated SQL WHERE clause
* for reuse by the caller.
* @param int $rows Number of rows per page, used to compute
* the SQL LIMIT clause when $apply_limits
* is true.
* @param bool $apply_limits Whether to apply a SQL LIMIT clause
* (default true).
*
* @return array The matching ARP/IP records.
*/
function mactrack_view_get_ip_records(&$sql_where, $rows, $apply_limits = true): array {
// form the 'where' clause for our main sql query
if (get_request_var('mac_filter') != '') {
$mac_filter = str_replace(':', '', (string) get_request_var('mac_filter'));
$mac_filter = str_replace('-', '', $mac_filter);
$mac_filter = str_replace('.', '', $mac_filter);
switch (get_request_var('mac_filter_type_id')) {
case '1': // do not filter
break;
case '2': // matches
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.mac_address = ' . db_qstr($mac_filter);
break;
case '3': // contains
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.mac_address LIKE ' . db_qstr('%' . $mac_filter . '%');
break;
case '4': // begins with
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.mac_address LIKE ' . db_qstr($mac_filter . '%');
break;
case '5': // does not contain
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.mac_address NOT LIKE ' . db_qstr('%' . $mac_filter . '%');
break;
case '6': // does not begin with
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.mac_address NOT LIKE ' . db_qstr($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 .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address = ' . db_qstr(get_request_var('ip_filter'));
break;
case '3': // contains
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address LIKE ' . db_qstr('%' . get_request_var('ip_filter') . '%');
break;
case '4': // begins with
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address LIKE ' . db_qstr(get_request_var('ip_filter') . '%');
break;
case '5': // does not contain
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address NOT LIKE ' . db_qstr('%' . get_request_var('ip_filter') . '%');
break;
case '6': // does not begin with
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address NOT LIKE ' . db_qstr(get_request_var('ip_filter') . '%');
break;
case '7': // is null
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address = ""';
break;
case '8': // is not null
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.ip_address != ""';
}
}
if (get_request_var('filter') != '') {
if (read_config_option('mt_reverse_dns') != '') {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' (mti.dns_hostname LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ' OR ' .
'mtod.vendor_name LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')';
} else {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' (mtod.vendor_name LIKE ' . db_qstr('%' . get_request_var('filter') . '%') . ')';
}
}
if ((get_request_var('site_id') != '-1')) {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.site_id = ' . get_filter_request_var('site_id');
}
if ((get_request_var('device_id') != '-1')) {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') .
' mti.device_id = ' . get_filter_request_var('device_id');
}
// 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 ($sql_where == '') {
return [];
}
}
if ((get_request_var('scan_date') == '2')) {
$last = db_fetch_cell('SELECT MAX(scan_date) FROM mac_track_scan_dates');
if ($last != '') {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mti.scan_date = ' . db_qstr($last);
}
} elseif ((get_request_var('scan_date') != '1') && get_request_var('scan_date') != '') {
$sql_where .= ($sql_where != '' ? ' AND' : 'WHERE') . ' mti.scan_date = ' . db_qstr(get_request_var('scan_date'));
}
$sql_order = get_order_string();
if ($apply_limits && $rows != 999999) {
$sql_limit = ' LIMIT ' . ($rows * (get_request_var('page') - 1)) . ', ' . $rows;
} else {
$sql_limit = '';
}
$query_string = "SELECT mti.*, mts.site_name, mtod.*, mtin.ifName
FROM mac_track_ips AS mti
LEFT JOIN mac_track_sites AS mts
ON mti.site_id = mts.site_id
LEFT JOIN mac_track_oui_database AS mtod
ON mtod.vendor_mac=SUBSTRING(mti.mac_address, 1, 6)
LEFT JOIN mac_track_interfaces AS mtin
ON mtin.device_id=mti.device_id
AND mtin.ifIndex=mti.port_number
$sql_where
$sql_order
$sql_limit";
// cacti_log("SQL: $query_string");
return db_fetch_assoc($query_string);
}
/**
* Renders the main ARP/IP list page: displays the IP address filter
* form, validates/stores this view's filter request variables, then
* displays a filtered, sorted, paginated table of ARP/IP entries with
* summary statistics. Called from this script's main dispatch as the
* default view.
*
* @return void
*
* @global string $title The page title, set for the
* surrounding page chrome.
* @global string $report Reserved/declared for parity
* with other functions in this
* file; not used directly here.
* @global array $mactrack_search_types Filter-type option list used
* by the address filter form.
* @global array $rows_selector Reserved/declared for parity
* with other functions in this
* file; not used directly here.
* @global array $config Cacti global configuration
* array.
* @global array $item_rows Default number of rows per
* page from Cacti settings.
*/
function mactrack_view_ips(): void {
global $title, $report, $mactrack_search_types, $rows_selector, $config;
global $item_rows;
mactrack_view_ips_validate_request_vars();
mactrack_tabs();
html_start_box($title, '100%', '', '3', 'center', '');
mactrack_ip_address_filter();
html_end_box();
$sql_where = '';
$rows = plugin_get_rows_per_page();
$port_results = mactrack_view_get_ip_records($sql_where, $rows, true);
// prevent table scans, either a device or site must be selected
if ($sql_where == '') {
$total_rows = 0;
} elseif (get_request_var('rows') == 1 || (get_request_var('scan_date') == 1)) {
$rows_query_string = "SELECT
COUNT(mti.device_id)
FROM mac_track_ips AS mti
LEFT JOIN mac_track_sites AS mts
ON mti.site_id=mts.site_id
LEFT JOIN mac_track_oui_database AS mtod
ON mtod.vendor_mac=SUBSTRING(mti.mac_address,1,6)
$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_ips AS mti
LEFT JOIN mac_track_sites AS mts
ON mti.site_id=mts.site_id
LEFT JOIN mac_track_oui_database AS mtod
ON mtod.vendor_mac=SUBSTRING(mti.mac_address,1,6)
$sql_where";
$total_rows = db_fetch_cell($rows_query_string);
}
$display_text1 = [
'site_name' => [
'display' => __('Site Name', 'mactrack'),
'sort' => 'ASC'
],
'device_name' => [
'display' => __('Switch Name', 'mactrack'),
'sort' => 'ASC'
],
'hostname' => [
'display' => __('Switch Hostname', 'mactrack'),
'sort' => 'ASC'
],
'ip_address' => [
'display' => __('ED IP Address', 'mactrack'),
'sort' => 'ASC'
],
];
$display_dns = [];
if (read_config_option('mt_reverse_dns') != '') {
$display_dns = [
'dns_hostname' => [
'display' => __('ED DNS Hostname', 'mactrack'),
'sort' => 'ASC'
]
];
}
$display_text2 = [
'mac_address' => [
'display' => __('ED MAC Address', 'mactrack'),
'sort' => 'ASC'
],
'vendor_name' => [
'display' => __('Vendor Name', 'mactrack'),
'sort' => 'ASC'
],
'port_number' => [
'display' => __('Port Number', 'mactrack'),
'align' => 'left',
'sort' => 'DESC'
],
'ifName' => [
'display' => __('Port Name', 'mactrack'),
'align' => 'left',
'sort' => 'ASC'
],
'scan_date' => [
'display' => __('Last Scan Date', 'mactrack'),
'align' => 'left',
'sort' => 'DESC'
]
];
$display_text = array_merge($display_text1, $display_dns, $display_text2);
$columns = cacti_sizeof($display_text);
$nav = html_nav_bar('mactrack_view_arp.php', MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, $columns, __('ARP Cache', 'mactrack'), 'page', 'main');
print $nav;
html_start_box('', '100%', '', '3', 'center', '');
html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'));
$i = 0;
if (cacti_sizeof($port_results)) {
foreach ($port_results as $port_result) {
form_alternate_row('line' . $i, true);
form_selectable_cell($port_result['site_name'], $i);
form_selectable_cell($port_result['device_name'], $i, '10%');
form_selectable_cell($port_result['hostname'], $i);
form_selectable_cell(filter_value($port_result['ip_address'], get_request_var('filter')), $i);
if (read_config_option('mt_reverse_dns') != '') {
form_selectable_cell(filter_value($port_result['dns_hostname'], get_request_var('filter')), $i);
}
form_selectable_cell(filter_value(mactrack_format_mac($port_result['mac_address']), get_request_var('filter')), $i);
form_selectable_cell(filter_value($port_result['vendor_name'], get_request_var('filter')), $i);
form_selectable_cell($port_result['port_number'], $i, '', 'left');
form_selectable_cell(!is_null($port_result['ifName']) ? $port_result['ifName'] : '', $i, '', 'left');
form_selectable_cell($port_result['scan_date'], $i, '', 'left');
form_end_row();
$i++;
}
} else {
if (get_request_var('site_id') == -1 && get_request_var('device_id') == -1) {
print '<tr><td colspan="10"><em>' . __('You must first choose a Site, Device or other search criteria.', 'mactrack') . '</em></td></tr>';
} else {
print '<tr><td colspan="10"><em>' . __('No Mactrack IP Results Found', 'mactrack') . '</em></td></tr>';
}
}
html_end_box(false);
if (cacti_sizeof($port_results)) {
print $nav;
mactrack_display_stats();
}
}
/**
* Renders the search/site/device/MAC/IP/scan-date filter form controls
* for the ARP/IP list view.
*
* @return void
*
* @global array $item_rows Rows-per-page option list used
* to populate the rows dropdown.
* @global array $rows_selector Reserved/declared for parity
* with other functions in this
* file; not used directly here.
* @global array $mactrack_search_types Filter-type option list (e.g.
* matches/contains/begins with)
* used to populate the MAC/IP
* filter type dropdowns.
*/
function mactrack_ip_address_filter(): void {
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 html_escape_request_var('filter'); ?>'>
</td>
<td>
<?php print __('Site', 'mactrack'); ?>
</td>
<td>
<select id='site_id'>
<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 (cacti_sizeof($sites)) {
foreach ($sites as $site) {
print '<option value="' . $site['site_id'] . '"';
if (get_request_var('site_id') == $site['site_id']) {
print ' selected';
} print '>' . html_escape($site['site_name']) . '</option>';
}
}
?>
</select>
</td>
<td>
<?php print __('Device', 'mactrack'); ?>
</td>
<td>
<select id='device_id'>
<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
ORDER BY device_name');
} else {
$filter_devices = db_fetch_assoc_prepared('SELECT DISTINCT device_id, device_name, hostname
FROM mac_track_devices
WHERE site_id = ?
ORDER BY device_name',
[get_request_var('site_id')]);
}
if (cacti_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 '>' . html_escape($filter_device['device_name'] . '(' . $filter_device['hostname'] . ')') . '</option>';
}
}
?>
</select>
</td>
<td>
<?php print __('IP\'s', 'mactrack'); ?>
</td>
<td>
<select id='rows'>
<?php
if (cacti_sizeof($rows_selector) > 0) {
foreach ($rows_selector as $key => $value) {
print '<option value="' . $key . '"';
if (get_request_var('rows') == $key) {
print ' selected';
} print '>' . $value . '</option>';
}
}
?>
</select>
</td>
<td>
<span>
<button type='submit' id='go' class='ui-button ui-corner-all ui-widget ui-state-active'><?php print __esc('Go', 'mactrack'); ?></button>
<button type='button' id='clear' class='ui-button ui-corner-all ui-widget'><?php print __esc('Clear', 'mactrack'); ?></button>
<button type='button' id='export' class='ui-button ui-corner-all ui-widget'><?php print __esc('Export', 'mactrack'); ?></button>
</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 <= cacti_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 html_escape_request_var('ip_filter'); ?>'>
</td>
<td>
<?php print __('Show', 'mactrack'); ?>
</td>
<td>
<select id='scan_date'>
<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 scan_date FROM mac_track_scan_dates ORDER BY scan_date DESC');
if (cacti_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 <= cacti_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 html_escape_request_var('mac_filter'); ?>'>
</td>
</tr>
</table>
</form>
<script type='text/javascript' <?php print plugin_mactrack_csp_nonce(); ?>>
function applyFilter() {
strURL = urlPath+'plugins/mactrack/mactrack_view_arp.php?report=arp&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 += '&scan_date=' + $('#scan_date').val();
loadPageNoHeader(strURL);
}
function clearFilter() {
strURL = urlPath+'plugins/mactrack/mactrack_view_arp.php?report=arp&header=false&clear=true';
loadPageNoHeader(strURL);
}
function exportRows() {
strURL = urlPath+'plugins/mactrack/mactrack_view_arp.php?report=arp&export=true';
document.location = strURL;
}
$(function() {
$('#site_id, #device_id, #rows, #scan_date').on('change', function() {
applyFilter();
});
$('#mactrack').on('submit', function(event) {
event.preventDefault();
applyFilter();
});
$('#clear').on('click', function() {
clearFilter();
});
$('#export').on('click', function() {
exportRows();
});
});
</script>
</td>
</tr>
<?php
}