from .tool.func import * def edit_req_2(conn, name): curs = conn.cursor() ip = ip_check() get_ver = flask.request.args.get('r', None) if get_ver: section = None else: section = flask.request.args.get('section', None) if acl_check(name) == 1: if acl_check(name, 'edit_req') == 1 or re.search('^user:', name) or get_ver: return re_error('/ban') else: if not get_ver: return redirect('/edit/' + url_pas(name)) else: get_ver = int(number_check(get_ver)) if not get_ver: curs.execute(db_change("select data from data where title = ?"), [name]) old = curs.fetchall() if not old: return redirect('/ban') else: curs.execute(db_change("select data, send, ip, date from history where title = ? and id = ? and type = 'req'"), [name, str(get_ver)]) old = curs.fetchall() if not old: return redirect('/w/' + url_pas(name)) if flask.request.method == 'POST': if captcha_post(flask.request.form.get('g-recaptcha-response', flask.request.form.get('g-recaptcha', ''))) == 1: return re_error('/error/13') else: captcha_post('', 0) if slow_edit_check() == 1: return re_error('/error/24') today = get_time() if get_ver: content = old[0][0] else: content = flask.request.form.get('content', '') if flask.request.form.get('otent', '') == content: return redirect('/w/' + url_pas(name)) if edit_filter_do(content) == 1: return re_error('/error/21') curs.execute(db_change('select data from other where name = "copyright_checkbox_text"')) copyright_checkbox_text_d = curs.fetchall() if copyright_checkbox_text_d and copyright_checkbox_text_d[0][0] != '' and flask.request.form.get('copyright_agreement', '') != 'yes': return re_error('/error/29') content = savemark(content) if old: leng = leng_check(len(flask.request.form.get('otent', '')), len(content)) if section: content = old[0][0].replace( flask.request.form.get('otent', '').replace('\r\n', '\n'), content.replace('\r\n', '\n') ) else: leng = '+' + str(len(content)) if get_ver: if old: curs.execute(db_change("update data set data = ? where title = ?"), [content, name]) else: 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 scan_user in curs.fetchall(): curs.execute(db_change("insert into alarm (name, data, date) values (?, ?, ?)"), [ scan_user[0], ip + ' | ' + name + ' | Edit', today ]) curs.execute(db_change("update history set type = '', send = ? where title = ? and id = ? and ip = ? and date = ? and type = 'req'"), [ old[0][1] + ' (' + ip + ' pass)', name, str(get_ver), old[0][2], old[0][3] ]) 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 ) else: history_plus( name, content, today, ip, flask.request.form.get('send', ''), leng, '', 'req' ) conn.commit() if get_ver: return redirect('/w/' + url_pas(name)) else: return redirect('/recent_changes?set=req') else: if old: data = old[0][0] else: data = '' data_old = data get_name = '' save_button = load_lang('edit_req') if not get_ver else load_lang('accept_edit_request') menu_plus = [[]] sub = load_lang('edit_req') disable = '' if not get_ver else 'disabled' 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 = '