Переглянути джерело

Merge pull request #979 from 2du/master

버그 버그 버그 버그
잉여개발기 (SPDV) 5 роки тому
батько
коміт
f90bf74f22

+ 1 - 0
emergency_tool.py

@@ -164,6 +164,7 @@ if what_i_do == '1':
 
     print('----')
     print('Rest : ' + str(len(title)))
+    print('Start : ' + title[0][0])
     time.sleep(1)
     print('----')
 

+ 1 - 0
language/en-US.json

@@ -208,6 +208,7 @@
         "add_star_doc" : "Add document(s) of interest",
         "get_sitemap" : "Create or renewal sitemap.xml",
         "simple_check" : "Simple check",
+        "add_user" : "Add user",
         "_comment_2.1_" : "Filter",
             "_comment_2.1.1_" : "List",
                 "interwiki_list" : "Interwiki(s) list",

+ 3 - 2
language/ko-KR.json

@@ -375,5 +375,6 @@
     "domain" : "도메인",
     "before_acl" : "이 문서를 이전에 편집한 적 있는 사람만",
     "30_day_acl" : "가입 후 30일이 지난 가입자만",
-    "simple_check" : "간편 검사"
-}
+    "simple_check" : "간편 검사",
+    "add_user" : "계정 추가"
+}

+ 6 - 3
route/login_register.py

@@ -7,10 +7,11 @@ def login_register_2(conn):
         return re_error('/ban')
 
     ip = ip_check()
-    if ip_or_user(ip) == 0:
+    admin = admin_check()
+    if admin != 1 and ip_or_user(ip) == 0:
         return redirect('/user')
 
-    if not admin_check() == 1:
+    if admin != 1:
         curs.execute(db_change('select data from other where name = "reg"'))
         set_d = curs.fetchall()
         if set_d and set_d[0][0] == 'on':
@@ -50,6 +51,7 @@ def login_register_2(conn):
         curs.execute(db_change('select data from other where name = "requires_approval"'))
         requires_approval = curs.fetchall()
         requires_approval = requires_approval and requires_approval[0][0] == 'on'
+        requires_approval = None if admin == 1 else requires_approval
 
         approval_question = ''
         if requires_approval:
@@ -62,7 +64,7 @@ def login_register_2(conn):
 
         curs.execute(db_change('select data from other where name = "email_have"'))
         sql_data = curs.fetchall()
-        if sql_data and sql_data[0][0] != '':
+        if sql_data and sql_data[0][0] != '' and admin != 1:
             flask.session['c_id'] = flask.request.form.get('id', None)
             flask.session['c_pw'] = hashed
             flask.session['c_key'] = ''.join(random.choice("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") for i in range(16))
@@ -138,6 +140,7 @@ def login_register_2(conn):
         curs.execute(db_change('select data from other where name = "requires_approval"'))
         requires_approval = curs.fetchall()
         requires_approval = requires_approval and requires_approval[0][0] == 'on'
+        requires_approval = None if admin == 1 else requires_approval
         if requires_approval:
             curs.execute(db_change('select data from other where name = "approval_question"'))
             data = curs.fetchall()

+ 1 - 0
route/main_manager.py

@@ -41,6 +41,7 @@ def main_manager_2(conn, num, r_ver):
                     <li><a href="/many_delete">''' + load_lang('many_delete') + '''</a></li>
                     <li><a href="/applications">''' + load_lang('application_list') + '''</a></li>
                     <li><a href="/api/sitemap.xml">''' + load_lang('get_sitemap') + '''</a></li>
+                    <li><a href="/register">''' + load_lang('add_user') + '''</a></li>
                     <li><a href="/setting">''' + load_lang('setting') + '''</a></li>
                 </ul>
                 <h3>''' + load_lang('filter') + '''</h3>

+ 13 - 14
route/tool/func.py

@@ -446,7 +446,7 @@ def edit_button():
     if admin_check() == 1:
         data += (' ' if data != '' else '') + '<a href="/edit_top">(' + load_lang('add') + ')</a>'
 
-    return data + '<hr class=\"main_hr\">'
+    return data + '<hr class="main_hr">'
 
 def ip_warring():
     if ip_or_user() != 0:
@@ -871,17 +871,17 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
 
         return 1
 
-    if tool == '' and acl_check(name, 'render') == 1:
-        return 1
-    
-    if tool == '' and tool == 'topic':
+    if tool == 'topic':
+        if not name:
+            curs.execute(db_change("select title from rd where code = ?"), [topic_num])
+            name = curs.fetchall()
+            name = name[0][0] if name else 'test'
+        
         end = 3
+    elif tool == 'render' or tool == '':
+        if tool == '' and acl_check(name, 'render') == 1:
+            return 1
 
-        if tool == 'topic' and not name:
-            curs.execute(db_change("select title from rd where code = ?"), [topic_num])
-            topic_data = curs.fetchall()
-            name = topic_data[0][0] if topic_data else 'test'
-    elif tool == 'render':
         end = 2
     else:
         end = 1
@@ -890,10 +890,8 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
         if tool == '':
             if i == 0:
                 curs.execute(db_change("select decu from acl where title = ?"), [name])
-            elif i == 1:
-                curs.execute(db_change('select data from other where name = "edit"'))
             else:
-                curs.execute(db_change("select view from acl where title = ?"), [name])
+                curs.execute(db_change('select data from other where name = "edit"'))
 
             num = 5
         elif tool == 'topic':
@@ -914,9 +912,10 @@ def acl_check(name = 'test', tool = '', topic_num = '1'):
 
             num = 5
         else:
+            # tool == 'render'
             if i == 0:
                 curs.execute(db_change("select view from acl where title = ?"), [name])
-            if i == 1:
+            else:
                 curs.execute(db_change("select data from other where name = 'all_view_acl'"))
 
             num = 5

+ 9 - 24
route/view_read.py

@@ -4,7 +4,6 @@ def view_read_2(conn, name):
     curs = conn.cursor()
 
     sub = ''
-    acl = 0
     div = ''
     ip = ip_check()
     run_redirect = ''
@@ -103,11 +102,6 @@ def view_read_2(conn, name):
             curs.execute(db_change("delete from cache_data where title = ?"), [name])
             if last_history_num:
                 curs.execute(db_change("insert into cache_data (title, data, id) values (?, ?, ?)"), [name, end_data, last_history_num[0][0]])
-                
-    curs.execute(db_change("select decu from acl where title = ?"), [name])
-    data = curs.fetchall()
-    if data:
-        acl = 1
 
     if end_data == 'HTTP Request 401.3':
         response_data = 401
@@ -155,11 +149,10 @@ def view_read_2(conn, name):
         acl = 0
         r_date = 0
     else:
-        if response_data == 404:
-            menu = [['edit/' + url_pas(name), load_lang('create')]]
-        else:
-            menu = [['edit/' + url_pas(name), load_lang('edit')]]
-
+        curs.execute(db_change("select decu from acl where title = ?"), [name])
+        acl = 1 if curs.fetchall() else 0
+        menu_acl = 1 if acl_check(name) == 1 else 0
+        menu = [['edit/' + url_pas(name), load_lang('create'), menu_acl]] if response_data == 404 else [['edit/' + url_pas(name), load_lang('edit'), menu_acl]]
         menu += [
             ['topic/' + url_pas(name), load_lang('discussion'), topic], 
             ['history/' + url_pas(name), load_lang('history')], 
@@ -184,11 +177,8 @@ def view_read_2(conn, name):
             menu += [['down/' + url_pas(name), load_lang('sub')]]
 
         curs.execute(db_change("select date from history where title = ? order by date desc limit 1"), [name])
-        date = curs.fetchall()
-        if date:
-            r_date = date[0][0]
-        else:
-            r_date = 0
+        r_date = curs.fetchall()
+        r_date = r_date[0][0] if r_date else 0
 
     div = end_data + div
 
@@ -202,20 +192,15 @@ def view_read_2(conn, name):
 
     curs.execute(db_change("select data from other where name = 'body'"))
     body = curs.fetchall()
-    if body:
-        div = body[0][0] + div
+    div = (body[0][0] + div) if body else div
 
     curs.execute(db_change("select data from other where name = 'bottom_body'"))
     body = curs.fetchall()
-    if body:
-        div += body[0][0]
+    div += body[0][0] if body else ''
 
     if ip_or_user(ip) == 0:
         curs.execute(db_change("select title from scan where user = ? and title = ?"), [ip, name])
-        if curs.fetchall():
-            watch_list = 2
-        else:
-            watch_list = 1
+        watch_list = 2 if curs.fetchall() else 1
     else:
         watch_list = 0
 

+ 2 - 2
version.json

@@ -1,10 +1,10 @@
 {
     "master" : {
-        "r_ver" : "v3.2.0-stable-10",
+        "r_ver" : "v3.2.0-stable-11",
         "c_ver" : "3200900",
         "s_ver" : "9"
     }, "stable" : {
-        "r_ver" : "v3.2.0-stable-10",
+        "r_ver" : "v3.2.0-stable-11",
         "c_ver" : "3200900",
         "s_ver" : "9"
     }