from .tool.func import * async def main_setting_main(): with get_db_connect() as conn: curs = conn.cursor() if await acl_check('', 'owner_auth', '', '') == 1: return await re_error(conn, 0) setting_list = { 0 : ['name', 'Wiki'], 2 : ['frontpage', 'FrontPage'], 4 : ['upload', '2'], 5 : ['skin', ''], 7 : ['reg', ''], 8 : ['ip_view', ''], 9 : ['back_up', ''], 10 : ['port', '3000'], 11 : ['key', load_random_key()], 12 : ['update', 'stable'], 15 : ['encode', 'sha3'], 16 : ['host', '0.0.0.0'], 19 : ['slow_edit', ''], 20 : ['requires_approval', ''], 21 : ['backup_where', ''], 22 : ['domain', ''], 23 : ['ua_get', ''], 24 : ['enable_comment', ''], 26 : ['edit_bottom_compulsion', ''], 27 : ['http_select', 'http'], 28 : ['title_max_length', ''], 29 : ['title_topic_max_length', ''], 30 : ['password_min_length', ''], 31 : ['wiki_access_password_need', ''], 32 : ['wiki_access_password', ''], 33 : ['history_recording_off', ''], 34 : ['namumark_compatible', ''], 35 : ['user_name_view', ''], 36 : ['link_case_insensitive', ''], 37 : ['move_with_redirect', ''], 38 : ['slow_thread', ''], 39 : ['edit_timeout', '5'], 40 : ['document_content_max_length', ''], 41 : ['backup_count', ''], 42 : ['ua_expiration_date', ''], 43 : ['auth_history_expiration_date', ''], 44 : ['auth_history_off', ''], 45 : ['user_name_level', ''], 46 : ['load_ip_select', ''], 47 : ['not_use_view_count', ''] } 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] ]) await acl_check(tool = 'owner_auth', memo = 'edit_set (main)') return redirect(conn, '/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, coverage) values (?, ?, "")'), [setting_list[i][0], setting_list[i][1]]) d_list[i] = db_data[0][0] if db_data else setting_list[i][1] init_set_list = get_init_set_list() # 언어도 변경 가능하도록 필요 encode_select = '' encode_select_data = init_set_list['encode']['list'] + ['sha256'] for encode_select_one in encode_select_data: if encode_select_one == d_list[15]: encode_select = '' + encode_select else: encode_select += '' tls_select = '' tls_select_data = ['http', 'https'] for tls_select_one in tls_select_data: if tls_select_one == d_list[27]: tls_select = '' + tls_select else: tls_select += '' check_box_div = [7, 8, '', 20, 23, 24, '', 26, 31, 33, 34, 35, 36, 37, 44, 45, 47] for i in range(0, len(check_box_div)): acl_num = check_box_div[i] if acl_num != '' and d_list[acl_num]: check_box_div[i] = 'checked="checked"' else: check_box_div[i] = '' branch_div = '' branch_list = ['stable', 'dev', 'beta'] for i in branch_list: if d_list[12] == i: branch_div = '' + branch_div else: branch_div += '' set_data = global_some_set_do('db_type') sqlite_only = '' if set_data != 'sqlite': sqlite_only = 'style="display:none;"' ip_load_select_data = '' ip_load_option = ['default', 'HTTP_X_REAL_IP', 'HTTP_CF_CONNECTING_IP', 'REMOTE_ADDR'] for for_a in ip_load_option: view_ip_option = for_a if for_a == 'default': view_ip_option = await get_lang('default') if d_list[46] == for_a: ip_load_select_data = '' + ip_load_select_data else: ip_load_select_data += '' basic_set = '''

''' + await get_lang('basic_set') + '''

''' + await get_lang('wiki_name') + '''

(''' + await get_lang('wiki_logo') + ''')
''' + await get_lang('main_page') + '''

''' + await get_lang('tls_method') + '''

''' + await get_lang('domain') + ''' (EX : 2du.pythonanywhere.com) (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('wiki_host') + '''

''' + await get_lang('wiki_port') + '''

''' + await get_lang('wiki_secret_key') + '''


''' + await get_lang('set_wiki_access_password') + ''' (''' + await get_lang('restart_required') + ''')

''' + await get_lang('wiki_load_ip_select') + ''' (''' + await get_lang('restart_required') + ''')

''' + await get_lang('authority_use_list') + '''


''' + await get_lang('authority_use_list_expiration_date') + ''' (''' + await get_lang('day') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('communication_set') + '''




''' return easy_minify(flask.render_template(await skin_check(conn), imp = [await get_lang('main_setting'), await wiki_set(), await wiki_custom(conn), wiki_css([0, 0])], data = await render_simple_set('''
''' + basic_set + '''

''' + await get_lang('design_set') + '''

''' + await get_lang('wiki_skin') + '''

''' + await get_lang('render_set') + '''



''' + await get_lang('login_set') + '''





''' + await get_lang('password_min_length') + ''' (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('encryption_method') + '''

''' + await get_lang('ua') + '''


''' + await get_lang('ua_expiration_date') + ''' (''' + await get_lang('day') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('server_set') + '''

''' + await get_lang('update_branch') + '''

''' + await get_lang('backup') + ''' (''' + await get_lang('sqlite_only') + ''')

''' + await get_lang('backup_warning') + ''' (EX : data_YYYYMMDDHHMMSS.db)

''' + await get_lang('backup_interval') + ''' (''' + await get_lang('hour') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('backup_where') + ''' (''' + await get_lang('default') + ''' : ''' + await get_lang('empty') + ''') (''' + await get_lang('example') + ''' : ./data/backup.db)

''' + await get_lang('backup_count') + ''' (''' + await get_lang('default') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('edit_set') + '''

''' + await get_lang('slow_edit') + ''' (''' + await get_lang('second') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')


''' + await get_lang('title_max_length') + ''' (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('title_topic_max_length') + ''' (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('max_file_size') + ''' (MB)



''' + await get_lang('slow_thread') + ''' (''' + await get_lang('second') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

''' + await get_lang('edit_timeout') + ''' (''' + await get_lang('second') + ''') (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''') (''' + await get_lang('linux_only') + ''')

''' + await get_lang('document_content_max_length') + ''' (''' + await get_lang('off') + ''' : ''' + await get_lang('empty') + ''')

'''), menu = [['setting', await get_lang('return')]] ))