from .tool.func import * def edit_2(conn, name): curs = conn.cursor() ip = ip_check() if acl_check(name) == 1: return re_error('/ban') if flask.request.method == 'POST': if captcha_post(flask.request.form.get('g-recaptcha-response', '')) == 1: return re_error('/error/13') else: captcha_post('', 0) if flask.request.form.get('otent', '') == flask.request.form.get('content', ''): return redirect('/w/' + url_pas(name)) if edit_filter_do(flask.request.form.get('content', '')) == 1: return re_error('/error/21') today = get_time() content = savemark(flask.request.form.get('content', '')) curs.execute(db_change("select data from data where title = ?"), [name]) old = curs.fetchall() if old: leng = leng_check(len(flask.request.form.get('otent', '')), len(content)) if flask.request.args.get('section', None): content = old[0][0].replace(flask.request.form.get('otent', ''), content) curs.execute(db_change("update data set data = ? where title = ?"), [content, name]) else: leng = '+' + str(len(content)) curs.execute(db_change("insert into data (title, data) values (?, ?)"), [name, content]) 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)]) curs.execute(db_change("select user from scan where title = ?"), [name]) for _ in curs.fetchall(): curs.execute(db_change("insert into alarm (name, data, date) values (?, ?, ?)"), [ ip, ip + ' | ' + name + ' | Edit', today ]) history_plus( name, content, today, ip, flask.request.form.get('send', ''), leng ) 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( title = name, data = content, num = 1 ) conn.commit() return redirect('/w/' + url_pas(name)) else: curs.execute(db_change("select data from data where title = ?"), [name]) new = curs.fetchall() if new: if flask.request.args.get('section', None): data = re.sub('\n(?P={1,6})', '
\g', html.escape('\n' + re.sub('\r\n', '\n', new[0][0]) + '\n')) i = 0 while 1: g_data = re.search('((?:
)(?:(?:(?!\n|
).)+)(?:\n*(?:(?:(?!
).)+\n*)+)?)', data) if g_data: if int(flask.request.args.get('section', '1')) - 1 == i: data = html.unescape(re.sub('
(?P={1,6})', '\n\g', g_data.groups()[0])) break else: data = re.sub('((?:
)(?:(?:(?!\n|
).)+)(?:\n*(?:(?:(?!
).)+\n*)+)?)', '\n', data, 1) i += 1 else: break else: data = new[0][0] else: data = '' data_old = data if not flask.request.args.get('section', None): get_name = ''' (' + load_lang('load') + ') (' + load_lang('edit_filter_rule') + ''')
''' else: get_name = '' if flask.request.args.get('plus', None): curs.execute(db_change("select data from data where title = ?"), [flask.request.args.get('plus', 'test')]) get_data = curs.fetchall() if get_data: data = get_data[0][0] get_name = '' curs.execute(db_change('select data from other where name = "edit_bottom_text"')) sql_d = curs.fetchall() if sql_d and sql_d[0][0] != '': b_text = '
' + sql_d[0][0] else: b_text = '' curs.execute(db_change('select data from other where name = "edit_help"')) sql_d = curs.fetchall() if sql_d and sql_d[0][0] != '': p_text = sql_d[0][0] else: p_text = load_lang('defalut_edit_help') return easy_minify(flask.render_template(skin_check(), imp = [name, wiki_set(), custom(), other2([' (' + load_lang('edit') + ')', 0])], data = get_name + '''
''' + edit_button() + '''

''' + captcha_get() + ip_warring() + '''
''' + b_text + '''
''', menu = [['w/' + url_pas(name), load_lang('return')], ['delete/' + url_pas(name), load_lang('delete')], ['move/' + url_pas(name), load_lang('move')]] ))