From 2c7f1346f618f2b6d77aaf5ab763313f7d51cdbe Mon Sep 17 00:00:00 2001
From: neptune
Date: Sun, 23 Aug 2020 03:59:53 -0400
Subject: Arreglados band con dynamicRead
---
cgi/framework.py | 7 +++++--
cgi/weabot.py | 11 ++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
(limited to 'cgi')
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, '' % 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, '' % 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, '' % board["dir"]
# Disallow posting if the site OR board is in maintenance
--
cgit v1.2.1-18-gbd029