greasemonkey Posted January 13, 2017 Share Posted January 13, 2017 @@ArtcoInc thank you Malcom.... I will definitely take a look at that. I had the code already to make optional removing the column - but no test on install if he column existed (which made it rather useless.... a user could never reinstall if they choose to leave the column). Quote Link to comment Share on other sites More sharing options...
burt Posted January 14, 2017 Share Posted January 14, 2017 Any option on removing the column on install? I'd leave the data as is. It can't hurt anything... Quote Link to comment Share on other sites More sharing options...
greasemonkey Posted January 16, 2017 Share Posted January 16, 2017 Ok I made an error in my hook... carrying over code from the previous version that required edits to the order class. global $order; $customers_ip = $order->customer['customers_ip']; So, I have redone the hook to include its own query.... <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ class hook_admin_orders_location { function listen_orderTab() { global $_GET; $customer_ip_query = tep_db_query("select customers_ip from orders where orders_id = '" . (int)$_GET['oID'] . "'"); $customer_ip_raw = tep_db_fetch_array($customer_ip_query); $customers_ip = $customer_ip_raw['customers_ip']; $tab_title = Location; $tab_link = substr(tep_href_link('orders.php', tep_get_all_get_params()), strlen($base_url)) . '#section_location_content'; $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$customers_ip")); $country = $geo["geoplugin_countryName"]; $city = $geo["geoplugin_city"]; $region = $geo["geoplugin_regionName"]; $latitude = $geo["geoplugin_latitude"]; $longitude = $geo["geoplugin_longitude"]; $output = <<<EOD <script> $(function() { $('#orderTabs ul').append('<li><a href="{$tab_link}">{$tab_title}</a></li>'); }); </script> <div id="section_location_content" style="padding: 10px;"> <p><strong>Customers Location: </strong>{$customers_ip}<br><br>{$country}<br>{$city}<br>{$region}<br>{$latitude}<br>{$longitude}</p> </div> EOD; return $output; } } ?> Quote Link to comment Share on other sites More sharing options...
greasemonkey Posted January 16, 2017 Share Posted January 16, 2017 @@burt, somewhat related question.... in my checkout_success content mod, to grab and store the customers IP address, you had suggested to use the built in function to get the IP. $customers_ip = tep_db_prepare_input(tep_get_ip_address()); In place of $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if(filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif(filter_var($forward, FILTER_VALIDATE_IP)) { $ip = $forward; } else { $ip = $remote; } Which I certainly understand.... however, have you noticed the built in function does not get IPV6 addresses? I've noticed, by looking at "who's online", about 25% of customers online have a "blank" IP address... and now that I have moved this over to my live site also notice about 25% of the orders are have no IP. I've drawn the conclusion - based on my original code where 100% had an IP and about 25% of those IP's where IPV6 (I believe... example below).... xxxx:1970:48e2:xx Thoughts???? Quote Link to comment Share on other sites More sharing options...
burt Posted January 17, 2017 Share Posted January 17, 2017 Thoughts???? If you work with whats already there, then when core gets updated it automatically fixes itself. However as we all know, that can take a while. Alternative is to make an inbuilt (in the module) function just for its own use... <--- this Quote Link to comment Share on other sites More sharing options...
Cary Posted November 28, 2018 Share Posted November 28, 2018 Anyone put this IP and Geo location content module together as a single user friendly add-on? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.