2du 4 gadi atpakaļ
vecāks
revīzija
264efc1b1a

+ 51 - 311
app.py

@@ -347,256 +347,38 @@ if os.path.exists('custom.py'):
     
 # Func
 # Func-inter_wiki
-app.add_url_rule(
-    rule = '/inter_wiki',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'inter_wiki' 
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/inter_wiki/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_inter_wiki',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/inter_wiki/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_inter_wiki',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
-
-app.add_url_rule(
-    rule = '/edit_top',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'edit_top'
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/edit_top/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_edit_top',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/edit_top/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_edit_top',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
+app.route('/inter_wiki', defaults = { 'tool' : 'inter_wiki' })(inter_wiki)
+app.route('/inter_wiki/del/<name>', defaults = { 'tool' : 'del_inter_wiki' })(inter_wiki_del)
+app.route('/inter_wiki/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_inter_wiki' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/image_license',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'image_license'
-    }, 
-    view_func = inter_wiki
-)
+app.route('/edit_top', defaults = { 'tool' : 'edit_top' })(inter_wiki)
+app.route('/edit_top/del/<name>', defaults = { 'tool' : 'del_edit_top' })(inter_wiki_del)
+app.route('/edit_top/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_edit_top' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/image_license/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_image_license',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
+app.route('/image_license', defaults = { 'tool' : 'image_license' })(inter_wiki)
+app.route('/image_license/del/<name>', defaults = { 'tool' : 'del_image_license' })(inter_wiki_del)
+app.route('/image_license/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_image_license' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/image_license/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_image_license',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
+app.route('/edit_filter', defaults = { 'tool' : 'edit_filter' })(inter_wiki)
+app.route('/edit_filter/del/<name>', defaults = { 'tool' : 'del_edit_filter' })(inter_wiki_del)
+app.route('/edit_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_edit_filter' })(inter_wiki_add)
+app.route('/edit_filter/add/<name>', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_edit_filter' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/edit_filter',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'edit_filter'
-    }, 
-    view_func = inter_wiki
-)
+app.route('/email_filter', defaults = { 'tool' : 'email_filter' })(inter_wiki)
+app.route('/email_filter/del/<name>', defaults = { 'tool' : 'del_email_filter' })(inter_wiki_del)
+app.route('/email_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_email_filter' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/edit_filter/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_edit_filter',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
+app.route('/file_filter', defaults = { 'tool' : 'file_filter' })(inter_wiki)
+app.route('/file_filter/del/<name>', defaults = { 'tool' : 'del_file_filter' })(inter_wiki_del)
+app.route('/file_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_file_filter' })(inter_wiki_add)
 
-# 이거 수정 필요 할 듯
-app.add_url_rule(
-    rule = '/edit_filter/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_edit_filter',
-        'name' : None
-    }, 
-    view_func = inter_wiki_add
-)
+app.route('/name_filter', defaults = { 'tool' : 'name_filter' })(inter_wiki)
+app.route('/name_filter/del/<name>', defaults = { 'tool' : 'del_name_filter' })(inter_wiki_del)
+app.route('/name_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_name_filter' })(inter_wiki_add)
 
-app.add_url_rule(
-    rule = '/edit_filter/add/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_edit_filter',
-        'name' : 'Test'
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
-
-app.add_url_rule(
-    rule = '/email_filter',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'email_filter'
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/email_filter/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_email_filter',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/email_filter/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_email_filter',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
-
-app.add_url_rule(
-    rule = '/file_filter',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'file_filter'
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/file_filter/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_file_filter',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/file_filter/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_file_filter',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
-
-app.add_url_rule(
-    rule = '/name_filter',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'name_filter'
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/name_filter/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_name_filter',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/name_filter/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_name_filter',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
-
-app.add_url_rule(
-    rule = '/extension_filter',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'extension_filter'
-    }, 
-    view_func = inter_wiki
-)
-
-app.add_url_rule(
-    rule = '/extension_filter/del/<name>',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'del_extension_filter',
-        'name' : 'Test'
-    }, 
-    view_func = inter_wiki_del
-)
-
-app.add_url_rule(
-    rule = '/extension_filter/add',
-    defaults = { 
-        'conn' : load_db.db_get(), 
-        'tool' : 'plus_extension_filter',
-        'name' : None
-    }, 
-    methods = ['GET', 'POST'],
-    view_func = inter_wiki_add
-)
+app.route('/extension_filter', defaults = { 'tool' : 'extension_filter' })(inter_wiki)
+app.route('/extension_filter/del/<name>', defaults = { 'tool' : 'del_extension_filter' })(inter_wiki_del)
+app.route('/extension_filter/add', methods = ['POST', 'GET'], defaults = { 'tool' : 'plus_extension_filter' })(inter_wiki_add)
 
 # Func-list
 # /list/document/old
@@ -948,12 +730,6 @@ def login_login():
 def login_login_2fa():
     return login_login_2fa_2(load_db.db_get())
 
-'''
-@app.route('/login/2fa/email', methods = ['POST', 'GET'])
-def login_2fa_email():
-    return login_login_2fa_email_2(load_db.db_get())
-'''
-
 @app.route('/register', methods = ['POST', 'GET'])
 def login_register():
     return login_register_2(load_db.db_get())
@@ -1041,68 +817,32 @@ app.route('/api/sitemap.xml')(api_sitemap)
 
 # Func-main
 # 여기도 전반적인 조정 시행 예정
-@app.route('/restart', methods = ['POST', 'GET'])
-def main_restart():
-    return main_restart_2(load_db.db_get())
-
-@app.route('/update', methods=['GET', 'POST'])
-def main_update():
-    return main_update_2(load_db.db_get())
-
-@app.route('/random')
-def main_title_random():
-    return main_title_random_2(load_db.db_get())
-
-@app.route('/upload', methods=['GET', 'POST'])
-def main_upload():
-    return main_upload_2(load_db.db_get())
-
-@app.route('/setting')
-@app.route('/setting/<int:num>', methods = ['POST', 'GET'])
-def setting(num = 0):
-    return main_setting_2(load_db.db_get(), num, data_db_set['type'])
-
-@app.route('/other')
-def main_other():
-    return main_other_2(load_db.db_get())
-
-@app.route('/manager', methods = ['POST', 'GET'])
-@app.route('/manager/<int:num>', methods = ['POST', 'GET'])
-def main_manager(num = 1):
-    return main_manager_2(load_db.db_get(), num)
-
-@app.route('/image/<everything:name>')
-def main_image_view(name = None):
-    return main_image_view_2(load_db.db_get(), name)
-
-@app.route('/skin_set')
-@app.route('/main_skin_set')
-def main_skin_set():
-    return main_skin_set_2(load_db.db_get())
-
-@app.route('/views/<everything:name>')
-def main_views(name = None):
-    return main_views_2(load_db.db_get(), name)
-
-@app.route('/test_func')
-def main_test_func():
-    return main_test_func_2(load_db.db_get())
-
-@app.route('/shutdown', methods = ['POST', 'GET'])
-def main_shutdown():
-    return main_shutdown_2(load_db.db_get())
-
-@app.route('/easter_egg.xml')
-def main_easter_egg():
-    return main_easter_egg_2(load_db.db_get())
-
-@app.route('/<regex("[^.]+\.(?:txt|xml)"):data>')
-def main_file(data = ''):
-    return main_file_2(load_db.db_get(), data)
-
-@app.errorhandler(404)
-def main_error_404(e):
-    return main_error_404_2(load_db.db_get())
+app.route('/other')(main_tool_other)
+app.route('/manager', methods = ['POST', 'GET'])(main_tool_admin)
+app.route('/manager/<int:num>', methods = ['POST', 'GET'])(main_tool_admin)
+app.route('/manager/<int:num>/<add_1>', methods = ['POST', 'GET'])(main_tool_admin)
+app.route('/manager/<int:num>/<add_1>/<add_2>', methods = ['POST', 'GET'])(main_tool_admin)
+
+app.route('/random')(main_func_random)
+app.route('/upload', methods = ['POST', 'GET'])(main_func_upload)
+app.route('/setting', defaults = { 'db_set' : data_db_set['type'] })(main_func_setting)
+app.route('/setting/<int:num>', methods = ['POST', 'GET'], defaults = { 'db_set' : data_db_set['type'] })(main_func_setting)
+app.route('/skin_set')(main_func_skin_set)
+app.route('/main_skin_set')(main_func_skin_set)
+app.route('/easter_egg.xml')(main_func_easter_egg)
+
+# views -> view
+app.route('/view/<everything:name>')(main_view)
+app.route('/views/<everything:name>')(main_view)
+app.route('/image/<everything:name>')(main_view_image)
+# 조정 계획 중
+app.route('/<regex("[^.]+\.(?:txt|xml)"):data>')(main_view_file)
+
+app.route('/shutdown', methods = ['POST', 'GET'])(main_sys_shutdown)
+app.route('/restart', methods = ['POST', 'GET'])(main_sys_restart)
+app.route('/update', methods = ['POST', 'GET'])(main_sys_update)
+
+app.errorhandler(404)(main_error_404)
     
 if __name__ == "__main__":
     do_server = netius.servers.WSGIServer(app = app)

+ 80 - 79
route/inter_wiki.py

@@ -1,84 +1,85 @@
 from .tool.func import *
 
-def inter_wiki(conn, tool):
-    curs = conn.cursor()
-
-    div = '<table id="main_table_set">'
-    div += '<tr id="main_table_top_tr">'
-    
-    div += '<td id="main_table_width">A</td>'
-    div += '<td id="main_table_width">B</td>'
-    div += '<td id="main_table_width">C</td>'
-    
-    div += '</tr>'
-    
-    admin = admin_check()
-
-    if tool == 'inter_wiki':
-        title = load_lang('interwiki_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'inter_wiki'"))
-    elif tool == 'email_filter':
-        title = load_lang('email_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'email'"))
-    elif tool == 'name_filter':
-        title = load_lang('id_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'name'"))
-    elif tool == 'edit_filter':
-        title = load_lang('edit_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'regex_filter'"))
-    elif tool == 'file_filter':
-        title = load_lang('file_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
-    elif tool == 'file_filter':
-        title = load_lang('file_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
-    elif tool == 'image_license':
-        title = load_lang('image_license_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'image_license'"))
-    elif tool == 'extension_filter':
-        title = load_lang('extension_filter_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'extension'"))
-    else:
-        title = load_lang('edit_tool_list')
-
-        curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
-
-    db_data = curs.fetchall()
-    for data in db_data:
-        div += '<tr>'
-        div += '<td>'
-
-        div += data[0]
-        if admin == 1:
-            div += ' <a href="/' + tool + '/add/' + url_pas(data[0]) + '">(' + load_lang('edit') + ')</a>'
-            div += ' <a href="/' + tool + '/del/' + url_pas(data[0]) + '">(' + load_lang('delete') + ')</a>'
-        
-        div += '</td>'
+def inter_wiki(tool):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        div = '<table id="main_table_set">'
+        div += '<tr id="main_table_top_tr">'
+
+        div += '<td id="main_table_width">A</td>'
+        div += '<td id="main_table_width">B</td>'
+        div += '<td id="main_table_width">C</td>'
+
+        div += '</tr>'
+
+        admin = admin_check()
 
         if tool == 'inter_wiki':
-            div += '<td><a id="out_link" href="' + data[1] + '">' + html.escape(data[1]) + '</a></td>'
+            title = load_lang('interwiki_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'inter_wiki'"))
+        elif tool == 'email_filter':
+            title = load_lang('email_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'email'"))
+        elif tool == 'name_filter':
+            title = load_lang('id_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'name'"))
+        elif tool == 'edit_filter':
+            title = load_lang('edit_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'regex_filter'"))
+        elif tool == 'file_filter':
+            title = load_lang('file_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
+        elif tool == 'file_filter':
+            title = load_lang('file_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
+        elif tool == 'image_license':
+            title = load_lang('image_license_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'image_license'"))
+        elif tool == 'extension_filter':
+            title = load_lang('extension_filter_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'extension'"))
         else:
-            div += '<td>' + html.escape(data[1]) + '</td>'
-            
-        div += '<td>' + html.escape(data[2]) + '</td>'
-        div += '</tr>'
-        
-    div += '</table>'
-            
-    if admin == 1:
-        div += '<hr class="main_hr">'
-        div += '<a href="/' + tool + '/add">(' + load_lang('add') + ')</a>'
-
-    return easy_minify(flask.render_template(skin_check(),
-        imp = [title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
-        data = div,
-        menu = [['manager/1', load_lang('return')]]
-    ))
+            title = load_lang('edit_tool_list')
+
+            curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
+
+        db_data = curs.fetchall()
+        for data in db_data:
+            div += '<tr>'
+            div += '<td>'
+
+            div += data[0]
+            if admin == 1:
+                div += ' <a href="/' + tool + '/add/' + url_pas(data[0]) + '">(' + load_lang('edit') + ')</a>'
+                div += ' <a href="/' + tool + '/del/' + url_pas(data[0]) + '">(' + load_lang('delete') + ')</a>'
+
+            div += '</td>'
+
+            if tool == 'inter_wiki':
+                div += '<td><a id="out_link" href="' + data[1] + '">' + html.escape(data[1]) + '</a></td>'
+            else:
+                div += '<td>' + html.escape(data[1]) + '</td>'
+
+            div += '<td>' + html.escape(data[2]) + '</td>'
+            div += '</tr>'
+
+        div += '</table>'
+
+        if admin == 1:
+            div += '<hr class="main_hr">'
+            div += '<a href="/' + tool + '/add">(' + load_lang('add') + ')</a>'
+
+        return easy_minify(flask.render_template(skin_check(),
+            imp = [title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
+            data = div,
+            menu = [['manager/1', load_lang('return')]]
+        ))

+ 207 - 206
route/inter_wiki_add.py

@@ -1,236 +1,237 @@
 from .tool.func import *
 
-def inter_wiki_add(conn, tool, name):
-    curs = conn.cursor()
-    
-    if not name:
-        if tool == 'plus_edit_filter':
-            return redirect('/manager/9')
-
-    if flask.request.method == 'POST':
-        if tool == 'plus_inter_wiki':
-            if name:
-                curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [name])
-
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [
-                flask.request.form.get('title', 'test')
-            ])
-            curs.execute(db_change('insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, "inter_wiki")'), [
-                flask.request.form.get('title', 'test'),
-                flask.request.form.get('link', 'test'),
-                flask.request.form.get('icon', '')
-            ])
-
-            admin_check(None, 'inter_wiki_plus')
-        elif tool == 'plus_edit_filter':
-            if admin_check(None, 'edit_filter edit') != 1:
-                return re_error('/error/3')
-
-            if flask.request.form.get('second', '0') == '0':
-                end = 'X'
-            else:
-                end = flask.request.form.get('second', 'X')
+def inter_wiki_add(tool, name = None):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if not name:
+            if tool == 'plus_edit_filter':
+                return redirect('/manager/9')
 
-            try:
-                re.compile(flask.request.form.get('content', 'test'))
+        if flask.request.method == 'POST':
+            if tool == 'plus_inter_wiki':
+                if name:
+                    curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [name])
 
-                curs.execute(db_change("delete from html_filter where html = ? and kind = 'regex_filter'"), [name])
-                curs.execute(db_change("insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, 'regex_filter')"), [
-                    name,
-                    flask.request.form.get('content', 'test'),
-                    end
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [
+                    flask.request.form.get('title', 'test')
+                ])
+                curs.execute(db_change('insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, "inter_wiki")'), [
+                    flask.request.form.get('title', 'test'),
+                    flask.request.form.get('link', 'test'),
+                    flask.request.form.get('icon', '')
                 ])
-            except:
-                return re_error('/error/23')
-        else:
-            plus_d = ''
 
-            if tool == 'plus_name_filter':
-                try:
-                    re.compile(flask.request.form.get('title', 'test'))
-                except:
-                    return re_error('/error/23')
+                admin_check(None, 'inter_wiki_plus')
+            elif tool == 'plus_edit_filter':
+                if admin_check(None, 'edit_filter edit') != 1:
+                    return re_error('/error/3')
 
-                admin_check(None, 'name_filter edit')
+                if flask.request.form.get('second', '0') == '0':
+                    end = 'X'
+                else:
+                    end = flask.request.form.get('second', 'X')
 
-                type_d = 'name'
-            elif tool == 'plus_file_filter':
                 try:
-                    re.compile(flask.request.form.get('title', 'test'))
+                    re.compile(flask.request.form.get('content', 'test'))
+
+                    curs.execute(db_change("delete from html_filter where html = ? and kind = 'regex_filter'"), [name])
+                    curs.execute(db_change("insert into html_filter (html, plus, plus_t, kind) values (?, ?, ?, 'regex_filter')"), [
+                        name,
+                        flask.request.form.get('content', 'test'),
+                        end
+                    ])
                 except:
                     return re_error('/error/23')
+            else:
+                plus_d = ''
 
-                admin_check(None, 'file_filter edit')
+                if tool == 'plus_name_filter':
+                    try:
+                        re.compile(flask.request.form.get('title', 'test'))
+                    except:
+                        return re_error('/error/23')
 
-                type_d = 'file'
-            elif tool == 'plus_email_filter':
-                admin_check(None, 'email_filter edit')
+                    admin_check(None, 'name_filter edit')
 
-                type_d = 'email'
-            elif tool == 'plus_image_license':
-                admin_check(None, 'image_license edit')
+                    type_d = 'name'
+                elif tool == 'plus_file_filter':
+                    try:
+                        re.compile(flask.request.form.get('title', 'test'))
+                    except:
+                        return re_error('/error/23')
 
-                type_d = 'image_license'
-            elif tool == 'plus_extension_filter':
-                admin_check(None, 'extension_filter edit')
+                    admin_check(None, 'file_filter edit')
 
-                type_d = 'extension'
-            else:
-                admin_check(None, 'edit_top edit')
+                    type_d = 'file'
+                elif tool == 'plus_email_filter':
+                    admin_check(None, 'email_filter edit')
 
-                type_d = 'edit_top'
-                plus_d = flask.request.form.get('markup', 'test')
+                    type_d = 'email'
+                elif tool == 'plus_image_license':
+                    admin_check(None, 'image_license edit')
 
-            if name:
-                curs.execute(db_change("delete from html_filter where html = ? and kind = ?"), [
-                    name,
-                    type_d
-                ])
+                    type_d = 'image_license'
+                elif tool == 'plus_extension_filter':
+                    admin_check(None, 'extension_filter edit')
+
+                    type_d = 'extension'
+                else:
+                    admin_check(None, 'edit_top edit')
+
+                    type_d = 'edit_top'
+                    plus_d = flask.request.form.get('markup', 'test')
+
+                if name:
+                    curs.execute(db_change("delete from html_filter where html = ? and kind = ?"), [
+                        name,
+                        type_d
+                    ])
 
-            curs.execute(db_change('insert into html_filter (html, kind, plus) values (?, ?, ?)'), [
-                flask.request.form.get('title', 'test'),
-                type_d,
-                plus_d
-            ])
+                curs.execute(db_change('insert into html_filter (html, kind, plus) values (?, ?, ?)'), [
+                    flask.request.form.get('title', 'test'),
+                    type_d,
+                    plus_d
+                ])
 
-        conn.commit()
+            conn.commit()
 
-        return redirect('/' + re.sub(r'^plus_', '', tool))
-    else:
-        get_sub = 0
-        if admin_check() != 1:
-            stat = 'disabled'
+            return redirect('/' + re.sub(r'^plus_', '', tool))
         else:
-            stat = ''
+            get_sub = 0
+            if admin_check() != 1:
+                stat = 'disabled'
+            else:
+                stat = ''
+
+            if tool == 'plus_inter_wiki':
+                if name:
+                    curs.execute(db_change("select html, plus, plus_t from html_filter where html = ? and kind = 'inter_wiki'"), [name])
+                    exist = curs.fetchall()
+                    if exist:
+                        value = exist[0]
+                    else:
+                        value = ['', '', '']
+                else:
+                    value = ['', '', '']
 
-        if tool == 'plus_inter_wiki':
-            if name:
-                curs.execute(db_change("select html, plus, plus_t from html_filter where html = ? and kind = 'inter_wiki'"), [name])
+                title = load_lang('interwiki_add')
+                form_data = '''
+                    ''' + load_lang('name') + '''
+                    <hr class="main_hr">
+                    <input value="''' + html.escape(value[0]) + '''" type="text" name="title">
+                    <hr class="main_hr">
+                    ''' + load_lang('link') + '''
+                    <hr class="main_hr">
+                    <input value="''' + html.escape(value[1]) + '''" type="text" name="link">
+                    <hr class="main_hr">
+                    ''' + load_lang('icon') + ''' (HTML)
+                    <hr class="main_hr">
+                    <input value="''' + html.escape(value[2]) + '''" type="text" name="icon">
+                '''
+            elif tool == 'plus_edit_filter':            
+                curs.execute(db_change("select plus, plus_t from html_filter where html = ? and kind = 'regex_filter'"), [name])
                 exist = curs.fetchall()
                 if exist:
-                    value = exist[0]
-                else:
-                    value = ['', '', '']
-            else:
-                value = ['', '', '']
-
-            title = load_lang('interwiki_add')
-            form_data = '''
-                ''' + load_lang('name') + '''
-                <hr class="main_hr">
-                <input value="''' + html.escape(value[0]) + '''" type="text" name="title">
-                <hr class="main_hr">
-                ''' + load_lang('link') + '''
-                <hr class="main_hr">
-                <input value="''' + html.escape(value[1]) + '''" type="text" name="link">
-                <hr class="main_hr">
-                ''' + load_lang('icon') + ''' (HTML)
-                <hr class="main_hr">
-                <input value="''' + html.escape(value[2]) + '''" type="text" name="icon">
-            '''
-        elif tool == 'plus_edit_filter':            
-            curs.execute(db_change("select plus, plus_t from html_filter where html = ? and kind = 'regex_filter'"), [name])
-            exist = curs.fetchall()
-            if exist:
-                textarea = exist[0][0]
-
-                if exist[0][1] == 'X':
-                    time_check = 'checked="checked"'
-                    time_data = ''
+                    textarea = exist[0][0]
+
+                    if exist[0][1] == 'X':
+                        time_check = 'checked="checked"'
+                        time_data = ''
+                    else:
+                        time_check = ''
+                        time_data = exist[0][1]
                 else:
+                    textarea = ''
                     time_check = ''
-                    time_data = exist[0][1]
+                    time_data = ''
+
+                insert_data = ''
+                if stat == '':
+                    t_data = [
+                        ['86400', load_lang('1_day')],
+                        ['432000‬', load_lang('5_day')],
+                        ['2592000', load_lang('30_day')],
+                        ['15552000', load_lang('180_day')],
+                        ['31104000‬', load_lang('360_day')],
+                        ['0', load_lang('limitless')]
+                    ]
+                    for i in t_data:
+                        insert_data += '<a href="javascript:insert_v(\'second\', \'' + i[0] + '\')">(' + i[1] + ')</a> '
+
+                title = load_lang('edit_filter_add')
+                form_data = '''
+                    <script>function insert_v(name, data) { document.getElementById(name).value = data; }</script>''' + insert_data + '''
+                    <hr class="main_hr">
+                    <input ''' + stat + ''' placeholder="''' + load_lang('second') + '''" id="second" name="second" type="text" value="''' + html.escape(time_data) + '''">
+                    <hr class="main_hr">
+                    <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
+                '''
+            elif tool == 'plus_name_filter':
+                title = load_lang('id_filter_add')
+                form_data = '' + \
+                    load_lang('regex') + \
+                    '<hr class="main_hr">' + \
+                    '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
+                ''
+            elif tool == 'plus_file_filter':
+                title = load_lang('file_filter_add')
+                form_data = '' + \
+                    load_lang('regex') + \
+                    '<hr class="main_hr">' + \
+                    '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
+                ''
+            elif tool == 'plus_email_filter':
+                title = load_lang('email_filter_add')
+                form_data = '' + \
+                    load_lang('email') + \
+                    '<hr class="main_hr">' + \
+                    '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
+                ''
+            elif tool == 'plus_image_license':
+                title = load_lang('image_license_add')
+                form_data = '' + \
+                    load_lang('license') + \
+                    '<hr class="main_hr">' + \
+                    '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
+                ''
+            elif tool == 'plus_extension_filter':
+                title = load_lang('extension_filter_add')
+                form_data = '' + \
+                    load_lang('extension') + \
+                    '<hr class="main_hr">' + \
+                    '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
+                ''
             else:
-                textarea = ''
-                time_check = ''
-                time_data = ''
-
-            insert_data = ''
-            if stat == '':
-                t_data = [
-                    ['86400', load_lang('1_day')],
-                    ['432000‬', load_lang('5_day')],
-                    ['2592000', load_lang('30_day')],
-                    ['15552000', load_lang('180_day')],
-                    ['31104000‬', load_lang('360_day')],
-                    ['0', load_lang('limitless')]
-                ]
-                for i in t_data:
-                    insert_data += '<a href="javascript:insert_v(\'second\', \'' + i[0] + '\')">(' + i[1] + ')</a> '
-
-            title = load_lang('edit_filter_add')
-            form_data = '''
-                <script>function insert_v(name, data) { document.getElementById(name).value = data; }</script>''' + insert_data + '''
-                <hr class="main_hr">
-                <input ''' + stat + ''' placeholder="''' + load_lang('second') + '''" id="second" name="second" type="text" value="''' + html.escape(time_data) + '''">
-                <hr class="main_hr">
-                <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
-            '''
-        elif tool == 'plus_name_filter':
-            title = load_lang('id_filter_add')
-            form_data = '' + \
-                load_lang('regex') + \
-                '<hr class="main_hr">' + \
-                '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
-            ''
-        elif tool == 'plus_file_filter':
-            title = load_lang('file_filter_add')
-            form_data = '' + \
-                load_lang('regex') + \
-                '<hr class="main_hr">' + \
-                '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
-            ''
-        elif tool == 'plus_email_filter':
-            title = load_lang('email_filter_add')
-            form_data = '' + \
-                load_lang('email') + \
-                '<hr class="main_hr">' + \
-                '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
-            ''
-        elif tool == 'plus_image_license':
-            title = load_lang('image_license_add')
-            form_data = '' + \
-                load_lang('license') + \
-                '<hr class="main_hr">' + \
-                '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
-            ''
-        elif tool == 'plus_extension_filter':
-            title = load_lang('extension_filter_add')
-            form_data = '' + \
-                load_lang('extension') + \
-                '<hr class="main_hr">' + \
-                '<input value="' + html.escape(name if name else '') + '" type="text" name="title">' + \
-            ''
-        else:
-            title = load_lang('edit_tool_add')
-            if name:
-                curs.execute(db_change("select plus from html_filter where html = ? and kind = 'edit_top'"), [name])
-                exist = curs.fetchall()
-                if exist:
-                    value = exist[0][0]
+                title = load_lang('edit_tool_add')
+                if name:
+                    curs.execute(db_change("select plus from html_filter where html = ? and kind = 'edit_top'"), [name])
+                    exist = curs.fetchall()
+                    if exist:
+                        value = exist[0][0]
+                    else:
+                        value = ''
                 else:
                     value = ''
-            else:
-                value = ''
-
-            form_data = '''
-                ''' + load_lang('title') + '''
-                <hr class="main_hr">
-                <input value="''' + html.escape(name if name else '') + '''" type="text" name="title">
-                <hr class="main_hr">
-                ''' + load_lang('markup') + '''
-                <hr class="main_hr">
-                <input value="''' + html.escape(value) + '''" type="text" name="markup">
-            '''
-
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [title, wiki_set(), wiki_custom(), wiki_css([get_sub, 0])],
-            data =  '''
-                    <form method="post">
-                        ''' + form_data + '''
-                        <hr class="main_hr">
-                        <button ''' + stat + ''' type="submit">''' + load_lang('add') + '''</button>
-                    </form>
-                    ''',
-            menu = [[re.sub('^plus_', '', tool), load_lang('return')]]
-        ))
+
+                form_data = '''
+                    ''' + load_lang('title') + '''
+                    <hr class="main_hr">
+                    <input value="''' + html.escape(name if name else '') + '''" type="text" name="title">
+                    <hr class="main_hr">
+                    ''' + load_lang('markup') + '''
+                    <hr class="main_hr">
+                    <input value="''' + html.escape(value) + '''" type="text" name="markup">
+                '''
+
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [title, wiki_set(), wiki_custom(), wiki_css([get_sub, 0])],
+                data =  '''
+                        <form method="post">
+                            ''' + form_data + '''
+                            <hr class="main_hr">
+                            <button ''' + stat + ''' type="submit">''' + load_lang('add') + '''</button>
+                        </form>
+                        ''',
+                menu = [[re.sub('^plus_', '', tool), load_lang('return')]]
+            ))

+ 24 - 23
route/inter_wiki_del.py

@@ -1,28 +1,29 @@
 from .tool.func import *
 
-def inter_wiki_del(conn, tool, name):
-    curs = conn.cursor()
+def inter_wiki_del(tool, name = 'Test'):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    if admin_check(None, tool) == 1:
-        if tool == 'del_inter_wiki':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [name])
-        elif tool == 'del_edit_filter':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'regex_filter'"), [name])
-        elif tool == 'del_name_filter':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'name'"), [name])
-        elif tool == 'del_file_filter':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'file'"), [name])
-        elif tool == 'del_email_filter':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'email'"), [name])
-        elif tool == 'del_image_license':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'image_license'"), [name])
-        elif tool == 'del_extension_filter':
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'extension'"), [name])
-        else:
-            curs.execute(db_change("delete from html_filter where html = ? and kind = 'edit_top'"), [name])
+        if admin_check(None, tool) == 1:
+            if tool == 'del_inter_wiki':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'inter_wiki'"), [name])
+            elif tool == 'del_edit_filter':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'regex_filter'"), [name])
+            elif tool == 'del_name_filter':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'name'"), [name])
+            elif tool == 'del_file_filter':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'file'"), [name])
+            elif tool == 'del_email_filter':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'email'"), [name])
+            elif tool == 'del_image_license':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'image_license'"), [name])
+            elif tool == 'del_extension_filter':
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'extension'"), [name])
+            else:
+                curs.execute(db_change("delete from html_filter where html = ? and kind = 'edit_top'"), [name])
 
-        conn.commit()
+            conn.commit()
 
-        return redirect('/' + re.sub(r'^del_', '', tool))
-    else:
-        return re_error('/error/3')
+            return redirect('/' + re.sub(r'^del_', '', tool))
+        else:
+            return re_error('/error/3')

+ 1 - 3
route/main_error_404.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_error_404_2(conn):
-    curs = conn.cursor()
-
+def main_error_404(e):
     if os.path.exists('404.html') and flask.request.path != '/':
         return open('404.html', encoding='utf8').read()
     else:

+ 1 - 3
route/main_easter_egg.py → route/main_func_easter_egg.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_easter_egg_2(conn):
-    curs = conn.cursor()
-
+def main_func_easter_egg(conn):
     return easy_minify(flask.render_template(skin_check(),
         imp = ['easter_egg.html', wiki_set(), wiki_custom(), wiki_css([0, 0])],
         data = open('./views/main_css/file/easter_egg.html', encoding='utf8').read(),

+ 13 - 0
route/main_func_random.py

@@ -0,0 +1,13 @@
+from .tool.func import *
+
+def main_func_random():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        curs.execute(db_change("" + \
+            "select title from data " + \
+            "where title not like 'user:%' and title not like 'category:%' and title not like 'file:%' " + \
+            "order by random() limit 1" + \
+        ""))
+        data = curs.fetchall()
+        return redirect('/w/' + url_pas(data[0][0])) if data else redirect()

+ 756 - 0
route/main_func_setting.py

@@ -0,0 +1,756 @@
+from .tool.func import *
+
+def main_func_setting(db_set, num = 0):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if not (num == 0 or num == 8) and admin_check() != 1:
+            return re_error('/ban')
+
+        if num == 0:
+            li_list = [
+                [1, load_lang('main_setting')],
+                [2, load_lang('text_setting')],
+                [5, 'robots.txt'],
+                [6, load_lang('ext_api_req_set')],
+                [3, load_lang('main_head')],
+                [4, load_lang('main_body')],
+                [7, load_lang('main_bottom_body')]
+            ]
+
+            li_data = ''.join(['<li><a href="/setting/' + str(li[0]) + '">' + li[1] + '</a></li>' for li in li_list])
+
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                data = '<h2>' + load_lang('list') + '</h2><ul class="inside_ul">' + li_data + '</ul>',
+                menu = [['manager', load_lang('return')]]
+            ))
+        elif num == 1:
+            i_list = {
+                0 : 'name',
+                2 : 'frontpage',
+                4 : 'upload',
+                5 : 'skin',
+                7 : 'reg',
+                8 : 'ip_view',
+                9 : 'back_up',
+                10 : 'port',
+                11 : 'key',
+                12 : 'update',
+                15 : 'encode',
+                16 : 'host',
+                19 : 'slow_edit',
+                20 : 'requires_approval',
+                21 : 'backup_where',
+                22 : 'domain',
+                23 : 'ua_get'
+            }
+            n_list = {
+                0 : 'Wiki',
+                2 : 'FrontPage',
+                4 : '2',
+                5 : '',
+                7 : '',
+                8 : '',
+                9 : '0',
+                10 : '3000',
+                11 : 'test',
+                12 : 'stable',
+                15 : 'sha3',
+                16 : '0.0.0.0',
+                19 : '0',
+                20 : '',
+                21 : '',
+                22 : flask.request.host_url,
+                23 : ''
+            }
+
+            if flask.request.method == 'POST':
+                for i in i_list:
+                    curs.execute(db_change("update other set data = ? where name = ?"), [
+                        flask.request.form.get(i_list[i], n_list[i]),
+                        i_list[i]
+                    ])
+
+                conn.commit()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/1')
+            else:
+                d_list = {}
+
+                for i in i_list:
+                    curs.execute(db_change('select data from other where name = ?'), [i_list[i]])
+                    sql_d = curs.fetchall()
+                    if sql_d:
+                        d_list[i] = sql_d[0][0]
+                    else:
+                        curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i_list[i], n_list[i]])
+
+                        d_list[i] = n_list[i]
+
+                conn.commit()
+
+                acl_div = ['']
+                encode_data = ['sha256', 'sha3']
+                for acl_data in encode_data:
+                    if acl_data == d_list[15]:
+                        acl_div[0] = '<option value="' + acl_data + '">' + acl_data + '</option>' + acl_div[0]
+                    else:
+                        acl_div[0] += '<option value="' + acl_data + '">' + acl_data + '</option>'
+
+                check_box_div = ['', '', '', '', '']
+                for i in range(0, len(check_box_div)):
+                    if i == 0:
+                        acl_num = 7
+                    elif i == 1:
+                        acl_num = 8
+                    elif i == 3:
+                        acl_num = 20
+                    else:
+                        acl_num = 23
+
+                    if d_list[acl_num]:
+                        check_box_div[i] = 'checked="checked"'
+
+                branch_div = ''
+                branch_list = ['stable', 'dev', 'beta']
+                for i in branch_list:
+                    if d_list[12] == i:
+                        branch_div = '<option value="' + i + '">' + i + '</option>' + branch_div
+                    else:
+                        branch_div += '<option value="' + i + '">' + i + '</option>'
+
+                sqlite_only = 'style="display:none;"' if db_set != 'sqlite' else ''
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang('main_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <form method="post" id="main_set_data">
+                            <h2>1. ''' + load_lang('basic_set') + '''</h2>
+                            <span>''' + load_lang('wiki_name') + '''</span>
+                            <hr class="main_hr">
+                            <input name="name" value="''' + html.escape(d_list[0]) + '''">
+                            <hr class="main_hr">
+
+                            <span><a href="/setting/9">(''' + load_lang('wiki_logo') + ''')</a></span>
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('main_page') + '''</span>
+                            <hr class="main_hr">
+                            <input name="frontpage" value="''' + html.escape(d_list[2]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('domain') + '''</span> (EX : http://2du.pythonanywhere.com/)
+                            <hr class="main_hr">
+                            <input name="''' + i_list[22] + '''" value="''' + html.escape(d_list[22]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('wiki_host') + '''</span>
+                            <hr class="main_hr">
+                            <input name="host" value="''' + html.escape(d_list[16]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('wiki_port') + '''</span>
+                            <hr class="main_hr">
+                            <input name="port" value="''' + html.escape(d_list[10]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('wiki_secret_key') + '''</span>
+                            <hr class="main_hr">
+                            <input type="password" name="key" value="''' + html.escape(d_list[11]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('encryption_method') + '''</span>
+                            <hr class="main_hr">
+                            <select name="encode">''' + acl_div[0] + '''</select>
+
+                            <h2>2. ''' + 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 'tenshi') + '''</select>
+
+                            <h2>3. ''' + load_lang('login_set') + '''</h2>
+                            <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''
+                            <hr class="main_hr">
+
+                            <input type="checkbox" name="ip_view" ''' + check_box_div[1] + '''> ''' + load_lang('hide_ip') + '''
+                            <hr class="main_hr">
+
+                            <input type="checkbox" name="requires_approval" ''' + check_box_div[3] + '''> ''' + load_lang('requires_approval') + '''
+                            <hr class="main_hr">
+
+                            <input type="checkbox" name="ua_get" ''' + check_box_div[4] + '''> ''' + load_lang('ua_get_off') + '''
+
+                            <h2>4. ''' + load_lang('server_set') + '''</h2>
+                            <span>''' + load_lang('max_file_size') + ''' (MB)</span>
+                            <hr class="main_hr">
+                            <input name="upload" value="''' + html.escape(d_list[4]) + '''">
+                            <hr class="main_hr">
+
+                            <span ''' + sqlite_only + '''>
+                                <span>
+                                    ''' + load_lang('backup_interval') + ' (' + load_lang('hour') + ') (' + load_lang('off') + ' : 0) ' + \
+                                    '(' + load_lang('restart_required') + ''')</span>
+                                <hr class="main_hr">
+                                <input name="back_up" value="''' + html.escape(d_list[9]) + '''">
+                                <hr class="main_hr">
+
+                                <span>
+                                    ''' + load_lang('backup_where') + ' (' + load_lang('empty') + ' : ' + load_lang('default') + ') ' + \
+                                    '(' + load_lang('restart_required') + ''') (EX : ./data/backup.db)
+                                </span>
+                                <hr class="main_hr">
+                                <input name="backup_where" value="''' + html.escape(d_list[21]) + '''">
+                                <hr class="main_hr">
+                            </span>
+
+                            <span>''' + load_lang('update_branch') + '''</span>
+                            <hr class="main_hr">
+                            <select name="update">''' + branch_div + '''</select>
+
+                            <h2>5. ''' + load_lang('edit_set') + '''</h2>
+                            <span><a href="/setting/8">(''' + load_lang('main_acl_setting') + ''')</a></span>
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('slow_edit') + ' (' + load_lang('second') + ') (' + load_lang('off') + ''' : 0)</span>
+                            <hr class="main_hr">
+                            <input name="''' + i_list[19] + '''" value="''' + html.escape(d_list[19]) + '''">
+
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                        <script>simple_render('main_set_data');</script>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 2:
+            i_list = [
+                'contract',
+                'no_login_warning',
+                'edit_bottom_text',
+                'copyright_checkbox_text',
+                'check_key_text',
+                'email_title',
+                'email_text',
+                'email_insert_text',
+                'password_search_text',
+                'reset_user_text',
+                'error_401',
+                'error_404',
+                'approval_question',
+                'edit_help',
+                'upload_help',
+                'upload_default',
+                'license'
+            ]
+            if flask.request.method == 'POST':
+                for i in i_list:
+                    curs.execute(db_change("update other set data = ? where name = ?"), [
+                        flask.request.form.get(i, ''),
+                        i
+                    ])
+
+                conn.commit()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/2')
+            else:
+                d_list = []
+
+                for i in i_list:
+                    curs.execute(db_change('select data from other where name = ?'), [i])
+                    sql_d = curs.fetchall()
+                    if sql_d:
+                        d_list += [sql_d[0][0]]
+                    else:
+                        curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i, ''])
+
+                        d_list += ['']
+
+                conn.commit()
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang('text_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <form method="post" id="main_set_data">
+                            <h2>1. ''' + load_lang('register_text') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[0] + '''">''' + html.escape(d_list[0]) + '''</textarea>
+
+                            <h2>2. ''' + load_lang('non_login_alert') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[1] + '''">''' + html.escape(d_list[1]) + '''</textarea>
+
+                            <h2>3. ''' + load_lang('edit_bottom_text') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[2] + '''">''' + html.escape(d_list[2]) + '''</textarea>
+
+                            <h2>4. ''' + load_lang('copyright_checkbox_text') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[3] + '''">''' + html.escape(d_list[3]) + '''</textarea>
+
+                            <h2>5. ''' + load_lang('check_key_text') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[4] + '''">''' + html.escape(d_list[4]) + '''</textarea>
+
+                            <h2>6. ''' + load_lang('email_title') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[5] + '''">''' + html.escape(d_list[5]) + '''</textarea>
+
+                            <h2>7. ''' + load_lang('email_text') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[6] + '''">''' + html.escape(d_list[6]) + '''</textarea>
+
+                            <h2>8. ''' + load_lang('email_insert_text') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[7] + '''">''' + html.escape(d_list[7]) + '''</textarea>
+
+                            <h2>9. ''' + load_lang('password_search_text') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[8] + '''">''' + html.escape(d_list[8]) + '''</textarea>
+
+                            <h2>10. ''' + load_lang('reset_user_text') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[9] + '''">''' + html.escape(d_list[9]) + '''</textarea>
+
+                            <h2>11. ''' + load_lang('error_401') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[10] + '''">''' + html.escape(d_list[10]) + '''</textarea>
+
+                            <h2>12. ''' + load_lang('error_404') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[11] + '''">''' + html.escape(d_list[11]) + '''</textarea>
+
+                            <h2>13. ''' + load_lang('approval_question') + '''</h2>
+                            <sup>(1)</sup>
+                            <hr class="main_hr">
+                            <textarea rows="3" name="''' + i_list[12] + '''">''' + html.escape(d_list[12]) + '''</textarea>
+
+                            <h2>14. ''' + load_lang('edit_help') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[13] + '''">''' + html.escape(d_list[13]) + '''</textarea>
+
+                            <h2>15. ''' + load_lang('upload_help') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[14] + '''">''' + html.escape(d_list[14]) + '''</textarea>
+
+                            <h2>16. ''' + load_lang('upload_default') + '''</h2>
+                            <textarea rows="3" name="''' + i_list[15] + '''">''' + html.escape(d_list[15]) + '''</textarea>
+
+                            <h2>17. ''' + load_lang('bottom_text') + ''' (HTML)</h2>
+                            <textarea rows="3" name="''' + i_list[16] + '''">''' + html.escape(d_list[16]) + '''</textarea>
+
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                        <ul id="footnote_data">
+                            <li><a href="#note_1" id="note_1_end">(1)</a> ''' + load_lang('approval_question_visible_only_when_approval_on') + '''</li>
+                        </ul>
+                        <script>simple_render('main_set_data');</script>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 3 or num == 4 or num == 7:
+            if flask.request.method == 'POST':
+                if num == 4:
+                    info_d = 'body'
+                    end_r = '4'
+                    coverage = ''
+                elif num == 7:
+                    info_d = 'bottom_body'
+                    end_r = '7'
+                    coverage = ''
+                else:
+                    info_d = 'head'
+                    end_r = '3'
+                    if flask.request.args.get('skin', '') == '':
+                        coverage = ''
+                    else:
+                        coverage = flask.request.args.get('skin', '')
+
+                curs.execute(db_change("select name from other where name = ? and coverage = ?"), [info_d, coverage])
+                if curs.fetchall():
+                    curs.execute(db_change("update other set data = ? where name = ? and coverage = ?"), [
+                        flask.request.form.get('content', ''),
+                        info_d,
+                        coverage
+                    ])
+                else:
+                    curs.execute(db_change("insert into other (name, data, coverage) values (?, ?, ?)"), [info_d, flask.request.form.get('content', ''), coverage])
+
+                conn.commit()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/' + end_r + '?skin=' + flask.request.args.get('skin', ''))
+            else:
+                if num == 4:
+                    curs.execute(db_change("select data from other where name = 'body'"))
+                    title = '_body'
+                    start = ''
+                    plus = '''
+                        <button id="preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
+                        <hr class="main_hr">
+                        <div id="see_preview"></div>
+                    '''
+                elif num == 7:
+                    curs.execute(db_change("select data from other where name = 'bottom_body'"))
+                    title = '_bottom_body'
+                    start = ''
+                    plus = '''
+                        <button id="preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
+                        <hr class="main_hr">
+                        <div id="see_preview"></div>
+                    '''
+                else:
+                    curs.execute(db_change("select data from other where name = 'head' and coverage = ?"), [flask.request.args.get('skin', '')])
+                    title = '_head'
+                    start = '' + \
+                        '<a href="?">(' + load_lang('all') + ')</a> ' + \
+                        ' '.join(['<a href="?skin=' + i + '">(' + i + ')</a>' for i in load_skin('', 1)]) + '''
+                        <hr class="main_hr">
+                        <span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span>
+                        <hr class="main_hr">
+                    '''
+                    plus = ''
+
+                head = curs.fetchall()
+                if head:
+                    data = head[0][0]
+                else:
+                    data = ''
+
+                if flask.request.args.get('skin', '') != '':
+                    sub_plus = ' (' + flask.request.args.get('skin', '') + ')'
+                else:
+                    sub_plus = ''
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang(data = 'main' + title, safe = 1), wiki_set(), wiki_custom(), wiki_css(['(HTML)' + sub_plus, 0])],
+                    data = '''
+                        <form method="post">
+                            ''' + start + '''
+                            <textarea rows="25" placeholder="''' + load_lang('enter_html') + '''" name="content" id="content">''' + html.escape(data) + '''</textarea>
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                            ''' + plus + '''
+                        </form>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 5:
+            if flask.request.method == 'POST':
+                curs.execute(db_change("select name from other where name = 'robot'"))
+                if curs.fetchall():
+                    curs.execute(db_change("update other set data = ? where name = 'robot'"), [flask.request.form.get('content', '')])
+                else:
+                    curs.execute(db_change("insert into other (name, data) values ('robot', ?)"), [flask.request.form.get('content', '')])
+
+                conn.commit()
+
+                fw = open('./robots.txt', 'w', encoding='utf8')
+                fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', '')))
+                fw.close()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/5')
+            else:
+                if not os.path.exists('robots.txt'):
+                    curs.execute(db_change('select data from other where name = "robot"'))
+                    robot_test = curs.fetchall()
+                    if robot_test:
+                        fw_test = open('./robots.txt', 'w', encoding='utf8')
+                        fw_test.write(re.sub('\r\n', '\n', robot_test[0][0]))
+                        fw_test.close()
+                    else:
+                        fw_test = open('./robots.txt', 'w', encoding='utf8')
+                        fw_test.write('User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/')
+                        fw_test.close()
+
+                        curs.execute(db_change('insert into other (name, data) values ("robot", "User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/")'))
+
+                curs.execute(db_change("select data from other where name = 'robot'"))
+                robot = curs.fetchall()
+                if robot:
+                    data = robot[0][0]
+                else:
+                    data = ''
+
+                f = open('./robots.txt', encoding='utf8')
+                lines = f.readlines()
+                f.close()
+
+                if not data or data == '':
+                    data = ''.join(lines)
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = ['robots.txt', wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <a href="/robots.txt">(''' + load_lang('view') + ''')</a>
+                        <hr class="main_hr">
+                        <form method="post">
+                            <textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 6:
+            i_list = [
+                'recaptcha',
+                'sec_re',
+                'smtp_server',
+                'smtp_port',
+                'smtp_security',
+                'smtp_email',
+                'smtp_pass',
+                'recaptcha_ver',
+                'oauth_client_id',
+                'email_have'
+            ]
+
+            if flask.request.method == 'POST':
+                for data in i_list:
+                    into_data = flask.request.form.get(data, '')
+
+                    curs.execute(db_change("update other set data = ? where name = ?"), [into_data, data])
+
+                conn.commit()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/6')
+            else:
+                d_list = []
+
+                x = 0
+
+                for i in i_list:
+                    curs.execute(db_change('select data from other where name = ?'), [i])
+                    sql_d = curs.fetchall()
+                    if sql_d:
+                        d_list += [sql_d[0][0]]
+                    else:
+                        curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i, ''])
+
+                        d_list += ['']
+
+                    x += 1
+
+                conn.commit()
+
+                security_radios = ''
+                for i in ['tls', 'starttls', 'plain']:
+                    security_radios += '<input name="smtp_security" type="radio" value="' + i + '" ' + ('checked' if d_list[4] == i else '') + '>' + i + '<hr class="main_hr">'
+
+                re_ver = ''
+                if d_list[7] == '':
+                    re_ver += '<option value="">v2</option><option value="v3">v3</option>'
+                else:
+                    re_ver += '<option value="v3">v3</option><option value="">v2</option>'
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang('ext_api_req_set'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <form method="post" id="main_set_data">
+                            <h2>1. ''' + load_lang('recaptcha') + '''</h2>
+                            <a href="https://www.google.com/recaptcha/admin">(Google)</a>
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('public_key') + '''</span>
+                            <hr class="main_hr">
+                            <input name="recaptcha" value="''' + html.escape(d_list[0]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('secret_key') + '''</span>
+                            <hr class="main_hr">
+                            <input name="sec_re" value="''' + html.escape(d_list[1]) + '''">
+                            <hr class="main_hr">
+
+                            <select name="recaptcha_ver">
+                                ''' + re_ver + '''
+                            </select>
+
+                            <h2>2. ''' + load_lang('email_setting') + '''</h1>
+                            <input type="checkbox" name="email_have" ''' + ('checked' if d_list[9] != '' else '')  + '''> ''' + \
+                                 load_lang('email_required') + '''
+
+                            <h2>2.1. ''' + load_lang('smtp_setting') + '''</h1>
+                            <a href="https://support.google.com/mail/answer/7126229">(Google)</a>
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('smtp_server') + '''</span>
+                            <hr class="main_hr">
+                            <input name="smtp_server" value="''' + html.escape(d_list[2]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('smtp_port') + '''</span>
+                            <hr class="main_hr">
+                            <input name="smtp_port" value="''' + html.escape(d_list[3]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('smtp_security') + '''</span>
+                            <hr class="main_hr">
+                            ''' + security_radios + '''
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('smtp_username') + '''</span>
+                            <hr class="main_hr">
+                            <input name="smtp_email" value="''' + html.escape(d_list[5]) + '''">
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('smtp_password') + '''</span>
+                            <hr class="main_hr">
+                            <input type="password" name="smtp_pass" value="''' + html.escape(d_list[6]) + '''">
+
+                            <h2>3. ''' + load_lang('oauth') + '''</h2>
+                            <a href="https://developers.google.com/identity/protocols/oauth2">(Google)</a>
+                            <hr class="main_hr">
+
+                            <span>''' + load_lang('oauth_client_id') + '''</span>
+                            <hr class="main_hr">
+                            <input name="oauth_client_id" value="''' + html.escape(d_list[8]) + '''">
+                            <hr class="main_hr">
+
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                        <script>simple_render('main_set_data');</script>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 8:
+            i_list = {
+                1 : 'edit',
+                2 : 'discussion',
+                3 : 'upload_acl',
+                4 : 'all_view_acl',
+                5 : 'many_upload_acl',
+                6 : 'vote_acl'
+            }
+
+            if flask.request.method == 'POST':
+                if admin_check(None, 'edit_set (' + str(num) + ')') != 1:
+                    return re_error('/ban')
+                else:
+                    for i in i_list:
+                        curs.execute(db_change("update other set data = ? where name = ?"), [
+                            flask.request.form.get(i_list[i], 'normal'),
+                            i_list[i]
+                        ])
+
+                    conn.commit()
+
+                    return redirect('/setting/8')
+            else:
+                d_list = {}
+
+                if admin_check() != 1:
+                    disable = 'disabled'
+                else:
+                    disable = ''
+
+                for i in i_list:
+                    curs.execute(db_change('select data from other where name = ?'), [i_list[i]])
+                    sql_d = curs.fetchall()
+                    if sql_d:
+                        d_list[i] = sql_d[0][0]
+                    else:
+                        curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i_list[i], 'normal'])
+
+                        d_list[i] = 'normal'
+
+                conn.commit()
+
+                acl_div = []
+                for i in range(0, len(i_list)):
+                    acl_div += ['']
+
+                acl_list = get_acl_list()
+                for i in range(0, len(i_list)):
+                    for data_list in acl_list:
+                        if data_list == d_list[i + 1]:
+                            check = 'selected="selected"'
+                        else:
+                            check = ''
+
+                        acl_div[i] += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang('main_acl_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <form method="post">
+                            <a href="/acl/TEST#exp">(''' + load_lang('reference') + ''')</a>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('document_acl') + '''</span> 
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="edit">''' + acl_div[0] + '''</select>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('discussion_acl') + '''</span>
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="discussion">''' + acl_div[1] + '''</select>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('upload_acl') + '''</span>
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="upload_acl">''' + acl_div[2] + '''</select>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('view_acl') + '''</span>
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="all_view_acl">''' + acl_div[3] + '''</select>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('many_upload_acl') + '''</span>
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="many_upload_acl">''' + acl_div[4] + '''</select>
+                            <hr class="main_hr">
+                            <span>''' + load_lang('vote_acl') + '''</span>
+                            <hr class="main_hr">
+                            <select ''' + disable + ''' name="vote_acl">''' + acl_div[5] + '''</select>
+                            <hr class="main_hr">
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        elif num == 9:
+            skin_list = [0] + load_skin('', 1)
+            i_list = []
+            for i in skin_list:
+                i_list += [['logo', '' if i == 0 else i]]
+
+            if flask.request.method == 'POST':
+                for i in i_list:
+                    curs.execute(db_change("update other set data = ? where name = ? and coverage = ?"), [
+                        flask.request.form.get(('main_css' if i[1] == '' else i[1]), ''),
+                        i[0], 
+                        i[1]
+                    ])
+
+                conn.commit()
+
+                admin_check(None, 'edit_set (' + str(num) + ')')
+
+                return redirect('/setting/9')
+            else:
+                d_list = []
+                for i in i_list:
+                    curs.execute(db_change('select data from other where name = ? and coverage = ?'), [i[0], i[1]])
+                    sql_d = curs.fetchall()
+                    if sql_d:
+                        d_list += [sql_d[0][0]]
+                    else:
+                        curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, ?)'), [i[0], '', i[1]])
+
+                        d_list += ['']
+
+                end_data = ''
+                for i in range(0, len(skin_list)):
+                    end_data += '' + \
+                        '<span>' + load_lang('wiki_logo') + ' ' + ('(' + skin_list[i] + ')' if skin_list[i] != 0 else '') + ' (HTML)' + \
+                        '<hr class="main_hr">' + \
+                        '<input name="' + (skin_list[i] if skin_list[i] != 0 else 'main_css') + '" value="' + html.escape(d_list[i]) + '">' + \
+                        '<hr class="main_hr">' + \
+                    ''
+
+                return easy_minify(flask.render_template(skin_check(),
+                    imp = [load_lang('wiki_logo'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                    data = '''
+                        <form method="post">
+                            ''' + end_data + '''
+                            <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                        </form>
+                    ''',
+                    menu = [['setting', load_lang('return')]]
+                ))
+        else:
+            return redirect()

+ 18 - 0
route/main_func_skin_set.py

@@ -0,0 +1,18 @@
+from .tool.func import *
+
+def main_func_skin_set(conn):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        data = flask.make_response(re_error('/error/5'))
+
+        curs.execute(db_change("select data from other where name = 'language'"))
+        main_data = curs.fetchall()
+
+        data.set_cookie('language', main_data[0][0])
+
+        curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip_check()])
+        user_data = curs.fetchall()
+        data.set_cookie('user_language', user_data[0][0] if user_data else main_data[0][0])
+
+        return data

+ 154 - 0
route/main_func_upload.py

@@ -0,0 +1,154 @@
+from .tool.func import *
+
+def main_func_upload():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if acl_check(None, 'upload') == 1:
+            return re_error('/ban')
+
+        if flask.request.method == 'POST':
+            if captcha_post(flask.request.form.get('g-recaptcha-response', flask.request.form.get('g-recaptcha', ''))) == 1:
+                return re_error('/error/13')
+            else:
+                captcha_post('', 0)
+
+            file_data = flask.request.files.getlist("f_data[]", None)
+            if not file_data:
+                return re_error('/error/9')
+
+            file_len = len(file_data)
+
+            if (int(wiki_set(3)) * 1000 * 1000 * file_len) < flask.request.content_length:
+                return re_error('/error/17')
+
+            if file_len == 1:    
+                file_num = None
+            else:
+                if acl_check(None, 'many_upload') == 1:
+                    return re_error('/ban')
+
+                file_num = 1
+
+            for data in file_data:
+                value = os.path.splitext(data.filename)[1]
+
+                curs.execute(db_change("select html from html_filter where kind = 'extension'"))
+                extension = [i[0].lower() for i in curs.fetchall()]
+                if not re.sub(r'^\.', '', value).lower() in extension:
+                    return re_error('/error/14')
+
+                if flask.request.form.get('f_name', None):
+                    name = flask.request.form.get('f_name', None) + (' ' + str(file_num) if file_num else '') + value
+                else:
+                    name = data.filename
+
+                piece = os.path.splitext(name)
+                if re.search(r'[^ㄱ-힣0-9a-zA-Z_\- ]', piece[0]):
+                    return re_error('/error/22')
+
+                e_data = sha224_replace(piece[0]) + piece[1]
+
+                curs.execute(db_change("select title from data where title = ?"), ['file:' + name])
+                if curs.fetchall():
+                    return re_error('/error/16')
+
+                curs.execute(db_change("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')
+
+                data_url_image = load_image_url()
+                if os.path.exists(os.path.join(data_url_image, e_data)):
+                    return re_error('/error/16')
+                else:
+                    data.save(os.path.join(data_url_image, e_data))
+
+                ip = ip_check()
+                g_lice = flask.request.form.get('f_lice', '')
+                file_size = os.stat(os.path.join(data_url_image, e_data)).st_size
+                file_size = str(round(file_size / 1000, 1))
+
+                curs.execute(db_change("select data from other where name = 'markup'"))
+                db_data = curs.fetchall()
+                if db_data and db_data[0][0] == 'namumark':
+                    file_d = '' + \
+                        flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
+                        '[[category:' + re.sub(r'\]', '_', flask.request.form.get('f_lice_sel', '')) + ']]\n' + \
+                        (g_lice if g_lice != '' else '') + \
+                    ''
+                else:
+                    file_d = '' + \
+                        flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
+                        (g_lice if g_lice != '' else '') + \
+                    ''
+
+                curs.execute(db_change("insert into data (title, data) values (?, ?)"), ['file:' + name, file_d])
+                curs.execute(db_change("insert into acl (title, data, type) values (?, 'admin', 'decu')"), ['file:' + name])
+
+                render_set(
+                    doc_name = 'file:' + name,
+                    doc_data = file_d,
+                    data_type = 'backlink'
+                )
+
+                history_plus(
+                    'file:' + name,
+                    file_d,
+                    get_time(),
+                    ip,
+                    '',
+                    '0',
+                    t_check = 'upload',
+                    mode = 'upload'
+                )
+
+                if file_num:
+                    file_num += 1
+
+            conn.commit()
+
+            return redirect('/w/file:' + name)
+        else:
+            license_list = '<option value="direct_input">' + load_lang('direct_input') + '</option>'
+            file_name = flask.request.args.get('name', '')
+
+            curs.execute(db_change("select html from html_filter where kind = 'image_license'"))
+            db_data = curs.fetchall()
+            license_list += ''.join(['<option value="' + i[0] + '">' + i[0] + '</option>' for i in db_data])
+
+            curs.execute(db_change("select data from other where name = 'upload_help'"))
+            db_data = curs.fetchall()
+            upload_help = ('<hr class="main_hr">' + db_data[0][0]) if db_data and db_data[0][0] != '' else ''
+
+            curs.execute(db_change("select data from other where name = 'upload_default'"))
+            db_data = curs.fetchall()
+            upload_default = html.escape(db_data[0][0]) if db_data and db_data[0][0] != '' else ''
+
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('upload'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                data = '''
+                    <a href="/file_filter">(''' + load_lang('file_filter_list') + ''')</a> <a href="/extension_filter">(''' + load_lang('extension_filter_list') + ''')</a>
+                    ''' + upload_help + '''
+                    <hr class="main_hr">
+                    ''' + load_lang('max_file_size') + ''' : ''' + wiki_set(3) + '''MB
+                    <hr class="main_hr">
+                    <form method="post" enctype="multipart/form-data" accept-charset="utf8">
+                        <input multiple="multiple" type="file" name="f_data[]">
+                        <hr class="main_hr">
+                        <input placeholder="''' + load_lang('file_name') + '''" name="f_name" value="''' + file_name + '''">
+                        <hr class="main_hr">
+                        <select name="f_lice_sel">
+                            ''' + license_list + '''
+                        </select>
+                        <hr class="main_hr">
+                        <textarea rows="10" placeholder="''' + load_lang('other') + '''" name="f_lice">''' + upload_default + '''</textarea>
+                        <hr class="main_hr">
+                        ''' + captcha_get() + '''
+                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
+                    </form>
+                ''',
+                menu = [['other', load_lang('return')]]
+            ))

+ 0 - 755
route/main_setting.py

@@ -1,755 +0,0 @@
-from .tool.func import *
-
-def main_setting_2(conn, num, db_set):
-    curs = conn.cursor()
-
-    if not (num == 0 or num == 8) and admin_check() != 1:
-        return re_error('/ban')
-
-    if num == 0:
-        li_list = [
-            [1, load_lang('main_setting')],
-            [2, load_lang('text_setting')],
-            [5, 'robots.txt'],
-            [6, load_lang('ext_api_req_set')],
-            [3, load_lang('main_head')],
-            [4, load_lang('main_body')],
-            [7, load_lang('main_bottom_body')]
-        ]
-
-        li_data = ''.join(['<li><a href="/setting/' + str(li[0]) + '">' + li[1] + '</a></li>' for li in li_list])
-        
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = '<h2>' + load_lang('list') + '</h2><ul class="inside_ul">' + li_data + '</ul>',
-            menu = [['manager', load_lang('return')]]
-        ))
-    elif num == 1:
-        i_list = {
-            0 : 'name',
-            2 : 'frontpage',
-            4 : 'upload',
-            5 : 'skin',
-            7 : 'reg',
-            8 : 'ip_view',
-            9 : 'back_up',
-            10 : 'port',
-            11 : 'key',
-            12 : 'update',
-            15 : 'encode',
-            16 : 'host',
-            19 : 'slow_edit',
-            20 : 'requires_approval',
-            21 : 'backup_where',
-            22 : 'domain',
-            23 : 'ua_get'
-        }
-        n_list = {
-            0 : 'Wiki',
-            2 : 'FrontPage',
-            4 : '2',
-            5 : '',
-            7 : '',
-            8 : '',
-            9 : '0',
-            10 : '3000',
-            11 : 'test',
-            12 : 'stable',
-            15 : 'sha3',
-            16 : '0.0.0.0',
-            19 : '0',
-            20 : '',
-            21 : '',
-            22 : flask.request.host_url,
-            23 : ''
-        }
-
-        if flask.request.method == 'POST':
-            for i in i_list:
-                curs.execute(db_change("update other set data = ? where name = ?"), [
-                    flask.request.form.get(i_list[i], n_list[i]),
-                    i_list[i]
-                ])
-
-            conn.commit()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/1')
-        else:
-            d_list = {}
-
-            for i in i_list:
-                curs.execute(db_change('select data from other where name = ?'), [i_list[i]])
-                sql_d = curs.fetchall()
-                if sql_d:
-                    d_list[i] = sql_d[0][0]
-                else:
-                    curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i_list[i], n_list[i]])
-
-                    d_list[i] = n_list[i]
-
-            conn.commit()
-
-            acl_div = ['']
-            encode_data = ['sha256', 'sha3']
-            for acl_data in encode_data:
-                if acl_data == d_list[15]:
-                    acl_div[0] = '<option value="' + acl_data + '">' + acl_data + '</option>' + acl_div[0]
-                else:
-                    acl_div[0] += '<option value="' + acl_data + '">' + acl_data + '</option>'
-
-            check_box_div = ['', '', '', '', '']
-            for i in range(0, len(check_box_div)):
-                if i == 0:
-                    acl_num = 7
-                elif i == 1:
-                    acl_num = 8
-                elif i == 3:
-                    acl_num = 20
-                else:
-                    acl_num = 23
-
-                if d_list[acl_num]:
-                    check_box_div[i] = 'checked="checked"'
-
-            branch_div = ''
-            branch_list = ['stable', 'dev', 'beta']
-            for i in branch_list:
-                if d_list[12] == i:
-                    branch_div = '<option value="' + i + '">' + i + '</option>' + branch_div
-                else:
-                    branch_div += '<option value="' + i + '">' + i + '</option>'
-
-            sqlite_only = 'style="display:none;"' if db_set != 'sqlite' else ''
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('main_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <form method="post" id="main_set_data">
-                        <h2>1. ''' + load_lang('basic_set') + '''</h2>
-                        <span>''' + load_lang('wiki_name') + '''</span>
-                        <hr class="main_hr">
-                        <input name="name" value="''' + html.escape(d_list[0]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span><a href="/setting/9">(''' + load_lang('wiki_logo') + ''')</a></span>
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('main_page') + '''</span>
-                        <hr class="main_hr">
-                        <input name="frontpage" value="''' + html.escape(d_list[2]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('domain') + '''</span> (EX : http://2du.pythonanywhere.com/)
-                        <hr class="main_hr">
-                        <input name="''' + i_list[22] + '''" value="''' + html.escape(d_list[22]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('wiki_host') + '''</span>
-                        <hr class="main_hr">
-                        <input name="host" value="''' + html.escape(d_list[16]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('wiki_port') + '''</span>
-                        <hr class="main_hr">
-                        <input name="port" value="''' + html.escape(d_list[10]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('wiki_secret_key') + '''</span>
-                        <hr class="main_hr">
-                        <input type="password" name="key" value="''' + html.escape(d_list[11]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('encryption_method') + '''</span>
-                        <hr class="main_hr">
-                        <select name="encode">''' + acl_div[0] + '''</select>
-                        
-                        <h2>2. ''' + 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 'tenshi') + '''</select>
-                        
-                        <h2>3. ''' + load_lang('login_set') + '''</h2>
-                        <input type="checkbox" name="reg" ''' + check_box_div[0] + '''> ''' + load_lang('no_register') + '''
-                        <hr class="main_hr">
-                        
-                        <input type="checkbox" name="ip_view" ''' + check_box_div[1] + '''> ''' + load_lang('hide_ip') + '''
-                        <hr class="main_hr">
-                        
-                        <input type="checkbox" name="requires_approval" ''' + check_box_div[3] + '''> ''' + load_lang('requires_approval') + '''
-                        <hr class="main_hr">
-                        
-                        <input type="checkbox" name="ua_get" ''' + check_box_div[4] + '''> ''' + load_lang('ua_get_off') + '''
-                        
-                        <h2>4. ''' + load_lang('server_set') + '''</h2>
-                        <span>''' + load_lang('max_file_size') + ''' (MB)</span>
-                        <hr class="main_hr">
-                        <input name="upload" value="''' + html.escape(d_list[4]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span ''' + sqlite_only + '''>
-                            <span>
-                                ''' + load_lang('backup_interval') + ' (' + load_lang('hour') + ') (' + load_lang('off') + ' : 0) ' + \
-                                '(' + load_lang('restart_required') + ''')</span>
-                            <hr class="main_hr">
-                            <input name="back_up" value="''' + html.escape(d_list[9]) + '''">
-                            <hr class="main_hr">
-                            
-                            <span>
-                                ''' + load_lang('backup_where') + ' (' + load_lang('empty') + ' : ' + load_lang('default') + ') ' + \
-                                '(' + load_lang('restart_required') + ''') (EX : ./data/backup.db)
-                            </span>
-                            <hr class="main_hr">
-                            <input name="backup_where" value="''' + html.escape(d_list[21]) + '''">
-                            <hr class="main_hr">
-                        </span>
-                        
-                        <span>''' + load_lang('update_branch') + '''</span>
-                        <hr class="main_hr">
-                        <select name="update">''' + branch_div + '''</select>
-                        
-                        <h2>5. ''' + load_lang('edit_set') + '''</h2>
-                        <span><a href="/setting/8">(''' + load_lang('main_acl_setting') + ''')</a></span>
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('slow_edit') + ' (' + load_lang('second') + ') (' + load_lang('off') + ''' : 0)</span>
-                        <hr class="main_hr">
-                        <input name="''' + i_list[19] + '''" value="''' + html.escape(d_list[19]) + '''">
-                        
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                    <script>simple_render('main_set_data');</script>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 2:
-        i_list = [
-            'contract',
-            'no_login_warning',
-            'edit_bottom_text',
-            'copyright_checkbox_text',
-            'check_key_text',
-            'email_title',
-            'email_text',
-            'email_insert_text',
-            'password_search_text',
-            'reset_user_text',
-            'error_401',
-            'error_404',
-            'approval_question',
-            'edit_help',
-            'upload_help',
-            'upload_default',
-            'license'
-        ]
-        if flask.request.method == 'POST':
-            for i in i_list:
-                curs.execute(db_change("update other set data = ? where name = ?"), [
-                    flask.request.form.get(i, ''),
-                    i
-                ])
-
-            conn.commit()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/2')
-        else:
-            d_list = []
-
-            for i in i_list:
-                curs.execute(db_change('select data from other where name = ?'), [i])
-                sql_d = curs.fetchall()
-                if sql_d:
-                    d_list += [sql_d[0][0]]
-                else:
-                    curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i, ''])
-
-                    d_list += ['']
-
-            conn.commit()
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('text_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <form method="post" id="main_set_data">
-                        <h2>1. ''' + load_lang('register_text') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[0] + '''">''' + html.escape(d_list[0]) + '''</textarea>
-                        
-                        <h2>2. ''' + load_lang('non_login_alert') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[1] + '''">''' + html.escape(d_list[1]) + '''</textarea>
-                        
-                        <h2>3. ''' + load_lang('edit_bottom_text') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[2] + '''">''' + html.escape(d_list[2]) + '''</textarea>
-                        
-                        <h2>4. ''' + load_lang('copyright_checkbox_text') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[3] + '''">''' + html.escape(d_list[3]) + '''</textarea>
-                        
-                        <h2>5. ''' + load_lang('check_key_text') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[4] + '''">''' + html.escape(d_list[4]) + '''</textarea>
-                        
-                        <h2>6. ''' + load_lang('email_title') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[5] + '''">''' + html.escape(d_list[5]) + '''</textarea>
-                        
-                        <h2>7. ''' + load_lang('email_text') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[6] + '''">''' + html.escape(d_list[6]) + '''</textarea>
-                        
-                        <h2>8. ''' + load_lang('email_insert_text') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[7] + '''">''' + html.escape(d_list[7]) + '''</textarea>
-                        
-                        <h2>9. ''' + load_lang('password_search_text') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[8] + '''">''' + html.escape(d_list[8]) + '''</textarea>
-                        
-                        <h2>10. ''' + load_lang('reset_user_text') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[9] + '''">''' + html.escape(d_list[9]) + '''</textarea>
-                        
-                        <h2>11. ''' + load_lang('error_401') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[10] + '''">''' + html.escape(d_list[10]) + '''</textarea>
-                        
-                        <h2>12. ''' + load_lang('error_404') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[11] + '''">''' + html.escape(d_list[11]) + '''</textarea>
-                        
-                        <h2>13. ''' + load_lang('approval_question') + '''</h2>
-                        <sup>(1)</sup>
-                        <hr class="main_hr">
-                        <textarea rows="3" name="''' + i_list[12] + '''">''' + html.escape(d_list[12]) + '''</textarea>
-                        
-                        <h2>14. ''' + load_lang('edit_help') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[13] + '''">''' + html.escape(d_list[13]) + '''</textarea>
-                        
-                        <h2>15. ''' + load_lang('upload_help') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[14] + '''">''' + html.escape(d_list[14]) + '''</textarea>
-                        
-                        <h2>16. ''' + load_lang('upload_default') + '''</h2>
-                        <textarea rows="3" name="''' + i_list[15] + '''">''' + html.escape(d_list[15]) + '''</textarea>
-                        
-                        <h2>17. ''' + load_lang('bottom_text') + ''' (HTML)</h2>
-                        <textarea rows="3" name="''' + i_list[16] + '''">''' + html.escape(d_list[16]) + '''</textarea>
-                        
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                    <ul id="footnote_data">
-                        <li><a href="#note_1" id="note_1_end">(1)</a> ''' + load_lang('approval_question_visible_only_when_approval_on') + '''</li>
-                    </ul>
-                    <script>simple_render('main_set_data');</script>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 3 or num == 4 or num == 7:
-        if flask.request.method == 'POST':
-            if num == 4:
-                info_d = 'body'
-                end_r = '4'
-                coverage = ''
-            elif num == 7:
-                info_d = 'bottom_body'
-                end_r = '7'
-                coverage = ''
-            else:
-                info_d = 'head'
-                end_r = '3'
-                if flask.request.args.get('skin', '') == '':
-                    coverage = ''
-                else:
-                    coverage = flask.request.args.get('skin', '')
-
-            curs.execute(db_change("select name from other where name = ? and coverage = ?"), [info_d, coverage])
-            if curs.fetchall():
-                curs.execute(db_change("update other set data = ? where name = ? and coverage = ?"), [
-                    flask.request.form.get('content', ''),
-                    info_d,
-                    coverage
-                ])
-            else:
-                curs.execute(db_change("insert into other (name, data, coverage) values (?, ?, ?)"), [info_d, flask.request.form.get('content', ''), coverage])
-
-            conn.commit()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/' + end_r + '?skin=' + flask.request.args.get('skin', ''))
-        else:
-            if num == 4:
-                curs.execute(db_change("select data from other where name = 'body'"))
-                title = '_body'
-                start = ''
-                plus = '''
-                    <button id="preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
-                    <hr class="main_hr">
-                    <div id="see_preview"></div>
-                '''
-            elif num == 7:
-                curs.execute(db_change("select data from other where name = 'bottom_body'"))
-                title = '_bottom_body'
-                start = ''
-                plus = '''
-                    <button id="preview" type="button" onclick="load_raw_preview(\'content\', \'see_preview\')">''' + load_lang('preview') + '''</button>
-                    <hr class="main_hr">
-                    <div id="see_preview"></div>
-                '''
-            else:
-                curs.execute(db_change("select data from other where name = 'head' and coverage = ?"), [flask.request.args.get('skin', '')])
-                title = '_head'
-                start = '' + \
-                    '<a href="?">(' + load_lang('all') + ')</a> ' + \
-                    ' '.join(['<a href="?skin=' + i + '">(' + i + ')</a>' for i in load_skin('', 1)]) + '''
-                    <hr class="main_hr">
-                    <span>&lt;style&gt;CSS&lt;/style&gt;<br>&lt;script&gt;JS&lt;/script&gt;</span>
-                    <hr class="main_hr">
-                '''
-                plus = ''
-
-            head = curs.fetchall()
-            if head:
-                data = head[0][0]
-            else:
-                data = ''
-
-            if flask.request.args.get('skin', '') != '':
-                sub_plus = ' (' + flask.request.args.get('skin', '') + ')'
-            else:
-                sub_plus = ''
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang(data = 'main' + title, safe = 1), wiki_set(), wiki_custom(), wiki_css(['(HTML)' + sub_plus, 0])],
-                data = '''
-                    <form method="post">
-                        ''' + start + '''
-                        <textarea rows="25" placeholder="''' + load_lang('enter_html') + '''" name="content" id="content">''' + html.escape(data) + '''</textarea>
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                        ''' + plus + '''
-                    </form>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 5:
-        if flask.request.method == 'POST':
-            curs.execute(db_change("select name from other where name = 'robot'"))
-            if curs.fetchall():
-                curs.execute(db_change("update other set data = ? where name = 'robot'"), [flask.request.form.get('content', '')])
-            else:
-                curs.execute(db_change("insert into other (name, data) values ('robot', ?)"), [flask.request.form.get('content', '')])
-
-            conn.commit()
-
-            fw = open('./robots.txt', 'w', encoding='utf8')
-            fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', '')))
-            fw.close()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/5')
-        else:
-            if not os.path.exists('robots.txt'):
-                curs.execute(db_change('select data from other where name = "robot"'))
-                robot_test = curs.fetchall()
-                if robot_test:
-                    fw_test = open('./robots.txt', 'w', encoding='utf8')
-                    fw_test.write(re.sub('\r\n', '\n', robot_test[0][0]))
-                    fw_test.close()
-                else:
-                    fw_test = open('./robots.txt', 'w', encoding='utf8')
-                    fw_test.write('User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/')
-                    fw_test.close()
-
-                    curs.execute(db_change('insert into other (name, data) values ("robot", "User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/")'))
-
-            curs.execute(db_change("select data from other where name = 'robot'"))
-            robot = curs.fetchall()
-            if robot:
-                data = robot[0][0]
-            else:
-                data = ''
-
-            f = open('./robots.txt', encoding='utf8')
-            lines = f.readlines()
-            f.close()
-
-            if not data or data == '':
-                data = ''.join(lines)
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = ['robots.txt', wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <a href="/robots.txt">(''' + load_lang('view') + ''')</a>
-                    <hr class="main_hr">
-                    <form method="post">
-                        <textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 6:
-        i_list = [
-            'recaptcha',
-            'sec_re',
-            'smtp_server',
-            'smtp_port',
-            'smtp_security',
-            'smtp_email',
-            'smtp_pass',
-            'recaptcha_ver',
-            'oauth_client_id',
-            'email_have'
-        ]
-
-        if flask.request.method == 'POST':
-            for data in i_list:
-                into_data = flask.request.form.get(data, '')
-
-                curs.execute(db_change("update other set data = ? where name = ?"), [into_data, data])
-
-            conn.commit()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/6')
-        else:
-            d_list = []
-
-            x = 0
-
-            for i in i_list:
-                curs.execute(db_change('select data from other where name = ?'), [i])
-                sql_d = curs.fetchall()
-                if sql_d:
-                    d_list += [sql_d[0][0]]
-                else:
-                    curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i, ''])
-
-                    d_list += ['']
-
-                x += 1
-
-            conn.commit()
-
-            security_radios = ''
-            for i in ['tls', 'starttls', 'plain']:
-                security_radios += '<input name="smtp_security" type="radio" value="' + i + '" ' + ('checked' if d_list[4] == i else '') + '>' + i + '<hr class="main_hr">'
-
-            re_ver = ''
-            if d_list[7] == '':
-                re_ver += '<option value="">v2</option><option value="v3">v3</option>'
-            else:
-                re_ver += '<option value="v3">v3</option><option value="">v2</option>'
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('ext_api_req_set'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <form method="post" id="main_set_data">
-                        <h2>1. ''' + load_lang('recaptcha') + '''</h2>
-                        <a href="https://www.google.com/recaptcha/admin">(Google)</a>
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('public_key') + '''</span>
-                        <hr class="main_hr">
-                        <input name="recaptcha" value="''' + html.escape(d_list[0]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('secret_key') + '''</span>
-                        <hr class="main_hr">
-                        <input name="sec_re" value="''' + html.escape(d_list[1]) + '''">
-                        <hr class="main_hr">
-                        
-                        <select name="recaptcha_ver">
-                            ''' + re_ver + '''
-                        </select>
-                        
-                        <h2>2. ''' + load_lang('email_setting') + '''</h1>
-                        <input type="checkbox" name="email_have" ''' + ('checked' if d_list[9] != '' else '')  + '''> ''' + \
-                             load_lang('email_required') + '''
-                        
-                        <h2>2.1. ''' + load_lang('smtp_setting') + '''</h1>
-                        <a href="https://support.google.com/mail/answer/7126229">(Google)</a>
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('smtp_server') + '''</span>
-                        <hr class="main_hr">
-                        <input name="smtp_server" value="''' + html.escape(d_list[2]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('smtp_port') + '''</span>
-                        <hr class="main_hr">
-                        <input name="smtp_port" value="''' + html.escape(d_list[3]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('smtp_security') + '''</span>
-                        <hr class="main_hr">
-                        ''' + security_radios + '''
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('smtp_username') + '''</span>
-                        <hr class="main_hr">
-                        <input name="smtp_email" value="''' + html.escape(d_list[5]) + '''">
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('smtp_password') + '''</span>
-                        <hr class="main_hr">
-                        <input type="password" name="smtp_pass" value="''' + html.escape(d_list[6]) + '''">
-                        
-                        <h2>3. ''' + load_lang('oauth') + '''</h2>
-                        <a href="https://developers.google.com/identity/protocols/oauth2">(Google)</a>
-                        <hr class="main_hr">
-                        
-                        <span>''' + load_lang('oauth_client_id') + '''</span>
-                        <hr class="main_hr">
-                        <input name="oauth_client_id" value="''' + html.escape(d_list[8]) + '''">
-                        <hr class="main_hr">
-                        
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                    <script>simple_render('main_set_data');</script>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 8:
-        i_list = {
-            1 : 'edit',
-            2 : 'discussion',
-            3 : 'upload_acl',
-            4 : 'all_view_acl',
-            5 : 'many_upload_acl',
-            6 : 'vote_acl'
-        }
-
-        if flask.request.method == 'POST':
-            if admin_check(None, 'edit_set (' + str(num) + ')') != 1:
-                return re_error('/ban')
-            else:
-                for i in i_list:
-                    curs.execute(db_change("update other set data = ? where name = ?"), [
-                        flask.request.form.get(i_list[i], 'normal'),
-                        i_list[i]
-                    ])
-
-                conn.commit()
-
-                return redirect('/setting/8')
-        else:
-            d_list = {}
-
-            if admin_check() != 1:
-                disable = 'disabled'
-            else:
-                disable = ''
-
-            for i in i_list:
-                curs.execute(db_change('select data from other where name = ?'), [i_list[i]])
-                sql_d = curs.fetchall()
-                if sql_d:
-                    d_list[i] = sql_d[0][0]
-                else:
-                    curs.execute(db_change('insert into other (name, data) values (?, ?)'), [i_list[i], 'normal'])
-
-                    d_list[i] = 'normal'
-
-            conn.commit()
-
-            acl_div = []
-            for i in range(0, len(i_list)):
-                acl_div += ['']
-
-            acl_list = get_acl_list()
-            for i in range(0, len(i_list)):
-                for data_list in acl_list:
-                    if data_list == d_list[i + 1]:
-                        check = 'selected="selected"'
-                    else:
-                        check = ''
-                    
-                    acl_div[i] += '<option value="' + data_list + '" ' + check + '>' + (data_list if data_list != '' else 'normal') + '</option>'
-
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('main_acl_setting'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <form method="post">
-                        <a href="/acl/TEST#exp">(''' + load_lang('reference') + ''')</a>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('document_acl') + '''</span> 
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="edit">''' + acl_div[0] + '''</select>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('discussion_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="discussion">''' + acl_div[1] + '''</select>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('upload_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="upload_acl">''' + acl_div[2] + '''</select>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('view_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="all_view_acl">''' + acl_div[3] + '''</select>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('many_upload_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="many_upload_acl">''' + acl_div[4] + '''</select>
-                        <hr class="main_hr">
-                        <span>''' + load_lang('vote_acl') + '''</span>
-                        <hr class="main_hr">
-                        <select ''' + disable + ''' name="vote_acl">''' + acl_div[5] + '''</select>
-                        <hr class="main_hr">
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    elif num == 9:
-        skin_list = [0] + load_skin('', 1)
-        i_list = []
-        for i in skin_list:
-            i_list += [['logo', '' if i == 0 else i]]
-        
-        if flask.request.method == 'POST':
-            for i in i_list:
-                curs.execute(db_change("update other set data = ? where name = ? and coverage = ?"), [
-                    flask.request.form.get(('main_css' if i[1] == '' else i[1]), ''),
-                    i[0], 
-                    i[1]
-                ])
-
-            conn.commit()
-
-            admin_check(None, 'edit_set (' + str(num) + ')')
-
-            return redirect('/setting/9')
-        else:
-            d_list = []
-            for i in i_list:
-                curs.execute(db_change('select data from other where name = ? and coverage = ?'), [i[0], i[1]])
-                sql_d = curs.fetchall()
-                if sql_d:
-                    d_list += [sql_d[0][0]]
-                else:
-                    curs.execute(db_change('insert into other (name, data, coverage) values (?, ?, ?)'), [i[0], '', i[1]])
-
-                    d_list += ['']
-            
-            end_data = ''
-            for i in range(0, len(skin_list)):
-                end_data += '' + \
-                    '<span>' + load_lang('wiki_logo') + ' ' + ('(' + skin_list[i] + ')' if skin_list[i] != 0 else '') + ' (HTML)' + \
-                    '<hr class="main_hr">' + \
-                    '<input name="' + (skin_list[i] if skin_list[i] != 0 else 'main_css') + '" value="' + html.escape(d_list[i]) + '">' + \
-                    '<hr class="main_hr">' + \
-                ''
-            
-            return easy_minify(flask.render_template(skin_check(),
-                imp = [load_lang('wiki_logo'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-                data = '''
-                    <form method="post">
-                        ''' + end_data + '''
-                        <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                    </form>
-                ''',
-                menu = [['setting', load_lang('return')]]
-            ))
-    else:
-        return redirect()

+ 0 - 20
route/main_skin_set.py

@@ -1,20 +0,0 @@
-from .tool.func import *
-
-def main_skin_set_2(conn):
-    curs = conn.cursor()
-
-    data = flask.make_response(re_error('/error/5'))
-
-    curs.execute(db_change("select data from other where name = 'language'"))
-    main_data = curs.fetchall()
-
-    data.set_cookie('language', main_data[0][0])
-
-    curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip_check()])
-    user_data = curs.fetchall()
-    if user_data:
-        data.set_cookie('user_language', user_data[0][0])
-    else:
-        data.set_cookie('user_language', main_data[0][0])
-
-    return data

+ 1 - 3
route/main_restart.py → route/main_sys_restart.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_restart_2(conn):
-    curs = conn.cursor()
-
+def main_sys_restart():
     if admin_check() != 1:
         return re_error('/error/3')
 

+ 1 - 3
route/main_shutdown.py → route/main_sys_shutdown.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_shutdown_2(conn):
-    curs = conn.cursor()
-    
+def main_sys_shutdown():
     if admin_check() != 1:
         return re_error('/error/3')
 

+ 63 - 0
route/main_sys_update.py

@@ -0,0 +1,63 @@
+from .tool.func import *
+
+def main_sys_update():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/error/3')
+
+        if flask.request.method == 'POST':
+            admin_check(None, 'update')
+
+            curs.execute(db_change('select data from other where name = "update"'))
+            up_data = curs.fetchall()
+            up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
+
+            print('----')
+            print('Update')
+            print('----')
+            if platform.system() == 'Linux':
+                ok = []
+
+                ok += [os.system('git remote rm origin')]
+                ok += [os.system('git remote add origin https://github.com/opennamu/opennamu.git')]
+                ok += [os.system('git fetch origin ' + up_data)]
+                ok += [os.system('git reset --hard origin/' + up_data)]
+                if (ok[0] and ok[1] and ok[2] and ok[3]) == 0:
+                    return redirect('/restart')
+                else:
+                    print('Error : update failed')
+            elif platform.system() == 'Windows':
+                os.system('rd /s /q route')
+                urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
+                zipfile.ZipFile('update.zip').extractall('')
+                ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
+                if ok == 0:
+                    os.system('rd /s /q opennamu-' + up_data)
+                    os.system('del update.zip')
+
+                    return redirect('/restart')
+                else:
+                    print('Error : update failed')
+
+            return re_error('/error/34')
+        else:
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('update'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                data = load_lang('update_warning') + '''
+                    <hr class=\"main_hr\">
+                    <ul class="inside_ul">
+                        <li>''' + load_lang('version') + ''' : <span id="ver_send_2"></span></li>
+                        <li id="ver_send" style="display: none;">''' + load_lang('lastest') + ''' : </li>
+                    </ul>
+                    <a href="https://github.com/openNAMU/openNAMU">(Beta)</a> <a href="https://github.com/openNAMU/openNAMU/tree/stable">(Stable)</a>
+                    <hr class=\"main_hr\">
+                    <form method="post">
+                        <button type="submit">''' + load_lang('update') + '''</button>
+                    </form>
+                    <script>load_ver();</script>
+                ''',
+                menu = [['manager', load_lang('return')]]
+            ))
+

+ 0 - 15
route/main_test_func.py

@@ -1,15 +0,0 @@
-import time
-from .tool.func import *
-
-def main_test_func_2(conn):
-    if admin_check() != 1:
-        return re_error('/error/3')
-    
-    test_start = time.time()
-
-    for _ in range(0, 10000):
-        load_lang('edit')
-        
-    end_time = "time :" + str(time.time() - test_start) + '\n'
-
-    return end_time

+ 0 - 12
route/main_title_random.py

@@ -1,12 +0,0 @@
-from .tool.func import *
-
-def main_title_random_2(conn):
-    curs = conn.cursor()
-
-    curs.execute(db_change("" + \
-        "select title from data " + \
-        "where title not like 'user:%' and title not like 'category:%' and title not like 'file:%' " + \
-        "order by random() limit 1" + \
-    ""))
-    data = curs.fetchall()
-    return redirect('/w/' + url_pas(data[0][0])) if data else redirect()

+ 10 - 11
route/main_manager.py → route/main_tool_admin.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_manager_2(conn, num):
-    curs = conn.cursor()
-
+def main_tool_admin(num = 1, add_1 = '', add_2 = ''):
     title_list = {
         0 : [load_lang('document_name'), 'acl', load_lang('acl')],
         1 : [0, 'check', load_lang('check')],
@@ -78,31 +76,32 @@ def main_manager_2(conn, num):
             menu = [['other', load_lang('return')]]
         ))
     elif not num - 1 > len(title_list):
+        num -= 2
         if flask.request.method == 'POST':
-            if flask.request.args.get('plus', None):
+            if add_2 != '':
                 return redirect(
-                    '/' + title_list[(num - 2)][1] + '/' + url_pas(flask.request.args.get('plus', 'test')) + '?plus=' + url_pas(flask.request.form.get('name', 'test'))
+                    '/' + title_list[num][1] + '/' + url_pas(add_2) + '?plus=' + url_pas(add_1)
                 )
             elif flask.request.form.get('regex', None):
-                return redirect('/' + title_list[(num - 2)][1] + '/' + url_pas(flask.request.form.get('name', 'test')) + '?type=regex')
+                return redirect('/' + title_list[num][1] + '/' + url_pas(add_1) + '?type=regex')
             else:
-                return redirect('/' + title_list[(num - 2)][1] + '/' + url_pas(flask.request.form.get('name', 'test')))
+                return redirect('/' + title_list[num][1] + '/' + url_pas(add_1))
         else:
             if title_list[(num - 2)][0] == 0:
                 placeholder = load_lang('user_name')
             else:
-                placeholder = title_list[(num - 2)][0]
+                placeholder = title_list[num][0]
 
             plus = ''
-            if num - 2 == 15:
+            if num == 15:
                 plus = '<input type="checkbox" name="regex"> ' + load_lang('regex') + '<hr class="main_hr">'
 
             return easy_minify(flask.render_template(skin_check(),
-                imp = [title_list[(num - 2)][2], wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                imp = [title_list[num][2], wiki_set(), wiki_custom(), wiki_css([0, 0])],
                 data = '''
                     <form method="post">
                         <input placeholder="''' + placeholder + '''" name="name" type="text">
-                        <hr class=\"main_hr\">
+                        <hr class="main_hr">
                         ''' + plus + '''
                         <button type="submit">''' + load_lang('go') + '''</button>
                     </form>

+ 1 - 3
route/main_other.py → route/main_tool_other.py

@@ -1,8 +1,6 @@
 from .tool.func import *
 
-def main_other_2(conn):
-    curs = conn.cursor()
-
+def main_tool_other():
     return easy_minify(flask.render_template(skin_check(),
         imp = [load_lang('other_tool'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
         data = '''

+ 0 - 62
route/main_update.py

@@ -1,62 +0,0 @@
-from .tool.func import *
-
-def main_update_2(conn):
-    curs = conn.cursor()
-
-    if admin_check() != 1:
-        return re_error('/error/3')
-
-    if flask.request.method == 'POST':
-        admin_check(None, 'update')
-
-        curs.execute(db_change('select data from other where name = "update"'))
-        up_data = curs.fetchall()
-        up_data = up_data[0][0] if up_data and up_data[0][0] in ['stable', 'beta', 'dev'] else 'stable'
-
-        print('----')
-        print('Update')
-        print('----')
-        if platform.system() == 'Linux':
-            ok = []
-
-            ok += [os.system('git remote rm origin')]
-            ok += [os.system('git remote add origin https://github.com/opennamu/opennamu.git')]
-            ok += [os.system('git fetch origin ' + up_data)]
-            ok += [os.system('git reset --hard origin/' + up_data)]
-            if (ok[0] and ok[1] and ok[2] and ok[3]) == 0:
-                return redirect('/restart')
-            else:
-                print('Error : update failed')
-        elif platform.system() == 'Windows':
-            os.system('rd /s /q route')
-            urllib.request.urlretrieve('https://github.com/opennamu/opennamu/archive/' + up_data + '.zip', 'update.zip')
-            zipfile.ZipFile('update.zip').extractall('')
-            ok = os.system('xcopy /y /s /r opennamu-' + up_data + ' .')
-            if ok == 0:
-                os.system('rd /s /q opennamu-' + up_data)
-                os.system('del update.zip')
-
-                return redirect('/restart')
-            else:
-                print('Error : update failed')
-
-        return re_error('/error/34')
-    else:
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('update'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = load_lang('update_warning') + '''
-                <hr class=\"main_hr\">
-                <ul class="inside_ul">
-                    <li>''' + load_lang('version') + ''' : <span id="ver_send_2"></span></li>
-                    <li id="ver_send" style="display: none;">''' + load_lang('lastest') + ''' : </li>
-                </ul>
-                <a href="https://github.com/openNAMU/openNAMU">(Beta)</a> <a href="https://github.com/openNAMU/openNAMU/tree/stable">(Stable)</a>
-                <hr class=\"main_hr\">
-                <form method="post">
-                    <button type="submit">''' + load_lang('update') + '''</button>
-                </form>
-                <script>load_ver();</script>
-            ''',
-            menu = [['manager', load_lang('return')]]
-        ))
-

+ 0 - 153
route/main_upload.py

@@ -1,153 +0,0 @@
-from .tool.func import *
-
-def main_upload_2(conn):
-    curs = conn.cursor()
-
-    if acl_check(None, 'upload') == 1:
-        return re_error('/ban')
-
-    if flask.request.method == 'POST':
-        if captcha_post(flask.request.form.get('g-recaptcha-response', flask.request.form.get('g-recaptcha', ''))) == 1:
-            return re_error('/error/13')
-        else:
-            captcha_post('', 0)
-
-        file_data = flask.request.files.getlist("f_data[]", None)
-        if not file_data:
-            return re_error('/error/9')
-
-        file_len = len(file_data)
-
-        if (int(wiki_set(3)) * 1000 * 1000 * file_len) < flask.request.content_length:
-            return re_error('/error/17')
-
-        if file_len == 1:    
-            file_num = None
-        else:
-            if acl_check(None, 'many_upload') == 1:
-                return re_error('/ban')
-
-            file_num = 1
-
-        for data in file_data:
-            value = os.path.splitext(data.filename)[1]
-            
-            curs.execute(db_change("select html from html_filter where kind = 'extension'"))
-            extension = [i[0].lower() for i in curs.fetchall()]
-            if not re.sub(r'^\.', '', value).lower() in extension:
-                return re_error('/error/14')
-
-            if flask.request.form.get('f_name', None):
-                name = flask.request.form.get('f_name', None) + (' ' + str(file_num) if file_num else '') + value
-            else:
-                name = data.filename
-
-            piece = os.path.splitext(name)
-            if re.search(r'[^ㄱ-힣0-9a-zA-Z_\- ]', piece[0]):
-                return re_error('/error/22')
-
-            e_data = sha224_replace(piece[0]) + piece[1]
-
-            curs.execute(db_change("select title from data where title = ?"), ['file:' + name])
-            if curs.fetchall():
-                return re_error('/error/16')
-
-            curs.execute(db_change("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')
-
-            data_url_image = load_image_url()
-            if os.path.exists(os.path.join(data_url_image, e_data)):
-                return re_error('/error/16')
-            else:
-                data.save(os.path.join(data_url_image, e_data))
-
-            ip = ip_check()
-            g_lice = flask.request.form.get('f_lice', '')
-            file_size = os.stat(os.path.join(data_url_image, e_data)).st_size
-            file_size = str(round(file_size / 1000, 1))
-
-            curs.execute(db_change("select data from other where name = 'markup'"))
-            db_data = curs.fetchall()
-            if db_data and db_data[0][0] == 'namumark':
-                file_d = '' + \
-                    flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
-                    '[[category:' + re.sub(r'\]', '_', flask.request.form.get('f_lice_sel', '')) + ']]\n' + \
-                    (g_lice if g_lice != '' else '') + \
-                ''
-            else:
-                file_d = '' + \
-                    flask.request.form.get('f_lice_sel', 'direct_input') + '\n' + \
-                    (g_lice if g_lice != '' else '') + \
-                ''
-
-            curs.execute(db_change("insert into data (title, data) values (?, ?)"), ['file:' + name, file_d])
-            curs.execute(db_change("insert into acl (title, data, type) values (?, 'admin', 'decu')"), ['file:' + name])
-
-            render_set(
-                doc_name = 'file:' + name,
-                doc_data = file_d,
-                data_type = 'backlink'
-            )
-
-            history_plus(
-                'file:' + name,
-                file_d,
-                get_time(),
-                ip,
-                '',
-                '0',
-                t_check = 'upload',
-                mode = 'upload'
-            )
-
-            if file_num:
-                file_num += 1
-
-        conn.commit()
-
-        return redirect('/w/file:' + name)
-    else:
-        license_list = '<option value="direct_input">' + load_lang('direct_input') + '</option>'
-        file_name = flask.request.args.get('name', '')
-
-        curs.execute(db_change("select html from html_filter where kind = 'image_license'"))
-        db_data = curs.fetchall()
-        license_list += ''.join(['<option value="' + i[0] + '">' + i[0] + '</option>' for i in db_data])
-
-        curs.execute(db_change("select data from other where name = 'upload_help'"))
-        db_data = curs.fetchall()
-        upload_help = ('<hr class="main_hr">' + db_data[0][0]) if db_data and db_data[0][0] != '' else ''
-
-        curs.execute(db_change("select data from other where name = 'upload_default'"))
-        db_data = curs.fetchall()
-        upload_default = html.escape(db_data[0][0]) if db_data and db_data[0][0] != '' else ''
-
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('upload'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = '''
-                <a href="/file_filter">(''' + load_lang('file_filter_list') + ''')</a> <a href="/extension_filter">(''' + load_lang('extension_filter_list') + ''')</a>
-                ''' + upload_help + '''
-                <hr class="main_hr">
-                ''' + load_lang('max_file_size') + ''' : ''' + wiki_set(3) + '''MB
-                <hr class="main_hr">
-                <form method="post" enctype="multipart/form-data" accept-charset="utf8">
-                    <input multiple="multiple" type="file" name="f_data[]">
-                    <hr class="main_hr">
-                    <input placeholder="''' + load_lang('file_name') + '''" name="f_name" value="''' + file_name + '''">
-                    <hr class="main_hr">
-                    <select name="f_lice_sel">
-                        ''' + license_list + '''
-                    </select>
-                    <hr class="main_hr">
-                    <textarea rows="10" placeholder="''' + load_lang('other') + '''" name="f_lice">''' + upload_default + '''</textarea>
-                    <hr class="main_hr">
-                    ''' + captcha_get() + '''
-                    <button id="save" type="submit">''' + load_lang('save') + '''</button>
-                </form>
-            ''',
-            menu = [['other', load_lang('return')]]
-        ))  

+ 3 - 5
route/main_views.py → route/main_view.py

@@ -1,12 +1,10 @@
 from .tool.func import *
-from . import main_error_404
-
-def main_views_2(conn, name):
-    curs = conn.cursor()
+from .main_error_404 import main_error_404
 
+def main_view(name = ''):
     file_name = re.search(r'([^/]+)$', name)
     if not file_name:
-        return main_error_404.main_error_404_2(conn)
+        return main_error_404(conn)
     else:
         file_name = file_name.group(1)
         dir_name = './views/' + re.sub(r'\.{2,}', '', re.sub(r'([^/]+)$', '', name))

+ 3 - 5
route/main_file.py → route/main_view_file.py

@@ -1,9 +1,7 @@
 from .tool.func import *
-from . import main_error_404
-
-def main_file_2(conn, data):
-    curs = conn.cursor()
+from .main_error_404 import main_error_404
 
+def main_view_file(data = ''):
     if data == 'robots.txt' and not os.path.exists('robots.txt'):
         return flask.Response('User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/', mimetype = 'text/plain')
     elif os.path.exists(data):
@@ -12,4 +10,4 @@ def main_file_2(conn, data):
         else:
             return flask.send_from_directory('./', data, mimetype = 'text/xml')
 
-    return main_error_404.main_error_404_2(conn)
+    return main_error_404()

+ 3 - 5
route/main_image_view.py → route/main_view_image.py

@@ -1,9 +1,7 @@
 from .tool.func import *
-from . import main_error_404
-
-def main_image_view_2(conn, name):
-    curs = conn.cursor()
+from .main_error_404 import main_error_404
 
+def main_view_image(name = ''):
     mime_type = re.search(r'([^.]+)$', name)
     if mime_type:
         mime_type = mime_type.group(1).lower()
@@ -15,4 +13,4 @@ def main_image_view_2(conn, name):
             mimetype = 'image/' + mime_type
         )
     else:
-        return main_error_404.main_error_404_2(conn)
+        return main_error_404()