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 += '
',
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 = '''
''',
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', None), 'contract'])
curs.execute("update other set data = ? where name = ?", [flask.request.form.get('no_login_warring', None), '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 = '''
''',
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'
else:
info_d = 'head'
end_r = '3'
curs.execute("select name from other where name = ?", [info_d])
if curs.fetchall():
curs.execute("update other set data = ? where name = ?", [flask.request.form.get('content', ''), info_d])
else:
curs.execute("insert into other (name, data) values (?, ?)", [info_d, flask.request.form.get('content', '')])
conn.commit()
admin_check(None, 'edit_set')
return redirect('/setting/' + end_r)
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'")
title = '_head'
start = '<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 = '''
''',
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', None)])
else:
curs.execute("insert into other (name, data) values ('robot', ?)", [flask.request.form.get('content', None)])
conn.commit()
fw = open('./robots.txt', 'w')
fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', None)))
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:
curs.execute("update other set data = ? where name = ?", [flask.request.form.get(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 = '''
''',
menu = [['setting', load_lang('return')]]
))
else:
return redirect()