Explorar o código

토론 내부 시스템 완전히 뜯어고침

Surplus_Up (2DU) %!s(int64=6) %!d(string=hai) anos
pai
achega
29b5558181

+ 1 - 1
app.py

@@ -171,7 +171,7 @@ if setup_tool != 0:
     create_data['data'] = ['title', 'data']
     create_data['cache_data'] = ['title', 'data', 'id']
     create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'send', 'leng', 'hide', 'type']
-    create_data['rd'] = ['title', 'sub', 'date', 'band', 'stop', 'agree']
+    create_data['rd'] = ['code', 'date', 'band', 'stop', 'agree']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user_set'] = ['name', 'id', 'data']
     create_data['user_application'] = ['id', 'pw', 'date', 'encode', 'question', 'answer', 'ip', 'ua', 'token', 'email']

+ 8 - 18
route/api_topic_sub.py

@@ -3,20 +3,17 @@ from .tool.func import *
 def api_topic_sub_2(conn, topic_num):
     curs = conn.cursor()
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    topic_num = str(topic_num)
 
     if flask.request.args.get('num', None):
-        curs.execute(db_change("select id, data, date, ip, block, top from topic where title = ? and sub = ? and id + 0 = ? + 0 order by id + 0 asc"), [
-            name,
-            sub,
+        curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? and id + 0 = ? + 0 order by id + 0 asc"), [
+            topic_num,
             flask.request.args.get('num', '')
         ])
     elif flask.request.args.get('top', None):
-        curs.execute(db_change("select id, data, date, ip, block, top from topic where title = ? and sub = ? and top = 'O' order by id + 0 asc"), [name, sub])
+        curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? and top = 'O' order by id + 0 asc"), [topic_num])
     else:
-        curs.execute(db_change("select id, data, date, ip, block, top from topic where title = ? and sub = ? order by id + 0 asc"), [name, sub])
+        curs.execute(db_change("select id, data, date, ip, block, top from topic where code = ? order by id + 0 asc"), [topic_num])
 
     data = curs.fetchall()
     if data:
@@ -37,21 +34,14 @@ def api_topic_sub_2(conn, topic_num):
                     t_data_f = ''
                     b_color = 'toron_color_not'
 
-                curs.execute(db_change("select who from re_admin where what = ? order by time desc limit 1"), [
-                    'blind (' + name + ' - ' + sub + '#' + str(i[0]) + ')'
-                ])
-                who_blind = curs.fetchall()
-                if who_blind:
-                    ip += ' (' + who_blind[0][0] + ' B)'
-                else:
-                    ip += ' (B)'
+                ip += ' (B)'
 
             if flask.request.args.get('render', None):
                 if i[0] == '1':
                     s_user = i[3]
                 else:
                     if flask.request.args.get('num', None):
-                        curs.execute(db_change("select ip from topic where title = ? and sub = ? order by id + 0 asc limit 1"), [name, sub])
+                        curs.execute(db_change("select ip from topic where code = ? order by id + 0 asc limit 1"), [topic_num])
                         g_data = curs.fetchall()
                         if g_data:
                             s_user = g_data[0][0]
@@ -68,7 +58,7 @@ def api_topic_sub_2(conn, topic_num):
                     t_color = 'toron_color'
 
                 if admin == 1 or b_color != 'toron_color_not':
-                    ip += ' <a href="/thread/' + str(topic_num) + '/admin/' + i[0] + '">(' + load_lang('discussion_tool') + ')</a>'
+                    ip += ' <a href="/thread/' + topic_num + '/admin/' + i[0] + '">(' + load_lang('discussion_tool') + ')</a>'
 
                 if t_data_f == '':
                     t_data_f = '[br]'

+ 29 - 17
route/tool/func.py

@@ -211,6 +211,13 @@ def update(ver_num):
             for i in ['jpg', 'jpeg', 'png', 'gif', 'webp']:
                 curs.execute(db_change("insert into html_filter (html, kind) values (?, 'extension')"), [i])
 
+    if ver_num < 3170400:
+        curs.execute(db_change("select title, sub, code from topic where id = '1'"))
+        change_topic = curs.fetchall()
+        for i in change_topic:
+            curs.execute(db_change("update topic set code = ? where title = ? and sub = ?"), [i[2], i[0], i[1]])
+            curs.execute(db_change("update rd set code = ? where title = ? and sub = ?"), [i[2], i[0], i[1]])
+
     conn.commit()
     print('Update pass')
     print('----')
@@ -232,14 +239,6 @@ def set_init():
         for i in [['smtp_server', 'imap.google.com'], ['smtp_port', '587'], ['smtp_security', 'tls']]:
             curs.execute(db_change("insert into other (name, data) values (?, ?)"), [i[0], i[1]])
 
-def topic_change(num):
-    curs.execute(db_change('select title, sub from topic where id = "1" and code = ?'), [str(num)])
-    db_data = curs.fetchall()
-    if db_data:
-        return [db_data[0][0], db_data[0][1]]
-    else:
-        return ['Test', 'Test']
-
 def pw_encode(data, data2 = '', type_d = ''):
     if type_d == '':
         curs.execute(db_change('select data from other where name = "encode"'))
@@ -816,7 +815,7 @@ def slow_edit_check():
 
     return 0
 
-def acl_check(name = 'test', tool = '', sub = 'test'):
+def acl_check(name = 'test', tool = '', topic_num = 'test'):
     ip = ip_check()
     get_ban = ban_check()
 
@@ -939,9 +938,9 @@ def acl_check(name = 'test', tool = '', sub = 'test'):
                     return 1
 
         if tool == 'topic':
-            curs.execute(db_change("select title from rd where title = ? and sub = ? and not stop = ''"), [name, sub])
+            curs.execute(db_change("select title from rd where code = ? and stop != ''"), [topic_num])
             if curs.fetchall():
-                if admin_check(3, 'topic (' + name + ')') != 1:
+                if admin_check(3, 'topic (code ' + topic_num + ')') != 1:
                     return 1
 
     return 0
@@ -1032,17 +1031,30 @@ def ban_insert(name, end, why, login, blocker, type_d = None):
         else:
             r_time = ''
 
-        curs.execute(db_change("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)"), [name, r_time, now_time, blocker, why, band])
-        curs.execute(db_change("insert into ban (block, end, why, band, login) values (?, ?, ?, ?, ?)"), [name, r_time, why, band, login])
+        curs.execute(db_change("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)"), [
+            name, 
+            r_time, 
+            now_time, 
+            blocker, 
+            why, 
+            band
+        ])
+        curs.execute(db_change("insert into ban (block, end, why, band, login) values (?, ?, ?, ?, ?)"), [
+            name, 
+            r_time, 
+            why, 
+            band, 
+            login
+        ])
 
     conn.commit()
 
-def rd_plus(title, sub, date):
-    curs.execute(db_change("select title from rd where title = ? and sub = ?"), [title, sub])
+def rd_plus(topic_num, date):
+    curs.execute(db_change("select code from rd where code = ?"), [topic_num])
     if curs.fetchall():
-        curs.execute(db_change("update rd set date = ? where title = ? and sub = ?"), [date, title, sub])
+        curs.execute(db_change("update rd set date = ? where code = ?"), [date, topic_num])
     else:
-        curs.execute(db_change("insert into rd (title, sub, date) values (?, ?, ?)"), [title, sub, date])
+        curs.execute(db_change("insert into rd (code, date) values (?, ?, ?)"), [topic_num, date])
 
     conn.commit()
 

+ 28 - 26
route/topic.py

@@ -3,21 +3,21 @@ from .tool.func import *
 def topic_2(conn, topic_num):
     curs = conn.cursor()
 
+    ban = acl_check(None, 'topic', topic_num)
+    admin = admin_check(3)
+    topic_num = str(topic_num)
+
     if flask.request.method == 'POST':
         name = flask.request.form.get('topic', 'test')
         sub = flask.request.form.get('title', 'test')
     else:
-        topic_change_data = topic_change(topic_num)
-        name = topic_change_data[0]
-        sub = topic_change_data[1]
-
-    ban = acl_check(name, 'topic', sub)
-    admin = admin_check(3)
-
-    curs.execute(db_change("select id from topic where title = ? and sub = ? limit 1"), [name, sub])
-    topic_exist = curs.fetchall()
-    if not topic_exist and len(sub) > 256:
-        return re_error('/error/11')
+        curs.execute(db_change("select title, sub from topic where code = ? and id = '1'"), [topic_num])
+        name = curs.fetchall()
+        if name:
+            sub = name[0][1]
+            name = name[0][0]
+        else:
+            return redirect('/')
 
     if flask.request.method == 'POST':
         if captcha_post(flask.request.form.get('g-recaptcha-response', '')) == 1:
@@ -31,13 +31,15 @@ def topic_2(conn, topic_num):
         if ban == 1:
             return re_error('/ban')
 
-        curs.execute(db_change("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1"), [name, sub])
+        curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
         old_num = curs.fetchall()
         if old_num:
             num = int(old_num[0][0]) + 1
         else:
             num = 1
 
+        num = str(num)
+
         match = re.search('^user:([^/]+)', name)
         if match:
             y_check = 0
@@ -60,7 +62,7 @@ def topic_2(conn, topic_num):
             if y_check == 1:
                 curs.execute(db_change('insert into alarm (name, data, date) values (?, ?, ?)'), [
                     match.groups()[0],
-                    ip + ' | <a href="/thread/' + str(topic_num) + '#' + str(num) + '">' + name + ' | ' + sub + ' | #' + str(num) + '</a>',
+                    ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>',
                     today
                 ])
 
@@ -68,35 +70,35 @@ def topic_2(conn, topic_num):
         data = cate_re.sub('[br]', flask.request.form.get('content', 'Test'))
 
         for rd_data in re.findall("(?:#([0-9]+))", data):
-            curs.execute(db_change("select ip from topic where title = ? and sub = ? and id = ?"), [name, sub, rd_data])
+            curs.execute(db_change("select ip from topic where code = ? and id = ?"), [topic_num, rd_data])
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
                 curs.execute(db_change('insert into alarm (name, data, date) values (?, ?, ?)'), [
                     ip_data[0][0],
-                    ip + ' | <a href="/thread/' + str(topic_num) + '#' + str(num) + '">' + name + ' | ' + sub + ' | #' + str(num) + '</a>',
+                    ip + ' | <a href="/thread/' + topic_num + '#' + num + '">' + name + ' | ' + sub + ' | #' + num + '</a>',
                     today
                 ])
 
         data = re.sub("(?P<in>#(?:[0-9]+))", '[[\g<in>]]', data)
         data = savemark(data)
 
-        rd_plus(name, sub, today)
-        curs.execute(db_change("insert into topic (id, title, sub, data, date, ip, block, top, code) values (?, ?, ?, ?, ?, ?, '', '', ?)"), [
-            str(num),
-            name,
-            sub,
+        rd_plus(topic_num, today)
+        curs.execute(db_change("insert into topic (id, title, sub, data, date, ip, code) values (?, ?, ?, ?, ?, ?, ?)"), [
+            num,
+            name if num == 1 else '',
+            sub if num == 1 else '',
             data,
             today,
             ip,
-            str(topic_num) if num == 1 else ''
+            topic_num
         ])
         conn.commit()
 
-        return redirect('/thread/' + str(topic_num) + '?where=bottom')
+        return redirect('/thread/' + topic_num + '?where=bottom')
     else:
         data = ''
 
-        curs.execute(db_change("select stop from rd where title = ? and sub = ? and stop != ''"), [name, sub])
+        curs.execute(db_change("select stop from rd where code = ? and stop != ''"), [topic_num])
         close_data = curs.fetchall()
         if (close_data and admin != 1) or ban == 1:
             display = 'display: none;'
@@ -107,8 +109,8 @@ def topic_2(conn, topic_num):
             <div id="top_topic"></div>
             <div id="main_topic"></div>
             <div id="plus_topic"></div>
-            <script>topic_top_load("''' + str(topic_num) + '''");</script>
-            <a href="/thread/''' + str(topic_num) + '/tool">(' + load_lang('topic_tool') + ''')</a>
+            <script>topic_top_load("''' + topic_num + '''");</script>
+            <a href="/thread/''' + topic_num + '/tool">(' + load_lang('topic_tool') + ''')</a>
             <hr class=\"main_hr\">
             <form style="''' + display + '''" method="post">
                 <textarea rows="10" id="content" placeholder="''' + load_lang('content') + '''" name="content"></textarea>
@@ -117,7 +119,7 @@ def topic_2(conn, topic_num):
                 <input style="display: none;" name="topic" value="''' + name + '''">
                 <input style="display: none;" name="title" value="''' + sub + '''">
                 <button type="submit">''' + load_lang('send') + '''</button>
-                <button id="preview" type="button" onclick="load_preview(\'''' + url_pas(name) + '\')">' + load_lang('preview') + '''</button>
+                <button id="preview" type="button" onclick="load_preview(\'\')">''' + load_lang('preview') + '''</button>
             </form>
             <hr class=\"main_hr\">
             <div id="see_preview"></div>

+ 10 - 11
route/topic_admin.py

@@ -3,14 +3,13 @@ from .tool.func import *
 def topic_admin_2(conn, topic_num, num):
     curs = conn.cursor()
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    num = str(num)
+    topic_num = str(topic_num)
 
-    curs.execute(db_change("select block, ip, date from topic where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+    curs.execute(db_change("select block, ip, date from topic where code = ? and id = ?"), [topic_num, num])
     data = curs.fetchall()
     if not data:
-        return redirect('/thread/' + str(topic_num))
+        return redirect('/thread/' + topic_num)
 
     ban = '''
         <h2>''' + load_lang('state') + '''</h2>
@@ -22,13 +21,13 @@ def topic_admin_2(conn, topic_num, num):
         <h2>''' + load_lang('other_tool') + '''</h2>
         <ul>
             <li>
-                <a href="/thread/''' + str(topic_num) + '/raw/' + str(num) + '''">''' + load_lang('raw') + '''</a>
+                <a href="/thread/''' + topic_num + '/raw/' + num + '''">''' + load_lang('raw') + '''</a>
             </li>
         </ul>
     '''
 
     if admin_check(3) == 1:
-        curs.execute(db_change("select id from topic where title = ? and sub = ? and id = ? and top = 'O'"), [name, sub, str(num)])
+        curs.execute(db_change("select id from topic where code = ? and id = ? and top = 'O'"), [topic_num, num])
         top_topic_d = curs.fetchall()
 
         curs.execute(db_change("select end from ban where block = ?"), [data[0][1]])
@@ -44,12 +43,12 @@ def topic_admin_2(conn, topic_num, num):
                     </a>
                 </li>
                 <li>
-                    <a href="/thread/''' + str(topic_num) + '/b/' + str(num) + '''">
+                    <a href="/thread/''' + topic_num + '/b/' + num + '''">
                         ''' + (load_lang('hide_release') if data[0][0] == 'O' else load_lang('hide')) + '''
                     </a>
                 </li>
                 <li>
-                    <a href="/thread/''' + str(topic_num) + '/notice/' + str(num) + '''">
+                    <a href="/thread/''' + topic_num + '/notice/' + num + '''">
                         ''' + (load_lang('pinned_release') if top_topic_d else load_lang('pinned')) + '''
                     </a>
                 </li>
@@ -57,7 +56,7 @@ def topic_admin_2(conn, topic_num, num):
         '''
 
     return easy_minify(flask.render_template(skin_check(),
-        imp = [load_lang('discussion_tool'), wiki_set(), custom(), other2([' (#' + str(num) + ')', 0])],
+        imp = [load_lang('discussion_tool'), wiki_set(), custom(), other2([' (#' + num + ')', 0])],
         data = ban,
-        menu = [['thread/' + str(topic_num) + '#' + str(num), load_lang('return')]]
+        menu = [['thread/' + topic_num + '#' + num, load_lang('return')]]
     ))

+ 8 - 9
route/topic_block.py

@@ -3,23 +3,22 @@ from .tool.func import *
 def topic_block_2(conn, topic_num, num):
     curs = conn.cursor()
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    topic_num = str(topic_num)
+    num = str(num)
 
-    if admin_check(3, 'blind (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
+    if admin_check(3, 'blind (code ' + topic_num + '#' + num + ')') != 1:
         return re_error('/error/3')
 
-    curs.execute(db_change("select block from topic where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+    curs.execute(db_change("select block from topic where code = ? and id = ?"), [topic_num, num])
     block = curs.fetchall()
     if block:
         if block[0][0] == 'O':
-            curs.execute(db_change("update topic set block = '' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+            curs.execute(db_change("update topic set block = '' where code = ? and id = ?"), [topic_num, num])
         else:
-            curs.execute(db_change("update topic set block = 'O' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+            curs.execute(db_change("update topic set block = 'O' where code = ? and id = ?"), [topic_num, num])
 
-        rd_plus(name, sub, get_time())
+        rd_plus(topic_num, get_time())
 
         conn.commit()
 
-    return redirect('/thread/' + str(topic_num) + '#' + str(num))
+    return redirect('/thread/' + topic_num + '#' + num)

+ 3 - 3
route/topic_close_list.py

@@ -21,7 +21,7 @@ def topic_close_list_2(conn, name):
         sub = load_lang('discussion_list')
         menu = [['w/' + url_pas(name), load_lang('document')]]
 
-        if acl_check(name, 'topic', sub) == 1:
+        if acl_check(None, 'topic', topic_num) == 1:
             display = 'display: none;'
         else:
             display = ''
@@ -62,12 +62,12 @@ def topic_close_list_2(conn, name):
             it_p = 0
 
             if tool == '':
-                curs.execute(db_change("select title from rd where title = ? and sub = ? and stop = 'O' order by sub asc"), [name, data[0]])
+                curs.execute(db_change("select title from rd where code = ? and stop != '' order by sub asc"), [first_topic[0][0]])
                 if curs.fetchall():
                     it_p = 1
 
             if it_p != 1:
-                curs.execute(db_change("select id from topic where title = ? and sub = ? order by date desc limit 1"), [name, data[0]])
+                curs.execute(db_change("select id from topic where code = ? order by date desc limit 1"), [first_topic[0][0]])
                 t_data = curs.fetchall()
 
                 div += '''

+ 4 - 6
route/topic_delete.py

@@ -6,13 +6,11 @@ def topic_delete_2(conn, topic_num):
     if admin_check(None) != 1:
         return re_error('/error/3')
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    topic_num = str(topic_num)
 
     if flask.request.method == 'POST':
-        curs.execute(db_change("delete from topic where title = ? and sub = ?"), [name, sub])
-        curs.execute(db_change("delete from rd where title = ? and sub = ?"), [name, sub])
+        curs.execute(db_change("delete from topic where code = ?"), [topic_num])
+        curs.execute(db_change("delete from rd where code = ?"), [topic_num])
         conn.commit()
 
         return redirect('/topic/' + url_pas(name))
@@ -25,5 +23,5 @@ def topic_delete_2(conn, topic_num):
                     <button type="submit">''' + load_lang('start') + '''</button>
                 </form>
             ''',
-            menu = [['thread/' + str(topic_num) + '/tool', load_lang('return')]]
+            menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
         ))

+ 11 - 16
route/topic_stop.py

@@ -8,24 +8,20 @@ def topic_stop_2(conn, topic_num):
 
     ip = ip_check()
     time = get_time()
-
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    topic_num = str(topic_num)
 
     if flask.request.method == 'POST':
-        curs.execute(db_change("select id from topic where title = ? and sub = ? order by id + 0 desc limit 1"), [name, sub])
+        curs.execute(db_change("select id from topic where code = ? order by id + 0 desc limit 1"), [topic_num])
         topic_check = curs.fetchall()
         if topic_check:
             stop_d = flask.request.form.get('stop_d', '')
             why_d = flask.request.form.get('why', '')
             agree_d = flask.request.form.get('agree', '')
 
-            curs.execute(db_change("update rd set stop = ?, agree = ? where title = ? and sub = ?"), [
+            curs.execute(db_change("update rd set stop = ?, agree = ? where code = ?"), [
                 stop_d,
                 agree_d,
-                name,
-                sub
+                topic_num
             ])
 
             if stop_d == 'S':
@@ -35,23 +31,22 @@ def topic_stop_2(conn, topic_num):
             else:
                 t_state = 'Normal'
 
-            curs.execute(db_change("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')"), [
+            curs.execute(db_change("insert into topic (id, data, date, ip, top, code) values (?, ?, ?, ?, '1', ?)"), [
                 str(int(topic_check[0][0]) + 1),
-                name,
-                sub,
                 t_state + (' (Agree)' if agree_d != '' else '') + (('[br][br]Why : ' + why_d) if why_d else ''),
                 time,
-                ip
+                ip,
+                topic_num
             ])
 
-            rd_plus(name, sub, time)
+            rd_plus(topic_num, time)
 
-        return redirect('/thread/' + str(topic_num))
+        return redirect('/thread/' + topic_num)
     else:
         stop_d_list = ''
         agree_check = ''
 
-        curs.execute(db_change("select stop, agree from rd where title = ? and sub = ? limit 1"), [name, sub])
+        curs.execute(db_change("select stop, agree from rd where code = ? limit 1"), [topic_num])
         rd_d = curs.fetchall()
         if rd_d[0][0] == 'O':
             stop_d_list += '''
@@ -93,5 +88,5 @@ def topic_stop_2(conn, topic_num):
                     <button type="submit">''' + load_lang('save') + '''</button>
                 </form>
             ''',
-            menu = [['thread/' + str(topic_num) + '/tool', load_lang('return')]]
+            menu = [['thread/' + topic_num + '/tool', load_lang('return')]]
         ))

+ 5 - 8
route/topic_tool.py

@@ -4,12 +4,9 @@ def topic_tool_2(conn, topic_num):
     curs = conn.cursor()
 
     data = ''
+    topic_num = str(topic_num)
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
-
-    curs.execute(db_change("select stop, agree from rd where title = ? and sub = ?"), [name, sub])
+    curs.execute(db_change("select stop, agree from rd where code = ?"), [topic_num])
     close_data = curs.fetchall()
     if close_data:
         if close_data[0][0] == 'S':
@@ -25,7 +22,7 @@ def topic_tool_2(conn, topic_num):
         data = '''
             <h2>''' + load_lang('admin_tool') + '''</h2>
             <ul>
-                <li><a href="/thread/''' + str(topic_num) + '/setting">' + load_lang('topic_setting') + '''</a></li>
+                <li><a href="/thread/''' + topic_num + '/setting">' + load_lang('topic_setting') + '''</a></li>
             </ul>
         '''
     data += '''
@@ -41,7 +38,7 @@ def topic_tool_2(conn, topic_num):
             <h2>''' + load_lang('owner') + '''</h2>
             <ul>
                 <li>
-                    <a href="/thread/''' + str(topic_num) + '''/delete">
+                    <a href="/thread/''' + topic_num + '''/delete">
                         ''' + load_lang('topic_delete') + '''
                     </a>
                 </li>
@@ -51,5 +48,5 @@ def topic_tool_2(conn, topic_num):
     return easy_minify(flask.render_template(skin_check(),
         imp = [load_lang('topic_tool'), wiki_set(), custom(), other2([0, 0])],
         data = data,
-        menu = [['thread/' + str(topic_num), load_lang('return')]]
+        menu = [['thread/' + topic_num, load_lang('return')]]
     ))

+ 9 - 11
route/topic_top.py

@@ -3,25 +3,23 @@ from .tool.func import *
 def topic_top_2(conn, topic_num, num):
     curs = conn.cursor()
 
-    topic_change_data = topic_change(topic_num)
-    name = topic_change_data[0]
-    sub = topic_change_data[1]
+    topic_num = str(topic_num)
+    num = str(num)
 
-    if admin_check(3, 'notice (' + name + ' - ' + sub + '#' + str(num) + ')') != 1:
+    if admin_check(3, 'notice (code ' + topic_num + '#' + num + ')') != 1:
         return re_error('/error/3')
 
-    curs.execute(db_change("select title from topic where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+    curs.execute(db_change("select title from topic where code = ? and id = ?"), [topic_num, num])
     if curs.fetchall():
-        curs.execute(db_change("select top from topic where id = ? and title = ? and sub = ?"), [str(num), name, sub])
+        curs.execute(db_change("select top from topic where code = ? and id = ?"), [topic_num, num])
         top_data = curs.fetchall()
         if top_data:
             if top_data[0][0] == 'O':
-                curs.execute(db_change("update topic set top = '' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
+                curs.execute(db_change("update topic set top = '' where code = ? and id = ?"), [topic_num, num])
             else:
-                curs.execute(db_change("update topic set top = 'O' where title = ? and sub = ? and id = ?"), [name, sub, str(num)])
-
-        rd_plus(name, sub, get_time())
+                curs.execute(db_change("update topic set top = 'O' where code = ? and id = ?"), [topic_num, num])
 
+        rd_plus(topic_num, get_time())
         conn.commit()
 
-    return redirect('/thread/' + str(topic_num) + '#' + str(num))
+    return redirect('/thread/' + topic_num + '#' + num)

+ 12 - 14
route/view_raw.py

@@ -6,13 +6,11 @@ def view_raw_2(conn, name, topic_num, num):
     if acl_check(name, 'render') == 1:
         return re_error('/ban')
 
-    sub_title = None
     if topic_num:
-        topic_change_data = topic_change(topic_num)
-        name = topic_change_data[0]
-        sub_title = topic_change_data[1]
+        topic_num = str(topic_num)
 
     v_name = name
+    num = str(num)
     sub = ' (' + load_lang('raw') + ')'
 
     if not num:
@@ -20,28 +18,28 @@ def view_raw_2(conn, name, topic_num, num):
         if num:
             num = int(number_check(num))
 
-    if not sub_title and num:
-        curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, str(num)])
+    if not topic_num and num:
+        curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, num])
         if curs.fetchall() and admin_check(6) != 1:
             return re_error('/error/3')
 
-        curs.execute(db_change("select data from history where title = ? and id = ?"), [name, str(num)])
+        curs.execute(db_change("select data from history where title = ? and id = ?"), [name, num])
 
-        sub += ' (r' + str(num) + ')'
+        sub += ' (r' + num + ')'
 
         menu = [['history/' + url_pas(name), load_lang('history')]]
-    elif sub_title:
+    elif topic_num:
         if admin_check(6) != 1:
-            curs.execute(db_change("select data from topic where id = ? and title = ? and sub = ? and block = ''"), [str(num), name, sub_title])
+            curs.execute(db_change("select data from topic where id = ? and code = ? and block = ''"), [num, topic_num])
         else:
-            curs.execute(db_change("select data from topic where id = ? and title = ? and sub = ?"), [str(num), name, sub_title])
+            curs.execute(db_change("select data from topic where id = ? and code = ?"), [num, topic_num])
 
         v_name = load_lang('discussion_raw')
-        sub = ' (#' + str(num) + ')'
+        sub = ' (#' + num + ')'
 
         menu = [
-            ['topic/' + url_pas(name) + '/sub/' + url_pas(sub_title) + '#' + str(num), load_lang('discussion')], 
-            ['topic/' + url_pas(name) + '/sub/' + url_pas(sub_title) + '/admin/' + str(num), load_lang('return')]
+            ['thread/' + topic_num + '#' + num, load_lang('discussion')], 
+            ['thread/' + topic_num + '/admin/' + num, load_lang('return')]
         ]
     else:
         curs.execute(db_change("select data from data where title = ?"), [name])

+ 2 - 2
version.json

@@ -1,7 +1,7 @@
 {
     "master" : {
-        "r_ver" : "v3.1.7-master-03",
-        "c_ver" : "3170002",
+        "r_ver" : "v3.1.7-master-04",
+        "c_ver" : "3170400",
         "s_ver" : "7"
     }, "stable" : {
         "r_ver" : "v3.1.6-stable-05",