Răsfoiți Sursa

Merge pull request #264 from 2DU/master

Master
ect (or 2du) 8 ani în urmă
părinte
comite
8fd61a939f
1 a modificat fișierele cu 38 adăugiri și 124 ștergeri
  1. 38 124
      app.py

+ 38 - 124
app.py

@@ -100,23 +100,9 @@ try:
     except:
         pass
 
-    try:
-        curs.execute('select ip from ok_login limit 1')
-    except:
-        curs.execute("create table ok_login(ip text, sub text)")
-        print('ok_login 테이블 생성')
-
-    try:
-        curs.execute("drop table move")
-        print("move 테이블 삭제")
-    except:
-        pass
-
-    try:
-        curs.execute('select name from filter limit 1')
-    except:
-        curs.execute("create table filter(name text, regex text, sub text)")
-        print("filter 테이블 생성")
+    curs.execute("create table if not exists ok_login(ip text, sub text)")
+    curs.execute("drop table if exists move")
+    curs.execute("create table if not exists filter(name text, regex text, sub text)")
 
     conn.commit()
 except:
@@ -159,101 +145,29 @@ def setup():
     try:
         curs.execute("select title from data limit 1")
     except:
-        try:
-            curs.execute("create table data(title text, data text, acl text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table history(id text, title text, data text, date text, ip text, send text, leng text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table rd(title text, sub text, date text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table user(id text, pw text, acl text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table ban(block text, end text, why text, band text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table topic(id text, title text, sub text, data text, date text, ip text, block text, top text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table stop(title text, sub text, close text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table rb(block text, end text, today text, blocker text, why text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table back(title text, link text, type text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table hidhi(title text, re text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table agreedis(title text, sub text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table custom(user text, css text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table other(name text, data text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table alist(name text, acl text)")
+        curs.execute("create table if not exists data(title text, data text, acl text)")
+        curs.execute("create table if not exists history(id text, title text, data text, date text, ip text, send text, leng text)")
+        curs.execute("create table if not exists rd(title text, sub text, date text)")
+        curs.execute("create table if not exists user(id text, pw text, acl text)")
+        curs.execute("create table if not exists ban(block text, end text, why text, band text)")
+        curs.execute("create table if not exists topic(id text, title text, sub text, data text, date text, ip text, block text, top text)")
+        curs.execute("create table if not exists stop(title text, sub text, close text)")
+        curs.execute("create table if not exists rb(block text, end text, today text, blocker text, why text)")
+        curs.execute("create table if not exists back(title text, link text, type text)")
+        curs.execute("create table if not exists hidhi(title text, re text)")
+        curs.execute("create table if not exists agreedis(title text, sub text)")
+        curs.execute("create table if not exists custom(user text, css text)")
+        curs.execute("create table if not exists other(name text, data text)")
+        curs.execute("create table if not exists alist(name text, acl text)")
+        curs.execute("create table if not exists re_admin(who text, what text, time text)")
+        curs.execute("create table if not exists alarm(name text, data text, date text)")
+        curs.execute("create table if not exists ua_d(name text, ip text, ua text, today text, sub text)")
+        curs.execute("create table if not exists ok_login(ip text, sub text)")
+        curs.execute("create table if not exists filter(name text, regex text, sub text)")
+
+        curs.execute("select name from alist where = '소유자'")
+        if(not curs.fetchall()):
             curs.execute("insert into alist (name, acl) values ('소유자', 'owner')")
-        except:
-            pass
-
-        try:
-            curs.execute("create table re_admin(who text, what text, time text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table alarm(name text, data text, date text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table ua_d(name text, ip text, ua text, today text, sub text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table ok_login(ip text, sub text)")
-        except:
-            pass
-
-        try:
-            curs.execute("create table filter(name text, regex text, sub text)")
-        except:
-            pass
 
         conn.commit()
 
@@ -375,22 +289,22 @@ def edit_set(num = 0):
                 imp = ['기본 설정', wiki_set(conn, 1), custom(conn), other2([0, 0])],
                 data = '<form method="post"> \
                             <span>이름</span><br><br> \
-                            <input placeholder="이름" type="text" name="name" value="' + html.escape(d_list[0]) + '"><br><br> \
+                            <input placeholder="이름" type="text" name="name" value="' + html.escape(d_list[0]) + '"><hr> \
                             <span>로고 (HTML)</span><br><br> \
-                            <input placeholder="로고" type="text" name="logo" value="' + html.escape(d_list[1]) + '"><br><br> \
+                            <input placeholder="로고" type="text" name="logo" value="' + html.escape(d_list[1]) + '"><hr> \
                             <span>대문</span><br><br> \
-                            <input placeholder="대문" type="text" name="frontpage" value="' + html.escape(d_list[2]) + '"><br><br> \
+                            <input placeholder="대문" type="text" name="frontpage" value="' + html.escape(d_list[2]) + '"><hr> \
                             <span>라이선스 (HTML)</span><br><br> \
-                            <input placeholder="라이선스" type="text" name="license" value="' + html.escape(d_list[3]) + '"><br><br> \
+                            <input placeholder="라이선스" type="text" name="license" value="' + html.escape(d_list[3]) + '"><hr> \
                             <span>파일 크기 [메가]</span><br><br> \
-                            <input placeholder="파일 크기" type="text" name="upload" value="' + html.escape(d_list[4]) + '"><br><br> \
+                            <input placeholder="파일 크기" type="text" name="upload" value="' + html.escape(d_list[4]) + '"><hr> \
                             <span>스킨</span><br><br> \
-                            <input placeholder="스킨" type="text" name="skin" value="' + html.escape(d_list[5]) + '"><br><br> \
+                            <input placeholder="스킨" type="text" name="skin" value="' + html.escape(d_list[5]) + '"><hr> \
                             <span>전역 ACL</span><br><br> \
-                            <select name="edit">' + div + '</select><br><br> \
+                            <select name="edit">' + div + '</select><hr> \
                             <input type="checkbox" name="reg" ' + ch_1 + '> 가입불가<br><br> \
                             <input type="checkbox" name="ip_view" ' + ch_2 + '> 아이피 비공개<br><br> \
-                            <input type="checkbox" name="all_title" ' + ch_3 + '> 모든 문서 보기 비활성화<br><br> \
+                            <input type="checkbox" name="all_title" ' + ch_3 + '> 모든 문서 보기 비활성화<hr> \
                             <span>백업 간격 [시간] (끄기 : 0) {재시작 필요}</span><br><br> \
                             <input placeholder="백업 간격" type="text" name="back_up" value="' + html.escape(d_list[9]) + '"><br><br> \
                             <button class="btn btn-primary" type="submit">저장</button> \
@@ -1127,7 +1041,7 @@ def revert(name = None, num = None):
             imp = [name, wiki_set(conn, 1), custom_data, other2([' (되돌리기)', 0])],
             data =  ip_warring + ' \
                     <form method="post"> \
-                        <input placeholder="사유" name="send" type="text"><br> \
+                        <input placeholder="사유" name="send" type="text"><hr> \
                         ' + captcha + ' \
                         <button class="btn btn-primary" type="submit">되돌리기</button> \
                     </form>',
@@ -1547,7 +1461,7 @@ def delete(name = None):
             imp = [name, wiki_set(conn, 1), custom_data, other2([' (삭제)', 0])],
             data = '<form method="post"> \
                         ' + ip_warring + ' \
-                        <input placeholder="사유" name="send" type="text"><br> \
+                        <input placeholder="사유" name="send" type="text"><hr> \
                         ' + captcha + ' \
                         <button class="btn btn-primary" type="submit">삭제</button> \
                     </form>',
@@ -1636,8 +1550,8 @@ def move(name = None):
             imp = [name, wiki_set(conn, 1), custom_data, other2([' (이동)', 0])],
             data = '<form method="post"> \
                         ' + ip_warring + ' \
-                        <input placeholder="문서명" value="' + name + '" name="title" type="text"><br> \
-                        <input placeholder="사유" name="send" type="text"><br> \
+                        <input placeholder="문서명" value="' + name + '" name="title" type="text"><hr> \
+                        <input placeholder="사유" name="send" type="text"><hr> \
                         ' + captcha + ' \
                         <button class="btn btn-primary" type="submit">이동</button> \
                     </form>',
@@ -3082,7 +2996,7 @@ def recent_changes(name = None, num = 1, what = 'all', tool = 'record'):
                 style[1] = 'background: gainsboro;'
 
             if(tool == 'history'):
-                title = data[0] + '판 '
+                title = '<a href="/w/' + url_pas(name) + '/r/' + data[0] + '">' + data[0] + '판</a> <a href="/raw/' + url_pas(name) + '/r/' + data[0] + '">(원본)</a> '
             else:
                 title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> (<a href="/history/' + url_pas(data[1]) + '">' + data[0] + '판</a>) '