|
1 | | -<script type="text/javascript"> |
2 | | -/* fix for ajax-loading tooltips */ |
3 | | -$('body').tooltip({ selector: '[rel=tooltip]' }); |
4 | | -</script> |
5 | | - |
6 | 1 | <?php |
7 | 2 |
|
8 | 3 | /* |
9 | 4 | * Script to display search results |
10 | 5 | **********************************/ |
11 | 6 |
|
12 | 7 | # for ajax-loaded pages |
13 | | -if(!is_object($Subnets)) { |
| 8 | +if(!isset($Subnets)) { |
14 | 9 | # include required scripts |
15 | 10 | require( dirname(__FILE__) . '/../../../functions/functions.php' ); |
16 | 11 |
|
|
26 | 21 |
|
27 | 22 | # set searchterm |
28 | 23 | if(isset($_REQUEST['ip'])) { |
| 24 | + // trim |
| 25 | + $_REQUEST['ip'] = trim($_REQUEST['ip']); |
29 | 26 | // escape |
30 | 27 | $_REQUEST['ip'] = htmlspecialchars($_REQUEST['ip']); |
31 | 28 |
|
|
38 | 35 | # change * to % for database wildchar |
39 | 36 | $search_term = str_replace("*", "%", $search_term); |
40 | 37 |
|
41 | | -# check if mac address or ip address |
42 | | -if(strlen($search_term)==17 && substr_count($search_term, ":") == 5) { |
43 | | - $type = "mac"; //count : -> must be 5 |
| 38 | + |
| 39 | +//initialize Pear IPv6 object |
| 40 | +require_once( dirname(__FILE__) . '/../../../functions/PEAR/Net/IPv6.php' ); |
| 41 | +$Net_IPv6 = new Net_IPv6(); |
| 42 | + |
| 43 | +// ipv6 ? |
| 44 | +if ($Net_IPv6->checkIPv6($search_term)!=false) { |
| 45 | + $type = "IPv6"; |
| 46 | +} |
| 47 | +// check if mac address or ip address |
| 48 | +elseif(strlen($search_term)==17 && substr_count($search_term, ":") == 5) { |
| 49 | + $type = "mac"; //count : -> must be 5 |
44 | 50 | } |
45 | 51 | else if(strlen($search_term) == 12 && (substr_count($search_term, ":") == 0) && (substr_count($search_term, ".") == 0)){ |
46 | | - $type = "mac"; //no dots or : -> mac without : |
| 52 | + $type = "mac"; //no dots or : -> mac without : |
47 | 53 | } |
48 | | -else{ |
49 | | - $type = $Addresses->identify_address( $search_term ); //identify address type |
| 54 | +else { |
| 55 | + $type = $Addresses->identify_address( $search_term ); //identify address type |
50 | 56 | } |
51 | 57 |
|
52 | 58 | # reformat if IP address for search |
|
82 | 88 | # search addresses |
83 | 89 | if(@$_REQUEST['addresses']=="on" && strlen($_REQUEST['ip'])>0) { $result_addresses = $Tools->search_addresses($search_term, $search_term_edited['high'], $search_term_edited['low']); } |
84 | 90 | # search subnets |
85 | | -if(@$_REQUEST['subnets']=="on" && strlen($_REQUEST['ip'])>0) { $result_subnets = $Tools->search_subnets($search_term, $search_term_edited['high'], $search_term_edited['low']); } |
| 91 | +if(@$_REQUEST['subnets']=="on" && strlen($_REQUEST['ip'])>0) { $result_subnets = $Tools->search_subnets($search_term, $search_term_edited['high'], $search_term_edited['low'], $_REQUEST['ip']); } |
86 | 92 | # search vlans |
87 | 93 | if(@$_REQUEST['vlans']=="on" && strlen($_REQUEST['ip'])>0) { $result_vlans = $Tools->search_vlans($search_term); } |
88 | 94 |
|
|
103 | 109 | ?> |
104 | 110 |
|
105 | 111 |
|
| 112 | +<script type="text/javascript"> |
| 113 | +/* fix for ajax-loading tooltips */ |
| 114 | +$('body').tooltip({ selector: '[rel=tooltip]' }); |
| 115 | +</script> |
| 116 | + |
| 117 | + |
106 | 118 | <!-- search result subnet --> |
107 | 119 | <?php if(@$_REQUEST['subnets']=="on") { ?> |
108 | 120 | <br> |
|
0 commit comments