filter_all.py 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from .tool.func import *
  2. def filter_all(tool):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. div = '<table id="main_table_set">'
  6. div += '<tr id="main_table_top_tr">'
  7. div += '<td id="main_table_width">A</td>'
  8. div += '<td id="main_table_width">B</td>'
  9. div += '<td id="main_table_width">C</td>'
  10. div += '</tr>'
  11. admin = admin_check()
  12. if tool == 'inter_wiki':
  13. title = load_lang('interwiki_list')
  14. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'inter_wiki'"))
  15. elif tool == 'email_filter':
  16. title = load_lang('email_filter_list')
  17. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'email'"))
  18. elif tool == 'name_filter':
  19. title = load_lang('id_filter_list')
  20. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'name'"))
  21. elif tool == 'edit_filter':
  22. title = load_lang('edit_filter_list')
  23. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'regex_filter'"))
  24. elif tool == 'file_filter':
  25. title = load_lang('file_filter_list')
  26. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
  27. elif tool == 'image_license':
  28. title = load_lang('image_license_list')
  29. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'image_license'"))
  30. elif tool == 'extension_filter':
  31. title = load_lang('extension_filter_list')
  32. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'extension'"))
  33. elif tool == 'document':
  34. title = load_lang('document_filter_list')
  35. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'document'"))
  36. elif tool == 'outer_link':
  37. title = load_lang('outer_link_filter_list')
  38. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'outer_link'"))
  39. else:
  40. title = load_lang('edit_tool_list')
  41. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
  42. db_data = curs.fetchall()
  43. for data in db_data:
  44. div += '<tr>'
  45. div += '<td>'
  46. div += html.escape(data[0])
  47. if admin == 1:
  48. if tool in ('inter_wiki', 'outer_link', 'edit_filter', 'document'):
  49. div += ' <a href="/filter/' + tool + '/add/' + url_pas(data[0]) + '">(' + load_lang('edit') + ')</a>'
  50. div += ' <a href="/filter/' + tool + '/del/' + url_pas(data[0]) + '">(' + load_lang('delete') + ')</a>'
  51. div += '</td>'
  52. if tool in ('inter_wiki', 'outer_link'):
  53. if tool == 'inter_wiki':
  54. div += '<td><a class="opennamu_link_out" href="' + html.escape(data[1]) + '">' + html.escape(data[1]) + '</a></td>'
  55. else:
  56. div += '<td>' + html.escape(data[1]) + '</td>'
  57. div += '<td>' + data[2] + '</td>'
  58. else:
  59. div += '<td>' + html.escape(data[1]) + '</td>'
  60. div += '<td>' + html.escape(data[2]) + '</td>'
  61. div += '</tr>'
  62. div += '</table>'
  63. if admin == 1:
  64. div += '<hr class="main_hr">'
  65. div += '<a href="/filter/' + tool + '/add">(' + load_lang('add') + ')</a>'
  66. return easy_minify(flask.render_template(skin_check(),
  67. imp = [title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
  68. data = div,
  69. menu = [['manager/1', load_lang('return')]]
  70. ))