Menu

#29 [r529] Search IP fix

Unstable_(example)
open
nobody
search (2) ip (1)
1
2015-05-01
2015-05-01
NeK
No

I found the root cause fort he search problem.

File: app\tools\search\search-results.php
File: app\tools\search\search-results-export.php

The problem is if the search term is exactly 12 in length.
Then it only checks if it does not contains "." or ":", then it handles it as mac.
But it misses to hanlde the case when it is 12 in length and does contain "." or ":".

The if-else is wrong here.

else if(strlen($search_term) == 12) {
    if( (substr_count($search_term, ":") == 0) && (substr_count($search_term, ".") == 0) )  { $type = "mac"; }  //no dots or : -> mac without :
}
else { $type = $Addresses->identify_address( $search_term ); }      # identify address type

This can be shorten to this:

# check if mac address or ip address
if(strlen($search_term)==17 && substr_count($search_term, ":") == 5)
{
        $type = "mac"; //count : -> must be 5
}
else if(strlen($search_term) == 12 && (substr_count($search_term, ":") == 0) && (substr_count($search_term, ".") == 0))
{
        $type = "mac"; //no dots or : -> mac without :
}
else
{
        $type = $Addresses->identify_address( $search_term ); //identify address type
}

Related

Commit: [r529]

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.