from .tool.func import * def vote_select_2(conn, num): curs = conn.cursor() curs.execute(db_change('select name, subject, data, type from vote where id = ? and user = ""'), [num]) data_list = curs.fetchall() if not data_list: return redirect('/vote') if data_list[0][3] == 'close' or data_list[0][3] == 'n_close': return redirect('/vote/end/' + num) if acl_check('', 'vote', num) == 1: return redirect('/vote/end/' + num) curs.execute(db_change('select user from vote where id = ? and user = ?'), [num, ip_check()]) if curs.fetchall(): return redirect('/vote/end/' + num) vote_data = re.findall(r'([^\n]+)', data_list[0][2].replace('\r\n', '\n')) if flask.request.method == 'POST': try: vaild_check = int(flask.request.form.get('vote_data', '0')) except: return redirect('/vote/' + num) if len(vote_data) - 1 < vaild_check: return redirect('/vote/' + num) curs.execute(db_change("insert into vote (name, id, subject, data, user, type) values ('', ?, '', ?, ?, 'select')"), [ num, str(vaild_check), ip_check() ]) conn.commit() return redirect('/vote/end/' + num) else: data = '' + \ '