diff options
author | neptune | 2020-08-23 03:59:53 -0400 |
---|---|---|
committer | neptune | 2020-08-23 03:59:53 -0400 |
commit | 2c7f1346f618f2b6d77aaf5ab763313f7d51cdbe (patch) | |
tree | f47411c1c39cd7c309cf772f289f8cf55d483746 /cgi | |
parent | 7ef25c75175383b1214673cddc1344d08953c629 (diff) | |
download | weabot-2c7f1346f618f2b6d77aaf5ab763313f7d51cdbe.tar.gz weabot-2c7f1346f618f2b6d77aaf5ab763313f7d51cdbe.tar.xz weabot-2c7f1346f618f2b6d77aaf5ab763313f7d51cdbe.zip |
Arreglados band con dynamicRead
Diffstat (limited to 'cgi')
-rw-r--r-- | cgi/framework.py | 7 | ||||
-rwxr-xr-x | cgi/weabot.py | 11 |
2 files changed, 15 insertions, 3 deletions
diff --git a/cgi/framework.py b/cgi/framework.py index dfaff3d..83624a8 100644 --- a/cgi/framework.py +++ b/cgi/framework.py @@ -49,8 +49,11 @@ def cleanDir(path, ext=None): os.remove(os.path.join(path, f)) -def addressIsBanned(ip, board): - bans = FetchAll("SELECT * FROM `bans` WHERE INET6_ATON('"+str(ip)+"') BETWEEN `ipstart` AND `ipend`") +def addressIsBanned(ip, board, blind_only=False): + query = "SELECT * FROM `bans` WHERE INET6_ATON('"+str(ip)+"') BETWEEN `ipstart` AND `ipend`" + if blind_only: + query += " AND `blind` = '1'" + bans = FetchAll(query) for ban in bans: if ban["boards"] != "": boards = pickle.loads(ban["boards"]) diff --git a/cgi/weabot.py b/cgi/weabot.py index 2ff7105..6d8b512 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -251,6 +251,11 @@ class weabot(object): OpenDb() board = setBoard(path_split[2]) caught = True + + # Redirect to ban page if user is banned + if addressIsBanned(self.environ['REMOTE_ADDR'], board["dir"], blind_only=True): + raise UserError, '<meta http-equiv="refresh" content="0; url=/cgi/banned/%s">' % board["dir"] + if len(path_split) > 4 and path_split[4] and board['board_type'] == '1': # try: self.output = dynamicRead( @@ -362,6 +367,11 @@ class weabot(object): # 4: post(s) OpenDb() board = setBoard(path_split[2]) + + # Redirect to ban page if user is banned + if addressIsBanned(self.environ['REMOTE_ADDR'], board["dir"], blind_only=True): + raise UserError, '<meta http-equiv="refresh" content="0; url=/cgi/banned/%s">' % board["dir"] + self.output = dynamicRead( int(path_split[3]), path_split[4]) elif path_split[1] == "preview": @@ -429,7 +439,6 @@ class weabot(object): # Redirect to ban page if user is banned if addressIsBanned(ip, board["dir"]): - #raise UserError, 'Tu host está en la lista negra.' raise UserError, '<meta http-equiv="refresh" content="0; url=/cgi/banned/%s">' % board["dir"] # Disallow posting if the site OR board is in maintenance |