Changeset 1550 in ExiteCMS for trunk/includes/geoip_include.php
- Timestamp:
- 07/27/08 14:26:17 (4 years ago)
- File:
-
- 1 edited
-
trunk/includes/geoip_include.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/geoip_include.php
r1478 r1550 29 29 global $db_prefix, $_GeoIP_result; 30 30 31 // convert the IP address to a number32 $ipnum = GeoIP_IP2Num($ip_addr);33 if (!$ipnum) return false;34 35 31 // not cached? 36 if (!isset($_GeoIP_result[$ip num])) {32 if (!isset($_GeoIP_result[$ip_addr])) { 37 33 38 34 // check if there is an exception defined … … 40 36 if ($data = dbarray($result)) { 41 37 // add it to the cache 42 $_GeoIP_result[$ip num] = $data['ip_code'];38 $_GeoIP_result[$ip_addr] = $data['ip_code']; 43 39 } else { 40 // convert the IP address to a number 41 $ipnum = GeoIP_IP2Num($ip_addr); 42 if (!$ipnum) return false; 44 43 // look this IP address up 45 44 $result = dbquery("SELECT * FROM ".$db_prefix."GeoIP WHERE '".sprintf("%u", $ipnum)."' BETWEEN ip_start_num AND ip_end_num LIMIT 1"); 46 45 if ($data = dbarray($result)) { 47 46 // add it to the cache 48 $_GeoIP_result[$ip num] = $data['ip_code'];47 $_GeoIP_result[$ip_addr] = $data['ip_code']; 49 48 } else { 50 $_GeoIP_result[$ip num] = false;49 $_GeoIP_result[$ip_addr] = false; 51 50 } 52 51 } … … 54 53 } 55 54 56 return $_GeoIP_result[$ip num];55 return $_GeoIP_result[$ip_addr]; 57 56 } 58 57 … … 71 70 global $db_prefix, $settings; 72 71 73 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = '".$settings['locale_code']."' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 74 if (!dbrows($result)) { 75 // no translated country names found, load the english set instead 76 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = 'en' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 72 // not cached? 73 if (!isset($_GeoIP_result[$ip_code])) { 74 75 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = '".$settings['locale_code']."' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 76 if (!dbrows($result)) { 77 // no translated country names found, load the english set instead 78 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = 'en' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 79 } 80 if (dbrows($result) == 0) { 81 $_GeoIP_result[$ip_code] = ""; 82 } else { 83 $data = dbarray($result); 84 $_GeoIP_result[$ip_code] = $data['locales_value']; 85 } 77 86 } 78 if (dbrows($result) == 0) { 79 return ""; 80 } 81 $data = dbarray($result); 82 return $data['locales_value']; 87 88 return $_GeoIP_result[$ip_code]; 83 89 } 84 90
Note: See TracChangeset
for help on using the changeset viewer.
