better advertisement check
#1

pawn Код:
stock AdvertisementCheck(string[])
{
    if(!isnull(string))
    {
        if(strfind(string,"www.",true)!=-1 || strfind(string,"http://",true)!=-1 || !strfind(string,".com",false) || !strfind(string,".net",false)
        || !strfind(string,".de",false) || !strfind(string,".org",false) || !strfind(string,".blog",false) || !strfind(string,".info",false)
        || !strfind(string,".co.cc",false))
        {
            return true;
        }
        new c=1,idx,tmp[32],ip[4],len=strlen(string);
        for(new i=0;i<len;i++)
            if(string[i]==' ')
                c++;
        for(new i=0;i<c;i++)
        {
            idx=0;
            tmp=strtok(string,idx);
            idx=0;
            tmp=strtok2(tmp,idx,':');
            ip=SplitIp(tmp);
            if(ip[0]>=0 && ip[1]>=0 && ip[2]>=0 && ip[3]>=0) // We have found an IP :o
                return true;
        }
    }
    return false;
}
say i accidentally type .complain i get banned... any ideas
Reply
#2

bump
Reply
#3

You should not get banned because you did not search for it in strfind. But test it on a local server.
Reply
#4

|| !strfind(string,".com",false) is there

but its stupid if u write .computer or something..
Reply
#5

I suggest using sscanf, because ".com" will allow for everything after the .com aswell, eg. .complain, .computer, .comply
Reply
#6

Antonio, can you show me how to use sscanf to check strings?
Reply
#7

i saw sscanf version of checking strings, but it would only check if the string contained the ip only

edit: E.G

pawn Код:
sscanf(text,"dcdcdcdc",text[0],.,text[1],.,text[2],.,text[3],:);
but if u like loop through the string, there might be problems


pawn Код:
for(new i; i<text[i]; i++
{
    sscanf(text[i],"dcdcdcdc",text[i],.,text[i],.,text[i],.,text[2],:);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)