Uppercase and mixed case domain names are now also correctly detected and linked

This commit is contained in:
Andre Lorbach 2008-09-19 11:47:04 +02:00
parent f047d1566c
commit 8f62806e5c
4 changed files with 39 additions and 6 deletions

View File

@ -77,16 +77,23 @@ if ( $content['oracle_type'] == "ip" )
{
$content['oracle_type_readable'] = "ip";
$content['oracle_kb_type'] = "ip";
if ( IsInternalIP($content['oracle_query']) )
$content['showonlinesearches'] = false;
else
$content['showonlinesearches'] = true;
}
else if ( $content['oracle_type'] == "domain" )
{
$content['oracle_type_readable'] = "domain";
$content['oracle_kb_type'] = "name";
$content['showonlinesearches'] = true;
}
else
{
$content['oracle_type_readable'] = "unknown type";
$content['oracle_kb_type'] = "";
$content['showonlinesearches'] = false;
}
$content['ORACLE_HELP_DETAIL'] = GetAndReplaceLangStr( $content['LN_ORACLE_HELP_DETAIL'], $content['oracle_type_readable'], $content['oracle_query'] ) ;

View File

@ -1032,7 +1032,7 @@ function AddContextLinks(&$sourceTxt)
if ( GetConfigSetting("EnableIPAddressResolve", 0, CFGLEVEL_USER) == 1 )
{
// Search for IP's and Add Reverse Lookup first!
$sourceTxt = preg_replace( '/([^\[])\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/e', "'\\1\\2.\\3.\\4.\\5' . ReverseResolveIP('\\2.\\3.\\4.\\5', '<font class=\"highlighted\"> {', '} </font>')", $sourceTxt );
$sourceTxt = preg_replace( '/([^\[])\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/ie', "'\\1\\2.\\3.\\4.\\5' . ReverseResolveIP('\\2.\\3.\\4.\\5', '<font class=\"highlighted\"> {', '} </font>')", $sourceTxt );
}
// Create if not set!
@ -1042,8 +1042,8 @@ function AddContextLinks(&$sourceTxt)
// Create Search Array
$search = array
(
'/\.([\w\d\_\-]+)\.(' . $szTLDDomains . ')([^a-zA-Z0-9\.])/e',
/* (?:127)| */ '/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/e',
'/\.([\w\d\_\-]+)\.(' . $szTLDDomains . ')([^a-zA-Z0-9\.])/ie',
/* (?:127)| */ '/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ie',
);
// Create Replace Array
@ -1079,9 +1079,8 @@ function InsertLookupLink( $szIP, $szDomain, $prepend, $append )
// check if it is an IP or domain
if ( strlen($szIP) > 0 )
{
// Split IP into array
/* // Split IP into array
$IPArray = explode(".", $szIP);
if (
(intval($IPArray[0]) == 10 ) ||
(intval($IPArray[0]) == 127 ) ||
@ -1089,6 +1088,8 @@ function InsertLookupLink( $szIP, $szDomain, $prepend, $append )
(intval($IPArray[0]) == 192 && intval($IPArray[1]) == 168) ||
(intval($IPArray[0]) == 255 )
)
*/
if ( IsInternalIP($szIP) )
// Do not create a LINK in this case!
$szReturn .= '<b>' . $szIP . '</b>';
else
@ -1114,6 +1115,29 @@ function InsertLookupLink( $szIP, $szDomain, $prepend, $append )
return $szReturn;
}
/*
* Helper function to check, if an IP Address is within private address space!
*/
function IsInternalIP($szIPAddress)
{
// Split IP into array
$IPArray = explode(".", $szIPAddress);
if (
(intval($IPArray[0]) == 10 ) ||
(intval($IPArray[0]) == 127 ) ||
(intval($IPArray[0]) == 172 && intval($IPArray[1]) >= 16 && intval($IPArray[1]) <= 31) ||
(intval($IPArray[0]) == 192 && intval($IPArray[1]) == 168) ||
(intval($IPArray[0]) == 255 )
)
// return true in this case
return true;
else
// This is an external IP
return false;
}
/*
* Reserve Resolve IP Address!
*/

View File

@ -39,6 +39,7 @@
<tr>
<td class="tableBackground">
<!-- IF showonlinesearches="true" -->
<br><br>
<table cellpadding="1" cellspacing="0" border="0" align="center" valign="top" width="800" class="table_with_border">
<tr><td class="title" align="center" colspan="4"><B>{LN_ORACLE_ONLINESEARCH}</B></td></tr>
@ -50,6 +51,7 @@
</td>
</tr>
</table>
<!-- ENDIF showonlinesearches="true" -->
<br><br>
<table cellpadding="1" cellspacing="0" border="0" align="center" valign="top" width="800" class="table_with_border">

View File

@ -245,7 +245,7 @@
<!-- ENDIF MiscShowDebugGridCounter="1" -->
<!-- BEGIN values -->
<td align="{FieldAlign}" class="{fieldcssclass}" {fieldbgcolor} valign="middle" {isnowrap}>
<td align="{FieldAlign}" class="{fieldcssclass}" {fieldbgcolor} valign="top" {isnowrap}>
<!-- IF hasbuttons="true" -->
<div id="menu">