filter_all.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 = acl_check(tool = 'owner_auth')
  12. admin = 1 if admin == 0 else 0
  13. if tool == 'inter_wiki':
  14. title = get_lang(conn, 'interwiki_list')
  15. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'inter_wiki'"))
  16. elif tool == 'email_filter':
  17. title = get_lang(conn, 'email_filter_list')
  18. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'email'"))
  19. elif tool == 'name_filter':
  20. title = get_lang(conn, 'id_filter_list')
  21. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'name'"))
  22. elif tool == 'edit_filter':
  23. title = get_lang(conn, 'edit_filter_list')
  24. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'regex_filter'"))
  25. elif tool == 'file_filter':
  26. title = get_lang(conn, 'file_filter_list')
  27. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'file'"))
  28. elif tool == 'image_license':
  29. title = get_lang(conn, 'image_license_list')
  30. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'image_license'"))
  31. elif tool == 'extension_filter':
  32. title = get_lang(conn, 'extension_filter_list')
  33. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'extension'"))
  34. elif tool == 'document':
  35. title = get_lang(conn, 'document_filter_list')
  36. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'document'"))
  37. elif tool == 'outer_link':
  38. title = get_lang(conn, 'outer_link_filter_list')
  39. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'outer_link'"))
  40. elif tool == 'template':
  41. title = get_lang(conn, 'template_document_list')
  42. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'template'"))
  43. else:
  44. title = get_lang(conn, 'edit_tool_list')
  45. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'edit_top'"))
  46. db_data = curs.fetchall()
  47. for data in db_data:
  48. div += '<tr>'
  49. div += '<td>'
  50. div += html.escape(data[0])
  51. if admin == 1:
  52. if tool in ('inter_wiki', 'outer_link', 'edit_filter', 'document', 'edit_top', 'template'):
  53. div += ' <a href="/filter/' + tool + '/add/' + url_pas(data[0]) + '">(' + get_lang(conn, 'edit') + ')</a>'
  54. div += ' <a href="/filter/' + tool + '/del/' + url_pas(data[0]) + '">(' + get_lang(conn, 'delete') + ')</a>'
  55. div += '</td>'
  56. if tool in ('inter_wiki', 'outer_link'):
  57. if tool == 'inter_wiki':
  58. div += '<td><a class="opennamu_link_out" href="' + html.escape(data[1]) + '">' + html.escape(data[1]) + '</a></td>'
  59. else:
  60. div += '<td>' + html.escape(data[1]) + '</td>'
  61. div += '<td>' + data[2] + '</td>'
  62. else:
  63. div += '<td>' + html.escape(data[1]) + '</td>'
  64. div += '<td>' + html.escape(data[2]) + '</td>'
  65. div += '</tr>'
  66. div += '</table>'
  67. if admin == 1:
  68. div += '<hr class="main_hr">'
  69. div += '<a href="/filter/' + tool + '/add">(' + get_lang(conn, 'add') + ')</a>'
  70. return easy_minify(conn, flask.render_template(skin_check(conn),
  71. imp = [title, wiki_set(conn), wiki_custom(conn), wiki_css([0, 0])],
  72. data = div,
  73. menu = [['manager/1', get_lang(conn, 'return')]]
  74. ))