Kaynağa Gözat

https://github.com/openNAMU/openNAMU/issues/1677

잉여개발기 (SPDV) 2 yıl önce
ebeveyn
işleme
fda0610986
4 değiştirilmiş dosya ile 44 ekleme ve 23 silme
  1. 11 0
      app.py
  2. 22 6
      route/main_setting_main.py
  3. 10 16
      route/tool/func.py
  4. 1 1
      version.json

+ 11 - 0
app.py

@@ -306,6 +306,17 @@ def do_every_day():
             time_calc = time_calc.strftime('%Y-%m-%d %H:%M:%S')
             
             curs.execute(db_change("delete from ua_d where today < ?"), [time_calc])
+            
+        # auth history 관리
+        curs.execute(db_change('select data from other where name = "auth_history_expiration_date"'))
+        db_data = curs.fetchall()
+        if db_data and db_data[0][0] != '':
+            time_db = int(number_check(db_data[0][0]))
+            
+            time_calc = datetime.date.today() - datetime.timedelta(days = time_db)
+            time_calc = time_calc.strftime('%Y-%m-%d %H:%M:%S')
+            
+            curs.execute(db_change("delete from re_admin where time < ?"), [time_calc])
 
         # 사이트맵 생성 관리
         curs.execute(db_change('select data from other where name = "sitemap_auto_make"'))

+ 22 - 6
route/main_setting_main.py

@@ -43,7 +43,9 @@ def main_setting_main(db_set):
             39 : ['edit_timeout', '5'],
             40 : ['document_content_max_length', ''],
             41 : ['backup_count', ''],
-            42 : ['ua_expiration_date', '']
+            42 : ['ua_expiration_date', ''],
+            43 : ['auth_history_expiration_date', ''],
+            44 : ['auth_history_off', '']
         }
 
         if flask.request.method == 'POST':
@@ -64,10 +66,7 @@ def main_setting_main(db_set):
                 curs.execute(db_change('select data from other where name = ?'), [setting_list[i][0]])
                 db_data = curs.fetchall()
                 if not db_data:
-                    curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, "")'), [
-                        setting_list[i][0],
-                        setting_list[i][1]
-                    ])
+                    curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, "")'), [setting_list[i][0], setting_list[i][1]])
 
                 d_list[i] = db_data[0][0] if db_data else setting_list[i][1]
             else:
@@ -93,7 +92,7 @@ def main_setting_main(db_set):
                 else:
                     tls_select += '<option value="' + tls_select_one + '">' + tls_select_one + '</option>'
 
-            check_box_div = [7, 8, '', 20, 23, 24, 25, 26, 31, 33, 34, 35, 36, 37]
+            check_box_div = [7, 8, '', 20, 23, 24, 25, 26, 31, 33, 34, 35, 36, 37, 44]
             for i in range(0, len(check_box_div)):
                 acl_num = check_box_div[i]
                 if acl_num != '' and d_list[acl_num]:
@@ -116,6 +115,7 @@ def main_setting_main(db_set):
                 data = render_simple_set('''
                     <form method="post">
                         <h2>''' + load_lang('basic_set') + '''</h2>
+                        
                         <span>''' + load_lang('wiki_name') + '''</span>
                         <hr class="main_hr">
                         <input name="name" value="''' + html.escape(d_list[0]) + '''">
@@ -165,8 +165,19 @@ def main_setting_main(db_set):
                         <span>''' + load_lang('set_wiki_access_password') + '''</span> (''' + load_lang('restart_required') + ''')
                         <hr class="main_hr">
                         <input type="password" name="wiki_access_password" value="''' + html.escape(d_list[32]) + '''">
+                        
+                        <h3>''' + load_lang('auth_history') + '''</h3>
+                        
+                        <input type="checkbox" name="auth_history_off" ''' + check_box_div[14] + '''> ''' + load_lang('auth_history_off') + '''
+                        <hr class="main_hr">
+                        
+                        <span>''' + load_lang('auth_history_expiration_date') + '''</span> (''' + load_lang('day') + ''') (''' + load_lang('off') + ''' : ''' + load_lang('empty') + ''')
+                        <hr class="main_hr">
+                        <input name="auth_history_expiration_date" value="''' + html.escape(d_list[43]) + '''">
+                        <hr class="main_hr">
 
                         <h3>''' + load_lang('communication_set') + '''</h3>
+                        
                         <input type="checkbox" name="enable_comment" ''' + check_box_div[5] + '''> ''' + load_lang('enable_comment_function') + ''' (''' + load_lang('not_working') + ''')
                         <hr class="main_hr">
 
@@ -174,11 +185,13 @@ def main_setting_main(db_set):
                         <hr class="main_hr">
 
                         <h2>''' + load_lang('design_set') + '''</h2>
+                        
                         <span>''' + load_lang('wiki_skin') + '''</span>
                         <hr class="main_hr">
                         <select name="skin">''' + load_skin(d_list[5] if d_list[5] != '' else 'ringo') + '''</select>
 
                         <h2>''' + load_lang('render_set') + '''</h2>
+                        
                         <input type="checkbox" name="namumark_compatible" ''' + check_box_div[10] + '''> ''' + load_lang('namumark_fully_compatible_mode') + '''
                         <hr class="main_hr">
                         
@@ -186,6 +199,7 @@ def main_setting_main(db_set):
                         <hr class="main_hr">
 
                         <h2>''' + load_lang('login_set') + '''</h2>
+                        
                         <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''
                         <hr class="main_hr">
 
@@ -220,6 +234,7 @@ def main_setting_main(db_set):
 
                         <span ''' + sqlite_only + '''>
                             <h3>''' + load_lang('backup') + ''' (''' + load_lang('sqlite_only') + ''')</h3>
+                            
                             <span>''' + load_lang('backup_warning') + ''' (EX : data_YYYYMMDDHHMMSS.db)</span>
                             <hr class="main_hr">
                             <hr class="main_hr">
@@ -241,6 +256,7 @@ def main_setting_main(db_set):
                         </span>
 
                         <h2>''' + load_lang('edit_set') + '''</h2>
+                        
                         <span>''' + load_lang('slow_edit') + '''</span> (''' + load_lang('second') + ''') (''' + load_lang('off') + ''' : ''' + load_lang('empty') + ''')
                         <hr class="main_hr">
                         <input name="slow_edit" value="''' + html.escape(d_list[19]) + '''">

+ 10 - 16
route/tool/func.py

@@ -1739,38 +1739,32 @@ def admin_check(num = None, what = None, name = ''):
         pass_ok = 0
 
         if ip_or_user(ip) == 0:
-            curs.execute(db_change(
-                "select data from user_set where id = ? and name = 'acl'"
-            ), [ip])
+            curs.execute(db_change("select data from user_set where id = ? and name = 'acl'"), [ip])
             user_auth = curs.fetchall()
             if user_auth:
                 user_auth = user_auth[0][0]
                 check = get_admin_auth_list(num)
                 
-                curs.execute(db_change(
-                    'select name from alist where name = ? and acl = "owner"'
-                ), [user_auth])
+                curs.execute(db_change('select name from alist where name = ? and acl = "owner"'), [user_auth])
                 if curs.fetchall():
                     pass_ok = 1
                 else:
                     if num == 'all':                    
-                        curs.execute(db_change(
-                            'select name from alist where name = ?'
-                        ), [user_auth])
+                        curs.execute(db_change('select name from alist where name = ?'), [user_auth])
                     else:
-                        curs.execute(db_change(
-                            'select name from alist where name = ? and acl = ?'
-                        ), [user_auth, check])
+                        curs.execute(db_change('select name from alist where name = ? and acl = ?'), [user_auth, check])
                         
                     if curs.fetchall():
                         pass_ok = 1
 
-                    
                 if pass_ok == 1:
                     if what:
-                        curs.execute(db_change(
-                            "insert into re_admin (who, what, time) values (?, ?, ?)"
-                        ), [ip, what, time_data])
+                        curs.execute(db_change('select data from other where name = "auth_history_off"'))
+                        db_data = curs.fetchall()
+                        if db_data and db_data[0][0] != '':
+                            pass
+                        else:
+                            curs.execute(db_change("insert into re_admin (who, what, time) values (?, ?, ?)"), [ip, what, time_data])
 
                     return 1
 

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.6-RC5-dev76",
+        "r_ver" : "v3.4.6-RC5-dev77",
         "c_ver" : "3500373",
         "s_ver" : "3500112"
     }