Explorar o código

문서명 필터 기능 추가

Surplus_Up (2DU) %!s(int64=7) %!d(string=hai) anos
pai
achega
857b4fb0d4

+ 3 - 3
app.py

@@ -289,15 +289,15 @@ def del_alarm():
 def alarm():
     return alarm_2(conn)
 
-@app.route('/<regex("inter_wiki|(?:edit|email|name)_filter"):tools>')
+@app.route('/<regex("inter_wiki|(?:edit|email|file|name)_filter"):tools>')
 def inter_wiki(tools = None):
     return inter_wiki_2(conn, tools)
 
-@app.route('/<regex("del_(?:inter_wiki|(?:edit|email|name)_filter)"):tools>/<name>')
+@app.route('/<regex("del_(?:inter_wiki|(?:edit|email|file|name)_filter)"):tools>/<name>')
 def del_inter(tools = None, name = None):
     return inter_wiki_del_2(conn, tools, name)
 
-@app.route('/<regex("plus_(?:inter_wiki|(?:edit|email|name)_filter)"):tools>', methods=['POST', 'GET'])
+@app.route('/<regex("plus_(?:inter_wiki|(?:edit|email|file|name)_filter)"):tools>', methods=['POST', 'GET'])
 @app.route('/<regex("plus_edit_filter"):tools>/<name>', methods=['POST', 'GET'])
 def plus_inter(tools = None, name = None):
     return inter_wiki_plus_2(conn, tools, name)

+ 3 - 0
language/en-US.json

@@ -86,6 +86,7 @@
         "in_progress" : "In progress",
         "start" : "Start",
         "pass" : "Passing",
+        "file_name" : "File name",
         "_comment_1.1_" : "Time",
             "second" : "Second(s)",
             "hour" : "Hour(s)",
@@ -167,11 +168,13 @@
                 "email_filter_list" : "Email filter(s) list",
                 "id_filter_list" : "ID filter(s) list",
                 "edit_filter_list" : "Contents filter(s) list",
+                "file_filter_list" : "File name filter(s) list",
             "_comment_2.1.2_" : "Add",
                 "interwiki_add" : "Interwiki add",
                 "edit_filter_add" : "Contents filter add",
                 "id_filter_add" : "ID filter add",
                 "email_filter_add" : "Email filter add",
+                "file_filter_add" : "File name filter add",
         "_comment_2.2_" : "Setting",
             "setting" : "Setting",
             "restart_required" : "Restart required",

+ 3 - 0
language/ko-KR.json

@@ -86,6 +86,7 @@
         "in_progress" : "진행중",
         "start" : "시작",
         "pass" : "넘기기",
+        "file_name" : "파일명",
         "_comment_1.1_" : "시간",
             "second" : "초",
             "hour" : "시간",
@@ -167,11 +168,13 @@
                 "email_filter_list" : "이메일 필터 목록",
                 "id_filter_list" : "ID 필터 목록",
                 "edit_filter_list" : "편집 필터 목록",
+                "file_filter_list" : "파일명 필터 목록",
             "_comment_2.1.2_" : "추가",
                 "interwiki_add" : "인터위키 추가",
                 "edit_filter_add" : "편집 필터 추가",
                 "id_filter_add" : "ID 필터 추가",
                 "email_filter_add" : "이메일 필터 추가",
+                "file_filter_add" : "파일명 필터 추가",
         "_comment_2.2_" : "설정",
             "setting" : "설정",
             "restart_required" : "재시작 필요",

+ 20 - 15
route/func_upload.py

@@ -37,6 +37,13 @@ def func_upload_2(conn):
         curs.execute("select title from data where title = ?", ['file:' + name])
         if curs.fetchall():
             return re_error('/error/16')
+
+        curs.execute("select html from html_filter where kind = 'file'")
+        db_data = curs.fetchall()
+        for i in db_data:
+            t_re = re.compile(i[0])
+            if t_re.search(name):
+                return redirect('/file_filter')
             
         ip = ip_check()
 
@@ -54,10 +61,6 @@ def func_upload_2(conn):
             data.save(os.path.join(app_var['path_data_image'], e_data))
         else:
             data.save(os.path.join(app_var['path_data_image'], e_data))
-            
-        curs.execute("select title from data where title = ?", ['file:' + name])
-        if curs.fetchall(): 
-            curs.execute("delete from data where title = ?", ['file:' + name])
         
         curs.execute("insert into data (title, data) values (?, ?)", ['file:' + name, '[[file:' + name + ']][br][br]{{{[[file:' + name + ']]}}}[br][br]' + lice])
         curs.execute("insert into acl (title, dec, dis, why, view) values (?, 'admin', '', '', '')", ['file:' + name])
@@ -77,16 +80,18 @@ def func_upload_2(conn):
         return easy_minify(flask.render_template(skin_check(), 
             imp = [load_lang('upload'), wiki_set(), custom(), other2([0, 0])],
             data =  '''
-                    <form method="post" enctype="multipart/form-data" accept-charset="utf8">
-                        <input type="file" name="f_data">
-                        <hr class=\"main_hr\">
-                        <input placeholder="''' + load_lang('name') + '''" name="f_name" type="text">
-                        <hr class=\"main_hr\">
-                        <input placeholder="''' + load_lang('license') + '''" name="f_lice" type="text">
-                        <hr class=\"main_hr\">
-                        ''' + captcha_get() + '''
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                    ''',
+                <a href="/file_filter">(''' + load_lang('file_filter_list') + ''')</a>
+                <hr class=\"main_hr\">
+                <form method="post" enctype="multipart/form-data" accept-charset="utf8">
+                    <input type="file" name="f_data">
+                    <hr class=\"main_hr\">
+                    <input placeholder="''' + load_lang('file_name') + '''" name="f_name" type="text">
+                    <hr class=\"main_hr\">
+                    <input placeholder="''' + load_lang('license') + '''" name="f_lice" type="text">
+                    <hr class=\"main_hr\">
+                    ''' + captcha_get() + '''
+                    <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                </form>
+            ''',
             menu = [['other', load_lang('return')]]
         ))  

+ 8 - 1
route/inter_wiki.py

@@ -35,13 +35,20 @@ def inter_wiki_2(conn, tools):
         div = ''
 
         curs.execute("select html from html_filter where kind = 'name'")
-    else:
+    elif tools == 'edit_filter':
         del_link = 'del_edit_filter'
         plus_link = 'manager/9'
         title = load_lang('edit_filter_list')
         div = ''
 
         curs.execute("select name from filter")
+    else:
+        del_link = 'del_file_filter'
+        plus_link = 'plus_file_filter'
+        title = load_lang('file_filter_list')
+        div = ''
+
+        curs.execute("select html from html_filter where kind = 'file'")
 
     db_data = curs.fetchall()
     if db_data:

+ 2 - 0
route/inter_wiki_del.py

@@ -10,6 +10,8 @@ def inter_wiki_del_2(conn, tools, name):
             curs.execute("delete from filter where name = ?", [name])
         elif tools == 'del_name_filter':
             curs.execute("delete from html_filter where html = ? and kind = 'name'", [name])
+        elif tools == 'del_file_filter':
+            curs.execute("delete from html_filter where html = ? and kind = 'file'", [name])
         else:
             curs.execute("delete from html_filter where html = ? and kind = 'email'", [name])
         

+ 32 - 11
route/inter_wiki_plus.py

@@ -6,6 +6,7 @@ def inter_wiki_plus_2(conn, tools, name):
     if flask.request.method == 'POST':
         if tools == 'plus_inter_wiki':
             curs.execute('insert into inter (title, link) values (?, ?)', [flask.request.form.get('title', None), flask.request.form.get('link', None)])
+            
             admin_check(None, 'inter_wiki_plus')
         elif tools == 'plus_edit_filter':
             if admin_check(1, 'edit_filter edit') != 1:
@@ -28,10 +29,26 @@ def inter_wiki_plus_2(conn, tools, name):
                 return re_error('/error/23')                
         else:
             if tools == 'plus_name_filter':
+                try:
+                    re.compile(flask.request.form.get('title', 'test'))
+                except:
+                    return re_error('/error/23') 
+
                 admin_check(None, 'name_filter edit')
+                
                 type_d = 'name'
+            elif tools == 'plus_file_filter':
+                try:
+                    re.compile(flask.request.form.get('title', 'test'))
+                except:
+                    return re_error('/error/23') 
+                
+                admin_check(None, 'file_filter edit')
+                
+                type_d = 'file'
             else:
                 admin_check(None, 'email_filter edit')
+                
                 type_d = 'email'
             
             curs.execute('insert into html_filter (html, kind) values (?, ?)', [flask.request.form.get('title', 'test'), type_d])
@@ -48,10 +65,10 @@ def inter_wiki_plus_2(conn, tools, name):
         if tools == 'plus_inter_wiki':
             title = load_lang('interwiki_add')
             form_data = '''
-                        <input placeholder="''' + load_lang('name') + '''" type="text" name="title">
-                        <hr class=\"main_hr\">
-                        <input placeholder="link" type="text" name="link">
-                        '''
+                <input placeholder="''' + load_lang('name') + '''" type="text" name="title">
+                <hr class=\"main_hr\">
+                <input placeholder="link" type="text" name="link">
+            '''
         elif tools == 'plus_edit_filter':
             curs.execute("select regex, sub from filter where name = ?", [name])
             exist = curs.fetchall()
@@ -71,19 +88,23 @@ def inter_wiki_plus_2(conn, tools, name):
 
             title = load_lang('edit_filter_add')
             form_data = '''
-                        <input placeholder="''' + load_lang('second') + '''" name="second" type="text" value="''' + html.escape(time_data) + '''">
-                        <hr class=\"main_hr\">
-                        <input ''' + stat + ''' type="checkbox" ''' + time_check + ''' name="limitless"> ''' + load_lang('limitless') + '''
-                        <hr class=\"main_hr\">
-                        <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
-                        '''
+                <input placeholder="''' + load_lang('second') + '''" name="second" type="text" value="''' + html.escape(time_data) + '''">
+                <hr class=\"main_hr\">
+                <input ''' + stat + ''' type="checkbox" ''' + time_check + ''' name="limitless"> ''' + load_lang('limitless') + '''
+                <hr class=\"main_hr\">
+                <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
+            '''
         elif tools == 'plus_name_filter':
             title = load_lang('id_filter_add')
-            form_data = '<input placeholder="' + load_lang('id') + ' ' + load_lang('regex') + '" type="text" name="title">'
+            form_data = '<input placeholder="' + load_lang('regex') + '" type="text" name="title">'
+        elif tools == 'plus_file_filter':
+            title = load_lang('file_filter_add')
+            form_data = '<input placeholder="' + load_lang('regex') + '" type="text" name="title">'
         else:
             title = load_lang('email_filter_add')
             form_data = '<input placeholder="email" type="text" name="title">'
 
+
         return easy_minify(flask.render_template(skin_check(), 
             imp = [title, wiki_set(), custom(), other2([0, 0])],
             data =  '''

+ 2 - 0
route/main_manager.py

@@ -6,6 +6,7 @@ def main_manager_2(conn, num):
     title_list = {
         0 : [load_lang('document_name'), 'acl'], 
         1 : [0, 'check'], 
+        2 : [load_lang('file_name'), 'plus_file_filter'],
         3 : [0, 'admin'], 
         4 : [0, 'record'], 
         5 : [0, 'topic_record'], 
@@ -42,6 +43,7 @@ def main_manager_2(conn, num):
                         <li><a href="/inter_wiki">''' + load_lang('interwiki_list') + '''</a></li>
                         <li><a href="/email_filter">''' + load_lang('email_filter_list') + '''</a></li>
                         <li><a href="/name_filter">''' + load_lang('id_filter_list') + '''</a></li>
+                        <li><a href="/file_filter">''' + load_lang('file_filter_list') + '''</a></li>
                     </ul>
                     <br>
                     <h2>''' + load_lang('server') + '''</h2>

+ 21 - 42
route/setting.py

@@ -114,48 +114,39 @@ def setting_2(conn, num):
                 data =  '''
                         <form method="post">
                             <span>''' + load_lang('wiki_name') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="name" value="''' + html.escape(d_list[0]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('wiki_logo') + ''' (HTML)</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="logo" value="''' + html.escape(d_list[1]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('main_page') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="frontpage" value="''' + html.escape(d_list[2]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('bottom_text') + ''' (HTML)</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="license" value="''' + html.escape(d_list[3]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('max_file_size') + ''' [MB]</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="upload" value="''' + html.escape(d_list[4]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('backup_interval') + ' [' + load_lang('hour') + '''] (off : 0) {restart}</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="back_up" value="''' + html.escape(d_list[9]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('wiki_skin') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <select name="skin">''' + div2 + '''</select>
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('default_acl') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <select name="edit">''' + div + '''</select>
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('default_discussion_acl') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <select name="discussion">''' + div4 + '''</select>
                             <hr class=\"main_hr\">
                             <input type="checkbox" name="reg" ''' + ch_1 + '''> ''' + load_lang('no_register') + '''
@@ -165,28 +156,23 @@ def setting_2(conn, num):
                             <input type="checkbox" name="email_have" ''' + ch_3 + '''> ''' + load_lang('email_required') + ''' {<a href="/setting/5">''' + load_lang('google_imap_required') + '''</a>}
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('wiki_host') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="host" value="''' + html.escape(d_list[16]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('wiki_port') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="port" value="''' + html.escape(d_list[10]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('wiki_secret_key') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="password" name="key" value="''' + html.escape(d_list[11]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('update_branch') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <select name="update">''' + div3 + '''</select>
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('encryption_method') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <select name="encode">''' + div5 + '''</select>
                             <hr class=\"main_hr\">
                             <button id="save" type="submit">''' + load_lang('save') + '''</button>
@@ -230,18 +216,15 @@ def setting_2(conn, num):
                 data =  '''
                         <form method="post">
                             <span>''' + load_lang('register_text') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="contract" value="''' + html.escape(d_list[0]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('non_login_alert') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="no_login_warring" value="''' + html.escape(d_list[1]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('edit_bottom_text') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input type="text" name="edit_bottom_text" value="''' + html.escape(d_list[2]) + '''">
                             <hr class=\"main_hr\">
                             <button id="save" type="submit">''' + load_lang('save') + '''</button>
@@ -399,24 +382,20 @@ def setting_2(conn, num):
                         <form method="post">
                             <h2><a href="https://www.google.com/recaptcha/admin">recaptcha</a></h2>
                             <span>''' + load_lang('recaptcha') + ''' (HTML)</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input placeholder="''' + load_lang('recaptcha') + ''' (HTML)" type="text" name="recaptcha" value="''' + html.escape(d_list[0]) + '''">
                             <hr class=\"main_hr\">
                             <span>''' + load_lang('recaptcha') + ' (' + load_lang('secret_key') + ''')</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input placeholder="''' + load_lang('recaptcha') + ' (' + load_lang('secret_key') + ''')" type="text" name="sec_re" value="''' + html.escape(d_list[1]) + '''">
                             <hr class=\"main_hr\">
                             <h2><a href="https://support.google.com/mail/answer/7126229">''' + load_lang('google_imap') + '</a> {' + load_lang('restart_required') + '''}</h1>
                             <span>''' + load_lang('google_email') + '''</span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input placeholder="''' + load_lang('google_email') + '''" type="text" name="g_email" value="''' + html.escape(d_list[2]) + '''">
                             <hr class=\"main_hr\">
                             <span><a href="https://security.google.com/settings/security/apppasswords">''' + load_lang('google_app_password') + '''</a></span>
-                            <br>
-                            <br>
+                            <hr class=\"main_hr\">
                             <input placeholder="''' + load_lang('google_app_password') + '''" type="password" name="g_pass" value="''' + html.escape(d_list[3]) + '''">
                             <hr class=\"main_hr\">
                             <button id="save" type="submit">''' + load_lang('save') + '''</button>

+ 5 - 5
route/topic.py

@@ -114,7 +114,7 @@ def topic_2(conn, name, sub):
                         </tr>
                     </tbody>
                 </table>
-                <br>
+                <hr class=\"main_hr\">
             '''    
 
         for topic_data in topic:
@@ -174,7 +174,7 @@ def topic_2(conn, name, sub):
                         </tr>
                     </tbody>
                 </table>
-                <br>
+                <hr class=\"main_hr\">
             '''
             number += 1
 
@@ -183,10 +183,10 @@ def topic_2(conn, name, sub):
                 <div id="plus"></div>
                 <script>topic_load("''' + name + '''", "''' + sub + '''");</script>
                 <a id="reload" href="javascript:void(0);" onclick="location.href.endsWith(\'#reload\')? location.reload(true):location.href=\'#reload\'">(''' + load_lang('reload') + ''')</a>
-                <form style="''' + display + '''" method="post">
-                <br>
-                <textarea style="height: 100px;" name="content"></textarea>
                 <hr class=\"main_hr\">
+                <form style="''' + display + '''" method="post">
+                    <textarea style="height: 100px;" name="content"></textarea>
+                    <hr class=\"main_hr\">
             ''' + captcha_get()
             
             if display == '':