2du 4 tahun lalu
induk
melakukan
41605dccba

+ 21 - 25
app.py

@@ -481,6 +481,7 @@ def view_diff(name = 'Test', num_a = 1, num_b = 1):
 def view_down(name = None):
     return view_down_2(load_db.db_get(), name)
 
+# everything 다음에 추가 붙은 경우에 대해서 재검토 필요
 @app.route('/w/<everything:name>/doc_rev/<int(signed = True):doc_rev>')
 @app.route('/w/<everything:name>/doc_from/<everything:doc_from>')
 @app.route('/w/<everything:name>')
@@ -488,34 +489,17 @@ def view_read(name = 'Test', doc_rev = 0, doc_from = ''):
     return view_read_2(load_db.db_get(), name, doc_rev, doc_from)
 
 # Func-edit
-@app.route('/revert/<everything:name>', methods = ['POST', 'GET'])
-def edit_revert(name = None):
-    return edit_revert_2(load_db.db_get(), name)
-
 app.route('/edit/<everything:name>', methods = ['POST', 'GET'])(edit)
 app.route('/edit/<everything:name>/doc_from/<everything:name_load>', methods = ['POST', 'GET'])(edit)
 app.route('/edit/<everything:name>/doc_section/<int:section>', methods = ['POST', 'GET'])(edit)
 
 # 개편 예정
-@app.route('/backlink_reset/<everything:name>')
-def edit_backlink_reset(name = 'Test'):
-    return edit_backlink_reset_2(load_db.db_get(), name)
-
-@app.route('/delete/<everything:name>', methods = ['POST', 'GET'])
-def edit_delete(name = None):
-    return edit_delete_2(load_db.db_get(), name)
-
-@app.route('/delete/doc_file/<everything:name>', methods = ['POST', 'GET'])
-def edit_delete_file(name = 'test.jpg'):
-    return edit_delete_file_2(load_db.db_get(), name)
-
-@app.route('/delete/doc_mutiple', methods = ['POST', 'GET'])
-def edit_delete_mutiple():
-    return edit_delete_mutiple_2(load_db.db_get())
-
-@app.route('/move/<everything:name>', methods = ['POST', 'GET'])
-def edit_move(name = None):
-    return edit_move_2(load_db.db_get(), name)
+app.route('/xref_reset/<everything:name>')(edit_backlink_reset)
+app.route('/delete/<everything:name>', methods = ['POST', 'GET'])(edit_delete)
+app.route('/delete_file/<everything:name>', methods = ['POST', 'GET'])(edit_delete_file)
+app.route('/delete_mutiple', methods = ['POST', 'GET'])(edit_delete_mutiple)
+app.route('/revert/<everything:name>', methods = ['POST', 'GET'])(edit_revert)
+app.route('/move/<everything:name>', methods = ['POST', 'GET'])(edit_move)
 
 # Func-topic
 @app.route('/recent_discuss')
@@ -690,12 +674,24 @@ app.route('/manager/<int:num>/<add_2>', methods = ['POST', 'GET'])(main_tool_adm
 
 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)
 
+app.route('/setting')(main_func_setting)
+app.route('/setting/main', defaults = { 'db_set' : data_db_set['type'] }, methods = ['POST', 'GET'])(main_func_setting_main)
+app.route('/setting/main/logo', methods = ['POST', 'GET'])(main_func_setting_main_logo)
+app.route('/setting/phrase', methods = ['POST', 'GET'])(main_func_setting_phrase)
+app.route('/setting/head', defaults = { 'num' : 3 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/head/<skin_name>', defaults = { 'num' : 3 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/body/top', defaults = { 'num' : 4 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/body/top/<skin_name>', defaults = { 'num' : 4 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/body/bottom', defaults = { 'num' : 7 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/body/bottom/<skin_name>', defaults = { 'num' : 7 }, methods = ['POST', 'GET'])(main_func_setting_head)
+app.route('/setting/robot', methods = ['POST', 'GET'])(main_func_setting_robot)
+app.route('/setting/external', methods = ['POST', 'GET'])(main_func_setting_external)
+app.route('/setting/acl', methods = ['POST', 'GET'])(main_func_setting_acl)
+
 # views -> view
 app.route('/view/<everything:name>')(main_view)
 app.route('/views/<everything:name>')(main_view)

+ 3 - 1
lang/en-US.json

@@ -106,6 +106,7 @@
         "domain" : "Domain",
         "result" : "Result",
         "incomplete" : "Incomplete",
+        "example" : "Example",
         "_comment_1.1_" : "Time",
             "second" : "Second(s)",
             "hour" : "Hour(s)",
@@ -264,6 +265,7 @@
                 "login_set" : "Login-related settings",
                 "server_set" : "Server-related settings",
                 "edit_set" : "Edit-related settings",
+                "communication_set" : "Communication-related settings",
     
                 "wiki_name" : "Wiki[s] name",
                 "wiki_logo" : "Wiki[s] logo",
@@ -466,4 +468,4 @@
     
             "challenge_title_thousandth_discussion" : "I think, therefore I am.",
             "challenge_info_thousandth_discussion" : "Post the 1000th discussion thread"
-}
+}

+ 15 - 14
route/edit_backlink_reset.py

@@ -1,18 +1,19 @@
 from .tool.func import *
 
-def edit_backlink_reset_2(conn, name):
-    curs = conn.cursor()
+def edit_backlink_reset(name = 'Test'):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    curs.execute(db_change("select data from data where title = ?"), [name])
-    old = curs.fetchall()
-    if old:
-        curs.execute(db_change("delete from back where link = ?"), [name])
-        curs.execute(db_change("delete from back where title = ? and type = 'no'"), [name])
-        
-        render_set(
-            doc_name = name,
-            doc_data = old[0][0],
-            data_type = 'backlink'
-        )
+        curs.execute(db_change("select data from data where title = ?"), [name])
+        old = curs.fetchall()
+        if old:
+            curs.execute(db_change("delete from back where link = ?"), [name])
+            curs.execute(db_change("delete from back where title = ? and type = 'no'"), [name])
 
-    return redirect('/xref/' + url_pas(name))
+            render_set(
+                doc_name = name,
+                doc_data = old[0][0],
+                data_type = 'backlink'
+            )
+
+        return redirect('/xref/' + url_pas(name))

+ 68 - 67
route/edit_delete.py

@@ -1,79 +1,80 @@
 from .tool.func import *
 
-def edit_delete_2(conn, name):
-    curs = conn.cursor()
+def edit_delete(name):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    ip = ip_check()
-    if acl_check(name) == 1:
-        return re_error('/ban')
+        ip = ip_check()
+        if acl_check(name) == 1:
+            return re_error('/ban')
 
-    curs.execute(db_change("select title from data where title = ?"), [name])
-    if not curs.fetchall():
-        return redirect('/w/' + url_pas(name))
+        curs.execute(db_change("select title from data where title = ?"), [name])
+        if not curs.fetchall():
+            return redirect('/w/' + url_pas(name))
 
-    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)
+        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)
 
-        if slow_edit_check() == 1:
-            return re_error('/error/24')
+            if slow_edit_check() == 1:
+                return re_error('/error/24')
 
-        curs.execute(db_change("select data from data where title = ?"), [name])
-        data = curs.fetchall()
-        if data:
-            today = get_time()
-            leng = '-' + str(len(data[0][0]))
+            curs.execute(db_change("select data from data where title = ?"), [name])
+            data = curs.fetchall()
+            if data:
+                today = get_time()
+                leng = '-' + str(len(data[0][0]))
 
-            history_plus(
-                name,
-                '',
-                today,
-                ip,
-                flask.request.form.get('send', ''),
-                leng,
-                t_check = 'delete',
-                mode = 'delete'
-            )
+                history_plus(
+                    name,
+                    '',
+                    today,
+                    ip,
+                    flask.request.form.get('send', ''),
+                    leng,
+                    t_check = 'delete',
+                    mode = 'delete'
+                )
 
-            curs.execute(db_change("select title, link from back where title = ? and not type = 'cat' and not type = 'no'"), [name])
-            for data in curs.fetchall():
-                curs.execute(db_change("insert into back (title, link, type) values (?, ?, 'no')"), [data[0], data[1]])
+                curs.execute(db_change("select title, link from back where title = ? and not type = 'cat' and not type = 'no'"), [name])
+                for data in curs.fetchall():
+                    curs.execute(db_change("insert into back (title, link, type) values (?, ?, 'no')"), [data[0], data[1]])
 
-            curs.execute(db_change("delete from back where link = ?"), [name])
-            curs.execute(db_change("delete from data where title = ?"), [name])
-            conn.commit()
+                curs.execute(db_change("delete from back where link = ?"), [name])
+                curs.execute(db_change("delete from data where title = ?"), [name])
+                conn.commit()
 
-        file_check = re.search(r'^file:(.+)\.(.+)$', name)
-        if file_check:
-            '''
-            file_check = file_check.groups()
-            file_directory = os.path.join(
-                load_image_url(), 
-                sha224_replace(file_check[0]) + '.' + file_check[1]
-            )
-            if os.path.exists(file_directory):
-                os.remove(file_directory)
-            '''
-            
-            pass
-        else:
-            curs.execute(db_change('select data from other where name = "count_all_title"'))
-            curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) - 1)])
+            file_check = re.search(r'^file:(.+)\.(.+)$', name)
+            if file_check:
+                '''
+                file_check = file_check.groups()
+                file_directory = os.path.join(
+                    load_image_url(), 
+                    sha224_replace(file_check[0]) + '.' + file_check[1]
+                )
+                if os.path.exists(file_directory):
+                    os.remove(file_directory)
+                '''
 
-        return redirect('/w/' + url_pas(name))
-    else:
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('delete') + ')', 0])],
-            data = '''
-                <form method="post">
-                    ''' + ip_warning() + '''
-                    <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                    <hr class="main_hr">
-                    ''' + captcha_get() + '''
-                    <button type="submit">''' + load_lang('delete') + '''</button>
-                </form>
-            ''',
-            menu = [['w/' + url_pas(name), load_lang('return')]]
-        ))
+                pass
+            else:
+                curs.execute(db_change('select data from other where name = "count_all_title"'))
+                curs.execute(db_change("update other set data = ? where name = 'count_all_title'"), [str(int(curs.fetchall()[0][0]) - 1)])
+
+            return redirect('/w/' + url_pas(name))
+        else:
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('delete') + ')', 0])],
+                data = '''
+                    <form method="post">
+                        ''' + ip_warning() + '''
+                        <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
+                        <hr class="main_hr">
+                        ''' + captcha_get() + '''
+                        <button type="submit">''' + load_lang('delete') + '''</button>
+                    </form>
+                ''',
+                menu = [['w/' + url_pas(name), load_lang('return')]]
+            ))

+ 42 - 41
route/edit_delete_file.py

@@ -1,43 +1,44 @@
 from .tool.func import *
 
-def edit_delete_file_2(conn, name):
-    curs = conn.cursor()
-
-    ip = ip_check()
-    if admin_check() == 0:
-        return re_error('/ban')
-
-    mime_type = re.search(r'([^.]+)$', name)
-    if mime_type:
-        mime_type = mime_type.group(1).lower()
-    else:
-        mime_type = 'jpg'
-
-    file_name = re.sub(r'\.([^.]+)$', '', name)
-    file_name = re.sub(r'^file:', '', file_name)
-    
-    file_all_name = sha224_replace(file_name) + '.' + mime_type
-    file_directory = os.path.join(load_image_url(), file_all_name)
-    
-    if not os.path.exists(file_directory):
-        return redirect('/w/' + url_pas(name))
-
-    if flask.request.method == 'POST':
-        admin_check(None, 'file del (' + name + ')')
-        os.remove(file_directory)
-
-        return redirect('/w/' + url_pas(name))
-    else:
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('file_delete') + ')', 0])],
-            data = '''
-                <form method="post">
-                    <img src="/image/''' + url_pas(file_all_name) + '''">
-                    <hr class="main_hr">
-                    <a href="/image/''' + url_pas(file_all_name) + '''">/image/''' + url_pas(file_all_name) + '''</a>
-                    <hr class="main_hr">
-                    <button type="submit">''' + load_lang('file_delete') + '''</button>
-                </form>
-            ''',
-            menu = [['w/' + url_pas(name), load_lang('return')]]
-        ))
+def edit_delete_file(name = 'test.jpg'):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        ip = ip_check()
+        if admin_check() == 0:
+            return re_error('/ban')
+
+        mime_type = re.search(r'([^.]+)$', name)
+        if mime_type:
+            mime_type = mime_type.group(1).lower()
+        else:
+            mime_type = 'jpg'
+
+        file_name = re.sub(r'\.([^.]+)$', '', name)
+        file_name = re.sub(r'^file:', '', file_name)
+
+        file_all_name = sha224_replace(file_name) + '.' + mime_type
+        file_directory = os.path.join(load_image_url(), file_all_name)
+
+        if not os.path.exists(file_directory):
+            return redirect('/w/' + url_pas(name))
+
+        if flask.request.method == 'POST':
+            admin_check(None, 'file del (' + name + ')')
+            os.remove(file_directory)
+
+            return redirect('/w/' + url_pas(name))
+        else:
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('file_delete') + ')', 0])],
+                data = '''
+                    <form method="post">
+                        <img src="/image/''' + url_pas(file_all_name) + '''">
+                        <hr class="main_hr">
+                        <a href="/image/''' + url_pas(file_all_name) + '''">/image/''' + url_pas(file_all_name) + '''</a>
+                        <hr class="main_hr">
+                        <button type="submit">''' + load_lang('file_delete') + '''</button>
+                    </form>
+                ''',
+                menu = [['w/' + url_pas(name), load_lang('return')]]
+            ))

+ 25 - 24
route/edit_delete_mutiple.py

@@ -1,30 +1,31 @@
 from .tool.func import *
 from . import edit_delete
 
-def edit_delete_mutiple_2(conn):
-    curs = conn.cursor()
+def edit_delete_mutiple():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    ip = ip_check()
-    if admin_check() != 1:
-        return re_error('/ban')
+        ip = ip_check()
+        if admin_check() != 1:
+            return re_error('/ban')
 
-    if flask.request.method == 'POST':
-        all_title = re.findall(r'([^\n]+)\n', flask.request.form.get('content', '').replace('\r\n', '\n') + '\n')
-        for name in all_title:
-            edit_delete.edit_delete_2(conn, name)
+        if flask.request.method == 'POST':
+            all_title = re.findall(r'([^\n]+)\n', flask.request.form.get('content', '').replace('\r\n', '\n') + '\n')
+            for name in all_title:
+                edit_delete.edit_delete_2(conn, name)
 
-        return redirect('/recent_changes')
-    else:
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [load_lang('many_delete'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
-            data = '''
-                <form method="post">
-                    <textarea rows="25" placeholder="''' + load_lang('many_delete_help') + '''" name="content"></textarea>
-                    <hr class=\"main_hr\">
-                    <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                    <hr class=\"main_hr\">
-                    <button type="submit">''' + load_lang('delete') + '''</button>
-                </form>
-            ''',
-            menu = [['manager/1', load_lang('return')]]
-        ))
+            return redirect('/recent_changes')
+        else:
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [load_lang('many_delete'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
+                data = '''
+                    <form method="post">
+                        <textarea rows="25" placeholder="''' + load_lang('many_delete_help') + '''" name="content"></textarea>
+                        <hr class=\"main_hr\">
+                        <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
+                        <hr class=\"main_hr\">
+                        <button type="submit">''' + load_lang('delete') + '''</button>
+                    </form>
+                ''',
+                menu = [['manager/1', load_lang('return')]]
+            ))

+ 144 - 143
route/edit_move.py

@@ -1,33 +1,131 @@
 from .tool.func import *
 
-def edit_move_2(conn, name):
-    curs = conn.cursor()
+def edit_move(name):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    if acl_check(name) == 1:
-        return re_error('/ban')
-
-    if flask.request.method == 'POST':
-        move_title = flask.request.form.get('title', 'test')
-        if acl_check(move_title) == 1:
+        if acl_check(name) == 1:
             return re_error('/ban')
 
-        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)
+        if flask.request.method == 'POST':
+            move_title = flask.request.form.get('title', 'test')
+            if acl_check(move_title) == 1:
+                return re_error('/ban')
 
-        if slow_edit_check() == 1:
-            return re_error('/error/24')
+            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)
 
-        curs.execute(db_change("select title from history where title = ?"), [move_title])
-        if curs.fetchall():
-            if flask.request.form.get('move_option', 'normal') == 'merge' and admin_check(None, 'merge documents') == 1:
-                curs.execute(db_change("select data from data where title = ?"), [move_title])
-                data = curs.fetchall()
-                if data:
-                    curs.execute(db_change("delete from data where title = ?"), [move_title])
-                    curs.execute(db_change("delete from back where link = ?"), [move_title])
+            if slow_edit_check() == 1:
+                return re_error('/error/24')
+
+            curs.execute(db_change("select title from history where title = ?"), [move_title])
+            if curs.fetchall():
+                if flask.request.form.get('move_option', 'normal') == 'merge' and admin_check(None, 'merge documents') == 1:
+                    curs.execute(db_change("select data from data where title = ?"), [move_title])
+                    data = curs.fetchall()
+                    if data:
+                        curs.execute(db_change("delete from data where title = ?"), [move_title])
+                        curs.execute(db_change("delete from back where link = ?"), [move_title])
+
+                    curs.execute(db_change("select data from data where title = ?"), [name])
+                    data = curs.fetchall()
+                    if data:
+                        curs.execute(db_change("update data set title = ? where title = ?"), [move_title, name])
+                        curs.execute(db_change("update back set link = ? where link = ?"), [move_title, name])
 
+                        data_in = data[0][0]
+                    else:
+                        data_in = ''
+
+                    history_plus(
+                        name,
+                        data_in,
+                        get_time(),
+                        ip_check(),
+                        flask.request.form.get('send', ''),
+                        '0',
+                        t_check = 'merge <a>' + name + '</a> - <a>' + move_title + '</a> move',
+                        mode = 'move'
+                    )
+
+                    curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
+                    curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [move_title])
+
+                    curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [move_title])
+                    data = curs.fetchall()
+
+                    num = data[0][0]
+
+                    curs.execute(db_change("select id from history where title = ? order by id + 0 asc"), [name])
+                    data = curs.fetchall()
+                    for move in data:
+                        curs.execute(db_change("update rc set title = ?, id = ? where title = ? and id = ?"), [
+                            move_title, 
+                            str(int(num) + int(move[0])), 
+                            name, 
+                            move[0]
+                        ])
+                        curs.execute(db_change("update history set title = ?, id = ? where title = ? and id = ?"), [
+                            move_title, 
+                            str(int(num) + int(move[0])), 
+                            name, 
+                            move[0]
+                        ])
+
+                    conn.commit()
+
+                    return redirect('/w/' + url_pas(move_title))
+                elif flask.request.form.get('move_option', 'normal') == 'reverse':
+                    var_name = ''
+                    i = 0
+                    while 1:
+                        curs.execute(db_change("select title from history where title = ?"), ['test ' + str(i)])
+                        if not curs.fetchall():
+                            curs.execute(db_change("select data from data where title = ?"), [name])
+                            data = curs.fetchall()
+                            if data:
+                                curs.execute(db_change("update data set title = ? where title = ?"), ['test ' + str(i), name])
+                                curs.execute(db_change("update back set link = ? where link = ?"), ['test ' + str(i), name])
+
+                            curs.execute(db_change("update history set title = ? where title = ?"), ['test ' + str(i), name])
+                            curs.execute(db_change("update rc set title = ? where title = ?"), ['test ' + str(i), name])
+
+                            break
+                        else:
+                            i += 1
+
+                    for title_name in [[move_title, name], ['test ' + str(i), move_title]]:
+                        curs.execute(db_change("select data from data where title = ?"), [title_name[0]])
+                        data = curs.fetchall()
+                        if data:
+                            curs.execute(db_change("update data set title = ? where title = ?"), [title_name[1], title_name[0]])
+                            curs.execute(db_change("update back set link = ? where link = ?"), [title_name[1], title_name[0]])
+
+                            data_in = data[0][0]
+                        else:
+                            data_in = ''
+
+                        history_plus(
+                            title_name[0],
+                            data_in,
+                            get_time(),
+                            ip_check(),
+                            flask.request.form.get('send', ''),
+                            '0',
+                            t_check = '<a>' + (title_name[0] if title_name[0] != 'test ' + str(i) else name) + '</a> - <a>' + title_name[1] + '</a> move',
+                            mode = 'move'
+                        )
+
+                        curs.execute(db_change("update history set title = ? where title = ?"), [title_name[1], title_name[0]])
+                        curs.execute(db_change("update rc set title = ? where title = ?"), [title_name[1], title_name[0]])
+                        conn.commit()
+
+                    return redirect('/w/' + url_pas(move_title))
+                else:
+                    return re_error('/error/19')
+            else:
                 curs.execute(db_change("select data from data where title = ?"), [name])
                 data = curs.fetchall()
                 if data:
@@ -45,134 +143,37 @@ def edit_move_2(conn, name):
                     ip_check(),
                     flask.request.form.get('send', ''),
                     '0',
-                    t_check = 'merge <a>' + name + '</a> - <a>' + move_title + '</a> move',
+                    t_check = '<a>' + name + '</a> - <a>' + move_title + '</a> move',
                     mode = 'move'
                 )
 
                 curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
                 curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [move_title])
 
-                curs.execute(db_change("select id from history where title = ? order by id + 0 desc limit 1"), [move_title])
-                data = curs.fetchall()
-
-                num = data[0][0]
-
-                curs.execute(db_change("select id from history where title = ? order by id + 0 asc"), [name])
-                data = curs.fetchall()
-                for move in data:
-                    curs.execute(db_change("update rc set title = ?, id = ? where title = ? and id = ?"), [
-                        move_title, 
-                        str(int(num) + int(move[0])), 
-                        name, 
-                        move[0]
-                    ])
-                    curs.execute(db_change("update history set title = ?, id = ? where title = ? and id = ?"), [
-                        move_title, 
-                        str(int(num) + int(move[0])), 
-                        name, 
-                        move[0]
-                    ])
-
+                curs.execute(db_change("update history set title = ? where title = ?"), [move_title, name])
+                curs.execute(db_change("update rc set title = ? where title = ?"), [move_title, name])
                 conn.commit()
 
                 return redirect('/w/' + url_pas(move_title))
-            elif flask.request.form.get('move_option', 'normal') == 'reverse':
-                var_name = ''
-                i = 0
-                while 1:
-                    curs.execute(db_change("select title from history where title = ?"), ['test ' + str(i)])
-                    if not curs.fetchall():
-                        curs.execute(db_change("select data from data where title = ?"), [name])
-                        data = curs.fetchall()
-                        if data:
-                            curs.execute(db_change("update data set title = ? where title = ?"), ['test ' + str(i), name])
-                            curs.execute(db_change("update back set link = ? where link = ?"), ['test ' + str(i), name])
-
-                        curs.execute(db_change("update history set title = ? where title = ?"), ['test ' + str(i), name])
-                        curs.execute(db_change("update rc set title = ? where title = ?"), ['test ' + str(i), name])
-
-                        break
-                    else:
-                        i += 1
-
-                for title_name in [[move_title, name], ['test ' + str(i), move_title]]:
-                    curs.execute(db_change("select data from data where title = ?"), [title_name[0]])
-                    data = curs.fetchall()
-                    if data:
-                        curs.execute(db_change("update data set title = ? where title = ?"), [title_name[1], title_name[0]])
-                        curs.execute(db_change("update back set link = ? where link = ?"), [title_name[1], title_name[0]])
-
-                        data_in = data[0][0]
-                    else:
-                        data_in = ''
-
-                    history_plus(
-                        title_name[0],
-                        data_in,
-                        get_time(),
-                        ip_check(),
-                        flask.request.form.get('send', ''),
-                        '0',
-                        t_check = '<a>' + (title_name[0] if title_name[0] != 'test ' + str(i) else name) + '</a> - <a>' + title_name[1] + '</a> move',
-                        mode = 'move'
-                    )
-
-                    curs.execute(db_change("update history set title = ? where title = ?"), [title_name[1], title_name[0]])
-                    curs.execute(db_change("update rc set title = ? where title = ?"), [title_name[1], title_name[0]])
-                    conn.commit()
-
-                return redirect('/w/' + url_pas(move_title))
-            else:
-                return re_error('/error/19')
         else:
-            curs.execute(db_change("select data from data where title = ?"), [name])
-            data = curs.fetchall()
-            if data:
-                curs.execute(db_change("update data set title = ? where title = ?"), [move_title, name])
-                curs.execute(db_change("update back set link = ? where link = ?"), [move_title, name])
-
-                data_in = data[0][0]
-            else:
-                data_in = ''
-
-            history_plus(
-                name,
-                data_in,
-                get_time(),
-                ip_check(),
-                flask.request.form.get('send', ''),
-                '0',
-                t_check = '<a>' + name + '</a> - <a>' + move_title + '</a> move',
-                mode = 'move'
-            )
-
-            curs.execute(db_change("update back set type = 'no' where title = ? and not type = 'cat' and not type = 'no'"), [name])
-            curs.execute(db_change("delete from back where title = ? and not type = 'cat' and type = 'no'"), [move_title])
-
-            curs.execute(db_change("update history set title = ? where title = ?"), [move_title, name])
-            curs.execute(db_change("update rc set title = ? where title = ?"), [move_title, name])
-            conn.commit()
-
-            return redirect('/w/' + url_pas(move_title))
-    else:
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('move') + ')', 0])],
-            data = '''
-                <form method="post">
-                    ''' + ip_warning() + '''
-                    <input placeholder="''' + load_lang('document_name') + '" value="' + name + '''" name="title" type="text">
-                    <hr class=\"main_hr\">
-                    <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                    <hr class=\"main_hr\">
-                    <select name="move_option">
-                        <option value="normal"> ''' + load_lang('normal') + '''</option>
-                        <option value="reverse"> ''' + load_lang('replace_move') + '''</option>
-                        ''' + ('<option value="merge"> ' + load_lang('merge_move') + '</option>' if admin_check() == 1 else '') + '''
-                    </select>
-                    <hr class=\"main_hr\">
-                    ''' + captcha_get() + '''
-                    <button type="submit">''' + load_lang('move') + '''</button>
-                </form>
-            ''',
-            menu = [['w/' + url_pas(name), load_lang('return')]]
-        ))
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('move') + ')', 0])],
+                data = '''
+                    <form method="post">
+                        ''' + ip_warning() + '''
+                        <input placeholder="''' + load_lang('document_name') + '" value="' + name + '''" name="title" type="text">
+                        <hr class=\"main_hr\">
+                        <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
+                        <hr class=\"main_hr\">
+                        <select name="move_option">
+                            <option value="normal"> ''' + load_lang('normal') + '''</option>
+                            <option value="reverse"> ''' + load_lang('replace_move') + '''</option>
+                            ''' + ('<option value="merge"> ' + load_lang('merge_move') + '</option>' if admin_check() == 1 else '') + '''
+                        </select>
+                        <hr class=\"main_hr\">
+                        ''' + captcha_get() + '''
+                        <button type="submit">''' + load_lang('move') + '''</button>
+                    </form>
+                ''',
+                menu = [['w/' + url_pas(name), load_lang('return')]]
+            ))

+ 67 - 66
route/edit_revert.py

@@ -1,82 +1,83 @@
 from .tool.func import *
 
-def edit_revert_2(conn, name):
-    curs = conn.cursor()
+def edit_revert(name):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
 
-    num = int(number_check(flask.request.args.get('num', '1')))
+        num = int(number_check(flask.request.args.get('num', '1')))
 
-    curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, str(num)])
-    if curs.fetchall() and admin_check(6) != 1:
-        return re_error('/error/3')
+        curs.execute(db_change("select title from history where title = ? and id = ? and hide = 'O'"), [name, str(num)])
+        if curs.fetchall() and admin_check(6) != 1:
+            return re_error('/error/3')
 
-    if acl_check(name) == 1:
-        return re_error('/ban')
+        if acl_check(name) == 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)
+        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)
 
-        if slow_edit_check() == 1:
-            return re_error('/error/24')
+            if slow_edit_check() == 1:
+                return re_error('/error/24')
 
-        curs.execute(db_change("select data from history where title = ? and id = ?"), [name, str(num)])
-        data = curs.fetchall()
-        if data:
-            if edit_filter_do(data[0][0]) == 1:
-                return re_error('/error/21')
+            curs.execute(db_change("select data from history where title = ? and id = ?"), [name, str(num)])
+            data = curs.fetchall()
+            if data:
+                if edit_filter_do(data[0][0]) == 1:
+                    return re_error('/error/21')
 
-        curs.execute(db_change("delete from back where link = ?"), [name])
-        conn.commit()
+            curs.execute(db_change("delete from back where link = ?"), [name])
+            conn.commit()
 
-        if data:
-            curs.execute(db_change("select data from data where title = ?"), [name])
-            data_old = curs.fetchall()
-            if data_old:
-                leng = leng_check(len(data_old[0][0]), len(data[0][0]))
-                curs.execute(db_change("update data set data = ? where title = ?"), [data[0][0], name])
-            else:
-                leng = '+' + str(len(data[0][0]))
-                curs.execute(db_change("insert into data (title, data) values (?, ?)"), [name, data[0][0]])
+            if data:
+                curs.execute(db_change("select data from data where title = ?"), [name])
+                data_old = curs.fetchall()
+                if data_old:
+                    leng = leng_check(len(data_old[0][0]), len(data[0][0]))
+                    curs.execute(db_change("update data set data = ? where title = ?"), [data[0][0], name])
+                else:
+                    leng = '+' + str(len(data[0][0]))
+                    curs.execute(db_change("insert into data (title, data) values (?, ?)"), [name, data[0][0]])
 
-            history_plus(
-                name,
-                data[0][0],
-                get_time(),
-                ip_check(),
-                flask.request.form.get('send', ''),
-                leng,
-                t_check = 'r' + str(num),
-                mode = 'revert'
-            )
+                history_plus(
+                    name,
+                    data[0][0],
+                    get_time(),
+                    ip_check(),
+                    flask.request.form.get('send', ''),
+                    leng,
+                    t_check = 'r' + str(num),
+                    mode = 'revert'
+                )
 
-            render_set(
-                doc_name = name,
-                doc_data = data[0][0],
-                data_type = 'backlink'
-            )
+                render_set(
+                    doc_name = name,
+                    doc_data = data[0][0],
+                    data_type = 'backlink'
+                )
 
-            conn.commit()
+                conn.commit()
 
-        return redirect('/w/' + url_pas(name))
-    else:
-        curs.execute(db_change("select title from history where title = ? and id = ?"), [name, str(num)])
-        if not curs.fetchall():
             return redirect('/w/' + url_pas(name))
+        else:
+            curs.execute(db_change("select title from history where title = ? and id = ?"), [name, str(num)])
+            if not curs.fetchall():
+                return redirect('/w/' + url_pas(name))
 
-        return easy_minify(flask.render_template(skin_check(),
-            imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('revert') + ')', 0])],
-            data =  '''
-                    <form method="post">
-                        <span>r''' + flask.request.args.get('num', '0') + '''</span>
-                        <hr class=\"main_hr\">
-                        ''' + ip_warning() + '''
-                        <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
-                        <hr class=\"main_hr\">
-                        ''' + captcha_get() + '''
-                        <button type="submit">''' + load_lang('revert') + '''</button>
-                    </form>
-                    ''',
-            menu = [['history/' + url_pas(name), load_lang('history')], ['recent_changes', load_lang('recent_change')]]
-        ))
+            return easy_minify(flask.render_template(skin_check(),
+                imp = [name, wiki_set(), wiki_custom(), wiki_css(['(' + load_lang('revert') + ')', 0])],
+                data =  '''
+                        <form method="post">
+                            <span>r''' + flask.request.args.get('num', '0') + '''</span>
+                            <hr class=\"main_hr\">
+                            ''' + ip_warning() + '''
+                            <input placeholder="''' + load_lang('why') + '''" name="send" type="text">
+                            <hr class=\"main_hr\">
+                            ''' + captcha_get() + '''
+                            <button type="submit">''' + load_lang('revert') + '''</button>
+                        </form>
+                        ''',
+                menu = [['history/' + url_pas(name), load_lang('history')], ['recent_changes', load_lang('recent_change')]]
+            ))

+ 18 - 765
route/main_func_setting.py

@@ -1,767 +1,20 @@
 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:
-            setting_list = {
-                0 : ['name', 'Wiki'],
-                2 : ['frontpage', 'FrontPage'],
-                4 : ['upload', '2'],
-                5 : ['skin', ''],
-                7 : ['reg', ''],
-                8 : ['ip_view', ''],
-                9 : ['back_up', '0'],
-                10 : ['port', '3000'],
-                11 : ['key', load_random_key()],
-                12 : ['update', 'stable'],
-                15 : ['encode', 'sha3'],
-                16 : ['host', '0.0.0.0'],
-                19 : ['slow_edit', '0'],
-                20 : ['requires_approval', ''],
-                21 : ['backup_where', ''],
-                22 : ['domain', flask.request.host_url],
-                23 : ['ua_get', ''],
-                24 : ['enable_comment', ''],
-                25 : ['enable_challenge', '']
-            }
-
-            if flask.request.method == 'POST':
-                for i in setting_list:
-                    curs.execute(db_change("update other set data = ? where name = ?"), [
-                        flask.request.form.get(setting_list[i][0], setting_list[i][1]),
-                        setting_list[i][0]
-                    ])
-
-                conn.commit()
-
-                admin_check(None, 'edit_set (' + str(num) + ')')
-
-                return redirect('/setting/1')
-            else:
-                d_list = {}
-                for i in setting_list:
-                    curs.execute(db_change('select data from other where name = ?'), [setting_list[i][0]])
-                    db_data = curs.fetchall()
-                    if not db_data:
-                        curs.execute(db_change('insert into other (name, data) values (?, ?)'), [setting_list[i][0], setting_list[i][1]])
-
-                    d_list[i] = db_data[0][0] if db_data else setting_list[i][1]
-                else:
-                    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
-                    elif i == 4:
-                        acl_num = 23
-                    elif i == 5:
-                        acl_num = 24
-                    elif i == 6:
-                        acl_num = 25
-
-                    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="''' + setting_list[22][0] + '''" 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>
-                            
-                            <h3>1.1. ''' + load_lang('communication_function') + '''</h3>
-                            <input type="checkbox" name="enable_comment" ''' + check_box_div[5] + '''> ''' + load_lang('enable_comment_function') + '''
-                            <hr class="main_hr">
-                            
-                            <input type="checkbox" name="enable_challenge" ''' + check_box_div[6] + '''> ''' + load_lang('enable_challenge_function') + '''
-                            <hr class="main_hr">
-
-                            <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>''' + load_lang('update_branch') + '''</span>
-                            <hr class="main_hr">
-                            <select name="update">''' + branch_div + '''</select>
-                            
-                            <span ''' + sqlite_only + '''>
-                                <h3>4.1. ''' + load_lang('sqlite') + '''</h3>
-                                <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') + ''') (''' + load_lang('example') + ''' : ./data/backup.db)
-                                </span>
-                                <hr class="main_hr">
-                                <input name="backup_where" value="''' + html.escape(d_list[21]) + '''">
-                                <hr class="main_hr">
-                            </span>
-
-                            <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="''' + setting_list[19][0] + '''" 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',
-                'topic_text'
-            ]
-            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>
-                            
-                            <h2>18. ''' + load_lang('topic_text') + '''</h2>
-                            <textarea rows="3" name="''' + i_list[17] + '''">''' + html.escape(d_list[17]) + '''</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']:
-                    if d_list[4] == i:
-                        security_radios = '<option value="' + i + '">' + i + '</option>' + security_radios
-                    else:
-                        security_radios += '<option value="' + i + '">' + i + '</option>'
-
-                re_ver_list = {
-                    '' : 'reCAPTCHA v2',
-                    'v3' : 'reCAPTCHA v3',
-                    'h' : 'hCAPTCHA'
-                }
-                re_ver = ''
-                for i in re_ver_list:
-                    if d_list[7] == i:
-                        re_ver = '<option value="' + i + '">' + re_ver_list[i] + '</option>' + re_ver
-                    else:
-                        re_ver += '<option value="' + i + '">' + re_ver_list[i] + '</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('captcha') + '''</h2>
-                            <a href="https://www.google.com/recaptcha/">(''' + load_lang('recaptcha') + ''')</a> <a href="https://www.hcaptcha.com/">(''' + load_lang('hcaptcha') + ''')</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">
-
-                            <span>''' + load_lang('version') + '''</span>
-                            <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">
-                            <select name="recaptcha_ver">
-                                ''' + security_radios + '''
-                            </select>
-                            <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') + ''' (''' + load_lang('incomplete') + ''')</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 += ['']
-                        
-                conn.commit()
-
-                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()
+def main_func_setting():
+    li_list = [
+        ['main', load_lang('main_setting')],
+        ['phrase', load_lang('text_setting')],
+        ['robot', 'robots.txt'],
+        ['external', load_lang('ext_api_req_set')],
+        ['head', load_lang('main_head')],
+        ['body_top', load_lang('main_body')],
+        ['body_bottom', 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')]]
+    ))

+ 97 - 0
route/main_func_setting_acl.py

@@ -0,0 +1,97 @@
+from .tool.func import *
+
+def main_func_setting_acl():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        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 (acl)') != 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/acl')
+        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')]]
+            ))

+ 145 - 0
route/main_func_setting_external.py

@@ -0,0 +1,145 @@
+from .tool.func import *
+
+def main_func_setting_external():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/ban')
+        
+        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 (external)')
+
+            return redirect('/setting/external')
+        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']:
+                if d_list[4] == i:
+                    security_radios = '<option value="' + i + '">' + i + '</option>' + security_radios
+                else:
+                    security_radios += '<option value="' + i + '">' + i + '</option>'
+
+            re_ver_list = {
+                '' : 'reCAPTCHA v2',
+                'v3' : 'reCAPTCHA v3',
+                'h' : 'hCAPTCHA'
+            }
+            re_ver = ''
+            for i in re_ver_list:
+                if d_list[7] == i:
+                    re_ver = '<option value="' + i + '">' + re_ver_list[i] + '</option>' + re_ver
+                else:
+                    re_ver += '<option value="' + i + '">' + re_ver_list[i] + '</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('captcha') + '''</h2>
+                        <a href="https://www.google.com/recaptcha/">(''' + load_lang('recaptcha') + ''')</a> <a href="https://www.hcaptcha.com/">(''' + load_lang('hcaptcha') + ''')</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">
+
+                        <span>''' + load_lang('version') + '''</span>
+                        <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">
+                        <select name="recaptcha_ver">
+                            ''' + security_radios + '''
+                        </select>
+                        <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') + ''' (''' + load_lang('incomplete') + ''')</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')]]
+            ))

+ 99 - 0
route/main_func_setting_head.py

@@ -0,0 +1,99 @@
+from .tool.func import *
+
+def main_func_setting_head(num, skin_name = ''):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/ban')
+        
+        if flask.request.method == 'POST':
+            if num == 4:
+                info_d = 'body'
+                end_r = 'body/top'
+                coverage = ''
+            elif num == 7:
+                info_d = 'bottom_body'
+                end_r = 'body/bottom'
+                coverage = ''
+            else:
+                info_d = 'head'
+                end_r = 'head'
+                if skin_name == '':
+                    coverage = ''
+                else:
+                    coverage = skin_name
+
+            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 (' + info_d + ')')
+
+            if skin_name == '':
+                return redirect('/setting/' + end_r)
+            else:
+                return redirect('/setting/' + end_r + '/' + skin_name)
+        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 = ?"), [skin_name])
+                title = '_head'
+                start = '' + \
+                    '<a href="?">(' + load_lang('all') + ')</a> ' + \
+                    ' '.join(['<a href="/setting/head/' + 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 skin_name != '':
+                sub_plus = ' (' + skin_name + ')'
+            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')]]
+            ))

+ 206 - 0
route/main_func_setting_main.py

@@ -0,0 +1,206 @@
+from .tool.func import *
+
+def main_func_setting_main(db_set):
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/ban')
+        
+        setting_list = {
+            0 : ['name', 'Wiki'],
+            2 : ['frontpage', 'FrontPage'],
+            4 : ['upload', '2'],
+            5 : ['skin', ''],
+            7 : ['reg', ''],
+            8 : ['ip_view', ''],
+            9 : ['back_up', '0'],
+            10 : ['port', '3000'],
+            11 : ['key', load_random_key()],
+            12 : ['update', 'stable'],
+            15 : ['encode', 'sha3'],
+            16 : ['host', '0.0.0.0'],
+            19 : ['slow_edit', '0'],
+            20 : ['requires_approval', ''],
+            21 : ['backup_where', ''],
+            22 : ['domain', flask.request.host_url],
+            23 : ['ua_get', ''],
+            24 : ['enable_comment', ''],
+            25 : ['enable_challenge', ''],
+            26 : ['edit_bottom_compulsion', '']
+        }
+
+        if flask.request.method == 'POST':
+            for i in setting_list:
+                curs.execute(db_change("update other set data = ? where name = ?"), [
+                    flask.request.form.get(setting_list[i][0], setting_list[i][1]),
+                    setting_list[i][0]
+                ])
+
+            conn.commit()
+
+            admin_check(None, 'edit_set (main)')
+
+            return redirect('/setting/main')
+        else:
+            d_list = {}
+            for i in setting_list:
+                curs.execute(db_change('select data from other where name = ?'), [setting_list[i][0]])
+                db_data = curs.fetchall()
+                if not db_data:
+                    curs.execute(db_change('insert into other (name, data) values (?, ?)'), [setting_list[i][0], setting_list[i][1]])
+
+                d_list[i] = db_data[0][0] if db_data else setting_list[i][1]
+            else:
+                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
+                elif i == 4:
+                    acl_num = 23
+                elif i == 5:
+                    acl_num = 24
+                elif i == 6:
+                    acl_num = 25
+                elif i == 7:
+                    acl_num = 26
+
+                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/main/logo">(''' + 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="''' + setting_list[22][0] + '''" 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>
+
+                        <h3>1.1. ''' + load_lang('communication_set') + '''</h3>
+                        <input type="checkbox" name="enable_comment" ''' + check_box_div[5] + '''> ''' + load_lang('enable_comment_function') + '''
+                        <hr class="main_hr">
+
+                        <input type="checkbox" name="enable_challenge" ''' + check_box_div[6] + '''> ''' + load_lang('enable_challenge_function') + '''
+                        <hr class="main_hr">
+
+                        <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>''' + load_lang('update_branch') + '''</span>
+                        <hr class="main_hr">
+                        <select name="update">''' + branch_div + '''</select>
+
+                        <span ''' + sqlite_only + '''>
+                            <h3>4.1. ''' + load_lang('sqlite_only') + '''</h3>
+                            <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') + ''') (''' + load_lang('example') + ''' : ./data/backup.db)
+                            </span>
+                            <hr class="main_hr">
+                            <input name="backup_where" value="''' + html.escape(d_list[21]) + '''">
+                            <hr class="main_hr">
+                        </span>
+
+                        <h2>5. ''' + load_lang('edit_set') + '''</h2>
+                        <span><a href="/setting/acl">(''' + 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="''' + setting_list[19][0] + '''" value="''' + html.escape(d_list[19]) + '''">
+                        
+                        <hr class="main_hr">
+                        <input type="checkbox" name="edit_bottom_compulsion" ''' + check_box_div[7] + '''> ''' + load_lang('edit_bottom_compulsion') + '''
+
+                        <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')]]
+            ))

+ 60 - 0
route/main_func_setting_main_logo.py

@@ -0,0 +1,60 @@
+from .tool.func import *
+
+def main_func_setting_main_logo():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+        
+        if admin_check() != 1:
+            return re_error('/ban')
+
+        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 (logo)')
+
+            return redirect('/setting/main/logo')
+        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 += ['']
+
+            conn.commit()
+
+            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/main', load_lang('return')]]
+            ))

+ 126 - 0
route/main_func_setting_phrase.py

@@ -0,0 +1,126 @@
+from .tool.func import *
+
+def main_func_setting_phrase():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/ban')
+        
+        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',
+            'topic_text'
+        ]
+        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 (phrase)')
+
+            return redirect('/setting/phrase')
+        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>
+
+                        <h2>18. ''' + load_lang('topic_text') + '''</h2>
+                        <textarea rows="3" name="''' + i_list[17] + '''">''' + html.escape(d_list[17]) + '''</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')]]
+            ))

+ 67 - 0
route/main_func_setting_robot.py

@@ -0,0 +1,67 @@
+from .tool.func import *
+
+def main_func_setting_robot():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        if admin_check() != 1:
+            return re_error('/ban')
+        
+        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 (robot)')
+
+            return redirect('/setting/robot')
+        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')]]
+            ))

+ 1 - 1
route/main_tool_admin.py

@@ -36,7 +36,7 @@ def main_tool_admin(num = 1, add_2 = ''):
                     <h2>2. ''' + load_lang('owner') + '''</h2>
                     <ul class="inside_ul">
                         <li><a href="/admin_group">''' + load_lang('admin_group_list') + '''</a></li>
-                        <li><a href="/delete/doc_mutiple">''' + load_lang('many_delete') + '''</a></li>
+                        <li><a href="/delete_mutiple">''' + load_lang('many_delete') + '''</a></li>
                         <li><a href="/app_submit">''' + load_lang('application_list') + '''</a></li>
                         <li><a href="/api/sitemap.xml">''' + load_lang('get_sitemap') + '''</a></li>
                         <li><a href="/register">''' + load_lang('add_user') + '''</a></li>

+ 1 - 1
route/view_read.py

@@ -74,7 +74,7 @@ def view_read_2(conn, name, doc_rev, doc_from):
                 <h2>CONTENT</h2>
             '''
 
-            menu += [['delete/doc_file/' + url_pas(name), load_lang('file_delete')]]
+            menu += [['delete_file/' + url_pas(name), load_lang('file_delete')]]
         else:
             file_data = ''
             

+ 1 - 1
route/view_xref.py

@@ -49,5 +49,5 @@ def view_xref_2(conn, name, xref_type = '1'):
     return easy_minify(flask.render_template(skin_check(),
         imp = [name, wiki_set(), wiki_custom(), wiki_css([data_sub, 0])],
         data = div,
-        menu = [['w/' + url_pas(name), load_lang('return')], ['backlink_reset/' + url_pas(name), load_lang('reset_backlink')]]
+        menu = [['w/' + url_pas(name), load_lang('return')], ['xref_reset/' + url_pas(name), load_lang('reset_backlink')]]
     ))

+ 1 - 1
version.json

@@ -1,6 +1,6 @@
 {
     "beta" : {
-        "r_ver" : "v3.4.4 (stable1) (beta3) (dev10)",
+        "r_ver" : "v3.4.4 (stable1) (beta3) (dev11)",
         "c_ver" : "3500105",
         "s_ver" : "3500110"
     }

+ 2 - 2
views/main_css/css/main.css

@@ -120,7 +120,7 @@ a {
 }
 
 /* 위키 내용 관련 */
-#toc, .opennamuTOC {
+#toc, .opennamu_TOC {
     border: 1px solid gainsboro;
     padding: 20px;
     
@@ -146,7 +146,7 @@ pre {
     white-space: pre-wrap;
 }
 
-#toc_title, .opennamuTOCtitle {
+#toc_title, .opennamu_TOC_title {
     font-size: 1.2rem;
 }
 

+ 3 - 2
views/main_css/js/render/markdown.js

@@ -1,5 +1,6 @@
 "use strict";
 
+// 걍 언더바로 통일하자
 class opennamu_render_markdown {
     // Init Part
     constructor(
@@ -486,8 +487,8 @@ class opennamu_render_markdown {
             } else if(x1 === 'toc') {
                 if(parser_data_temp_other['toc'] !== '') {
                     return '' +
-                        '<div class="opennamuTOC">' + 
-                            '<span class="opennamuTOCtitle">' +
+                        '<div class="opennamu_TOC">' + 
+                            '<span class="opennamu_TOC_title">' +
                                 'TOC' +
                             '</span>' + 
                             '<br>' +