Surplus_Up (2DU) 7 лет назад
Родитель
Сommit
122d136fe1
3 измененных файлов с 42 добавлено и 38 удалено
  1. 23 37
      app.py
  2. 3 0
      emergency_tool.py
  3. 16 1
      func.py

+ 23 - 37
app.py

@@ -15,7 +15,7 @@ import random
 
 from func import *
 
-r_ver = 'v3.0.8-master-06'
+r_ver = 'v3.0.8-master-07'
 c_ver = ''.join(re.findall('[0-9]', r_ver))
 
 print('version : ' + r_ver)
@@ -134,7 +134,7 @@ if setup_tool != 0:
     create_data['data'] = ['title', 'data']
     create_data['cache_data'] = ['title', 'data']
     create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'send', 'leng', 'hide', 'type']
-    create_data['rd'] = ['title', 'sub', 'date', 'band']
+    create_data['rd'] = ['title', 'sub', 'date', 'band', 'stop']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user_set'] = ['name', 'id', 'data']
     create_data['ban'] = ['block', 'end', 'why', 'band', 'login']
@@ -877,7 +877,7 @@ def not_close_topic():
     curs.execute('select title, sub from rd order by date desc')
     n_list = curs.fetchall()
     for data in n_list:
-        curs.execute('select * from stop where title = ? and sub = ? and close = "O"', [data[0], data[1]])
+        curs.execute('select * from rd where title = ? and sub = ? and close = "O"', [data[0], data[1]])
         is_close = curs.fetchall()
         if not is_close:
             div += '<li><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
@@ -1325,26 +1325,18 @@ def recent_discuss():
                     </tr>
             '''
     
-    curs.execute("select title, sub, date from rd order by date desc limit 50")
+    if m_sub == 0:
+        curs.execute("select title, sub, date from rd where not stop = 'O' order by date desc limit 50")
+    else:
+        curs.execute("select title, sub, date from rd where stop = 'O' order by date desc limit 50")
+        
     for data in curs.fetchall():
         title = html.escape(data[0])
         sub = html.escape(data[1])
-        
-        close = 0
-        
-        if flask.request.args.get('what', 'normal') == 'normal':
-            curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [data[0], data[1]])
-            if curs.fetchall():
-                close = 1
-        else:
-            curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [data[0], data[1]])
-            if not curs.fetchall():
-                close = 1
 
-        if close == 0:
-            div += '<tr><td><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + title + '</a> (' + sub + ')</td><td>' + data[2] + '</td></tr>'
-    else:
-        div += '</tbody></table>'
+        div += '<tr><td><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + title + '</a> (' + sub + ')</td><td>' + data[2] + '</td></tr>'
+    
+    div += '</tbody></table>'
             
     return easy_minify(flask.render_template(skin_check(), 
         imp = [load_lang('recent') + ' ' + load_lang('discussion'), wiki_set(), custom(), other2([m_sub, 0])],
@@ -2221,7 +2213,7 @@ def topic_stop(name = None, sub = None, tool = None):
     if tool == 'close':
         set_list = [
             'O', 
-            '', 
+            'S', 
             load_lang('discussion', 1) + ' ' + load_lang('close', 1), 
             load_lang('discussion', 1) + ' ' + load_lang('open', 1)
         ]
@@ -2255,14 +2247,13 @@ def topic_stop(name = None, sub = None, tool = None):
                 curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, '" + load_lang('agreement', 1) + " O', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
                 curs.execute("insert into agreedis (title, sub) values (?, ?)", [name, sub])
         else:
-            curs.execute("select title from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[0]])
+            curs.execute("select title from rd where title = ? and sub = ? and stop = ?", [name, sub, set_list[0]])
             if curs.fetchall():
                 curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, set_list[3], time, ip])
-                curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[0]])
+                curs.execute("update rd set stop = '' where title = ? and sub = ?", [name, sub])
             else:
                 curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, ?, ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, set_list[2], time, ip])
-                curs.execute("insert into stop (title, sub, close) values (?, ?, ?)", [name, sub, set_list[0]])
-                curs.execute("delete from stop where title = ? and sub = ? and close = ?", [name, sub, set_list[1]])
+                curs.execute("update rd set stop = ? where title = ? and sub = ?", [set_list[0], name, sub])
         
         rd_plus(name, sub, time)
         
@@ -2371,10 +2362,10 @@ def topic(name = None, sub = None):
         
         return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#reload')
     else:
-        curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, sub])
+        curs.execute("select title from rd where title = ? and sub = ? and stop = 'O'", [name, sub])
         close_data = curs.fetchall()
         
-        curs.execute("select title from stop where title = ? and sub = ? and close = ''", [name, sub])
+        curs.execute("select title from rd where title = ? and sub = ? and stop = 'S'", [name, sub])
         stop_data = curs.fetchall()
         
         curs.execute("select id from topic where title = ? and sub = ? limit 1", [name, sub])
@@ -2546,7 +2537,7 @@ def close_topic_list(name = None, tool = None):
         menu = [['topic/' + url_pas(name), load_lang('list')]]
         
         if tool == 'close':
-            curs.execute("select sub from stop where title = ? and close = 'O' order by sub asc", [name])
+            curs.execute("select sub from rd where title = ? and stop = 'O' order by sub asc", [name])
             
             sub = load_lang('close') + ''
         elif tool == 'agree':
@@ -2574,7 +2565,7 @@ def close_topic_list(name = None, tool = None):
                 it_p = 0
                 
                 if sub == load_lang('discussion') + ' ' + load_lang('list'):
-                    curs.execute("select title from stop where title = ? and sub = ? and close = 'O' order by sub asc", [name, data[0]])
+                    curs.execute("select title from rd where title = ? and sub = ? and stop = 'O' order by sub asc", [name, data[0]])
                     if curs.fetchall():
                         it_p = 1
                 
@@ -3382,14 +3373,9 @@ def read_view(name = None):
             if redirect_data:
                 return redirect('/w/' + redirect_data[0][0] + '?from=' + name)
 
-
-    curs.execute("select sub from rd where title = ? order by date desc", [name])
-    for data in curs.fetchall():
-        curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [name, data[0]])
-        if not curs.fetchall():
-            sub += ' (' + load_lang('discussion') + ')'
-
-            break
+    curs.execute("select sub from rd where title = ? and not stop = 'O' order by date desc", [name])
+    if curs.fetchall():
+        sub += ' (' + load_lang('discussion') + ')'
 
     curs.execute("select link from back where title = ? and type = 'cat' order by link asc", [name])
                 
@@ -4110,7 +4096,7 @@ def api_w(name = ''):
     curs.execute("select data from data where title = ?", [name])
     data = curs.fetchall()
     if data:
-        json_data = { "title" : name, "data" : render_set(data = data[0][0]) }
+        json_data = { "title" : name, "data" : render_set(title = name, data = data[0][0]) }
     
         return flask.jsonify(json_data)
     else:

+ 3 - 0
emergency_tool.py

@@ -21,6 +21,7 @@ print('3. ban delete')
 print('4. change port')
 print('5. change skin')
 print('6. change password')
+print('7. reset version')
 
 print('select : ', end = '')
 what_i_do = input()
@@ -87,6 +88,8 @@ elif what_i_do == '6':
         hashed = bcrypt.hashpw(bytes(user_pw, 'utf-8'), bcrypt.gensalt()).decode()
        
     curs.execute("update user set pw = ? where id = ?", [hashed, user_name])
+elif what_i_do == '7':
+    curs.execute("update other set data = '00000' where name = 'ver'")
 
 conn.commit()
 

+ 16 - 1
func.py

@@ -116,6 +116,21 @@ def update():
             print('사용자 to user, 파일 to file, 분류 to category')
     except:
         pass
+        
+    # v3.0.8 rd 테이블, stop 테이블 통합
+    try:
+        curs.execute("select title from stop")
+        if curs.fetchall():
+            curs.execute("select title, sub from rd")
+            for data in curs.fetchall():
+                curs.execute("select title from stop where title = ? and sub = ? and close = 'O'", [data[0], data[1]])
+                if curs.fetchall():
+                    curs.execute("update rd set stop = 'O' where title = ? and sub = ?", [data[0], data[1]])
+                
+        curs.execute("drop table stop")
+    except:
+        pass
+    
 
 def pw_encode(data, data2 = '', type_d = ''):
     if type_d == '':
@@ -679,7 +694,7 @@ def topic_check(name, sub):
             if not admin_check(3, 'topic (' + name + ')') == 1:
                 return 1
         
-    curs.execute("select title from stop where title = ? and sub = ?", [name, sub])
+    curs.execute("select title from rd where title = ? and sub = ? and not stop = ''", [name, sub])
     if curs.fetchall():
         if not admin_check(3, 'topic (' + name + ')') == 1:
             return 1