Changeset 5466
- Timestamp:
- 28/06/2009 02:40:24 (9 months ago)
- Location:
- Mirrors/AMXModX/dlls/geoip_ex
- Files:
-
- 4 modified
-
GeoIPCity.c (modified) (1 diff)
-
geoip_amxx.cpp (modified) (14 diffs)
-
include/geoip_ex.inc (modified) (9 diffs)
-
sdk/moduleconfig.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
Mirrors/AMXModX/dlls/geoip_ex/GeoIPCity.c
r5454 r5466 116 116 else 117 117 { 118 record->city = malloc( str_length +1 );118 record->city = malloc( str_length + 1 ); 119 119 strncpy( record->city, ( const char * ) record_buf, str_length + 1 ); 120 120 } 121 121 } 122 122 123 record_buf += ( str_length + 1);123 record_buf += ( str_length + 1 ); 124 124 str_length = 0; 125 125 -
Mirrors/AMXModX/dlls/geoip_ex/geoip_amxx.cpp
r5454 r5466 51 51 { 52 52 const char *ccode = GeoIP_country_code_by_addr( gi, ip ); 53 53 54 if ( ccode ) 54 55 { … … 60 61 { 61 62 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 62 if ( rec ) 63 64 if ( rec && rec->country_code ) 63 65 { 64 66 MF_SetAmxString( amx, params[2], rec->country_code, 2 ); … … 80 82 { 81 83 const char *ccode = GeoIP_country_code3_by_addr( gi, ip ); 84 82 85 if ( ccode ) 83 86 { … … 89 92 { 90 93 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 91 if ( rec ) 94 95 if ( rec && rec->country_code3 ) 92 96 { 93 97 MF_SetAmxString( amx, params[2], rec->country_code3, 3 ); … … 109 113 { 110 114 const char *ccode = GeoIP_country_name_by_addr( gi, ip ); 115 111 116 if ( ccode ) 112 117 { … … 117 122 { 118 123 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 119 if ( rec ) 124 125 if ( rec && rec->country_name ) 120 126 { 121 127 return MF_SetAmxString( amx, params[2], rec->country_name , params[3] ); 122 128 } 123 129 } 124 125 130 126 131 return MF_SetAmxString( amx, params[2], "error", params[3] ); … … 138 143 GeoIPRecord* rec = GeoIP_record_by_addr( gi, ip ); 139 144 140 if ( rec ) 141 { 142 cell res = MF_SetAmxString( amx, params[2], rec->city ? rec->city : "error", params[3] ); 143 free( rec ); 144 return res; 145 if ( rec && rec->city ) 146 { 147 return MF_SetAmxString( amx, params[2], rec->city, params[3] ); 145 148 } 146 149 } … … 159 162 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 160 163 161 return ( rec ) ? amx_ftoc( rec->latitude ) : 0; 164 if ( rec && rec->latitude ) 165 { 166 return amx_ftoc( rec->latitude ); 167 } 162 168 } 163 169 … … 175 181 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 176 182 177 return ( rec ) ? amx_ftoc( rec->longitude ) : 0; 183 if ( rec && rec->longitude ) 184 { 185 return amx_ftoc( rec->longitude ); 186 } 178 187 } 179 188 … … 186 195 { 187 196 int len = 0; 188 char *ip = MF_GetAmxString( amx, params[1], 0, &len);189 190 StripPort( ip ); 191 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 192 193 if ( rec )194 { 195 MF_SetAmxString( amx, params[2], rec->region, 2);197 char *ip = MF_GetAmxString( amx, params[1], 0, &len ); 198 199 StripPort( ip ); 200 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 201 202 if ( rec && rec->region ) 203 { 204 MF_SetAmxString( amx, params[2], rec->region, 3 ); 196 205 return 1; 197 206 } … … 211 220 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 212 221 213 if ( rec )222 if ( rec && rec->country_code && rec->region ) 214 223 { 215 224 const char *region = GeoIP_region_name_by_code( rec->country_code, rec->region ); … … 231 240 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 232 241 233 if ( rec )242 if ( rec && rec->country_code && rec->region ) 234 243 { 235 244 const char *timezone = GeoIP_time_zone_by_country_and_region( rec->country_code, rec->region ); … … 251 260 GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 252 261 253 if ( rec )262 if ( rec && rec->continent_code ) 254 263 { 255 264 MF_SetAmxString( amx, params[2], rec->continent_code, 2 ); … … 336 345 337 346 { "geoip_distance" , amx_geoip_distance }, 347 338 348 { NULL , NULL }, 339 349 }; -
Mirrors/AMXModX/dlls/geoip_ex/include/geoip_ex.inc
r5454 r5466 1 1 /* 2 2 GeoIP module functions for AMX Mod X 3 by David "BAILOPAN" Anderson 3 by David "BAILOPAN" Anderson. 4 Modified by Arkshine. 4 5 (C) Copyrighted under the GNU General Public License, Version 2 5 6 */ … … 22 23 23 24 /** 24 * Lookup the two character country code for a given IP address.25 * look up the two character country code for a given IP address. 25 26 * e.g: "US", "CA", etc. 26 27 * 27 * @param ip The IP address to look up.28 * @param result The result buffer. If the look up does not succeed, the buffer is not modified.29 * @return true on a successful look up, false on a failed lookup.28 * @param ip The IP address to look up. 29 * @param result The result buffer. If the look up does not succeed, the buffer is not modified. 30 * @return true on a successful look up, false on a failed look up. 30 31 */ 31 32 native bool:geoip_code2_ex( const ip[], result[3] ); 32 33 33 34 /** 34 * Lookup the three character country code for a given IP address.35 * look up the three character country code for a given IP address. 35 36 * e.g: "USA", "CAN", etc. 36 37 * 37 * @param ip The IP address to look up.38 * @param result The result buffer. If the look up does not succeed, the buffer is not modified.39 * @return true on a successful look up, false on a failed lookup.38 * @param ip The IP address to look up. 39 * @param result The result buffer. If the look up does not succeed, the buffer is not modified. 40 * @return true on a successful look up, false on a failed look up. 40 41 */ 41 42 native bool:geoip_code3_ex( const ip[], result[4] ); … … 43 44 /** 44 45 * @deprecated 45 * Lookup the two character country code for a given IP address.46 * look up the two character country code for a given IP address. 46 47 * 47 * @note This native will overflow the buffer by one cell on an unknown ip look up!48 * @note This native will overflow the buffer by one cell on an unknown ip look up! 48 49 * @note Use geoip_code2_ex instead! 49 50 * 50 * @param ip The IP address to look up.51 * @param ip The IP address to look up. 51 52 * @param result The result buffer. 52 53 */ … … 55 56 /** 56 57 * @deprecated 57 * Lookup the three character country code for a given IP address.58 * look up the three character country code for a given IP address. 58 59 * 59 * @note This native will overflow the buffer by one cell on an unknown ip look up!60 * @note This native will overflow the buffer by one cell on an unknown ip look up! 60 61 * @note Use geoip_code3_ex instead! 61 62 * 62 * @param ip The IP address to look up.63 * @param ip The IP address to look up. 63 64 * @param result The result buffer. 64 65 */ … … 66 67 67 68 /** 68 * Lookup the full country name for the given IP address. Sets the buffer to "error" on69 * an unsuccessful look up.69 * look up the full country name for the given IP address. Sets the buffer to "error" on 70 * an unsuccessful look up. 70 71 * 71 * @param ip The IP address to look up.72 * @param result The result of the geoip look up.72 * @param ip The IP address to look up. 73 * @param result The result of the geoip look up. 73 74 * @param len The maximum length of the result buffer. 74 75 */ … … 76 77 77 78 /** 78 * Lookup the full city name for the given IP address. Sets the buffer to "error" on79 * an unsuccessful look up.79 * look up the full city name for the given IP address. Sets the buffer to "error" on 80 * an unsuccessful look up. 80 81 * 81 * @param ip The IP address to look up.82 * @param result The result of the geoip look up.82 * @param ip The IP address to look up. 83 * @param result The result of the geoip look up. 83 84 * @param len The maximum length of the result buffer. 84 85 */ … … 86 87 87 88 /** 88 * Lookup the city's latitude for the given IP address.89 * look up the city's latitude for the given IP address. 89 90 * 90 * @param ip The IP address to look up.91 * @return The result of the geoip look up, 0 if latitude is not found.91 * @param ip The IP address to look up. 92 * @return The result of the geoip look up, 0 if latitude is not found. 92 93 */ 93 94 native Float:geoip_latitude( const ip[] ); 94 95 95 96 /** 96 * Lookup the city's longitude for the given IP address. Returns97 * look up the city's longitude for the given IP address. Returns 97 98 * 98 * @param ip The IP address to look up.99 * @return The result of the geoip look up, 0 if longitude is not found.99 * @param ip The IP address to look up. 100 * @return The result of the geoip look up, 0 if longitude is not found. 100 101 */ 101 102 native Float:geoip_longitude( const ip[] ); 102 103 103 104 /** 104 * Lookup the region/state code for the given IP address.105 * look up the region/state code for the given IP address. 105 106 * e.g: "OH", "CA", "11", etc. 106 107 * 107 108 * @note It can be a number depending. 108 109 * 109 * @param ip The IP address to look up.110 * @param result The result of the geoip look up.111 * @return true on a successful look up, false on a failed lookup.110 * @param ip The IP address to look up. 111 * @param result The result of the geoip look up. 112 * @return true on a successful look up, false on a failed look up. 112 113 */ 113 114 native bool:geoip_region( const ip[], result[4] ); 114 115 115 116 /** 116 * Lookup the full region/state name for the given IP address. Sets the buffer to "error" on117 * an unsuccessful look up.117 * look up the full region/state name for the given IP address. Sets the buffer to "error" on 118 * an unsuccessful look up. 118 119 * 119 * @param ip The IP address to look up.120 * @param result The result of the geoip look up.120 * @param ip The IP address to look up. 121 * @param result The result of the geoip look up. 121 122 * @param len The maximum length of the result buffer. 122 123 */ … … 124 125 125 126 /** 126 * Look up the full time zone for the given IP address. Sets the buffer to "error" on127 * an unsuccessful look up.127 * Look up the full time zone for the given IP address. Sets the buffer to "error" on 128 * an unsuccessful look up. 128 129 * 129 * @param ip The IP address to look up.130 * @param result The result of the geoip look up.130 * @param ip The IP address to look up. 131 * @param result The result of the geoip look up. 131 132 * @param len The maximum length of the result buffer. 132 133 */ 133 134 native geoip_timezone( const ip[], result[], len = 45 ); 134 135 135 * Lookup the continent code for a given IP address. 136 /** 137 * Look up the continent code for a given IP address. 136 138 * 137 * @note The code can be retrieved as integer numberor string (2 characters).139 * @note The code can be retrieved as integer or string (2 characters). 138 140 * @note Possible continent codes are AF, AS, EU, NA, OC, SA for 139 141 * Africa(1), Asia(2), Europe(3), North America(4), Oceania(5) and South America(6). 140 142 * 141 * @param ip The IP address to look up.142 * @param result The result of the geoip look up. This param is optional.143 * If the look up does not succeed, the buffer is not modified.144 * @return The result of the geoip look up, 0 on a failed lookup.143 * @param ip The IP address to look up. 144 * @param result The result of the geoip look up. This param is optional. 145 * If the look up does not succeed, the buffer is not modified. 146 * @return The result of the geoip look up, 0 on a failed look up. 145 147 */ 146 148 enum Continent 147 149 { 148 AFRICA = 1, 150 CONTINENT_ERROR = 0, 151 AFRICA, 149 152 ASIA, 150 153 EUROPE, … … 154 157 } 155 158 native Continent:geoip_continent_code( const ip[], result[3] = "" ); 159 156 160 /** 157 161 * Calculate the distance between geographical coordinates, latitude and longitude. -
Mirrors/AMXModX/dlls/geoip_ex/sdk/moduleconfig.h
r5454 r5466 16 16 */ 17 17 #define MODULE_NAME "GeoIP Extented" 18 #define MODULE_VERSION "1.0. 1"18 #define MODULE_VERSION "1.0.2" 19 19 #define MODULE_AUTHOR "AMX Mod X Dev Team / Arkshine" 20 20 #define MODULE_URL "http://www.amxmodx.org/"

