<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Web Wiz Support and Community Forums : Bug 7.92 bannedip</title>
  <link>https://forums.webwiz.net/</link>
  <description><![CDATA[This is an XML content feed of; Web Wiz Support and Community Forums : Web Wiz Forums : Bug 7.92 bannedip]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Mon, 13 Apr 2026 19:58:41 +0000</pubDate>
  <lastBuildDate>Sat, 06 Aug 2005 14:53:33 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.08</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forums.webwiz.net/RSS_post_feed.asp?TID=16121</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Web Wiz Support and Community Forums]]></title>
   <url>https://forums.webwiz.net/forum_images/web_wiz_forums.png</url>
   <link>https://forums.webwiz.net/</link>
  </image>
  <item>
   <title><![CDATA[Bug 7.92 bannedip : I noticed that the bannedIP bug...]]></title>
   <link>https://forums.webwiz.net/bug-7-92-bannedip_topic16121_post88344.html#88344</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="https://forums.webwiz.net/member_profile.asp?PF=19649">JJLatWebWiz</a><br /><strong>Subject:</strong> 16121<br /><strong>Posted:</strong> 06&nbsp;August&nbsp;2005 at 2:53pm<br /><br />I noticed that the bannedIP bug is still in 7.92 (and 7.95).  In the <em>functions/functions_common.asp</em>, look for <font face="Courier New, Courier, mono">Function BannedIP()</font>.  The standard coding truncates the User IP variable (<font face="Courier New, Courier, mono">strUserIPAddress</font>) to the length of the wildcarded banned IP and doesn't restore the variable to the full IP for future comparisons.  sfd19 provided a very efficient <a href="http://forums.webwiz.net/forum_posts.asp?TID=12385#74540" target="_blank">solid fix</a>.  So, the following code should replace the existing function:<br /><br /><table width="99%"><tr><td><pre class="BBcode"><br />'******************************************<br />'****&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Banned IP's&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*****<br />'******************************************<br />Private Function bannedIP()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Declare variables<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim rsIPAddr<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim strCheckIPAddress<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim strUserIPAddress<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim blnIPMatched<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Intilise variable<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blnIPMatched = False<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Get the users IP<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strUserIPAddress = getIP()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Intialise the ADO recordset object<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set rsIPAddr = Server.CreateObject("ADODB.Recordset")<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Get any banned IP address from the database<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Initalise the strSQL variable with an SQL statement to query the database to count the number of topics in the forums<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If strDatabaseType = "SQLServer" Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSQL = "EXECUTE " & strDbProc & "BannedIPs"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strSQL = "SELECT " & strDbTable & "BanList.IP FROM " & strDbTable & "BanList WHERE " & strDbTable & "BanList.IP Is Not Null;"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Query the database<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsIPAddr.Open strSQL, adoCon<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Loop through the IP address and check 'em out<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do while NOT rsIPAddr.EOF <font color=red>and NOT blnIPMatched</font><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Get the IP address to check from the recordset<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;strCheckIPAddress = rsIPAddr("IP")<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'See if we need to check the IP range or just one IP address<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'If the last character is a * then this is a wildcard range to be checked<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Right(strCheckIPAddress, 1) = "*" Then<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Remove the wildcard charcter form the IP<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  strCheckIPAddress = Replace(strCheckIPAddress, "*", "", 1, -1, 1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'See if whats left of the IP matches<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strCheckIPAddress = <font color=red>Mid(strUserIPAddress, 1, Len(strCheckIPAddress))</font> Then blnIPMatched = True<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Else check the IP address metches&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Else check to see if the IP address match<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strCheckIPAddress = strUserIPAddress Then blnIPMatched = True<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Move to the next record<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsIPAddr.MoveNext<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Clean up<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rsIPAddr.Close<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set rsIPAddr = Nothing<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Return the function<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bannedIP = blnIPMatched<br />End Function<br /></pre></td></tr></table><br /><br />Most importantly, the function will do a proper IP address comparison, but the change above also stops checking the list after the first match, which could save time and processor resources.<br /><br />EDIT 10/24/2005: corrected "strCheckIP Address" to "strCheckIPAddress" and removed extraneous "&nbs p;".<br /><span style="font-size:10px"><br /><br />Edited by JJLatWebWiz - 24&nbsp;October&nbsp;2005 at 12:22pm</span>]]>
   </description>
   <pubDate>Sat, 06 Aug 2005 14:53:33 +0000</pubDate>
   <guid isPermaLink="true">https://forums.webwiz.net/bug-7-92-bannedip_topic16121_post88344.html#88344</guid>
  </item> 
 </channel>
</rss>