from .tool.func import * def setting_2(conn, num): curs = conn.cursor() if num != 0 and admin_check() != 1: return re_error('/ban') if num == 0: li_list = [ load_lang('main_setting'), load_lang('text_setting'), load_lang('main_head'), load_lang('main_body'), 'robots.txt', 'Google' ] x = 0 li_data = '' for li in li_list: x += 1 li_data += '
  • ' + li + '
  • ' return easy_minify(flask.render_template(skin_check(), imp = [load_lang('setting'), wiki_set(), custom(), other2([0, 0])], data = '

    ' + load_lang('list') + '

    ', menu = [['manager', load_lang('return')]] )) elif num == 1: i_list = ['name', 'logo', 'frontpage', 'license', 'upload', 'skin', 'edit', 'reg', 'ip_view', 'back_up', 'port', 'key', 'update', 'email_have', 'discussion', 'encode', 'host'] n_list = ['wiki', '', 'FrontPage', 'CC 0', '2', '', 'normal', '', '', '0', '3000', 'test', 'stable', '', 'normal', 'sha256', '0.0.0.0'] if flask.request.method == 'POST': i = 0 for data in i_list: curs.execute("update other set data = ? where name = ?", [flask.request.form.get(data, n_list[i]), data]) i += 1 conn.commit() admin_check(None, 'edit_set') return redirect('/setting/1') else: d_list = [] x = 0 for i in i_list: curs.execute('select data from other where name = ?', [i]) sql_d = curs.fetchall() if sql_d: d_list += [sql_d[0][0]] else: curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]]) d_list += [n_list[x]] x += 1 conn.commit() div = '' acl_list = [[load_lang('member'), 'login'], [load_lang('ip'), 'normal'], [load_lang('admin'), 'admin']] for i in acl_list: if i[1] == d_list[6]: div = '' + div else: div += '' div4 = '' for i in acl_list: if i[1] == d_list[14]: div4 = '' + div4 else: div4 += '' ch_1 = '' if d_list[7]: ch_1 = 'checked="checked"' ch_2 = '' if d_list[8]: ch_2 = 'checked="checked"' ch_3 = '' if d_list[13]: ch_3 = 'checked="checked"' div2 = load_skin(d_list[5]) div3 ='' if d_list[12] == 'stable': div3 += '' div3 += '' else: div3 += '' div3 += '' div5 ='' encode_data = ['sha256', 'sha3'] for i in encode_data: if d_list[15] == i: div5 = '' + div5 else: div5 += '' return easy_minify(flask.render_template(skin_check(), imp = [load_lang('main_setting'), wiki_set(), custom(), other2([0, 0])], data = '''
    ''' + load_lang('wiki_name') + '''


    ''' + load_lang('wiki_logo') + ''' (HTML)


    ''' + load_lang('main_page') + '''


    ''' + load_lang('bottom_text') + ''' (HTML)


    ''' + load_lang('max_file_size') + ''' [MB]


    ''' + load_lang('backup_interval') + ' [' + load_lang('hour') + '''] (off : 0) {restart}


    ''' + load_lang('wiki_skin') + '''


    ''' + load_lang('default_acl') + '''


    ''' + load_lang('default_discussion_acl') + '''


    ''' + load_lang('no_register') + '''
    ''' + load_lang('hide_ip') + '''
    ''' + load_lang('email_required') + ''' {''' + load_lang('google_imap_required') + '''}
    ''' + load_lang('wiki_host') + '''


    ''' + load_lang('wiki_port') + '''


    ''' + load_lang('wiki_secret_key') + '''


    ''' + load_lang('update_branch') + '''


    ''' + load_lang('encryption_method') + '''


    ''', menu = [['setting', load_lang('return')]] )) elif num == 2: if flask.request.method == 'POST': curs.execute("update other set data = ? where name = ?", [flask.request.form.get('contract', ''), 'contract']) curs.execute("update other set data = ? where name = ?", [flask.request.form.get('no_login_warring', ''), 'no_login_warring']) conn.commit() admin_check(None, 'edit_set') return redirect('/setting/2') else: i_list = ['contract', 'no_login_warring'] n_list = ['', ''] d_list = [] x = 0 for i in i_list: curs.execute('select data from other where name = ?', [i]) sql_d = curs.fetchall() if sql_d: d_list += [sql_d[0][0]] else: curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]]) d_list += [n_list[x]] x += 1 conn.commit() return easy_minify(flask.render_template(skin_check(), imp = [load_lang('text_setting'), wiki_set(), custom(), other2([0, 0])], data = '''
    ''' + load_lang('register_text') + '''


    ''' + load_lang('non_login_alert') + '''


    ''', menu = [['setting', load_lang('return')]] )) elif num == 3 or num == 4: if flask.request.method == 'POST': if num == 4: info_d = 'body' end_r = '4' coverage = '' else: info_d = 'head' end_r = '3' if flask.request.args.get('skin', '') == '': coverage = '' else: coverage = flask.request.args.get('skin', '') curs.execute("select name from other where name = ? and coverage = ?", [info_d, coverage]) if curs.fetchall(): curs.execute("update other set data = ?, coverage = ? where name = ?", [ flask.request.form.get('content', ''), coverage, info_d ]) else: curs.execute("insert into other (name, data, coverage) values (?, ?, ?)", [info_d, flask.request.form.get('content', ''), coverage]) conn.commit() admin_check(None, 'edit_set') return redirect('/setting/' + end_r + '?skin=' + flask.request.args.get('skin', '')) else: if num == 4: curs.execute("select data from other where name = 'body'") title = '_body' start = '' else: curs.execute("select data from other where name = 'head' and coverage = ?", [flask.request.args.get('skin', '')]) title = '_head' start = '(' + load_lang('all') + ') ' + \ ' '.join(['(' + i + ')' for i in load_skin('', 1)]) + \ '''
    <style>CSS</style>
    <script>JS</script>

    ''' head = curs.fetchall() if head: data = head[0][0] else: data = '' return easy_minify(flask.render_template(skin_check(), imp = [load_lang(data = 'main' + title, safe = 1), wiki_set(), custom(), other2([0, 0])], data = '''
    ''' + start + '''
    ''', menu = [['setting', load_lang('return')]] )) elif num == 5: if flask.request.method == 'POST': curs.execute("select name from other where name = 'robot'") if curs.fetchall(): curs.execute("update other set data = ? where name = 'robot'", [flask.request.form.get('content', '')]) else: curs.execute("insert into other (name, data) values ('robot', ?)", [flask.request.form.get('content', '')]) conn.commit() fw = open('./robots.txt', 'w') fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', ''))) fw.close() admin_check(None, 'edit_set') return redirect('/setting/4') else: curs.execute("select data from other where name = 'robot'") robot = curs.fetchall() if robot: data = robot[0][0] else: data = '' f = open('./robots.txt', 'r') 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(), custom(), other2([0, 0])], data = ''' (view)

    ''', menu = [['setting', load_lang('return')]] )) elif num == 6: i_list = ['recaptcha', 'sec_re', 'g_email', 'g_pass'] if flask.request.method == 'POST': for data in i_list: if data == 'g_email': into_data = re.sub('@.*$', '', flask.request.form.get(data, '')) else: into_data = flask.request.form.get(data, '') curs.execute("update other set data = ? where name = ?", [into_data, data]) conn.commit() admin_check(None, 'edit_set') return redirect('/setting/6') else: n_list = ['', '', '', ''] d_list = [] x = 0 for i in i_list: curs.execute('select data from other where name = ?', [i]) sql_d = curs.fetchall() if sql_d: d_list += [sql_d[0][0]] else: curs.execute('insert into other (name, data) values (?, ?)', [i, n_list[x]]) d_list += [n_list[x]] x += 1 conn.commit() return easy_minify(flask.render_template(skin_check(), imp = ['Google', wiki_set(), custom(), other2([0, 0])], data = '''

    recaptcha

    ''' + load_lang('recaptcha') + ''' (HTML)


    ''' + load_lang('recaptcha') + ' (' + load_lang('secret_key') + ''')


    ''' + load_lang('google_imap') + ' {' + load_lang('restart_required') + '''}

    ''' + load_lang('google_email') + '''


    ''' + load_lang('google_app_password') + '''


    ''', menu = [['setting', load_lang('return')]] )) else: return redirect()