From 2f0af65405ad93d449534b1467aa54c95fa37b67 Mon Sep 17 00:00:00 2001 From: junk Date: Thu, 8 Apr 2021 21:44:40 -0400 Subject: Arreglos a manage --- cgi/formatting.py | 8 -- cgi/framework.py | 12 +- cgi/manage.py | 235 ++++++++++++++++++++++------------- cgi/post.py | 13 +- cgi/templates/manage/menu.html | 3 +- cgi/templates/manage/mod.html | 15 ++- cgi/templates/manage/news.html | 52 ++++---- cgi/templates/manage/recent.html | 67 +++++----- cgi/templates/manage/recyclebin.html | 4 +- cgi/weabot.py | 18 ++- static/css/ib.css | 21 ---- static/css/spc/manage.css | 33 +++++ static/css/txt/baisano.css | 1 + 13 files changed, 275 insertions(+), 207 deletions(-) create mode 100644 static/css/spc/manage.css diff --git a/cgi/formatting.py b/cgi/formatting.py index 0003f5c..47922c9 100644 --- a/cgi/formatting.py +++ b/cgi/formatting.py @@ -36,14 +36,6 @@ def format_post(message, ip, parentid, parent_timestamp=0): if Settings.USE_HTML: message = onlyAllowedHTML(message) - # [code] tag - if board["dir"] == "tech": - message = re.compile(r"\[code\](.+)\[/code\]", re.DOTALL | - re.IGNORECASE).sub(r"
\1
", message)
- if board["allow_spoilers"]:
- message = re.compile(r"\[spoiler\](.+)\[/spoiler\]", re.DOTALL |
- re.IGNORECASE).sub(r'\1', message)
-
if Settings.VIDEO_THUMBS:
(message, affected) = videoThumbs(message)
# if affected:
diff --git a/cgi/framework.py b/cgi/framework.py
index 898d6a1..94f6f30 100644
--- a/cgi/framework.py
+++ b/cgi/framework.py
@@ -24,8 +24,7 @@ def setBoard(dir):
if not dir:
raise UserError, _("The specified board is invalid.")
logging.debug("Seteando el board " + dir)
- board = FetchOne(
- "SELECT * FROM `boards` WHERE `dir` = '%s' LIMIT 1" % _mysql.escape_string(dir))
+ board = FetchOne("SELECT * FROM `boards` WHERE `dir` = '%s' LIMIT 1" % _mysql.escape_string(dir))
if not board:
raise UserError, _("The specified board is invalid.")
@@ -96,7 +95,8 @@ def addressIsProxy(ip):
def addressIsES(ip):
ES = ['AR', 'BO', 'CL', 'CO', 'CR', 'CU', 'EC', 'ES', 'GF',
- 'GY', 'GT', 'HN', 'MX', 'NI', 'PA', 'PE', 'PY', 'PR', 'SR', 'UY', 'VE', 'v6'] # 'BR',
+ 'GY', 'GT', 'HN', 'MX', 'NI', 'PA', 'PE', 'PY', 'PR',
+ 'SR', 'UY', 'VE', 'v6'] # 'BR',
return getCountry(ip) in ES
@@ -176,10 +176,10 @@ def formatDate(t=None, home=False):
if not home:
try:
board = Settings._.BOARD
- if board["dir"] == 'world':
- daylist = days['en']
- elif board["dir"] == '2d':
+ if board["dir"] == '2d':
daylist = days['jp']
+ elif board["dir"] == 'world':
+ daylist = days['en']
except:
pass
diff --git a/cgi/manage.py b/cgi/manage.py
index f30674a..9818247 100644
--- a/cgi/manage.py
+++ b/cgi/manage.py
@@ -24,8 +24,7 @@ def manage(self, path_split):
if 'username' in self.formdata and 'password' in self.formdata:
# If no admin accounts available, create admin:admin
- first_admin = FetchOne(
- "SELECT 1 FROM `staff` WHERE `rights` = 0 LIMIT 1", 0)
+ first_admin = FetchOne("SELECT 1 FROM `staff` WHERE `rights` = 0 LIMIT 1", 0)
if not first_admin:
InsertDb("INSERT INTO `staff` (`username`, `password`, `added`, `rights`) VALUES ('admin', '" +
_mysql.escape_string(genPasswdHash("admin")) + "', 0, 0)")
@@ -178,17 +177,18 @@ def manage(self, path_split):
template_values = {"mode": 1, 'boards': boardlist()}
elif len(path_split) > 4:
parentid = int(path_split[4])
- posts = FetchAll('SELECT id, timestamp, timestamp_formatted, name, message, file, thumb, IS_DELETED, locked, subject, length, INET6_NTOA(ip) AS ip FROM `posts` WHERE (parentid = %d OR id = %d) AND boardid = %s ORDER BY `id` ASC' % (
- parentid, parentid, board['id']))
+ # make sure it's the full thread
+ check = FetchOne("SELECT `parentid` FROM `posts` WHERE `id` = %s AND `boardid` = %s LIMIT 1" % (parentid, board['id']))
+ if check['parentid'] != "0":
+ parentid = int(check['parentid'])
+
+ posts = FetchAll('SELECT id, timestamp, timestamp_formatted, name, message, file, thumb, IS_DELETED, locked, subject, length, INET6_NTOA(ip) AS ip FROM `posts` WHERE (parentid = %d OR id = %d) AND boardid = %s ORDER BY `id` ASC' % (parentid, parentid, board['id']))
template_filename = "mod.html"
- template_values = {"mode": 3,
- "dir": board["dir"], "posts": posts}
+ template_values = {"mode": 3, "dir": board["dir"], "posts": posts}
else:
- threads = FetchAll(
- "SELECT * FROM `posts` WHERE boardid = %s AND parentid = 0 ORDER BY `bumped` DESC" % board["id"])
+ threads = FetchAll("SELECT * FROM `posts` WHERE boardid = %s AND parentid = 0 ORDER BY `bumped` DESC" % board["id"])
template_filename = "mod.html"
- template_values = {"mode": 2,
- "dir": board["dir"], "threads": threads}
+ template_values = {"mode": 2, "dir": board["dir"], "threads": threads}
elif path_split[2] == "recent":
posts = FetchAll("SELECT posts.id, posts.subject, dir, boards.board_type, parentid, file, thumb, timestamp_formatted, timestamp, posts.message, INET6_NTOA(ip) AS ip, posts.name, email, tripcode, boards.name AS board_name FROM posts INNER JOIN boards ON posts.boardid = boards.id WHERE posts.timestamp > UNIX_TIMESTAMP() - 86400 ORDER BY timestamp DESC")
template_filename = "recent.html"
@@ -205,28 +205,27 @@ def manage(self, path_split):
member_rights = '3'
if path_split[3] == 'edit':
- if len(path_split) > 4:
- member = FetchOne(
- 'SELECT * FROM `staff` WHERE `id` = ' + _mysql.escape_string(path_split[4]) + ' LIMIT 1')
- if member:
- member_username = member['username']
- member_rights = member['rights']
- action = 'edit/' + member['id']
-
- try:
- if self.formdata.get('user'):
- if self.formdata['rights'] in ['0', '1', '2', '3']:
- action_taken = True
-
- UpdateDb("UPDATE `staff` SET `username` = '" + _mysql.escape_string(
- self.formdata['user']) + "', `rights` = " + self.formdata['rights'] + " WHERE `id` = " + member['id'] + " LIMIT 1")
- message = _(
- 'Staff member updated.')
- logAction(staff_account['username'], _(
- 'Updated staff account for %s') % self.formdata['user'])
- template_filename = "message.html"
- except:
- pass
+ if len(path_split) > 4:
+ member = FetchOne('SELECT * FROM `staff` WHERE `id` = ' + _mysql.escape_string(path_split[4]) + ' LIMIT 1')
+ if member:
+ member_username = member['username']
+ member_rights = member['rights']
+ action = 'edit/' + member['id']
+
+ try:
+ if self.formdata.get('user'):
+ if self.formdata['rights'] in ['0', '1', '2', '3']:
+ action_taken = True
+
+ UpdateDb("UPDATE `staff` SET `username` = '" + _mysql.escape_string(
+ self.formdata['user']) + "', `rights` = " + self.formdata['rights'] + " WHERE `id` = " + member['id'] + " LIMIT 1")
+ message = _(
+ 'Staff member updated.')
+ logAction(staff_account['username'], _(
+ 'Updated staff account for %s') % self.formdata['user'])
+ template_filename = "message.html"
+ except:
+ pass
else:
action = 'add'
try:
@@ -275,8 +274,7 @@ def manage(self, path_split):
action_taken = True
message = '' + _(
- 'Click here to confirm the deletion of that staff member') + ''
+ path_split[4] + '">' + _('Click here to confirm the deletion of that staff member') + ''
template_filename = "message.html"
elif path_split[3] == 'delete_confirmed':
if not moderator:
@@ -332,8 +330,7 @@ def manage(self, path_split):
pass
template_filename = "delete.html"
- template_values = {
- 'do_ban': do_ban, 'curboard': path_split[3], 'postid': path_split[4]}
+ template_values = {'do_ban': do_ban, 'curboard': path_split[3], 'postid': path_split[4]}
elif path_split[2] == 'delete_confirmed':
if not moderator:
return
@@ -453,7 +450,8 @@ def manage(self, path_split):
elif path_split[2] == 'move':
raise NotImplementedError
- if not moderator:
+ #if not moderator:
+ if not administrator:
return
oldboardid = ""
@@ -532,15 +530,13 @@ def manage(self, path_split):
post['name'] = board['anonymous']
# fix date and (re)add post ID if necessary
- post['timestamp_formatted'] = formatTimestamp(
- post['timestamp'])
+ post['timestamp_formatted'] = formatTimestamp(post['timestamp'])
if board["useid"] != '0':
if post["parentid"]:
tym = parent_time
else:
tym = post["timestamp"]
- post['timestamp_formatted'] += ' ID:' + iphash(inet_ntoa(long(
- post['ip'])), post, tym, board["useid"], False, '', False, False, (board["countrycode"] in ['1', '2']))
+ post['timestamp_formatted'] += ' ID:' + iphash(post['ip'], post, tym, board["useid"], False, '', False, False, (board["countrycode"] in ['1', '2']))
# insert new post and get its new ID
new_id = post.insert()
@@ -604,10 +600,8 @@ def manage(self, path_split):
# lock original, set expiration to 1 day
exp = timestamp()+86400
- exp_format = datetime.datetime.fromtimestamp(
- exp).strftime("%d/%m")
- sql = "UPDATE `posts` SET `locked`=1, `expires`={exp}, `expires_formatted`=\"{exp_format}\" WHERE `boardid`=\"{oldboard}\" AND id=\"{oldthread}\"".format(
- exp=exp, exp_format=exp_format, oldboard=oldboardid, oldthread=oldthread)
+ exp_format = datetime.datetime.fromtimestamp(exp).strftime("%d/%m")
+ sql = "UPDATE `posts` SET `locked`=1, `expires`={exp}, `expires_formatted`=\"{exp_format}\" WHERE `boardid`=\"{oldboard}\" AND id=\"{oldthread}\"".format(exp=exp, exp_format=exp_format, oldboard=oldboardid, oldthread=oldthread)
UpdateDb(sql)
# insert notice message
@@ -616,11 +610,9 @@ def manage(self, path_split):
board = setBoard(oldboard)
if board['board_type'] == '1':
- thread_url = "/{newboard}/read/{newthread}".format(
- newboard=newboard, newthread=newthread)
+ thread_url = "/{newboard}/read/{newthread}".format(newboard=newboard, newthread=newthread)
else:
- thread_url = "/{newboard}/res/{newthread}.html".format(
- newboard=newboard, newthread=newthread)
+ thread_url = "/{newboard}/res/{newthread}.html".format(newboard=newboard, newthread=newthread)
notice_post = Post(board["id"])
notice_post["parentid"] = oldthread
@@ -643,8 +635,7 @@ def manage(self, path_split):
message += "done"
- logAction(staff_account['username'], "Movido hilo %s/%s a %s/%s." %
- (oldboard, oldthread, newboard, newthread))
+ logAction(staff_account['username'], "Movido hilo %s/%s a %s/%s." % (oldboard, oldthread, newboard, newthread))
else:
template_filename = "move.html"
template_values = {'boards': boardlist(
@@ -1048,10 +1039,8 @@ def manage(self, path_split):
else:
regenerateFrontPages()
- message = "Eliminado post %s permanentemente." % (
- '/' + board['dir'] + '/' + post['id'])
- logAction(
- staff_account['username'], message + ' Contenido: ' + post['message'] + ' IP: ' + post['ip'])
+ message = "Post %s eliminado permanentemente" % ('/' + board['dir'] + '/' + post['id'])
+ logAction(staff_account['username'], message + ' desde papelera. Contenido: ' + post['message'] + ' IP: ' + post['ip'])
# Delete more than 1 post
if 'deleteall' in self.formdata.keys():
@@ -1073,14 +1062,13 @@ def manage(self, path_split):
board = setBoard(dir)
deletePost(int(postid), None)
if post['parentid'] != '0':
- threadUpdated(post['parentid'])
+ threadUpdated(post['parentid'])
else:
- regenerateFrontPages()
+ regenerateFrontPages()
deleted += 1
# Delete post end
- logAction(staff_account['username'], _(
- 'Permadeleted %s post(s).') % str(deleted))
+ logAction(staff_account['username'], _('Permadeleted %s post(s).') % str(deleted))
message = _('Permadeleted %s post(s).') % str(deleted)
# Start
@@ -1257,11 +1245,15 @@ def manage(self, path_split):
elif path_split[2] == 'trim':
if not administrator:
return
+
board = setBoard(path_split[3])
trimThreads()
self.output = "done trimming"
return
elif path_split[2] == 'setexpires':
+ if not administrator:
+ return
+
board = setBoard(path_split[3])
parentid = int(path_split[4])
days = int(path_split[5])
@@ -1281,18 +1273,25 @@ def manage(self, path_split):
elif path_split[2] == 'fixflood':
if not administrator:
return
+
board = setBoard('zonavip')
threads = FetchAll(
"SELECT * FROM posts WHERE boardid = %s AND parentid = 0 AND subject LIKE 'querido mod%%'" % board['id'])
+
for thread in threads:
self.output += "%sHilo: ${posts[0]['subject']} (#{posts[0]['length']}) | |||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#{"Abrir hilo" if posts[0]['locked'] == "1" else "Cerrar hilo"} / -#{"Quitar permasage" if posts[0]['locked'] == "2" else "Permasage"} / -Mover hilo | |||||||||||||||||||||||||||
+ Ver en BaI / + #{"Abrir hilo" if posts[0]['locked'] == "1" else "Cerrar hilo"} / + #{"Quitar permasage" if posts[0]['locked'] == "2" else "Permasage"} / + Mover hilo + | +|||||||||||||||||||||||||||
# | ID | @@ -64,7 +69,7 @@||||||||||||||||||||||||||
#{i} | #{p['id']} | -${p['timestamp_formatted']} | +${p['timestamp_formatted']} | ${p['name']} | ${p['message']} |
diff --git a/cgi/templates/manage/news.html b/cgi/templates/manage/news.html
index 33b8f49..feec2a5 100644
--- a/cgi/templates/manage/news.html
+++ b/cgi/templates/manage/news.html
@@ -13,32 +13,42 @@
| |||||||||||||||||||||
- + | + + + + | +
+
+ #{post['id']}
+
+ : #{post['subject']}
- |
-
-
- ##{post['id']} #{post['subject']} en
- #{post['board_name']} hace
- #{post['timestamp_formatted']}
- por #{post['name']}
-
-
-
-
-
-
- #{post['email']} #{post['tripcode']}
-
-
- Ver hilo completo
-
- Ver
- hilo en BaI
-
- |
- - #{post['ip']} - | -- - - - | + : #{post['name']}#{post['tripcode']} + : Hace #{post['timestamp_formatted']} + @ #{post['board_name']} + ++ #{post['ip']} + | ++ Eliminar + & + Ban + | ||||||||||||||||||||
X R |
- | #{post['id']} | -${post['timestamp_formatted']} | +#{post['id']} | +${post['timestamp_formatted']} | ${post['dir']} | ${post['IS_DELETED']} | ${post['ip']} | diff --git a/cgi/weabot.py b/cgi/weabot.py index eba4c72..8a9f82e 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -160,7 +160,7 @@ class weabot(object): # call post function (post_url, ttaken, unused) = self.make_post(ip, boarddir, parent, trap1, trap2, name, - email, subject, message, file, file_original, spoil, oek_file, password, noimage, mobile) + email, subject, message, file, file_original, spoil, oek_file, password, noimage, mobile) # make redirect self.output += make_redirect(post_url, ttaken) @@ -266,8 +266,7 @@ class weabot(object): if len(path_split) > 4 and path_split[4] and board['board_type'] == '1': # try: - self.output = dynamicRead( - int(path_split[3]), path_split[4], True) + self.output = dynamicRead(int(path_split[3]), path_split[4], True) # except: # self.output = threadPage(path_split[3], True) elif board['board_type'] == '1': @@ -313,10 +312,8 @@ class weabot(object): elif path_split[1] == "random": caught = True OpenDb() - board = FetchOne( - "SELECT `id`, `dir`, `board_type` FROM `boards` WHERE `secret` = 0 AND `id` <> 1 AND `id` <> 13 AND `id` <> 34 ORDER BY RAND() LIMIT 1") - thread = FetchOne( - "SELECT `id`, `timestamp` FROM `posts` WHERE `parentid` = 0 AND `boardid` = %s ORDER BY RAND() LIMIT 1" % board['id']) + board = FetchOne("SELECT `id`, `dir`, `board_type` FROM `boards` WHERE `secret` = 0 AND `id` <> 1 AND `id` <> 13 AND `id` <> 34 ORDER BY RAND() LIMIT 1") + thread = FetchOne("SELECT `id`, `timestamp` FROM `posts` WHERE `parentid` = 0 AND `boardid` = %s ORDER BY RAND() LIMIT 1" % board['id']) if board['board_type'] == '1': url = Settings.HOME_URL + \ board['dir'] + '/read/' + thread['timestamp'] + '/' @@ -380,8 +377,7 @@ class weabot(object): 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]) + self.output = dynamicRead(int(path_split[3]), path_split[4]) elif path_split[1] == "preview": caught = True OpenDb() @@ -397,7 +393,7 @@ class weabot(object): import modapi caught = True self.headers = [("Content-Type", "application/json"), ("Access-Control-Allow-Origin", "*"), ("Access-Control-Allow-Methods", - "PUT, GET, POST, DELETE, OPTIONS"), ("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With")] + "PUT, GET, POST, DELETE, OPTIONS"), ("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With")] OpenDb() modapi.api(self, path_split) if not caught: @@ -602,7 +598,7 @@ class weabot(object): # make ID hash if board["useid"] != '0': post["timestamp_formatted"] += ' ID:' + iphash(ip, post, tim, board["useid"], mobile, - self.environ["HTTP_USER_AGENT"], cap_id, hide_end, (board["countrycode"] in ['1', '2'])) + self.environ["HTTP_USER_AGENT"], cap_id, hide_end, (board["countrycode"] in ['1', '2'])) # use for future file checks xfile = (file or oek_file) diff --git a/static/css/ib.css b/static/css/ib.css index ac2f96b..18b0010 100644 --- a/static/css/ib.css +++ b/static/css/ib.css @@ -282,27 +282,6 @@ textarea { margin-top: 8px; text-align: center; } -.managertable th, -.managertable td { - padding: 0.2em; -} -.managertable .recentPostHeader { - display: block; - font-size: 0.9em; - padding-bottom: 0.25em; - opacity: 65%; -} -.managertable .message { - display: block; -} -.managertable .message.vip { - font-family: Mona, Monapo, IPAMonaPGothic, "MS PGothic", YOzFontAA97; -} -.managertable .actions { - display: block; - margin-top: 0.5em; - font-size: 0.75em; -} #q-p { position: absolute; border: 1px dotted gray; diff --git a/static/css/spc/manage.css b/static/css/spc/manage.css new file mode 100644 index 0000000..9217877 --- /dev/null +++ b/static/css/spc/manage.css @@ -0,0 +1,33 @@ +#adminmenu { + text-align:center; +} +#adminmenu table { + display:inline-block;font-size:10pt;margin-top:2px;text-align:left; +} +#adminmenu a { + font-weight:bold; +} +label { + vertical-align:top; +} +dd p { + margin:0; +} +.managertable th, +.managertable td { + padding: 0.2em; +} +.managertable .recentpost { + vertical-align: top; +} +.managertable .recentinfo { + font-size: 0.9em; + opacity: 0.6; +} +.managertable .recentmsg { + line-height: 18px; + margin: 0.5em 0; +} +.managertable .actions { + font-size: 0.75em; +} \ No newline at end of file diff --git a/static/css/txt/baisano.css b/static/css/txt/baisano.css index 3e0bf40..f0373cb 100644 --- a/static/css/txt/baisano.css +++ b/static/css/txt/baisano.css @@ -1,3 +1,4 @@ +/* 2ch型 */ body, textarea { color: #000; -- cgit v1.2.1-18-gbd029