function getCountryGeoLocation() { include_once 'ip2locationlite.class.php'; //Set geolocation cookie if (!isset($_COOKIE["geolocation_juzon"])) { $ipLite = new ip2location_lite(); $ipLite->setKey('06fc082707b16fc07af8082fdeceed43569eece7ad373b60b82a8870b0f555c6'); $visitorGeolocation = $ipLite->getCountry($_SERVER['REMOTE_ADDR']); if ($visitorGeolocation['statusCode'] == 'OK') { $data = base64_encode(serialize($visitorGeolocation)); setcookie("geolocation_juzon", $data, time() + 3600 * 24 * 7); //set cookie for 1 week } } else { $visitorGeolocation = unserialize(base64_decode($_COOKIE["geolocation_juzon"])); } return $visitorGeolocation; //array(5) { ["statusCode"]=> string(2) "OK" ["statusMessage"]=> string(0) "" ["ipAddress"]=> string(14) "113.190.88.196" ["countryCode"]=> string(2) "VN" ["countryName"]=> string(8) "VIET NAM" } }
<?php // Database connection string //$ConnStr = "Driver={SQL Server};Server=92.55.94.2;Database=draft;uid=sa;pwd=G30net#"; if (ReadCookies("DefaultLanguage") == "") { include 'ip2locationlite.class.php'; //Load the class $ipLite = new ip2location_lite(); $ipLite->setKey('6fd5f186e30b05cfb5da94f5d9f073a66242543b9521cd5969c7fd903fa1b878'); //Language variable $locations = $ipLite->getCountry("217.16.79.81"); //$locations = $ipLite->getCountry(getIP()); //$errors = $ipLite->getError(); //Getting the result if (!empty($locations) && is_array($locations)) { foreach ($locations as $field => $val) { if ($field == "countryCode") { $defLang = $val; } } } if ($defLang == "US") { $defLang = "en"; } $defLang = strtolower($defLang); WriteCookies("DefaultLanguage", $defLang, 14); } else { $defLang = strtolower(ReadCookies("DefaultLanguage")); } if ($_SERVER['HTTP_HOST'] == "panorama.gps-ks.com" || $_SERVER['HTTP_HOST'] == "gps-ks.com") { $defLang = "al";
<?php include_once 'ip2locationlite.class.php'; //Set geolocation cookie if (!$_COOKIE["geolocation"]) { $ipLite = new ip2location_lite(); $ipLite->setKey('239493602d86db252cf667f5121ad2ec98c88127e4cdc4f25208ad1535119b2c'); $visitorGeolocation = $ipLite->getCountry($_SERVER['REMOTE_ADDR']); if ($visitorGeolocation['statusCode'] == 'OK') { $data = base64_encode(serialize($visitorGeolocation)); setcookie("geolocation", $data, time() + 3600 * 24 * 7); //set cookie for 1 week } } else { $visitorGeolocation = unserialize(base64_decode($_COOKIE["geolocation"])); } echo $visitorGeolocation; var_dump($visitorGeolocation);
function PricerrTheme_get_country_code_of_ip($ip) { global $wpdb; $s = "select * from " . $wpdb->prefix . "job_ipcache where ipnr='{$ip}'"; $r = $wpdb->get_results($s); if (count($r) == 0) { $ipLite = new ip2location_lite(); $ipLite->setKey(get_option('PricerrTheme_ip_key_db')); //Get errors and locations $locations = $ipLite->getCountry($ip); $ccode = $locations['countryCode']; $s = "insert into " . $wpdb->prefix . "job_ipcache (ipnr, country) values('{$ip}','{$ccode}')"; $wpdb->query($s); return $ccode; } return $r[0]->country; }