From 7ce3ee2c0a5378b5935479b50dcb99d4731b1d5a Mon Sep 17 00:00:00 2001
From: TDavis
Date: Sat, 30 Mar 2019 00:53:47 -0300
Subject: Mover hilos fix
Mover hilos fix 2
Mover hilos fix INTENTO 3
Mover hilos fix 4 Test 1
Mover hilos fix 4 Test 2
Mover hilos fix 4 Test 3
Mover hilos fix 4 Test 4
Mover hilos fix 4 Test 5
Mover hilos fix 4 Test 6
Mover hilos fix 4 Test 7
Mover hilos fix 4 Test 8
Mover hilos fix 4 Test 9
Arreglando función para mover hilos y función para buscar posts por IP
---
cgi/formatting.py | 12 ++++--------
cgi/manage.py | 49 +++++++++++++++++++++++++++++++++--------------
cgi/templates/banned.html | 30 ++++++++++-------------------
3 files changed, 49 insertions(+), 42 deletions(-)
diff --git a/cgi/formatting.py b/cgi/formatting.py
index d21bee2..6b2d8bc 100644
--- a/cgi/formatting.py
+++ b/cgi/formatting.py
@@ -121,11 +121,8 @@ def iphash(ip, post, t, useid, mobile, agent, cap_id, hide_end, has_countrycode)
id = '???'
else:
day = int((current_t + (Settings.TIME_ZONE*3600)) / 86400)
- word = ',' + str(day)
-
- # Make difference by thread
- word += ',' + str(t)
-
+ word = ',' + str(day) # IDs change every 24 hours
+ word += ',' + str(t) # IDs vary depending on thread
id = hide_data(ip + word, 6, "id", Settings.SECRET)
if hide_end:
@@ -164,9 +161,8 @@ def iphash(ip, post, t, useid, mobile, agent, cap_id, hide_end, has_countrycode)
if addressIsBanned(ip, ""):
id += '#'
- if (not has_countrycode and
- not addressIsTor(ip) and
- (addressIsProxy(ip) or not addressIsES(ip))):
+ elif (not has_countrycode and not addressIsTor(ip) and
+ (addressIsProxy(ip) or not addressIsES(ip))):
id += '!'
return id
diff --git a/cgi/manage.py b/cgi/manage.py
index 44731ba..71ed647 100644
--- a/cgi/manage.py
+++ b/cgi/manage.py
@@ -421,6 +421,7 @@ def manage(self, path_split):
board = setBoard(oldboardid)
oldboard = board['dir']
oldboardsubject = board['subject']
+ oldboardname = board['anonymous']
# get old posts
posts = FetchAll("SELECT * FROM `posts` WHERE (`id` = {0} OR `parentid` = {0}) AND `boardid` = {1} ORDER BY id ASC".format(oldthread, board['id']))
@@ -460,17 +461,30 @@ def manage(self, path_split):
moved_thumbs.append(post['thumb'])
if is_op:
moved_cats.append(post['thumb'])
-
+
# fix subject if necessary
if post['subject'] and post['subject'] == oldboardsubject:
post['subject'] = board['subject']
-
+
+ # fix new default name
+ if post['name'] == oldboardname:
+ post['name'] = board['anonymous']
+
+ # fix date and (re)add post ID if necessary
+ 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']))
+
# insert new post and get its new ID
new_id = post.insert()
-
+
# save the reference (BBS = post number, IB = new ID)
refs[old_id] = num if board['board_type'] == '1' else new_id
-
+
# this was an OP
message += "newthread = %s parentid = %s
" % (newthreadid, p['parentid'])
if is_op:
@@ -480,6 +494,7 @@ def manage(self, path_split):
# BBS = new thread timestamp, IB = new thread ID
newthread = post['timestamp'] if board['board_type'] == '1' else new_id
+ parent_time = post['timestamp']
# log it
message += "%s -> %s
" % (old_id, new_id)
@@ -523,6 +538,7 @@ def manage(self, path_split):
# insert notice message
if 'msg' in self.formdata:
+ leavemsg = True
board = setBoard(oldboard)
if board['board_type'] == '1':
@@ -540,11 +556,13 @@ def manage(self, path_split):
notice_post["timestamp_formatted"] = "Hilo movido"
notice_post["bumped"] = oldbumped
notice_post.insert()
+ regenerateFrontPages()
+ regenerateThreadPage(oldthread)
- # regenerate
+ # regenerate again (fix?)
+ board = setBoard(newboardid)
regenerateFrontPages()
regenerateThreadPage(newthreadid)
- regenerateThreadPage(oldthread)
message += "done"
@@ -1181,13 +1199,13 @@ def manage(self, path_split):
posts = FetchAll('SELECT * FROM `posts` WHERE `boardid` = %s' % board['id'])
self.output = "total: %d
" % len(posts)
for post in posts:
- new_timestamp_formatted = formatTimestamp(post['timestamp'])
- tim = 0
- if board["useid"] != '0':
- new_timestamp_formatted += ' ID:' + iphash(post['ip'], '', tim, '1', False, False, False, '0')
- self.output += "%s - %s
" % (post['id'], new_timestamp_formatted)
- query = "UPDATE `posts` SET timestamp_formatted = '%s' WHERE boardid = '%s' AND id = '%s'" % (new_timestamp_formatted, board['id'], post['id'])
- UpdateDb(query)
+ new_timestamp_formatted = formatTimestamp(post['timestamp'])
+ tim = 0
+ if board["useid"] != '0':
+ new_timestamp_formatted += ' ID:' + iphash(post['ip'], '', tim, '1', False, False, False, '0')
+ self.output += "%s - %s
" % (post['id'], new_timestamp_formatted)
+ query = "UPDATE `posts` SET timestamp_formatted = '%s' WHERE boardid = '%s' AND id = '%s'" % (new_timestamp_formatted, board['id'], post['id'])
+ UpdateDb(query)
return
elif path_split[2] == 'fixname':
board = setBoard(path_split[3])
@@ -1686,7 +1704,10 @@ def manage(self, path_split):
if self.formdata['ip'] != '':
formatted_ip = str(inet_aton(self.formdata['ip']))
posts = FetchAll("SELECT posts.*, boards.dir, boards.board_type, boards.subject AS default_subject FROM `posts` JOIN `boards` ON boards.id = posts.boardid WHERE ip = '%s' ORDER BY posts.timestamp DESC" % _mysql.escape_string(formatted_ip))
- ip = self.formdata['ip']
+ if '.' in self.formdata['ip']:
+ ip = self.formdata['ip']
+ else:
+ ip = inet_ntoa(long(self.formdata['ip']))
template_filename = "ipshow.html"
template_values = {"mode": 1, "ip": ip, "host": getHost(ip), "country": getCountry(ip), "tor": addressIsTor(ip), "posts": posts}
logAction(staff_account['username'], "ipshow on {}".format(ip))
diff --git a/cgi/templates/banned.html b/cgi/templates/banned.html
index 72f2abe..f63dd41 100644
--- a/cgi/templates/banned.html
+++ b/cgi/templates/banned.html
@@ -3,14 +3,11 @@
P.S: En muchos casos a pesar de que hayas sido expulsado del sitio se concede el acceso a la sección Meta
-¡Gracias por usar Bienvenido a Internet BBS/IB!
+P.S: En muchos casos a pesar de que hayas sido expulsado del sitio se concede el acceso a la sección Meta
+¡Gracias por usar Bienvenido a Internet BBS/IB!
-- cgit v1.2.1-18-gbd029