Preventing from advertise.

Started by Xmair, Sep 14, 2015, 12:25 PM

Previous topic - Next topic

Xmair

Hello guys, How can I check if a player has wrote an IP like xx.xx.xx.xx so the server can kick him for advertising.
I think it will be done onPlayerChat.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

.

I guess you could:
_IP_MATCH_REGEX <- regexp(@"(?:[0-9]{1,3}\.){3}[0-9]{1,3}");
ContainsIPAddress <- @(s) (_IP_MATCH_REGEX.search(s) != null);

Not very accurate but neither the regular expression implementation in squirrel is complete.

local a = "Invalid address 000.0000.00.00 that should not match";
local b = "Valid address 192.168.1.1 that should match";
local c = "Invalid address 912.456.123.123 that matches due to the regex limitations in squirrel";

print(ContainsIPAddress(a));
print(ContainsIPAddress(b));
print(ContainsIPAddress(c));

[SCRIPT]  false
[SCRIPT]  true
[SCRIPT]  true
.

EK.IceFlake


.

#3
Quote from: NE.CrystalBlue on Sep 14, 2015, 01:59 PM192-168-0-1 NO MATCH

Yeah, sure, feel free to do better:

192 168 0 1 NO MATCH
192,168,0,1 NO MATCH
192+168+0+1 NO MATCH
192~168~0~1 NO MATCH
192<168<0<1 NO MATCH
192>168>0>1 NO MATCH
192:168:0:1 NO MATCH
192|168|0|1 NO MATCH
192'168'0'1 NO MATCH
192?168?0?1 NO MATCH
192/168/0/1 NO MATCH
192\168\0\1 NO MATCH
192*168*0*1 NO MATCH
192&168&0&1 NO MATCH
192%168%0%1 NO MATCH
192$168$0$1 NO MATCH
192#168#0#1 NO MATCH
192@168@0@1 NO MATCH
192!168!0!1 NO MATCH
192^168^0^1 NO MATCH
192(168(0(1 NO MATCH
192)168)0)1 NO MATCH
192=168=0=1 NO MATCH
192_168_0_1 NO MATCH
192;168;0;1 NO MATCH
192[168[0[1 NO MATCH
192]168]0]1 NO MATCH
192{168{0{1 NO MATCH
192}168}0}1 NO MATCH
192`168`0`1 NO MATCH
.

.

_IP_MATCH_REGEX <- regexp(@"(?:[0-9]{1,3}\W){3}[0-9]{1,3}");
ContainsIPAddress <- @(s) (_IP_MATCH_REGEX.search(s) != null);

local IPs = [
    @"This is an 192 168 0 1 obfuscated ip address",
    @"This is an 192.168.0.1 obfuscated ip address",
    @"This is an 192-168-0-1 obfuscated ip address",
    @"This is an 192,168,0,1 obfuscated ip address",
    @"This is an 192+168+0+1 obfuscated ip address",
    @"This is an 192~168~0~1 obfuscated ip address",
    @"This is an 192<168<0<1 obfuscated ip address",
    @"This is an 192>168>0>1 obfuscated ip address",
    @"This is an 192:168:0:1 obfuscated ip address",
    @"This is an 192|168|0|1 obfuscated ip address",
    @"This is an 192'168'0'1 obfuscated ip address",
    @"This is an 192?168?0?1 obfuscated ip address",
    @"This is an 192/168/0/1 obfuscated ip address",
    @"This is an 192\168\0\1 obfuscated ip address",
    @"This is an 192*168*0*1 obfuscated ip address",
    @"This is an 192&168&0&1 obfuscated ip address",
    @"This is an 192%168%0%1 obfuscated ip address",
    @"This is an 192$168$0$1 obfuscated ip address",
    @"This is an 192#168#0#1 obfuscated ip address",
    @"This is an 192@168@0@1 obfuscated ip address",
    @"This is an 192!168!0!1 obfuscated ip address",
    @"This is an 192^168^0^1 obfuscated ip address",
    @"This is an 192(168(0(1 obfuscated ip address",
    @"This is an 192)168)0)1 obfuscated ip address",
    @"This is an 192=168=0=1 obfuscated ip address",
    @"This is an 192_168_0_1 obfuscated ip address",
    @"This is an 192;168;0;1 obfuscated ip address",
    @"This is an 192[168[0[1 obfuscated ip address",
    @"This is an 192]168]0]1 obfuscated ip address",
    @"This is an 192{168{0{1 obfuscated ip address",
    @"This is an 192}168}0}1 obfuscated ip address",
    @"This is an 192`168`0`1 obfuscated ip address"
];

foreach (s in IPs)
{
    if (ContainsIPAddress(s))
    {
        print("Matched :::: " + s);
    }
}

[SCRIPT]  Matched :::: This is an 192 168 0 1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192.168.0.1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192-168-0-1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192,168,0,1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192+168+0+1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192~168~0~1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192<168<0<1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192>168>0>1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192:168:0:1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192|168|0|1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192'168'0'1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192?168?0?1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192/168/0/1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192\168\0\1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192*168*0*1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192&168&0&1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192%168%0%1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192$168$0$1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192#168#0#1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192@168@0@1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192!168!0!1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192^168^0^1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192(168(0(1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192)168)0)1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192=168=0=1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192;168;0;1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192[168[0[1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192]168]0]1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192{168{0{1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192}168}0}1 obfuscated ip address
[SCRIPT]  Matched :::: This is an 192`168`0`1 obfuscated ip address

If you want overkill!

.

Thijn

Why do you even make people admin? You shouldn't handle every fucking thing server side. Some things are for the admins to handle. That's why they're there.

KAKAN

What about a domain? It'll just catch the IP, no domains :P
oh no

.

Quote from: KAKAN on Sep 14, 2015, 05:52 PMWhat about a domain? It'll just catch the IP, no domains :P

DAFUQ DID THE GUY ABOVE JUST SAID?
.

Thijn