Thread: AntiCommerce
View Single Post
Plugin Info:     Modification:          Category:          Approver:   Alka (6)
Scherzo
Senior Member
Join Date: Feb 2007
Location: Kwidzyn, Poland
Old 10-26-2008 , 07:45   AntiCommerce
Reply With Quote #1

AntiCommerce 1.2a

Description:
Anti spam filter. It doesn`t allow put addresses websites or/and IPs servers in chat or/and nick (controlled by cvars). This plugin, based on regular expression, is weapon against spammers.
Included admins immunity support.


Cvars:
  • ac_log 0|1 (default 1)
Mean it will create log file (1) with found adverts or not (0).
If ac_log 1 you should create 'advert' folder in logs/ directory.
  • ac_what2search 0|1|2|3 (default 3)
Define which adverts it should search. Value from list:
  • 0 - nothing (sth like plugin disabled)
  • 1 - only IP`s
  • 2 - only WWW addresses
  • 3 - both
  • ac_punish 0|1|2 (default 0)
Chose punishment for spammers
  • 0 - warning
  • 1 - kick
  • 2 - ban
  • ac_bantime <time> (default 1)
If 'ac_punish 2' it define how long player will be banned (in minutes)
  • ac_punishbyname 0|1 (default 1)
If = 0 plugin doesn`t kick and ban for advert in nick
  • ac_changename 0|1 (default 1)
If = 1 and ac_punishbyname 1 changes found nick on 'Player' (defined as const)
  • ac_punishbysay 0|1 (default 1)
If = 0 plugin doesn`t kick and ban for advert in chat messages
  • ac_banip 0|1 (default 0)
Work when ac_punish 2.
ac_banip 1 will ban user by ip,
ac_banip 0 will ban user by authid.

  • ac_firstadvert 0|1 (default 1)
If =1 and found first player`s advert plugin set for him ac_punish 0 - only warning to know that this is doesn`t allowed on server. For next adverts use actual cvar value.
  • No longer ac_flex_pattern 0|1
  • ac_ips_chars "<chars>" (default [NALPHANUM])
Define list of chars, which can be between bytes of IP to punish. In standard IP it is simple dot (.), but you can punish for other , fe. "12. 12, 12.12". Default value mean: "all not alphanumeric chars". It is single value - don`t add other chars (bad used could make pattern invalid, so it is blocked) to this, create own list of chars. Instead double quote char (") use [q] alias.
Examples:
ac_ips_chars " .,"
ac_ips_chars " .-="
ac_ips_chars " .'[q]"

  • ac_max_chars <num> (default 3)
Max count of chars from list 'ac_ips_chars' in string. Value 3 mean, that 12...12.12.12 will be punished but 12....12.12.12 will not. Use 0 when want catch all more than 1.
Cmds
  • register_exception <text>
Add <text> to list of exceptions. For this addresses it won`t punish (allowed addresess).
You can add websites and servers addresses. Plugin automatic add IP of your server.
If you need more than 15 exception slots, change
this constant and recompile:

#define MAX_EXC 15

Important: Don`t include 'http://' and 'www' in domains and port in IPs!
  • showexc
Show in console list of exceptions (only for admins).

Modules:
<regex>
<sockets>

Files:
.amxx to plugins/ directory
.txt to data/lang/
directory

ML:
[en]
[pl]
[de] - by Mordekay

[es] - byjowy77
[ru] - by xPaw
[bp] - by tmen_13
[hu] - by KuyteKuyte
[lt] - by hlev (replaced this by shadowski)
[ro] - by htudor
[bg] - by ivkos
[nl] - by crazyeffect
[fr] - by arkshine
[ua] - Strikerr
[sk] - Seehank

History:

1.2a
Added: admin can modificate IP pattern
Fixed: punish delayed for block player`s message
1.2
Fixed: new IP pattern
which was put in comment to preg_match() PHP function by Jonathan Camenisch.
(I rewrite to flexible version.)
It is much better than mine included to v1.1

1.1e
Added: cvar ac_flex_pattern define using standard or flexible pattern of IP

1.1d
Fixed: better than in 1.1c - fixed multi-catch on connect
Added: cvar 'ac_firstadvert' to warning before kick/ban
Fixed: exception registering

1.1c
Added: if ac_punish 0 in first round nick is not checking (thx Mordekay).


1.1b
Added: log suspected matches (not punished, but formated like website address)
More clean code; also added some comments

1.1a
Some optimalizations
Fixed: logging with user IP if ac_banip 1
Added: if player kicked or banned plugin show in console reason quote (shadowski`s suggestion)

1.1
Added: using sockets module to check URLs
Added: cvar ac_what2search
Added: amxbans support
Changed: port of server is not necessary to get punishment(suggested by lpf_kb)
Default MAX_EXC increased to 15

1.0
base


Other:
If ac_log 1 you should create advert folder in logs/ directory. I put mkdir function, but tested only on local computer, where chmod is not important.
Scherzo a.k.a. R3X

Thx Allucard for suggestion.
Thx sapir5522 for idea of cvar 'ac_banip', help in debug and more
Attached Files
File Type: sma Get Plugin or Get Source (anticommerce.sma - 12730 views - 9.2 KB)
File Type: txt anticommerce.txt (5.7 KB, 7750 views)

Last edited by Scherzo; 03-04-2009 at 12:05. Reason: update
Scherzo is offline