Blocking ip addresses
i trying create ip blocking small application. made table in db go manually , add ip addresses want boot out of web site. put code on application.cfm file when come site kicks them out before it. @ first using cade kick 1 ip address out, want multiple made inot db app. can me code?
<cfquery name="iptable" datasource="#sitedatasource#" username="#siteuserid#" password="#sitepassword#" maxrows=1>
select ipadd.reject,
from iptable
<cfif listfind(valuelist(q1.ipaddress), cgi.remote_addr) true>
<cflocation url=" http://www.anyplaceiwant.com" addtoken="no">
<cfelse>
-everything (web site or application.cfm) want others see code goes here-
</cfif>
</cfquery>
does code right? can put cfquery onto application.cfm file?
thanks
<cfquery name="iptable" datasource="#sitedatasource#" username="#siteuserid#" password="#sitepassword#" maxrows=1>
select ipadd.reject,
from iptable
<cfif listfind(valuelist(q1.ipaddress), cgi.remote_addr) true>
<cflocation url=" http://www.anyplaceiwant.com" addtoken="no">
<cfelse>
-everything (web site or application.cfm) want others see code goes here-
</cfif>
</cfquery>
does code right? can put cfquery onto application.cfm file?
thanks
you cannot have <cflocation> tag within <cfquery> tag. second, can query database user's ip address , forgo listfind().
<cfquery name="iptable" ...>
select ipadd.reject
from iptable
where ipadd.reject = '#cgi.remote_addr#'
</cfquery>
<cfif iptable.recordcount>
<cflocation url=" http://www.anyplaceiwant.com" addtoken="no">
<cfabort>
</cfif>
however add blocked ips @ web server level, rather application level. if have access web server ideal have offloaded query , resulting logic web server, designed such task.
that said, , hope don't burst bubble, blocking on ip address more trouble worth given how defeated is. extremely easy spoof ip address , circumvent block.
<cfquery name="iptable" ...>
select ipadd.reject
from iptable
where ipadd.reject = '#cgi.remote_addr#'
</cfquery>
<cfif iptable.recordcount>
<cflocation url=" http://www.anyplaceiwant.com" addtoken="no">
<cfabort>
</cfif>
however add blocked ips @ web server level, rather application level. if have access web server ideal have offloaded query , resulting logic web server, designed such task.
that said, , hope don't burst bubble, blocking on ip address more trouble worth given how defeated is. extremely easy spoof ip address , circumvent block.
More discussions in ColdFusion
adobe
Comments
Post a Comment