Search.php doesn't retrieve IP addresses from the "other" table (only from the "system" one). Also, it retrieves IPs only if they are padded with '0' (010.099.003.123, instead of 10.99.3.123). I fixed it with the following changes: 1. In the include_functions.php page, replace the function ip_trans_to($ip) with the following: [code] function ip_trans_to($ip) { if (($ip <> "") AND (!(is_null($ip)))){ $myip = explode(".",$ip); $ip = substr("000" . $myip[0], -3); if(isset($myip[1])){ $myip[1] = substr("000" . $myip[1], -3); $ip = $ip . "." . $myip[1];} if(isset($myip[2])){ $myip[2] = substr("000" . $myip[2], -3); $ip = $ip . "." . $myip[2];} if(isset($myip[3])){ $myip[3] = substr("000" . $myip[3], -3); $ip = $ip . "." . $myip[3];} } else { $ip = " Not-Networked"; } return $ip; } [/code] 2. In the search.php page, comment line 65 [code] //$sql .= "net_ip_address LIKE '%$search%' OR "; [/code] comment line 87 [code] //if (strpos(strtoupper($myrow["net_ip_address"]), $search) !== false){$search_field = "IP Address"; $search_result = $myrow["net_ip_address"];} [/code] add at line 199 [code] // Search for IP address into "system" table
$search_padded = ip_trans_to($search);
$sql = "SELECT DISTINCT system_name, system_uuid, net_ip_address "; $sql .= "FROM system WHERE "; $sql .= "net_ip_address LIKE '%$search%' OR "; $sql .= "net_ip_address LIKE '%$search_padded%'";
$result = mysql_query($sql, $db); if ($myrow = mysql_fetch_array($result)){ do { if (strpos(strtoupper($myrow["net_ip_address"]), $search) !== false) {$search_field = "IP Address"; $search_result = $myrow["net_ip_address"];} else {if (strpos(strtoupper($myrow["net_ip_address"]), $search_padded) !== false) {$search_field = "IP Address"; $search_result = ip_trans($myrow["net_ip_address"]);} } $bgcolor = change_row_color($bgcolor,$bg1,$bg2); $result_set[] = array($myrow["system_name"], $myrow["system_uuid"], ip_trans($myrow["net_ip_address"]), $search_field, $search_result); } while ($myrow = mysql_fetch_array($result));
} else {}
// Search for IP address into "other" table
$search_padded = ip_trans_to($search);
$sql = "SELECT DISTINCT other_network_name, other_id, other_ip_address "; $sql .= "FROM other WHERE "; $sql .= "other_ip_address LIKE '%$search%' OR "; $sql .= "other_ip_address LIKE '%$search_padded%'";
$result = mysql_query($sql, $db); if ($myrow = mysql_fetch_array($result)){ do { if (strpos(strtoupper($myrow["other_ip_address"]), $search) !== false) {$search_field = "Device IP Address"; $search_result = $myrow["other_ip_address"];} else {if (strpos(strtoupper($myrow["other_ip_address"]), $search_padded) !== false) {$search_field = "Device IP Address"; $search_result = ip_trans($myrow["other_ip_address"]);} } $bgcolor = change_row_color($bgcolor,$bg1,$bg2); $result_set[] = array($myrow["other_network_name"], $myrow["other_id"], ip_trans($myrow["other_ip_address"]), $search_field, $search_result); } while ($myrow = mysql_fetch_array($result));
} else {}
[/code]
_________________ Edoardo
|