• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cgi.remote_addr and cgi.remote_host and hit counter

Contributor ,
Sep 02, 2006 Sep 02, 2006

Copy link to clipboard

Copied

Hi,
I am a beginner. Borrowed and modified script for a counter as well as some statistics. Everything works fine except that the IP address of the visitor always shows as 216.251.42.XX . I've tried to have friends access the site from all over just to check if I get a different IP address but its still 216.251.42.XX

I wonder if someone can advise me on where I am going wrong.
Thank you in advance.
THE CF SYNTAX BEING USED BY ME is AS FOLLOWS:
<cfquery name="updateHits" datasource="#RequestDSN#">
UPDATE hit_counter SET hit_count = hit_count + 1
</cfquery>
<CFIF isdefined("Cookie.user_id")>
<CFSET user_id=trim(Cookie.user_id)>
<CFELSE>
<CFSET user_id="">
</CFIF>
<cfset currentdate = #DateFormat(Now(), "dd mmm yy")#>
<cfset currenttime = #TimeFormat(Now(), "hh:mm:ss")#>
<CFSET address = cgi.remote_addr>
<CFSET host = cgi.remote_host>
<CFSET referer = cgi.http_referer>
<CFSET agent = cgi.http_user_agent>
<CFSET page = cgi.script_name>
<CFIF NOT Len(host)>
<CFSET host = "unknown">
</CFIF>
<CFIF NOT LEN(referer)>
<CFSET referer = "unknown">
</CFIF>
<cfquery name="userstats" datasource="#RequestDSN#">
INSERT INTO stats (VISITDATE, VISITTIME, ADDRESS, HOST, REFERER, AGENT, PAGE)
VALUES ('#currentdate#', '#currenttime#', '#address#', '#host#', '#referer#', '#agent#', '#page#')
</cfquery>
TOPICS
Advanced techniques

Views

827

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Sep 02, 2006 Sep 02, 2006
Solved my problem: Should use the cfif statement below instead of just the cfset address = cg.remote_addr
<CFIF #CGI.HTTP_X_Forwarded_For# EQ "">
<CFSET address="#CGI.Remote_Addr#">
<CFELSE>
<CFSET address="#CGI.HTTP_X_Forwarded_For#">

Votes

Translate

Translate
Contributor ,
Sep 02, 2006 Sep 02, 2006

Copy link to clipboard

Copied

Solved my problem: Should use the cfif statement below instead of just the cfset address = cg.remote_addr
<CFIF #CGI.HTTP_X_Forwarded_For# EQ "">
<CFSET address="#CGI.Remote_Addr#">
<CFELSE>
<CFSET address="#CGI.HTTP_X_Forwarded_For#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 04, 2006 Sep 04, 2006

Copy link to clipboard

Copied

LATEST
quote:

Originally posted by: jasan3114<CFIF #CGI.HTTP_X_Forwarded_For# EQ "">


You don't need the #-signs in the aboce statement.
Might even hinder performance by a little.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation