Просмотр исходного кода

Merge pull request #1 from 2du/master

이렇게 하는건가
hoparkgo9ma 7 лет назад
Родитель
Сommit
24dfccc6a6
6 измененных файлов с 63 добавлено и 57 удалено
  1. 28 48
      app.py
  2. 3 0
      emergency_tool.py
  3. 26 5
      func.py
  4. 4 2
      mark.py
  5. 1 1
      readme-ko.md
  6. 1 1
      readme.md

+ 28 - 48
app.py

@@ -15,7 +15,7 @@ import random
 
 
 from func import *
 from func import *
 
 
-r_ver = 'v3.0.8-master-06'
+r_ver = 'v3.0.8-master-08'
 c_ver = ''.join(re.findall('[0-9]', r_ver))
 c_ver = ''.join(re.findall('[0-9]', r_ver))
 
 
 print('version : ' + r_ver)
 print('version : ' + r_ver)
@@ -77,10 +77,8 @@ curs.execute('create table if not exists user(test text)')
 curs.execute('create table if not exists user_set(test text)')
 curs.execute('create table if not exists user_set(test text)')
 curs.execute('create table if not exists ban(test text)')
 curs.execute('create table if not exists ban(test text)')
 curs.execute('create table if not exists topic(test text)')
 curs.execute('create table if not exists topic(test text)')
-curs.execute('create table if not exists stop(test text)')
 curs.execute('create table if not exists rb(test text)')
 curs.execute('create table if not exists rb(test text)')
 curs.execute('create table if not exists back(test text)')
 curs.execute('create table if not exists back(test text)')
-curs.execute('create table if not exists agreedis(test text)')
 curs.execute('create table if not exists custom(test text)')
 curs.execute('create table if not exists custom(test text)')
 curs.execute('create table if not exists other(test text)')
 curs.execute('create table if not exists other(test text)')
 curs.execute('create table if not exists alist(test text)')
 curs.execute('create table if not exists alist(test text)')
@@ -114,10 +112,8 @@ if setup_tool != 0:
         'user_set',
         'user_set',
         'ban', 
         'ban', 
         'topic', 
         'topic', 
-        'stop', 
         'rb', 
         'rb', 
         'back', 
         'back', 
-        'agreedis', 
         'custom', 
         'custom', 
         'other', 
         'other', 
         'alist', 
         'alist', 
@@ -134,15 +130,13 @@ if setup_tool != 0:
     create_data['data'] = ['title', 'data']
     create_data['data'] = ['title', 'data']
     create_data['cache_data'] = ['title', 'data']
     create_data['cache_data'] = ['title', 'data']
     create_data['history'] = ['id', 'title', 'data', 'date', 'ip', 'send', 'leng', 'hide', 'type']
     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', 'agree']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user'] = ['id', 'pw', 'acl', 'date', 'encode']
     create_data['user_set'] = ['name', 'id', 'data']
     create_data['user_set'] = ['name', 'id', 'data']
     create_data['ban'] = ['block', 'end', 'why', 'band', 'login']
     create_data['ban'] = ['block', 'end', 'why', 'band', 'login']
     create_data['topic'] = ['id', 'title', 'sub', 'data', 'date', 'ip', 'block', 'top']
     create_data['topic'] = ['id', 'title', 'sub', 'data', 'date', 'ip', 'block', 'top']
-    create_data['stop'] = ['title', 'sub', 'close']
     create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band']
     create_data['rb'] = ['block', 'end', 'today', 'blocker', 'why', 'band']
     create_data['back'] = ['title', 'link', 'type']
     create_data['back'] = ['title', 'link', 'type']
-    create_data['agreedis'] = ['title', 'sub']
     create_data['custom'] = ['user', 'css']
     create_data['custom'] = ['user', 'css']
     create_data['other'] = ['name', 'data']
     create_data['other'] = ['name', 'data']
     create_data['alist'] = ['name', 'acl']
     create_data['alist'] = ['name', 'acl']
@@ -877,7 +871,7 @@ def not_close_topic():
     curs.execute('select title, sub from rd order by date desc')
     curs.execute('select title, sub from rd order by date desc')
     n_list = curs.fetchall()
     n_list = curs.fetchall()
     for data in n_list:
     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()
         is_close = curs.fetchall()
         if not is_close:
         if not is_close:
             div += '<li><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
             div += '<li><a href="/topic/' + url_pas(data[0]) + '/sub/' + url_pas(data[1]) + '">' + data[0] + ' (' + data[1] + ')</a></li>'
@@ -1325,26 +1319,18 @@ def recent_discuss():
                     </tr>
                     </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():
     for data in curs.fetchall():
         title = html.escape(data[0])
         title = html.escape(data[0])
         sub = html.escape(data[1])
         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(), 
     return easy_minify(flask.render_template(skin_check(), 
         imp = [load_lang('recent') + ' ' + load_lang('discussion'), wiki_set(), custom(), other2([m_sub, 0])],
         imp = [load_lang('recent') + ' ' + load_lang('discussion'), wiki_set(), custom(), other2([m_sub, 0])],
@@ -2221,7 +2207,7 @@ def topic_stop(name = None, sub = None, tool = None):
     if tool == 'close':
     if tool == 'close':
         set_list = [
         set_list = [
             'O', 
             'O', 
-            '', 
+            'S', 
             load_lang('discussion', 1) + ' ' + load_lang('close', 1), 
             load_lang('discussion', 1) + ' ' + load_lang('close', 1), 
             load_lang('discussion', 1) + ' ' + load_lang('open', 1)
             load_lang('discussion', 1) + ' ' + load_lang('open', 1)
         ]
         ]
@@ -2247,22 +2233,21 @@ def topic_stop(name = None, sub = None, tool = None):
     topic_check = curs.fetchall()
     topic_check = curs.fetchall()
     if topic_check:
     if topic_check:
         if tool == 'agree':
         if tool == 'agree':
-            curs.execute("select title from agreedis where title = ? and sub = ?", [name, sub])
+            curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
             if curs.fetchall():
             if curs.fetchall():
                 curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, '" + load_lang('agreement', 1) + " X', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
                 curs.execute("insert into topic (id, title, sub, data, date, ip, block, top) values (?, ?, ?, '" + load_lang('agreement', 1) + " X', ?, ?, '', '1')", [str(int(topic_check[0][0]) + 1), name, sub, time, ip])
-                curs.execute("delete from agreedis where title = ? and sub = ?", [name, sub])
+                curs.execute("update rd set agree = '' where title = ? and sub = ?", [name, sub])
             else:
             else:
                 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 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])
+                curs.execute("update rd set agree = 'O' where title = ? and sub = ?", [name, sub])
         else:
         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():
             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("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:
             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 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)
         rd_plus(name, sub, time)
         
         
@@ -2371,10 +2356,10 @@ def topic(name = None, sub = None):
         
         
         return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#reload')
         return redirect('/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#reload')
     else:
     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()
         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()
         stop_data = curs.fetchall()
         
         
         curs.execute("select id from topic where title = ? and sub = ? limit 1", [name, sub])
         curs.execute("select id from topic where title = ? and sub = ? limit 1", [name, sub])
@@ -2396,7 +2381,7 @@ def topic(name = None, sub = None):
             else:
             else:
                 all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">(' + load_lang('stop') + ')</a> '
                 all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/stop">(' + load_lang('stop') + ')</a> '
 
 
-            curs.execute("select title from agreedis where title = ? and sub = ?", [name, sub])
+            curs.execute("select title from rd where title = ? and sub = ? and agree = 'O'", [name, sub])
             if curs.fetchall():
             if curs.fetchall():
                 all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(' + load_lang('release') + ')</a>'
                 all_data += '<a href="/topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '/tool/agree">(' + load_lang('release') + ')</a>'
             else:
             else:
@@ -2546,11 +2531,11 @@ def close_topic_list(name = None, tool = None):
         menu = [['topic/' + url_pas(name), load_lang('list')]]
         menu = [['topic/' + url_pas(name), load_lang('list')]]
         
         
         if tool == 'close':
         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') + ''
             sub = load_lang('close') + ''
         elif tool == 'agree':
         elif tool == 'agree':
-            curs.execute("select sub from agreedis where title = ? order by sub asc", [name])
+            curs.execute("select sub from rd where title = ? and agree = 'O' order by sub asc", [name])
             
             
             sub = load_lang('agreement') + ''
             sub = load_lang('agreement') + ''
         else:
         else:
@@ -2574,7 +2559,7 @@ def close_topic_list(name = None, tool = None):
                 it_p = 0
                 it_p = 0
                 
                 
                 if sub == load_lang('discussion') + ' ' + load_lang('list'):
                 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():
                     if curs.fetchall():
                         it_p = 1
                         it_p = 1
                 
                 
@@ -3382,14 +3367,9 @@ def read_view(name = None):
             if redirect_data:
             if redirect_data:
                 return redirect('/w/' + redirect_data[0][0] + '?from=' + name)
                 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])
     curs.execute("select link from back where title = ? and type = 'cat' order by link asc", [name])
                 
                 
@@ -4110,7 +4090,7 @@ def api_w(name = ''):
     curs.execute("select data from data where title = ?", [name])
     curs.execute("select data from data where title = ?", [name])
     data = curs.fetchall()
     data = curs.fetchall()
     if data:
     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)
         return flask.jsonify(json_data)
     else:
     else:

+ 3 - 0
emergency_tool.py

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

+ 26 - 5
func.py

@@ -61,10 +61,7 @@ def render_set(title = '', data = '', num = 0):
     if acl_check(title, 'render') == 1:
     if acl_check(title, 'render') == 1:
         return 'http request 401.3'
         return 'http request 401.3'
     else:
     else:
-        curs.execute('select data from other where name = "markup"')
-        markup = curs.fetchall()
-
-        return namumark(title, data, num, markup[0][0])
+        return namumark(title, data, num)
 
 
 def captcha_get():
 def captcha_get():
     data = ''
     data = ''
@@ -119,6 +116,30 @@ def update():
             print('사용자 to user, 파일 to file, 분류 to category')
             print('사용자 to user, 파일 to file, 분류 to category')
     except:
     except:
         pass
         pass
+        
+    # v3.0.8 rd, agreedis, stop 테이블 통합
+    try:
+        curs.execute("select title, sub, close from stop")
+        for i in curs.fetchall():
+            if i[2] == '':
+                curs.execute("update rd set stop = 'S' where title = ? and sub = ?", [i[0], i[1]])
+            else:
+                curs.execute("update rd set stop = 'O' where title = ? and sub = ?", [i[0], i[1]])
+    except:
+        pass
+        
+    try:
+        curs.execute("select title, sub from agreedis")
+        for i in curs.fetchall():
+            curs.execute("update rd set agree = 'O' where title = ? and sub = ?", [i[0], i[1]])
+    except:
+        pass
+         
+    try:
+        curs.execute("drop table if exists stop")
+        curs.execute("drop table if exists agreedis")
+    except:
+        pass
 
 
 def pw_encode(data, data2 = '', type_d = ''):
 def pw_encode(data, data2 = '', type_d = ''):
     if type_d == '':
     if type_d == '':
@@ -682,7 +703,7 @@ def topic_check(name, sub):
             if not admin_check(3, 'topic (' + name + ')') == 1:
             if not admin_check(3, 'topic (' + name + ')') == 1:
                 return 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 curs.fetchall():
         if not admin_check(3, 'topic (' + name + ')') == 1:
         if not admin_check(3, 'topic (' + name + ')') == 1:
             return 1
             return 1

+ 4 - 2
mark.py

@@ -39,9 +39,11 @@ def plusing(data):
         if not curs.fetchall():
         if not curs.fetchall():
             curs.execute("insert into back (title, link, type) values (?, ?, ?)", [data_in[1], data_in[0], data_in[2]])
             curs.execute("insert into back (title, link, type) values (?, ?, ?)", [data_in[1], data_in[0], data_in[2]])
 
 
-def namumark(title = '', data = None, num = 0, markup = 'namumark'):
+def namumark(title = '', data = None, num = 0):
     if data != None:
     if data != None:
-        if markup == 'namumark':
+        curs.execute('select data from other where name = "markup"')
+        rep_data = curs.fetchall()
+        if rep_data[0][0] == 'namumark':
             data = namu(conn, data, title, num)
             data = namu(conn, data, title, num)
         else:
         else:
             data = ['', '', []]
             data = ['', '', []]

+ 1 - 1
readme-ko.md

@@ -1,6 +1,6 @@
 opennamu
 opennamu
 ====
 ====
-![Python 3.5 Required](https://img.shields.io/badge/python-3.5-blue.svg?longCache=true&style=flat-square)
+![Python 3.5 이상 필요](https://img.shields.io/badge/python-%3E%3D%203.5-blue.svg)
 
 
 오픈나무는 파이썬 기반의 위키 엔진입니다. 파이썬과 그 의존성 모듈만 설치하면 사용할 수 있으며, 코드를 직접 수정하여 좀 더 주제에 특화된 위키를 만들 수 있습니다.
 오픈나무는 파이썬 기반의 위키 엔진입니다. 파이썬과 그 의존성 모듈만 설치하면 사용할 수 있으며, 코드를 직접 수정하여 좀 더 주제에 특화된 위키를 만들 수 있습니다.
 
 

+ 1 - 1
readme.md

@@ -1,6 +1,6 @@
 opennamu
 opennamu
 ====
 ====
-![Python 3.5 Required](https://img.shields.io/badge/python-3.5-blue.svg?longCache=true&style=flat-square)
+![Python 3.5 or later Required](https://img.shields.io/badge/python-%3E%3D%203.5-blue.svg)
 
 
 opennamu is a Python-based wiki engine. If you install Python and its underlying modules, you will be able to create wikis.
 opennamu is a Python-based wiki engine. If you install Python and its underlying modules, you will be able to create wikis.