Changeset 5466

Show
Ignore:
Timestamp:
28/06/2009 02:40:24 (9 months ago)
Author:
NiLuJe
Message:

AMX Mod X:

  • Resync GeoIPEx (1.0.2)
Location:
Mirrors/AMXModX/dlls/geoip_ex
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • Mirrors/AMXModX/dlls/geoip_ex/GeoIPCity.c

    r5454 r5466  
    116116                else  
    117117                { 
    118                         record->city = malloc( str_length+1 ); 
     118                        record->city = malloc( str_length + 1 ); 
    119119                        strncpy( record->city, ( const char * ) record_buf, str_length + 1 ); 
    120120                } 
    121121        } 
    122122 
    123         record_buf += (str_length + 1); 
     123        record_buf += ( str_length + 1 ); 
    124124        str_length = 0; 
    125125 
  • Mirrors/AMXModX/dlls/geoip_ex/geoip_amxx.cpp

    r5454 r5466  
    5151        { 
    5252                const char *ccode = GeoIP_country_code_by_addr( gi, ip ); 
     53 
    5354                if ( ccode ) 
    5455                { 
     
    6061        { 
    6162                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    62                 if ( rec ) 
     63 
     64                if ( rec && rec->country_code ) 
    6365                { 
    6466                        MF_SetAmxString( amx, params[2], rec->country_code, 2 ); 
     
    8082        { 
    8183                const char *ccode = GeoIP_country_code3_by_addr( gi, ip ); 
     84 
    8285                if ( ccode ) 
    8386                { 
     
    8992        { 
    9093                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    91                 if ( rec ) 
     94 
     95                if ( rec && rec->country_code3 ) 
    9296                { 
    9397                        MF_SetAmxString( amx, params[2], rec->country_code3, 3 ); 
     
    109113        { 
    110114                const char *ccode = GeoIP_country_name_by_addr( gi, ip ); 
     115 
    111116                if ( ccode ) 
    112117                { 
     
    117122        { 
    118123                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    119                 if ( rec ) 
     124 
     125                if ( rec && rec->country_name ) 
    120126                { 
    121127                        return MF_SetAmxString( amx, params[2], rec->country_name , params[3] ); 
    122128                } 
    123129        } 
    124  
    125130         
    126131        return MF_SetAmxString( amx, params[2], "error", params[3] ); 
     
    138143                GeoIPRecord* rec = GeoIP_record_by_addr( gi, ip ); 
    139144                 
    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] ); 
    145148                } 
    146149        } 
     
    159162                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    160163 
    161                 return ( rec ) ? amx_ftoc( rec->latitude ) : 0; 
     164                if ( rec && rec->latitude ) 
     165                { 
     166                        return amx_ftoc( rec->latitude ); 
     167                } 
    162168        } 
    163169         
     
    175181                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    176182 
    177                 return ( rec ) ? amx_ftoc( rec->longitude ) : 0; 
     183                if ( rec && rec->longitude ) 
     184                { 
     185                        return amx_ftoc( rec->longitude ); 
     186                } 
    178187        } 
    179188         
     
    186195        { 
    187196                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 ); 
    196205                        return 1; 
    197206                } 
     
    211220                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    212221                 
    213                 if ( rec ) 
     222                if ( rec && rec->country_code && rec->region ) 
    214223                { 
    215224                        const char *region = GeoIP_region_name_by_code( rec->country_code, rec->region ); 
     
    231240                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    232241 
    233                 if ( rec ) 
     242                if ( rec && rec->country_code && rec->region ) 
    234243                { 
    235244                        const char *timezone = GeoIP_time_zone_by_country_and_region( rec->country_code, rec->region ); 
     
    251260                GeoIPRecord *rec = GeoIP_record_by_addr( gi, ip ); 
    252261 
    253                 if ( rec ) 
     262                if ( rec && rec->continent_code ) 
    254263                { 
    255264                        MF_SetAmxString( amx, params[2], rec->continent_code, 2 ); 
     
    336345 
    337346        { "geoip_distance"              , amx_geoip_distance     }, 
     347 
    338348        { NULL                                  , NULL                                   }, 
    339349}; 
  • Mirrors/AMXModX/dlls/geoip_ex/include/geoip_ex.inc

    r5454 r5466  
    11/*  
    22   GeoIP module functions for AMX Mod X 
    3    by David "BAILOPAN" Anderson 
     3   by David "BAILOPAN" Anderson. 
     4   Modified by Arkshine. 
    45   (C) Copyrighted under the GNU General Public License, Version 2 
    56*/ 
     
    2223 
    2324/** 
    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. 
    2526 * e.g: "US", "CA", etc. 
    2627 * 
    27  * @param ip            The IP address to lookup. 
    28  * @param result        The result buffer.  If the lookup does not succeed, the buffer is not modified. 
    29  * @return                      true on a successful lookup, 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. 
    3031 */ 
    3132native bool:geoip_code2_ex( const ip[], result[3] ); 
    3233 
    3334/** 
    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. 
    3536 * e.g: "USA", "CAN", etc. 
    3637 * 
    37  * @param ip            The IP address to lookup. 
    38  * @param result        The result buffer.  If the lookup does not succeed, the buffer is not modified. 
    39  * @return                      true on a successful lookup, 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. 
    4041 */ 
    4142native bool:geoip_code3_ex( const ip[], result[4] ); 
     
    4344/** 
    4445 * @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. 
    4647 * 
    47  * @note This native will overflow the buffer by one cell on an unknown ip lookup! 
     48 * @note This native will overflow the buffer by one cell on an unknown ip look up! 
    4849 * @note Use geoip_code2_ex instead! 
    4950 * 
    50  * @param ip            The IP address to lookup. 
     51 * @param ip            The IP address to look up. 
    5152 * @param result        The result buffer. 
    5253 */ 
     
    5556/** 
    5657 * @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. 
    5859 * 
    59  * @note This native will overflow the buffer by one cell on an unknown ip lookup! 
     60 * @note This native will overflow the buffer by one cell on an unknown ip look up! 
    6061 * @note Use geoip_code3_ex instead! 
    6162 * 
    62  * @param ip            The IP address to lookup. 
     63 * @param ip            The IP address to look up. 
    6364 * @param result        The result buffer. 
    6465 */ 
     
    6667 
    6768/** 
    68  * Lookup the full country name for the given IP address. Sets the buffer to "error" on 
    69  * an unsuccessful lookup. 
     69 * look up the full country name for the given IP address. Sets the buffer to "error" on 
     70 * an unsuccessful look up. 
    7071 * 
    71  * @param ip            The IP address to lookup. 
    72  * @param result        The result of the geoip lookup. 
     72 * @param ip            The IP address to look up. 
     73 * @param result        The result of the geoip look up. 
    7374 * @param len           The maximum length of the result buffer. 
    7475 */ 
     
    7677 
    7778/**  
    78  * Lookup the full city name for the given IP address. Sets the buffer to "error" on 
    79  * an unsuccessful lookup.  
     79 * look up the full city name for the given IP address. Sets the buffer to "error" on 
     80 * an unsuccessful look up.  
    8081 *  
    81  * @param ip            The IP address to lookup.  
    82  * @param result        The result of the geoip lookup.  
     82 * @param ip            The IP address to look up.  
     83 * @param result        The result of the geoip look up.  
    8384 * @param len           The maximum length of the result buffer.  
    8485 */  
     
    8687 
    8788/**  
    88  * Lookup the city's latitude for the given IP address. 
     89 * look up the city's latitude for the given IP address. 
    8990 *  
    90  * @param ip            The IP address to lookup.  
    91  * @return                      The result of the geoip lookup, 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. 
    9293 */  
    9394native Float:geoip_latitude( const ip[] );  
    9495 
    9596/**  
    96  * Lookup the city's longitude for the given IP address. Returns  
     97 * look up the city's longitude for the given IP address. Returns  
    9798 *  
    98  * @param ip            The IP address to lookup.  
    99  * @return                      The result of the geoip lookup, 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.  
    100101 */  
    101102native Float:geoip_longitude( const ip[] ); 
    102103 
    103104/** 
    104  * Lookup the region/state code for the given IP address. 
     105 * look up the region/state code for the given IP address. 
    105106 * e.g: "OH", "CA", "11", etc. 
    106107 * 
    107108 * @note It can be a number depending. 
    108109 * 
    109  * @param ip            The IP address to lookup. 
    110  * @param result        The result of the geoip lookup. 
    111  * @return                      true on a successful lookup, 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. 
    112113 */ 
    113114native bool:geoip_region( const ip[], result[4] ); 
    114115 
    115116/** 
    116  * Lookup the full region/state name for the given IP address. Sets the buffer to "error" on 
    117  * an unsuccessful lookup. 
     117 * look up the full region/state name for the given IP address. Sets the buffer to "error" on 
     118 * an unsuccessful look up. 
    118119 * 
    119  * @param ip            The IP address to lookup. 
    120  * @param result        The result of the geoip lookup. 
     120 * @param ip            The IP address to look up. 
     121 * @param result        The result of the geoip look up. 
    121122 * @param len           The maximum length of the result buffer. 
    122123 */ 
     
    124125 
    125126/** 
    126  * Lookup the full time zone for the given IP address. Sets the buffer to "error" on 
    127  * an unsuccessful lookup. 
     127 * Look up the full time zone for the given IP address. Sets the buffer to "error" on 
     128 * an unsuccessful look up. 
    128129 * 
    129  * @param ip            The IP address to lookup. 
    130  * @param result        The result of the geoip lookup. 
     130 * @param ip            The IP address to look up. 
     131 * @param result        The result of the geoip look up. 
    131132 * @param len           The maximum length of the result buffer. 
    132133 */ 
    133134native geoip_timezone( const ip[], result[], len = 45 ); 
    134135 
    135  * Lookup the continent code for a given IP address. 
     136/** 
     137 * Look up the continent code for a given IP address. 
    136138 * 
    137  * @note The code can be retrieved as integer number or string (2 characters). 
     139 * @note The code can be retrieved as integer or string (2 characters). 
    138140 * @note Possible continent codes are AF, AS, EU, NA, OC, SA for  
    139141 * Africa(1), Asia(2), Europe(3), North America(4), Oceania(5) and South America(6). 
    140142 * 
    141  * @param ip            The IP address to lookup. 
    142  * @param result        The result of the geoip lookup. This param is optional.  
    143  *                                      If the lookup does not succeed, the buffer is not modified. 
    144  * @return                      The result of the geoip lookup, 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. 
    145147 */ 
    146148enum Continent 
    147149{ 
    148         AFRICA = 1, 
     150        CONTINENT_ERROR = 0, 
     151        AFRICA, 
    149152        ASIA, 
    150153        EUROPE, 
     
    154157} 
    155158native Continent:geoip_continent_code( const ip[], result[3] = "" ); 
     159 
    156160/** 
    157161 * Calculate the distance between geographical coordinates, latitude and longitude. 
  • Mirrors/AMXModX/dlls/geoip_ex/sdk/moduleconfig.h

    r5454 r5466  
    1616 */ 
    1717#define MODULE_NAME "GeoIP Extented" 
    18 #define MODULE_VERSION "1.0.1" 
     18#define MODULE_VERSION "1.0.2" 
    1919#define MODULE_AUTHOR "AMX Mod X Dev Team / Arkshine" 
    2020#define MODULE_URL "http://www.amxmodx.org/"