logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
ray22901031  
#1 Posted : Thursday, December 8, 2022 11:11:53 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 827

Thanks: 3 times
Was thanked: 13 time(s) in 13 post(s)
We had a similar problem with the order module, but it was fixed, where is the online report getting its IP info from? It's definitely not getting it from the same place that the order module gets it, so there's another bit of code executing someplace else.

Many Thanks
-Ray

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

Katie S  
#2 Posted : Thursday, December 8, 2022 2:01:20 PM(UTC)
Katie S

Rank: Advanced Member

Groups: System, Administrators, Developers, Registered, HelpDesk
Joined: 10/29/2018(UTC)
Posts: 423

Thanks: 4 times
Was thanked: 34 time(s) in 33 post(s)
Hi Ray,

Is it possible that the IP is changing? I just tested my own IP using an offsite What's my IP report, and then comparing the Who's Online report and the IP recorded with the order. They are all matching.

Thanks for your support!

Katie
Secure eCommerce Software and Hosting
ray22901031  
#3 Posted : Thursday, December 8, 2022 4:32:05 PM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 827

Thanks: 3 times
Was thanked: 13 time(s) in 13 post(s)
Hi Katie,

Of course, you're getting the same IP address because you're not using Cloudflare. The post below well better explain it better.

https://www.ablecommerce...he-UserHostAddress-value

We have already changed this a year ago at the CommerceBuilder level, under the SessionFacacade.cs file.

That is where Ablecommerce gets its IP from, at least when it comes to orders, but the report seems to be using another bit of code someplace else.

Instead of me going through the source code trying to figure out where it is, I was just wondering if somebody knew the location of where the report is getting the IP address from because it's not coming from the SessionFacacade.cs file.

In summary, my orders IPs are coming from Cloudflare's True-Client-IP, and the report is not.

I hope this additional detail explains things better.

Thanks,
-Ray
Jay  
#4 Posted : Thursday, December 8, 2022 4:54:00 PM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Areas\Admin\Controllers\ReportController.cs has this:
Code:

        protected string GetIpAddress(object usrObj)
        {
            User usr = usrObj as User;
            if (usr == null) return "";

            if (usr.PageViews.Count > 0)
            {
                CommerceBuilder.Reporting.PageView pv = usr.PageViews[0];
                return pv.RemoteIP;
            }

            return "";
        }

So I guess it is whatever sets the value in PageViews table, which leads me to Services\PageTracker.cs in the source code. There's a procedure called RecordPageRequest that does:
Code:

pageView.RemoteIP = StringHelper.Truncate(application.Request.UserHostAddress, 39);
ray22901031  
#5 Posted : Thursday, December 8, 2022 5:15:31 PM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 827

Thanks: 3 times
Was thanked: 13 time(s) in 13 post(s)
Thank you Jay.

Something is amiss here, below is the modified UserHostAddress function which works perfectly and has been working perfectly for the last year. This is located in the commerce builder section. This is what the order section of Ablecommerce sees and uses.

About Line 78

Code:
public string UserHostAddress
        {
            get
            {
                HttpContext current = HttpContext.Current;
                if (current != null)
                {
                    if (!string.IsNullOrWhiteSpace(current.Request.Headers["CF-CONNECTING-IP"]))
                    {
                        return current.Request.Headers["CF-CONNECTING-IP"];
                    }
                    else
                    {
                        return current.Request.UserHostAddress;
                    }
                }
                return string.Empty;
            }
        }



But somehow, the report is not executing this function, instead it is picking up an IP from someplace else. There's something else going on, but not in the mood to trace it at the moment.

Thanks

Edited by user Thursday, December 8, 2022 5:19:01 PM(UTC)  | Reason: Not specified

ray22901031  
#6 Posted : Thursday, December 8, 2022 5:55:44 PM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 827

Thanks: 3 times
Was thanked: 13 time(s) in 13 post(s)
OK, the information that's coming from the report is coming from the audit logs.

The information that the audit logs are recording is not the true IP, so when I have the time, I need to find the function or the procedures that are being used by the audit logs and modify the code, so it writes to the logs the proper true client IP.

So, there are two procedures in play here, one for the actual order itself which is live, and resides in commerce builder, and the other one for the audit logs which has a slight delay, and not sure of its location at this time.

I'll put this on the agenda of things to do this month.

-Ray

UPDATE: that information is coming from the page view table not the audit logs, my blunder. However, the IP addresses are all incorrect, the IP here are coming from a different source, this is true for the audit logs and the table page view. What's happening to regular support, are they on holiday? - thanks

Edited by user Thursday, December 8, 2022 10:48:59 PM(UTC)  | Reason: Not specified

judy at Web2Market  
#7 Posted : Friday, December 9, 2022 10:22:59 AM(UTC)
judy at Web2Market

Rank: Advanced Member

Groups: Developers
Joined: 11/7/2018(UTC)
Posts: 289

Thanks: 21 times
Was thanked: 5 time(s) in 5 post(s)
I had to get real ip for a site that uses Sucuri. I put the code for pageviews in the source code Services/PageTracker.cs, RecordPageRequest method.

Edited by user Friday, December 9, 2022 10:23:50 AM(UTC)  | Reason: Not specified

ray22901031  
#8 Posted : Friday, December 9, 2022 10:46:16 AM(UTC)
ray22901031

Rank: Advanced Member

Groups: Authorized User, Developers
Joined: 2/17/2019(UTC)
Posts: 827

Thanks: 3 times
Was thanked: 13 time(s) in 13 post(s)
Hi Judy,

Thank you very much for your reply, this is definitely the area that is creating the problem. As you can see in the " SessionFacacade.cs" code above, we are specifically telling it to use "CF-CONNECTING-IP", which is what's recommended.

This works and has been working for over a year, and the true IP shows up in orders, but for whatever reason, it's not being properly applied to the PageTracker.cs.

I'll have my other developer take a look at it and if necessary force it to apply it here as well.

I truly appreciate your input on this, as this is certainly the source of the issue when it comes to the error logs and the page view entries in the table not grabbing the proper user's true IP.

Have a great holiday,
-Ray
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.