coyacollection Posted August 8, 2013 Share Posted August 8, 2013 "You cannot access our store from your country. We apologize for the inconvenience." About 2 months ago, we switched from AT&T DSL to U-verse. As a result of that switch, our IP addresses switched from 192.xxx.xxx.xxx to 168.xxx.xxx.xxx. We had to reconfigure our network. Since then, we have received the above message (country blocked message) when trying to access our website as a customer would (not as an administrator). Our geolocation settings are set to allow US access, and we have whitelisted the associated IP addresses, and still, no luck. When trying to access the website via smartphone over wifi, the website loads as it should. The IP address on the smartphone and the computer display as the same. Does anyone have any other solutions? Thanks! Link to comment Share on other sites More sharing options...
El Patron Posted August 8, 2013 Share Posted August 8, 2013 it may be that your whitelisted IP address is not what PrestaShop see's. It may be that your 'real' IP address is behind 1) a proxy server or 2) a load balancer. In which case another IP address would be used. you could try dumping the $_SERVER and as used to build the return from function getRemoteAddr if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] && (!isset($_SERVER['REMOTE_ADDR']) || preg_match('/^127\..*/i', trim($_SERVER['REMOTE_ADDR'])) || preg_match('/^172\.16.*/i', trim($_SERVER['REMOTE_ADDR'])) || preg_match('/^192\.168\.*/i', trim($_SERVER['REMOTE_ADDR'])) || preg_match('/^10\..*/i', trim($_SERVER['REMOTE_ADDR'])))) { if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')) { $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); return $ips[0]; } else return $_SERVER['HTTP_X_FORWARDED_FOR']; } return $_SERVER['REMOTE_ADDR']; Link to comment Share on other sites More sharing options...
coyacollection Posted August 8, 2013 Author Share Posted August 8, 2013 Thanks for the suggestion El Patron! Could you please direct me to where I can find that code? I'm assuming it's not on the PrestaShop administrator page anywhere. The closest I could get was finding a reference to the "getRemoteAddr" function on the "FrontController.php" page, which was uploaded on the hosting site. In the alternative, do you know of a way to find out which IP address PrestaShop sees? Then I could just whitelist those IP addresses, too. Thanks, again! Link to comment Share on other sites More sharing options...
El Patron Posted August 8, 2013 Share Posted August 8, 2013 please note: I am assuming of course that there is no bug in the whitelist code. classes/Tools.php you willl find the function, but don't put the code there You could just put it in FrontController where it returns remote address: http://screencast.com/t/jGlp5Iav Link to comment Share on other sites More sharing options...
coyacollection Posted August 8, 2013 Author Share Posted August 8, 2013 Thanks, again, for your help El Patron! Below is the corresponding code I have currently for that section. Do I insert the code from your first response after the "$user_Ip" statement, and before the "$ips" statement? I don't seem to have a "print_r" statement. protected static function isInWhitelistForGeolocation() { $allowed = false; $userIp = Tools::getRemoteAddr(); $ips = explode(';', Configuration::get('PS_GEOLOCATION_WHITELIST')); if (is_array($ips) && count($ips)) foreach ($ips as $ip) if (!empty($ip) && strpos($userIp, $ip) === 0) $allowed = true; return $allowed; } Link to comment Share on other sites More sharing options...
El Patron Posted August 9, 2013 Share Posted August 9, 2013 you need to add the print_r statement... Link to comment Share on other sites More sharing options...
coyacollection Posted August 9, 2013 Author Share Posted August 9, 2013 Thanks for your help and your patience! I'm sorry, I'm not familiar with coding, so please let me know if I did something wrong. I pasted in the code from above, and added the print_r statement, so now it looks like the next post (I tried including the code in this post, but it wouldn't post for some reason). We are still unable to access our website using our computers, but still able to access from our smartphones. Thank you! Link to comment Share on other sites More sharing options...
coyacollection Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) For some reason I wasn't able to post the code or a screenshot of the code, so here is a link to a screenshot. Edited August 9, 2013 by coyacollection (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted August 9, 2013 Share Posted August 9, 2013 you would only need to paste in the print_r where I have it located. you should only have this code active while testing, as it may result in abnormal shopping cart behaviour. next test, add exit(0); after print_r...note this will halt the shop...so remove code after you have obtained the ip address. Link to comment Share on other sites More sharing options...
coyacollection Posted August 9, 2013 Author Share Posted August 9, 2013 (edited) I have adjusted the code as in the screenshot. Where does it show the IP address? We're still seeing the same country-blocked message only. Thanks! Edited August 9, 2013 by coyacollection (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted August 10, 2013 Share Posted August 10, 2013 As you can tell, debugging this in the forum is a somewhat slow process. If the exit(0); was place after the print_r and your site did not 'stop', then it did not execute the whitelist. My suggestion is to open a problem report on the PS forge. here http://forge.prestas.../Dashboard.jspa Please post the problem report back here. Link to comment Share on other sites More sharing options...
El Patron Posted August 10, 2013 Share Posted August 10, 2013 I pm'ed you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now