filter_all.py 4.3 KB

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