Quellcode durchsuchen

문서 편집 횟수 50회 ACL 추가

Surplus_Up (2DU) vor 7 Jahren
Ursprung
Commit
39d66d6aa3
4 geänderte Dateien mit 71 neuen und 14 gelöschten Zeilen
  1. 2 0
      language/en-US.json
  2. 2 0
      language/ko-KR.json
  3. 13 3
      route/acl.py
  4. 54 11
      route/tool/func.py

+ 2 - 0
language/en-US.json

@@ -79,6 +79,7 @@
         "previous" : "Previous",
         "authority" : "Authority",
         "connect" : "Connect",
+        "explanation" : "Explanation",
         "_comment_1.1_" : "Time",
             "second" : "Second(s)",
             "hour" : "Hour(s)",
@@ -144,6 +145,7 @@
         "user_document" : "User[s] document",
         "user_head" : "User[s] <head>",
         "user_document_acl" : "User[s] document ACL",
+        "50_edit" : "50+ editing of all documents",
         "_comment_2.1_" : "Filter",
             "_comment_2.1.1_" : "List",
                 "interwiki_list" : "Interwiki(s) list",

+ 2 - 0
language/ko-KR.json

@@ -79,6 +79,7 @@
         "previous" : "이전",
         "authority" : "권한",
         "connect" : "연결",
+        "explanation" : "설명",
         "_comment_1.1_" : "시간",
             "second" : "초",
             "hour" : "시간",
@@ -144,6 +145,7 @@
         "user_document" : "사용자 문서",
         "user_head" : "사용자 <head>",
         "user_document_acl" : "사용자 문서 ACL",
+        "50_edit" : "모든 문서 편집 횟수 50회 이상",
         "_comment_2.1_" : "필터",
             "_comment_2.1.1_" : "목록",
                 "interwiki_list" : "인터위키 목록",

+ 13 - 3
route/acl.py

@@ -66,9 +66,9 @@ def acl_2(conn, name):
         data = '<h2>' + load_lang('document_acl') + '</h2><hr class=\"main_hr\"><select name="dec" ' + check_ok + '>'
     
         if re.search('^user:', name):
-            acl_list = [['', load_lang('normal')], ['user', load_lang('member')], ['all', load_lang('all')]]
+            acl_list = [['', 'normal'], ['user', 'member'], ['all', 'all']]
         else:
-            acl_list = [['', load_lang('normal')], ['user', load_lang('member')], ['admin', load_lang('admin')]]
+            acl_list = [['', 'normal'], ['user', 'member'], ['admin', 'admin'], ['50_edit', '50 edit']]
         
         curs.execute("select dec from acl where title = ?", [name])
         acl_data = curs.fetchall()
@@ -106,7 +106,17 @@ def acl_2(conn, name):
                     
                 data += '<option value="' + data_list[0] + '" ' + check + '>' + data_list[1] + '</option>'
                 
-            data += '</select>'
+            data += '''
+                </select>
+                <h2>''' + load_lang('explanation') + '''</h2>
+                <ul>
+                    <li>normal : ''' + load_lang('normal') + '''</li>
+                    <li>admin : ''' + load_lang('admin') + '''</li>
+                    <li>member : ''' + load_lang('member') + '''</li>
+                    <li>50 edit : ''' + load_lang('50_edit') + ''' (+ member)</li>
+                    <li>all : ''' + load_lang('all') + '''</li>
+                </ul>
+            '''
                 
             if check_ok == '':
                 if acl_data:

+ 54 - 11
route/tool/func.py

@@ -167,7 +167,7 @@ def update():
     except:
         pass
 
-    # Start Data Migration Code
+    # Start : Data Migration Code
     app_var = json.loads(open(os.path.abspath('./data/app_variables.json'), encoding='utf-8').read())
 
     if os.path.exists('image'):
@@ -191,7 +191,7 @@ def update():
         with open(app_var['path_oauth_setting'], 'w') as f:
             f.write(json.dumps(old_oauth_data, sort_keys = True, indent = 4))
 
-    # -> End Data Migration Code
+    # End
 
 def pw_encode(data, data2 = '', type_d = ''):
     if type_d == '':
@@ -651,6 +651,22 @@ def acl_check(name, tool = ''):
                 if ip_or_user(ip):
                     return 1
 
+            if acl_data[0][0] == '50_edit':
+                if ip_or_user(ip):
+                    return 1
+                
+                if admin_check(5, 'view (' + name + ')') != 1:
+                    curs.execute("select count(title) from history where ip = ?", [ip])
+                    count = curs.fetchall()
+                    if count:
+                        count = count[0][0]
+                    else:
+                        count = 0
+
+                    if count < 50:
+                        return 1
+
+
             if acl_data[0][0] == 'admin':
                 if ip_or_user(ip):
                     return 1
@@ -690,37 +706,64 @@ def acl_check(name, tool = ''):
         if re.search("^file:", name) and admin_check(None, 'file edit (' + name + ')') != 1:
             return 1
 
-        curs.execute("select acl from user where id = ?", [ip])
-        user_data = curs.fetchall()
-
         curs.execute("select dec from acl where title = ?", [name])
         acl_data = curs.fetchall()
         if acl_data:
             if acl_data[0][0] == 'user':
-                if not user_data:
+                if ip_or_user(ip):
                     return 1
 
             if acl_data[0][0] == 'admin':
-                if not user_data:
+                if ip_or_user(ip):
+                    return 1
+
+                if admin_check(5, 'topic send (' + name + ')') != 1:
                     return 1
 
-                if not admin_check(5, 'edit (' + name + ')') == 1:
+            if acl_data[0][0] == '50_edit':
+                if ip_or_user(ip):
                     return 1
+                
+                if admin_check(5, 'topic send (' + name + ')') != 1:
+                    curs.execute("select count(title) from history where ip = ?", [ip])
+                    count = curs.fetchall()
+                    if count:
+                        count = count[0][0]
+                    else:
+                        count = 0
+
+                    if count < 50:
+                        return 1
 
         curs.execute('select data from other where name = "edit"')
         set_data = curs.fetchall()
         if set_data:
             if set_data[0][0] == 'login':
-                if not user_data:
+                if ip_or_user(ip):
                     return 1
 
             if set_data[0][0] == 'admin':
-                if not user_data:
+                if ip_or_user(ip):
                     return 1
 
-                if not admin_check(5) == 1:
+                if admin_check(5, 'edit (' + name + ')') != 1:
                     return 1
 
+            if acl_data[0][0] == '50_edit':
+                if ip_or_user(ip):
+                    return 1
+                
+                if admin_check(5, 'edit (' + name + ')') != 1:
+                    curs.execute("select count(title) from history where ip = ?", [ip])
+                    count = curs.fetchall()
+                    if count:
+                        count = count[0][0]
+                    else:
+                        count = 0
+
+                    if count < 50:
+                        return 1
+
         return 0
 
 def ban_check(ip = None, tool = None):