= ipFrom and INET_ATON('".$ipAddress."') <= ipTo and ";
}
if (!empty($ispName)) {
$query1 = $query1."UPPER(ispName) LIKE UPPER('%".str_replace( "'", "''", $ispName )."%') and ";
}
if (!empty($region)) {
$query1 = $query1."UPPER(region) = UPPER('".str_replace( "'", "''", $region )."') and ";
}
if (!empty($country)) {
$query1 = $query1."countryCode = '".str_replace( "'", "''", $country )."' and ";
}
$query2 = "";
if (!empty($gnl)) {
$query2 = $query2.", list_detail as d ";
}
$query2 = $query2." WHERE ";
if (!empty($gnl)) {
$query2 = $query2."d.list_id = '".$gnl."' and d.ipFrom = s.ipFrom and d.ipTo = s.ipTo and ";
}
if (!empty($ipAddressip2l)) {
$query2 = $query2."INET_ATON('".$ipAddress."') >= s.ipFrom and INET_ATON('".$ipAddress."') <= s.ipTo and ";
}
if (!empty($ispNameip2l)) {
$query2 = $query2."UPPER(s.ispName) LIKE UPPER('%".str_replace( "'", "''", $ispName )."%') and ";
}
if (!empty($region)) {
$query2 = $query2."UPPER(s.region) = UPPER('".str_replace( "'", "''", $region )."') and ";
}
if (!empty($country)) {
$query2 = $query2."s.countryCode = '".str_replace( "'", "''", $country )."' and ";
}
if ( $gnl == "")
{
if ( $ip2l !== "" ) {
$query = "";
if ( $gnlSort == 'y' )
{
$query = "SELECT INET_NTOA(ipFrom) as ipFromText, INET_NTOA(ipTo) as ipToText, countryCode, countryName,
latitude, longitude, region, ispName, city, zipcode
FROM ip2l_db14 WHERE ";
$query = $query.$query1." NOT EXISTS ( SELECT list_id FROM list_detail
WHERE list_detail.ipFrom = ip2l_db14.ipFrom AND list_detail.ipTo = ip2l_db14.ipTo )";
}
else
{
$query = "SELECT INET_NTOA(ipFrom) as ipFromText, INET_NTOA(ipTo) as ipToText, countryCode, countryName,
latitude, longitude, region, ispName, city, zipcode
FROM ip2l_db14 WHERE ";
$query = $query.$query1." 1=1";
}
$result = mysqli_query ( $GLOBALS['__mysqli_conn'], $query ) ;
$num_rows = mysqli_num_rows( $result );
$rangeTotal = $num_rows;
$query = "";
if ( $gnlSort == 'y' )
{
$query = "SELECT INET_NTOA(ipFrom) as ipFromText, INET_NTOA(ipTo) as ipToText, countryCode, countryName,
latitude, longitude, region, ispName, city, zipcode
FROM ip2l_db14 WHERE ";
$query = $query.$query1." NOT EXISTS ( SELECT list_id FROM list_detail
WHERE list_detail.ipFrom = ip2l_db14.ipFrom AND list_detail.ipTo = ip2l_db14.ipTo ) LIMIT ".( ($pageID)*200 ).", 200";
}
else
{
$query = "SELECT INET_NTOA(ipFrom) as ipFromText, INET_NTOA(ipTo) as ipToText, countryCode, countryName,
latitude, longitude, region, ispName, city, zipcode
FROM ip2l_db14 WHERE ";
$query = $query.$query1." 1=1 LIMIT ".( ($pageID)*200 ).", 200";
}
$ip2l_result = mysqli_query ($GLOBALS['__mysqli_conn'], $query);
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$pageTotal = floor( ( $rangeTotal-1 )/200 ) ;
$ip2lRows = mysqli_num_rows($ip2l_result);
}
if ($ipGeo != "") {
$query = "";
$query = "SELECT INET_NTOA(ipFrom) as ipFromText, INET_NTOA(ipTo) as ipToText,
priority, countryCode, countryName, longitude, latitude,
region, city, zipcode, timeZone, ispName, domainName, info_source
FROM ip_geolocation
WHERE ";
$query = $query.$query1." 1=1";
$geo_result = mysqli_query ( $GLOBALS['__mysqli_conn'], $query ) ;
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$geoRows = mysqli_num_rows($geo_result);
}
if ($subscriber != "") {
//There is no empty check for $ipAddress since that is the only query that makes sense
//If the user does not set it then an empty result set is returned
$iplist_result = mysqli_query ($GLOBALS['__mysqli_conn'],
"SELECT INET_NTOA(d.ipFrom) as ipFromText, INET_NTOA(d.ipTo) as ipToText, d.list_id,
d.cidr, s.list_name, SUBSTRING_INDEX(d.cidr,'/',1) as startIP
FROM list_detail as d, subscriber_lists as s
WHERE INET_ATON('".$ipAddress."') >= ipFrom AND INET_ATON('".$ipAddress."') <= ipTo
AND d.list_id = s.list_id");
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$subscriberRows = mysqli_num_rows($iplist_result);
}
}
else
{
if ($ip2l != "") {
$query= "SELECT INET_NTOA(s.ipFrom) as ipFromText, INET_NTOA(s.ipTo) as ipToText, s.countryCode, s.countryName,
s.latitude, s.longitude, s.region, s.ispName, s.city, s.zipcode
FROM ip2l_db14 as s ";
$query = $query.$query2." 1=1";
$result = mysqli_query ( $GLOBALS['__mysqli_conn'], $query ) ;
$num_rows = mysqli_num_rows( $result );
$rangeTotal = $num_rows;
$query = "";
$query = "SELECT INET_NTOA(s.ipFrom) as ipFromText, INET_NTOA(s.ipTo) as ipToText, s.countryCode, s.countryName,
s.latitude, s.longitude, s.region, s.ispName, s.city, s.zipcode
FROM ip2l_db14 as s ";
$query = $query.$query2." 1=1 LIMIT ".( ($pageID)*200 ).", 200";
$ip2l_result = mysqli_query ($GLOBALS['__mysqli_conn'], $query);
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$pageTotal = floor( ( $rangeTotal-1 )/200 ) ;
$ip2lRows = mysqli_num_rows($ip2l_result);
}
if ($ipGeo != "") {
$query = "";
$query = "SELECT INET_NTOA(s.ipFrom) as ipFromText, INET_NTOA(s.ipTo) as ipToText,
s.priority, s.countryCode, s.countryName, s.longitude, s.latitude,
s.region, s.city, s.zipcode, s.timeZone, s.ispName, s.domainName, s.info_source, INET_NTOA(d.ipFrom) as ipFromTextd, d.list_id
FROM ip_geolocation as s ";
if (!empty($priority)) {
$query = $query.$query2."s.priority = ".intval($priority)." and ";
}
$query = $query.$query2." 1=1";
$geo_result = mysqli_query ( $GLOBALS['__mysqli_conn'], $query ) ;
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$geoRows = mysqli_num_rows($geo_result);
}
if ($subscriber != "") {
//There is no empty checl for $ipAddress since that is the only query that makes sense
//If the user does not set it that an empty result set is returned
$iplist_result = mysqli_query ($GLOBALS['__mysqli_conn'],
"SELECT INET_NTOA(list_detail.ipFrom) as ipFromText, INET_NTOA(list_detail.ipTo) as ipToText, list_detail.list_id,
list_detail.cidr, subscriber_lists.list_name, SUBSTRING_INDEX(list_detail.cidr,'/',1) as startIP
FROM list_detail, subscriber_lists
WHERE INET_ATON('".$ipAddress."') >= ipFrom AND INET_ATON('".$ipAddress."') <= ipTo
AND list_detail.list_id = subscriber_lists.list_id");
check_for_mysqli_error($GLOBALS['__mysqli_conn']);
$subscriberRows = mysqli_num_rows($iplist_result);
}
}
function imask ( $this )
{
// use base_convert not dechex because dechex is broken and returns 0x80000000 instead of 0xffffffff
return base_convert ( ( pow(2,32) - pow(2, (32-$this)) ), 10, 16 ) ;
}
function imaxblock ( $ibase, $tbit )
{
while ($tbit > 0)
{
$im = hexdec(imask($tbit-1));
$imand = $ibase & $im;
if ($imand != $ibase)
{
break;
}
$tbit--;
}
return $tbit;
}
function range2cidrlist ( $start, $end )
{
// this function returns an array of cidr lists that map the range given
$result = array();
while ($end >= $start)
{
$maxsize = imaxblock($start,32);
$x = log($end - $start + 1)/log(2);
$maxdiff = floor(32 - floor($x));
$ip = long2ip($start);
if ($maxsize < $maxdiff)
{
$maxsize = $maxdiff;
}
array_push($result,"$ip/$maxsize");
$start += pow(2, (32-$maxsize));
}
return $result;
}
?>
Source | IP From | IP To | Priority | Region | City | Country | Zip Code | Coordinates | ISP Name | List | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
= $geos["info_source"] ?> | = $geos["ipFromText"] ?> | = $geos["ipToText"] ?> | = $geos["priority"] ?> | = $geos["region"] ?> | = $geos["city"] ?> | = $geos["countryName"] ?> | = $geos["zipcode"] ?> | ,= $geos["longitude"] ?>" target="_blank" title="View location on map" alt="View location on map">= $geos["latitude"] ?>, = $geos["longitude"] ?> | = $geos["ispName"] ?> | $gnl ) { $name = $gnl["name"]; $num = $gnl["num"]; if ( $num == $sizeof_result ) { ?> = $name ?> = $name ?> |
||||
ip2l | = $ip2ls["ipFromText"] ?> | = $ip2ls["ipToText"] ?> | - | = $ip2ls["region"] ?> | = $ip2ls["city"] ?> | = $ip2ls["countryName"] ?> | = $ip2ls["zipcode"] ?> | ,= $ip2ls["longitude"] ?>" target="_blank" title="View location on map" alt="View location on map">= $ip2ls["latitude"] ?>, = $ip2ls["longitude"] ?> | = $ip2ls["ispName"] ?> | |||||
ip2l | = $ip2ls["ipFromText"] ?> | = $ip2ls["ipToText"] ?> | - | = $ip2ls["region"] ?> | = $ip2ls["city"] ?> | = $ip2ls["countryName"] ?> | = $ip2ls["zipcode"] ?> | ,= $ip2ls["longitude"] ?>" target="_blank" title="View location on map" alt="View location on map">= $ip2ls["latitude"] ?>, = $ip2ls["longitude"] ?> | = $ip2ls["ispName"] ?> | |||||
= $iplists["list_name"] ?> | = $iplists["ipFromText"] ?> | = $iplists["ipToText"] ?> | - | - | - | - | - | - | - | - |