|
@@ -6,52 +6,38 @@ def main_func_setting_robot():
|
|
|
|
|
|
|
|
if admin_check() != 1:
|
|
if admin_check() != 1:
|
|
|
return re_error('/ban')
|
|
return re_error('/ban')
|
|
|
|
|
+
|
|
|
|
|
+ curs.execute(db_change("select data from other where name = 'robot'"))
|
|
|
|
|
+ db_data = curs.fetchall()
|
|
|
|
|
+ if db_data:
|
|
|
|
|
+ data = db_data[0][0]
|
|
|
|
|
+ else:
|
|
|
|
|
+ data = ''
|
|
|
|
|
+
|
|
|
|
|
+ curs.execute(db_change("select data from other where name = 'robot_default'"))
|
|
|
|
|
+ db_data_2 = curs.fetchall()
|
|
|
|
|
+ if db_data_2 and db_data_2[0][0] != '':
|
|
|
|
|
+ default_data = 'checked'
|
|
|
|
|
+ else:
|
|
|
|
|
+ default_data = ''
|
|
|
|
|
|
|
|
if flask.request.method == 'POST':
|
|
if flask.request.method == 'POST':
|
|
|
- curs.execute(db_change("select name from other where name = 'robot'"))
|
|
|
|
|
- if curs.fetchall():
|
|
|
|
|
|
|
+ if db_data:
|
|
|
curs.execute(db_change("update other set data = ? where name = 'robot'"), [flask.request.form.get('content', '')])
|
|
curs.execute(db_change("update other set data = ? where name = 'robot'"), [flask.request.form.get('content', '')])
|
|
|
else:
|
|
else:
|
|
|
curs.execute(db_change("insert into other (name, data) values ('robot', ?)"), [flask.request.form.get('content', '')])
|
|
curs.execute(db_change("insert into other (name, data) values ('robot', ?)"), [flask.request.form.get('content', '')])
|
|
|
|
|
|
|
|
- conn.commit()
|
|
|
|
|
|
|
+ if db_data_2:
|
|
|
|
|
+ curs.execute(db_change("update other set data = ? where name = 'robot_default'"), [flask.request.form.get('default', '')])
|
|
|
|
|
+ else:
|
|
|
|
|
+ curs.execute(db_change("insert into other (name, data) values ('robot_default', ?)"), [flask.request.form.get('default', '')])
|
|
|
|
|
|
|
|
- fw = open('./robots.txt', 'w', encoding='utf8')
|
|
|
|
|
- fw.write(re.sub('\r\n', '\n', flask.request.form.get('content', '')))
|
|
|
|
|
- fw.close()
|
|
|
|
|
|
|
+ conn.commit()
|
|
|
|
|
|
|
|
admin_check(None, 'edit_set (robot)')
|
|
admin_check(None, 'edit_set (robot)')
|
|
|
|
|
|
|
|
return redirect('/setting/robot')
|
|
return redirect('/setting/robot')
|
|
|
else:
|
|
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(),
|
|
return easy_minify(flask.render_template(skin_check(),
|
|
|
imp = ['robots.txt', wiki_set(), wiki_custom(), wiki_css([0, 0])],
|
|
imp = ['robots.txt', wiki_set(), wiki_custom(), wiki_css([0, 0])],
|
|
|
data = '''
|
|
data = '''
|
|
@@ -60,6 +46,8 @@ def main_func_setting_robot():
|
|
|
<form method="post">
|
|
<form method="post">
|
|
|
<textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
|
|
<textarea rows="25" name="content">''' + html.escape(data) + '''</textarea>
|
|
|
<hr class="main_hr">
|
|
<hr class="main_hr">
|
|
|
|
|
+ <input type="checkbox" name="default" ''' + default_data + '''> ''' + load_lang('default') + '''
|
|
|
|
|
+ <hr class="main_hr">
|
|
|
<button id="opennamu_js_save" type="submit">''' + load_lang('save') + '''</button>
|
|
<button id="opennamu_js_save" type="submit">''' + load_lang('save') + '''</button>
|
|
|
</form>
|
|
</form>
|
|
|
''',
|
|
''',
|