func.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. # 모듈들 불러옴
  2. import css_html_js_minify
  3. import flask
  4. import json
  5. import sqlite3
  6. import hashlib
  7. import requests
  8. import re
  9. import html
  10. import os
  11. # 일부 툴 불러옴
  12. from set_mark.tool import *
  13. # 나무마크 불러옴
  14. from mark import *
  15. # 서브 언어팩 불러옴
  16. json_data = open(os.path.join('language', 'en-US.json'), 'rt', encoding='utf-8').read()
  17. else_lang = json.loads(json_data)
  18. def load_conn(data):
  19. global conn
  20. global curs
  21. conn = data
  22. curs = conn.cursor()
  23. load_conn2(data)
  24. def captcha_get():
  25. data = ''
  26. if custom()[2] == 0:
  27. curs.execute('select data from other where name = "recaptcha"')
  28. recaptcha = curs.fetchall()
  29. if recaptcha and recaptcha[0][0] != '':
  30. curs.execute('select data from other where name = "sec_re"')
  31. sec_re = curs.fetchall()
  32. if sec_re and sec_re[0][0] != '':
  33. data += recaptcha[0][0] + '<hr>'
  34. return data
  35. def update():
  36. # 호환성 설정
  37. try:
  38. curs.execute("alter table history add hide text default ''")
  39. curs.execute('select title, re from hidhi')
  40. for rep in curs.fetchall():
  41. curs.execute("update history set hide = 'O' where title = ? and id = ?", [rep[0], rep[1]])
  42. curs.execute("drop table if exists hidhi")
  43. print('move table hidhi')
  44. except:
  45. pass
  46. try:
  47. curs.execute("alter table user add date text default ''")
  48. print('user table add column date')
  49. except:
  50. pass
  51. try:
  52. curs.execute("alter table rb add band text default ''")
  53. print('rb table add column band')
  54. except:
  55. pass
  56. try:
  57. curs.execute("alter table ban add login text default ''")
  58. print('ban table add column login')
  59. except:
  60. pass
  61. try:
  62. curs.execute("select title, acl from data where acl != ''")
  63. for rep in curs.fetchall():
  64. curs.execute("insert into acl (title, dec, dis, why) values (?, ?, '', '')", [rep[0], rep[1]])
  65. curs.execute("alter table data drop acl")
  66. print('data table delete column acl')
  67. except:
  68. pass
  69. try:
  70. curs.execute("alter table user add email text default ''")
  71. print('user table add column email')
  72. except:
  73. pass
  74. try:
  75. curs.execute('select name, sub from filter where sub != "X" and sub != ""')
  76. filter_name = curs.fetchall()
  77. if filter_name:
  78. for filter_delete in filter_name:
  79. if filter_delete[1] != '' or filter_delete[1] != 'X':
  80. curs.execute("update filter set sub = '' where name = ?", [filter_delete[0]])
  81. print('filter data fix')
  82. except:
  83. pass
  84. try:
  85. curs.execute("alter table user add skin text default ''")
  86. print('user table add column skin')
  87. except:
  88. pass
  89. # 3.0.5 사용자 문서, 파일 문서, 분류 문서 영어화
  90. try:
  91. all_rep = [['사용자:', 'user:'], ['파일:', 'file:'], ['분류:', 'category:']]
  92. all_rep2 = ['data', 'history', 'acl', 'topic', 'back']
  93. for i in range(3):
  94. for j in range(6):
  95. if not j == 5:
  96. curs.execute('select title from ' + all_rep2[j] + ' where title like ?', [all_rep[i][0] + '%'])
  97. else:
  98. curs.execute('select link from back where link like ?', [all_rep[i][0] + '%'])
  99. user_rep = curs.fetchall()
  100. for user_rep2 in user_rep:
  101. print(str(j) + ' : ' + user_rep2[0])
  102. first = re.sub('^' + all_rep[i][0], all_rep[i][1], user_rep2[0])
  103. if j == 0:
  104. curs.execute("update data set title = ? where title = ?", [first, user_rep2[0]])
  105. elif j == 1:
  106. curs.execute("update history set title = ? where title = ?", [first, user_rep2[0]])
  107. elif j == 2:
  108. curs.execute("update acl set title = ? where title = ?", [first, user_rep2[0]])
  109. elif j == 3:
  110. curs.execute("update topic set title = ? where title = ?", [first, user_rep2[0]])
  111. elif j == 4:
  112. curs.execute("update back set title = ? where title = ?", [first, user_rep2[0]])
  113. elif j == 5:
  114. curs.execute("update back set link = ? where link = ?", [first, user_rep2[0]])
  115. print('사용자 to user, 파일 to file, 분류 to category')
  116. except:
  117. pass
  118. conn.commit()
  119. def captcha_post(re_data, num = 1):
  120. if num == 1:
  121. if custom()[2] == 0 and captcha_get() != '':
  122. curs.execute('select data from other where name = "sec_re"')
  123. sec_re = curs.fetchall()
  124. if sec_re and sec_re[0][0] != '':
  125. data = requests.get('https://www.google.com/recaptcha/api/siteverify', params = { 'secret' : sec_re, 'response' : re_data })
  126. if not data:
  127. return 0
  128. else:
  129. json_data = data.json()
  130. if data.status_code == 200 and json_data['success'] == True:
  131. return 0
  132. else:
  133. return 1
  134. else:
  135. return 0
  136. else:
  137. return 0
  138. else:
  139. pass
  140. def load_lang(data):
  141. global lang
  142. try:
  143. if lang:
  144. pass
  145. except:
  146. curs.execute("select data from other where name = 'language'")
  147. rep_data = curs.fetchall()
  148. json_data = open(os.path.join('language', rep_data[0][0] + '.json'), 'rt', encoding='utf-8').read()
  149. lang = json.loads(json_data)
  150. if data == 'please_all':
  151. return lang
  152. else:
  153. if data in lang:
  154. return lang[data]
  155. else:
  156. return else_lang[data]
  157. def ip_or_user(data):
  158. if re.search('(\.|:)', data):
  159. return 1
  160. else:
  161. return 0
  162. def edit_help_button():
  163. # https://stackoverflow.com/questions/11076975/insert-text-into-textarea-at-cursor-position-javascript
  164. '''
  165. <script>
  166. function insertAtCursor(myField, myValue) {
  167. if (document.selection) {
  168. document.getElementById(myField).focus();
  169. sel = document.selection.createRange();
  170. sel.text = myValue;
  171. } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0') {
  172. var startPos = document.getElementById(myField).selectionStart;
  173. var endPos = document.getElementById(myField).selectionEnd;
  174. document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos) + myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length);
  175. } else {
  176. document.getElementById(myField).value += myValue;
  177. }
  178. }
  179. </script>
  180. '''
  181. insert_list = [['[[]]', '링크'], ['[()]', '매크로'], ['{{{#!}}}', '중괄호']]
  182. '<a href="javascript:void(0);" onclick="insertAtCursor(\'content\', \'B\');">(A)</a>'
  183. return ['', '']
  184. def ip_warring():
  185. if custom()[2] == 0:
  186. curs.execute('select data from other where name = "no_login_warring"')
  187. data = curs.fetchall()
  188. if data and data[0][0] != '':
  189. text_data = '<span>' + data[0][0] + '</span><hr>'
  190. else:
  191. text_data = '<span>' + load_lang('no_login_warring') + '</span><hr>'
  192. else:
  193. text_data = ''
  194. return text_data
  195. def skin_check():
  196. skin = './views/acme/'
  197. try:
  198. curs.execute('select skin from user where id = ?', [ip_check()])
  199. skin_exist = curs.fetchall()
  200. if skin_exist and skin_exist[0][0] != '':
  201. if os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.html')) == 1:
  202. skin = './views/' + skin_exist[0][0] + '/'
  203. else:
  204. curs.execute('select data from other where name = "skin"')
  205. skin_exist = curs.fetchall()
  206. if skin_exist:
  207. if os.path.exists(os.path.abspath('./views/' + skin_exist[0][0] + '/index.html')) == 1:
  208. skin = './views/' + skin_exist[0][0] + '/'
  209. except:
  210. pass
  211. return skin + 'index.html'
  212. def next_fix(link, num, page, end = 50):
  213. list_data = ''
  214. if num == 1:
  215. if len(page) == end:
  216. list_data += '<hr><a href="' + link + str(num + 1) + '">(' + load_lang('next') + ')</a>'
  217. elif len(page) != end:
  218. list_data += '<hr><a href="' + link + str(num - 1) + '">(' + load_lang('previous') + ')</a>'
  219. else:
  220. list_data += '<hr><a href="' + link + str(num - 1) + '">(' + load_lang('previous') + ')</a> <a href="' + link + str(num + 1) + '">(' + load_lang('next') + ')</a>'
  221. return list_data
  222. def other2(data):
  223. return data + ['Deleted']
  224. def wiki_set(num = 1):
  225. if num == 1:
  226. data_list = []
  227. curs.execute('select data from other where name = ?', ['name'])
  228. db_data = curs.fetchall()
  229. if db_data and db_data[0][0] != '':
  230. data_list += [db_data[0][0]]
  231. else:
  232. data_list += ['Wiki']
  233. curs.execute('select data from other where name = "license"')
  234. db_data = curs.fetchall()
  235. if db_data and db_data[0][0] != '':
  236. data_list += [db_data[0][0]]
  237. else:
  238. data_list += ['CC 0']
  239. data_list += ['', '']
  240. curs.execute('select data from other where name = "logo"')
  241. db_data = curs.fetchall()
  242. if db_data and db_data[0][0] != '':
  243. data_list += [db_data[0][0]]
  244. else:
  245. data_list += [data_list[0]]
  246. curs.execute("select data from other where name = 'head'")
  247. db_data = curs.fetchall()
  248. if db_data and db_data[0][0] != '':
  249. data_list += [db_data[0][0]]
  250. else:
  251. data_list += ['']
  252. return data_list
  253. if num == 2:
  254. var_data = 'FrontPage'
  255. curs.execute('select data from other where name = "frontpage"')
  256. elif num == 3:
  257. var_data = '2'
  258. curs.execute('select data from other where name = "upload"')
  259. db_data = curs.fetchall()
  260. if db_data and db_data[0][0] != '':
  261. return db_data[0][0]
  262. else:
  263. return var_data
  264. def diff(seqm):
  265. output = []
  266. for opcode, a0, a1, b0, b1 in seqm.get_opcodes():
  267. if opcode == 'equal':
  268. output += [seqm.a[a0:a1]]
  269. elif opcode == 'insert':
  270. output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
  271. elif opcode == 'delete':
  272. output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
  273. elif opcode == 'replace':
  274. output += ["<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>"]
  275. output += ["<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>"]
  276. return ''.join(output)
  277. def admin_check(num, what):
  278. ip = ip_check()
  279. curs.execute("select acl from user where id = ?", [ip])
  280. user = curs.fetchall()
  281. if user:
  282. reset = 0
  283. while 1:
  284. if num == 1 and reset == 0:
  285. check = 'ban'
  286. elif num == 3 and reset == 0:
  287. check = 'toron'
  288. elif num == 4 and reset == 0:
  289. check = 'check'
  290. elif num == 5 and reset == 0:
  291. check = 'acl'
  292. elif num == 6 and reset == 0:
  293. check = 'hidel'
  294. elif num == 7 and reset == 0:
  295. check = 'give'
  296. else:
  297. check = 'owner'
  298. curs.execute('select name from alist where name = ? and acl = ?', [user[0][0], check])
  299. if curs.fetchall():
  300. if what:
  301. curs.execute("insert into re_admin (who, what, time) values (?, ?, ?)", [ip, what, get_time()])
  302. conn.commit()
  303. return 1
  304. else:
  305. if reset == 0:
  306. reset = 1
  307. else:
  308. break
  309. def ip_pas(raw_ip):
  310. hide = 0
  311. if re.search("(\.|:)", raw_ip):
  312. if not re.search("^" + load_lang('tool') + ":", raw_ip):
  313. curs.execute("select data from other where name = 'ip_view'")
  314. data = curs.fetchall()
  315. if data and data[0][0] != '':
  316. ip = '<span style="font-size: 75%;">' + hashlib.md5(bytes(raw_ip, 'utf-8')).hexdigest() + '</span>'
  317. if not admin_check('ban', None):
  318. hide = 1
  319. else:
  320. ip = raw_ip
  321. else:
  322. ip = raw_ip
  323. hide = 1
  324. else:
  325. curs.execute("select title from data where title = ?", ['user:' + raw_ip])
  326. if curs.fetchall():
  327. ip = '<a href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
  328. else:
  329. ip = '<a id="not_thing" href="/w/' + url_pas('user:' + raw_ip) + '">' + raw_ip + '</a>'
  330. if hide == 0:
  331. ip += ' <a href="/record/' + url_pas('user:' + raw_ip) + '">(' + load_lang('record') + ')</a>'
  332. return ip
  333. def custom():
  334. if 'MyMaiToNight' in flask.session:
  335. user_head = flask.session['MyMaiToNight']
  336. else:
  337. user_head = ''
  338. if 'Now' in flask.session and flask.session['Now'] == 1:
  339. curs.execute('select name from alarm where name = ? limit 1', [ip_check()])
  340. if curs.fetchall():
  341. user_icon = 2
  342. else:
  343. user_icon = 1
  344. else:
  345. user_icon = 0
  346. if user_icon != 0:
  347. curs.execute('select email from user where id = ?', [ip_check()])
  348. data = curs.fetchall()
  349. if data:
  350. email = data[0][0]
  351. else:
  352. email = ''
  353. else:
  354. email = ''
  355. if user_icon != 0:
  356. user_name = ip_check()
  357. else:
  358. user_name = load_lang('user')
  359. return ['', '', user_icon, user_head, email, user_name]
  360. def acl_check(name):
  361. ip = ip_check()
  362. if ban_check() == 1:
  363. return 1
  364. acl_c = re.search("^user:([^/]*)", name)
  365. if acl_c:
  366. acl_n = acl_c.groups()
  367. if admin_check(5, None) == 1:
  368. return 0
  369. curs.execute("select dec from acl where title = ?", ['user:' + acl_n[0]])
  370. acl_data = curs.fetchall()
  371. if acl_data:
  372. if acl_data[0][0] == 'all':
  373. return 0
  374. if acl_data[0][0] == 'user' and not re.search("(\.|:)", ip):
  375. return 0
  376. if ip != acl_n[0] or re.search("(\.|:)", ip):
  377. return 1
  378. if ip == acl_n[0] and not re.search("(\.|:)", ip) and not re.search("(\.|:)", acl_n[0]):
  379. return 0
  380. else:
  381. return 1
  382. file_c = re.search("^file:(.*)", name)
  383. if file_c and admin_check(5, 'edit (' + name + ')') != 1:
  384. return 1
  385. curs.execute("select acl from user where id = ?", [ip])
  386. user_data = curs.fetchall()
  387. curs.execute("select dec from acl where title = ?", [name])
  388. acl_data = curs.fetchall()
  389. if acl_data:
  390. if acl_data[0][0] == 'user':
  391. if not user_data:
  392. return 1
  393. if acl_data[0][0] == 'admin':
  394. if not user_data:
  395. return 1
  396. if not admin_check(5, 'edit (' + name + ')') == 1:
  397. return 1
  398. curs.execute('select data from other where name = "edit"')
  399. set_data = curs.fetchall()
  400. if set_data:
  401. if set_data[0][0] == 'user':
  402. if not user_data:
  403. return 1
  404. if set_data[0][0] == 'admin':
  405. if not user_data:
  406. return 1
  407. if not admin_check(5, None) == 1:
  408. return 1
  409. return 0
  410. def ban_check():
  411. ip = ip_check()
  412. band = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
  413. if band:
  414. band_it = band.groups()[0]
  415. else:
  416. band_it = 'Not'
  417. curs.execute("select block from ban where block = ?", [band_it])
  418. band_d = curs.fetchall()
  419. curs.execute("select block from ban where block = ?", [ip])
  420. ban_d = curs.fetchall()
  421. if band_d or ban_d:
  422. return 1
  423. return 0
  424. def topic_check(name, sub):
  425. ip = ip_check()
  426. if ban_check() == 1:
  427. return 1
  428. curs.execute("select acl from user where id = ?", [ip])
  429. user_data = curs.fetchall()
  430. curs.execute("select dis from acl where title = ?", [name])
  431. acl_data = curs.fetchall()
  432. if acl_data:
  433. if acl_data[0][0] == 'user':
  434. if not user_data:
  435. return 1
  436. if acl_data[0][0] == 'admin':
  437. if not user_data:
  438. return 1
  439. if not admin_check(3, 'topic (' + name + ')') == 1:
  440. return 1
  441. curs.execute("select title from stop where title = ? and sub = ?", [name, sub])
  442. if curs.fetchall():
  443. if not admin_check(3, 'topic (' + name + ')') == 1:
  444. return 1
  445. return 0
  446. def ban_insert(name, end, why, login, blocker):
  447. time = get_time()
  448. if re.search("^([0-9]{1,3}\.[0-9]{1,3})$", name):
  449. band = 'O'
  450. else:
  451. band = ''
  452. curs.execute("select block from ban where block = ?", [name])
  453. if curs.fetchall():
  454. curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [name, load_lang('release'), time, blocker, '', band])
  455. curs.execute("delete from ban where block = ?", [name])
  456. else:
  457. if login != '':
  458. login = 'O'
  459. else:
  460. login = ''
  461. if end != '':
  462. end += ' 00:00:00'
  463. curs.execute("insert into rb (block, end, today, blocker, why, band) values (?, ?, ?, ?, ?, ?)", [name, end, time, blocker, why, band])
  464. curs.execute("insert into ban (block, end, why, band, login) values (?, ?, ?, ?, ?)", [name, end, why, band, login])
  465. conn.commit()
  466. def rd_plus(title, sub, date):
  467. curs.execute("select title from rd where title = ? and sub = ?", [title, sub])
  468. if curs.fetchall():
  469. curs.execute("update rd set date = ? where title = ? and sub = ?", [date, title, sub])
  470. else:
  471. curs.execute("insert into rd (title, sub, date) values (?, ?, ?)", [title, sub, date])
  472. def history_plus(title, data, date, ip, send, leng):
  473. curs.execute("select id from history where title = ? order by id + 0 desc limit 1", [title])
  474. id_data = curs.fetchall()
  475. if id_data:
  476. curs.execute("insert into history (id, title, data, date, ip, send, leng) values (?, ?, ?, ?, ?, ?, ?)", [str(int(id_data[0][0]) + 1), title, data, date, ip, send, leng])
  477. else:
  478. curs.execute("insert into history (id, title, data, date, ip, send, leng) values ('1', ?, ?, ?, ?, ?, ?)", [title, data, date, ip, send + ' (' + load_lang('new') + ' ' + load_lang('document') + ')', leng])
  479. def leng_check(first, second):
  480. if first < second:
  481. all_plus = '+' + str(second - first)
  482. elif second < first:
  483. all_plus = '-' + str(first - second)
  484. else:
  485. all_plus = '0'
  486. return all_plus
  487. def redirect(data):
  488. return '<meta http-equiv="refresh" content="0; url=' + data + '">'
  489. def re_error(data):
  490. if data == '/ban':
  491. ip = ip_check()
  492. end = '<li>' + load_lang('why') + ' : ' + load_lang('authority_error') + '</li>'
  493. if ban_check() == 1:
  494. curs.execute("select end, why from ban where block = ?", [ip])
  495. end_data = curs.fetchall()
  496. if not end_data:
  497. match = re.search("^([0-9]{1,3}\.[0-9]{1,3})", ip)
  498. if match:
  499. curs.execute("select end, why from ban where block = ?", [match.groups()[0]])
  500. end_data = curs.fetchall()
  501. if end_data:
  502. end = '<li>' + load_lang('state') + ' : '
  503. if end_data[0][0]:
  504. now = int(re.sub('(\-| |:)', '', get_time()))
  505. day = int(re.sub('(\-| |:)', '', end_data[0][0]))
  506. if now >= day:
  507. curs.execute("delete from ban where block = ?", [ip])
  508. conn.commit()
  509. end += 'Re Try.'
  510. else:
  511. end += load_lang('why') + ' : ' + end_data[0][0]
  512. else:
  513. end += load_lang('why') + ' : ' + load_lang('limitless')
  514. end += '</li>'
  515. if end_data[0][1] != '':
  516. end += '<li>' + load_lang('why') + ' : ' + end_data[0][1] + '</li>'
  517. return css_html_js_minify.html_minify(flask.render_template(skin_check(),
  518. imp = ['Error', wiki_set(1), custom(), other2([0, 0])],
  519. data = '<h2>Error</h2><ul>' + end + '</ul>',
  520. menu = 0
  521. ))
  522. else:
  523. error_data = re.search('\/error\/([0-9]+)', data)
  524. if error_data:
  525. num = int(error_data.groups()[0])
  526. if num == 1:
  527. data = load_lang('no_login_error')
  528. elif num == 2:
  529. data = load_lang('no_exist_user_error')
  530. elif num == 3:
  531. data = load_lang('authority_error')
  532. elif num == 4:
  533. data = load_lang('no_admin_block_error')
  534. elif num == 6:
  535. data = load_lang('same_id_exist_error')
  536. elif num == 7:
  537. data = load_lang('long_id_error')
  538. elif num == 8:
  539. data = load_lang('id_char_error')
  540. elif num == 9:
  541. data = load_lang('file_exist_error')
  542. elif num == 10:
  543. data = load_lang('password_error')
  544. elif num == 13:
  545. data = load_lang('recaptcha_error')
  546. elif num == 14:
  547. data = load_lang('file_extension_error')
  548. elif num == 15:
  549. data = load_lang('edit_record_error')
  550. elif num == 16:
  551. data = load_lang('same_file_error')
  552. elif num == 17:
  553. data = load_lang('file_capacity_error') + ' ' + wiki_set(3)
  554. elif num == 19:
  555. data = load_lang('decument_exist_error')
  556. elif num == 20:
  557. data = load_lang('password_diffrent_error')
  558. elif num == 21:
  559. data = load_lang('edit_filter_error')
  560. elif num == 22:
  561. data = load_lang('file_name_error')
  562. else:
  563. data = '???'
  564. return css_html_js_minify.html_minify(flask.render_template(skin_check(),
  565. imp = ['Error', wiki_set(1), custom(), other2([0, 0])],
  566. data = '<h2>Error</h2><ul><li>' + data + '</li></ul>',
  567. menu = 0
  568. ))
  569. else:
  570. return redirect('/')