Raised This Month: $ Target: $400
 0% 

is worth and possible cache user ip and auth in index as global string var?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
seriousspot
BANNED
Join Date: Mar 2013
Location: Lithuania / Norway
Old 08-03-2013 , 15:28   Re: is worth and possible cache user ip and auth in index as global string var?
Reply With Quote #1

Quote:
Originally Posted by YamiKaitou View Post
What I meant was it all depends on how many times you call get_user_ip or get_user_authid throughout the life of that players connection.



Don't understand the question, hence why I didn't answer it
alot of times, its management, technical, stastics, admin AIO plugin


memory leaks*, I am sorry
seriousspot is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-03-2013 , 15:47   Re: is worth and possible cache user ip and auth in index as global string var?
Reply With Quote #2

PHP Code:
#include < amxmodx >

public plugin_init()
{
    
register_clcmd("say /info""ClCmd_Say_Info");
}

GGETPLAYERAUTHID(idbGet false)
{
    static 
szAuthid[33][32];
    if( 
bGet )
    {
        
get_user_authid(idszAuthid[id], charsmax(szAuthid[]));
    }
    return 
szAuthid[id];
}

public 
client_connect(id)
{
    
GETPLAYERIP(idtrue);
}

public 
client_authorized(id)
{
    
GGETPLAYERAUTHID(idtrue);
}

GETPLAYERAUTHID(idbGet false)
{
    static 
szAuthid[33][32];
    if( 
bGet )
    {
        
get_user_authid(idszAuthid[id], charsmax(szAuthid[]));
    }
    return 
szAuthid[id];
}

GETPLAYERIP(idbGet false)
{
    static 
szAddress[33][16];
    if( 
bGet )
    {
        
get_user_ip(idszAddress[id], charsmax(szAddress[]), 1);
    }
    return 
szAddress[id];
}

public 
ClCmd_Say_Info(id)
{
    
client_print(idprint_chat"Your IP is ^"%s^" and your SteamID is ^"%s^""GETPLAYERIP(id), GETPLAYERAUTHID(id));
}

// function in which you need to use steamid more that one and ip more than once :
public function( id )
{
    static 
szAuthid[32], szIp[16];
    
szAuthid GETPLAYERAUTHID(id);
    
szIp GETPLAYERIP(id);

    if( !(
'0' <= szAuthid[10] <= '9') && !IsLocalIpszIp ) )
    {
        
client_print(idprint_chat"Your IP is ^"%s^" and your SteamID is ^"%s^" tell us you are not using steam"szIpszAuthid);
    }
}

IsLocalIp( const IP[] )
{
    return 
false;

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
seriousspot
BANNED
Join Date: Mar 2013
Location: Lithuania / Norway
Old 08-03-2013 , 16:25   Re: is worth and possible cache user ip and auth in index as global string var?
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
#include < amxmodx >

public plugin_init()
{
    
register_clcmd("say /info""ClCmd_Say_Info");
}

GGETPLAYERAUTHID(idbGet false)
{
    static 
szAuthid[33][32];
    if( 
bGet )
    {
        
get_user_authid(idszAuthid[id], charsmax(szAuthid[]));
    }
    return 
szAuthid[id];
}

public 
client_connect(id)
{
    
GETPLAYERIP(idtrue);
}

public 
client_authorized(id)
{
    
GGETPLAYERAUTHID(idtrue);
}

GETPLAYERAUTHID(idbGet false)
{
    static 
szAuthid[33][32];
    if( 
bGet )
    {
        
get_user_authid(idszAuthid[id], charsmax(szAuthid[]));
    }
    return 
szAuthid[id];
}

GETPLAYERIP(idbGet false)
{
    static 
szAddress[33][16];
    if( 
bGet )
    {
        
get_user_ip(idszAddress[id], charsmax(szAddress[]), 1);
    }
    return 
szAddress[id];
}

public 
ClCmd_Say_Info(id)
{
    
client_print(idprint_chat"Your IP is ^"%s^" and your SteamID is ^"%s^""GETPLAYERIP(id), GETPLAYERAUTHID(id));
}

// function in which you need to use steamid more that one and ip more than once :
public function( id )
{
    static 
szAuthid[32], szIp[16];
    
szAuthid GETPLAYERAUTHID(id);
    
szIp GETPLAYERIP(id);

    if( !(
'0' <= szAuthid[10] <= '9') && !IsLocalIpszIp ) )
    {
        
client_print(idprint_chat"Your IP is ^"%s^" and your SteamID is ^"%s^" tell us you are not using steam"szIpszAuthid);
    }
}

IsLocalIp( const IP[] )
{
    return 
false;


done myself i think more efficient way, but on client_disconnect don't know how to reset


PHP Code:
#include <amxmodx>
#include <regex>


#define REGEX_IP "\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
#define REGEX_AUTH "^^STEAM_0:(0|1):\d+$"

#define is_valid_ip(%1) (regex_match_c(%1, regex_ip, regex_return) > 0)
#define is_valid_auth(%1) (regex_match_c(%1, regex_auth, regex_return) > 0)

new Regex:regex_ipRegex:regex_authregex_returng_AUTH[33][64], g_IP[33][16]

public 
plugin_init() {
    
// regex stuff
    
new error[2]
    
regex_ip regex_compile(REGEX_IPregex_returnerrorcharsmax(error))
    
regex_auth regex_compile(REGEX_AUTHregex_returnerrorcharsmax(error))
    
    
// testing
    
    
register_concmd("/test""echo")
}

public 
client_authorized(id) {
    new 
AUTH[64// future proof
    
    
get_user_authid(idAUTHcharsmax(AUTH))
    
    if (
is_valid_auth(AUTH)) {
        
g_AUTH[id] = AUTH
    
}
    
    else {
        
// client is not authorized
        
return 1
    
}
    
    return 
0
}

public 
client_connect(id) {
    new 
IP[16
    
    
get_user_ip(idIPcharsmax(IP), 1)
    
    if (
is_valid_ip(IP)) {
        
g_IP[id] = IP
    
}
    
    else {
        
// client ip is not valid
        
return 1
    
}
    
    return 
0
}

/*

        TODO

public client_disconnect(id) {
    new null = 0
    
    g_AUTH[id] = null
    g_IP[id] = null
}


*/

public echo(id) {
    
client_print(idprint_console"AUTH: %s, IP: %s"g_AUTH[id], g_IP[id])


Last edited by seriousspot; 08-03-2013 at 16:26.
seriousspot is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode