filter_all.py 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. elif tool == 'template':
  40. title = load_lang('template_document_list')
  41. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'template'"))
  42. else:
  43. title = load_lang('edit_tool_list')
  44. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
  45. db_data = curs.fetchall()
  46. for data in db_data:
  47. div += '<tr>'
  48. div += '<td>'
  49. div += html.escape(data[0])
  50. if admin == 1:
  51. if tool in ('inter_wiki', 'outer_link', 'edit_filter', 'document', 'edit_top', 'template'):
  52. div += ' <a href="/filter/' + tool + '/add/' + url_pas(data[0]) + '">(' + load_lang('edit') + ')</a>'
  53. div += ' <a href="/filter/' + tool + '/del/' + url_pas(data[0]) + '">(' + load_lang('delete') + ')</a>'
  54. div += '</td>'
  55. if tool in ('inter_wiki', 'outer_link'):
  56. if tool == 'inter_wiki':
  57. div += '<td><a class="opennamu_link_out" href="' + html.escape(data[1]) + '">' + html.escape(data[1]) + '</a></td>'
  58. else:
  59. div += '<td>' + html.escape(data[1]) + '</td>'
  60. div += '<td>' + data[2] + '</td>'
  61. else:
  62. div += '<td>' + html.escape(data[1]) + '</td>'
  63. div += '<td>' + html.escape(data[2]) + '</td>'
  64. div += '</tr>'
  65. div += '</table>'
  66. if admin == 1:
  67. div += '<hr class="main_hr">'
  68. div += '<a href="/filter/' + tool + '/add">(' + load_lang('add') + ')</a>'
  69. return easy_minify(flask.render_template(skin_check(),
  70. imp = [title, wiki_set(), wiki_custom(), wiki_css([0, 0])],
  71. data = div,
  72. menu = [['manager/1', load_lang('return')]]
  73. ))