user2825 LiteCart Fan Από India Μέλος από Μαρ 2016 user2825 29 Απρ 2017 01:43 Hi, I've got the store behind cloudflare firewall. Now, the thing is that I want to log the client IP address in the orders. If I use $_SERVER['REMOTE_ADDR'] I get back my cloudflare IP Address, but not the client ones. Could you kindly assist in this case? Regards, db
tim Founder Από Sweden Μέλος από Μαΐ 2013 tim 29 Απρ 2017 01:46 Did you look at the wiki article? https://wiki.litecart.net/doku.php?id=how_to_configure_litecart_with_cloudflare
user2825 LiteCart Fan Από India Μέλος από Μαρ 2016 user2825 29 Απρ 2017 01:52 Thanks for the quick reply, Tim. Well, I did.But the thing is that I've configured the store checkout so that guests (not registered) can use it. And I've set some custom data in the fields for mysql database. The question is, how do I extract their IP addresses and store them in mysql? It's okay if I store them in any compatible column. EDIT: After adding this: if (isset($_SERVER['HTTP_CF_VISITOR']) { if (preg_match('#https#i', $_SERVER['HTTP_CF_VISITOR'])) { $_SERVER['HTTPS'] = 'On'; $_SERVER['SERVER_PORT'] = 443; $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } } the store won't load. EDIT2: I removed that, it works again. My main requirement is that, in the email I receive when there is any purchase, I want to see the IP Address of the customer.
tim Founder Από Sweden Μέλος από Μαΐ 2013 tim 29 Απρ 2017 22:12 What the code does is replace REMOTE_ADDR with the real IP so you can get it the usual way in PHP by $_SERVER['REMOTE_ADDR']. There is missing a paranthesis at the end: if (isset($_SERVER['HTTP_CF_VISITOR'])) {