Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
[Extra] ?qip enhancement

 
Post new topic   Reply to topic Printable version
 View previous topic  No anti in center Post :: Post Region solutions  View next topic  
Author Message
Siaon
Novice


Age:42
Joined: Dec 04 2002
Posts: 49
Offline

PostPosted: Fri Apr 09, 2004 10:12 am    Post subject: [Extra] ?qip enhancement Reply to topic Reply with quote

Replace in aliasdb.c

Code: Show/Hide
local helptext_t qip_help =
"Targets: none or player\n"
"Args: -i<ip address or pattern> -l<limit>\n"
"Queries the alias database for players connecting from that ip.\n"
"Queries can be an exact address, ?qip -i216.34.65.%, or ?qip -i216.34.65.0/24.\n";

local void Cqip(const char *params, Player *p, const Target *target)
{
    char ip [256];
    unsigned int limit;

    if (target->type != T_ARENA && target->type != T_PLAYER)
        return;

    if (!strstr(params,"-i") && target->type != T_PLAYER)
        return;

    p->flags.during_query = 1;

    if (strstr(params,"-l"))
    {
        limit = atoi(strstr(params,"-l")+2);

        if ( limit < 1 )
            limit = 1;

        if ( limit > 500 )
            limit = 500;
    } else
    {
        limit = 50;
    }

    if (target->type == T_PLAYER)
    {
        db->Query(dbcb_nameipmac, p, 1,
            "select name, inet_ntoa(ip), macid, to_days(now()) - to_days(lastseen) as daysago "
            "from " TABLE_NAME " "
            "where ip = inet_aton(?) "
            "order by name "
            "limit # ",
            target->u.p->ipaddr, limit);
    }
    else
    {
        if (strchr(strstr(params,"-i")+2, ' '))
        {
            ip [strchr(strstr(params,"-i")+2, ' ')-params-2] = 0;

            strncpy ( ip, strstr(params,"-i")+2, strchr(strstr(params,"-i")+2, ' ')-params-2);
        }
        else
        {
            strcpy ( ip, strstr(params,"-i")+2);
        }

        if (strchr(params, '/'))
        {
            char baseip[16];
            const char *next;
            unsigned int bits;

            next = delimcpy(baseip, ip, sizeof(baseip), '/');
            if (!next) return;
            bits = atoi(next);

            db->Query(dbcb_nameipmac, p, 1,
                "select name, inet_ntoa(ip), macid, to_days(now()) - to_days(lastseen) as daysago "
                "from " TABLE_NAME " "
                "where (ip & ((~0) << (32-#))) = (inet_aton(?) & ((~0) << (32-#))) "
                "order by name "
                "limit # ",
                bits, baseip, bits, limit);
        }
        else if (strchr(ip, '%'))
        {
            /* this is going to be a really really slow query... */
            db->Query(dbcb_nameipmac, p, 1,
                "select name, inet_ntoa(ip), macid, to_days(now()) - to_days(lastseen) as daysago "
                "from " TABLE_NAME " "
                "where inet_ntoa(ip) like ? "
                "order by name "
                "limit #",
                ip, limit);
        }
        else /* try exact ip match */
        {
            db->Query(dbcb_nameipmac, p, 1,
                "select name, inet_ntoa(ip), macid, to_days(now()) - to_days(lastseen) as daysago "
                "from " TABLE_NAME " "
                "where ip = inet_aton(?) "
                "order by name "
                "limit # ",
                ip, limit);
        }
    }
}

_________________

Yesterday was history, Tomorrow's a mystery. Today is a gift, that's why it's called the present.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Qndre
Server Help Squatter


Gender:Gender:Male
Joined: Jan 25 2004
Posts: 295
Offline

PostPosted: Tue Apr 13, 2004 2:02 pm    Post subject: Reply to topic Reply with quote

I don't understand why it's called ?qip
Back to top
View users profile Send private message Add User to Ignore List
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Apr 13, 2004 5:13 pm    Post subject: Reply to topic Reply with quote

Q, for query, IP for what method to query. Thus, as a shorthand for queryip, you remove a bunch of letters to make it qip.
Back to top
View users profile Send private message Add User to Ignore List Send email
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Tue Apr 13, 2004 7:08 pm    Post subject: Reply to topic Reply with quote

technically one could 'alias' the function though to have a ?queryip correct? icon_smile.gif
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Tue Apr 13, 2004 8:14 pm    Post subject: Reply to topic Reply with quote

I'm not sure ASSS has command aliases. A module itself could make them, but I don't think you can do it externally (at the moment).
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Siaon
Novice


Age:42
Joined: Dec 04 2002
Posts: 49
Offline

PostPosted: Sat Apr 24, 2004 10:54 am    Post subject: Reply to topic Reply with quote

I'm working on it, I'll post it here asap.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
divine.216
Guest


Offline

PostPosted: Thu Apr 29, 2004 5:11 pm    Post subject: Reply to topic Reply with quote

Stop nesting redundant str*** calls... this is a realistic language, you are supposed to actually think about what's going on when you issue a call. Not to mention that it makes your code harder to read.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 660 page(s) served in previous 5 minutes.

phpBB Created this page in 0.437473 seconds : 32 queries executed (90.9%): GZIP compression disabled