filter_all.py 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('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 = await get_lang('template_document_list')
  45. curs.execute(db_change("select html, plus, plus_t from html_filter where kind = 'template'"))
  46. else:
  47. title = await get_lang('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]) + '">(' + await get_lang('edit') + ')</a>'
  57. div += ' <a href="/filter/' + tool + '/del/' + url_pas(data[0]) + '">(' + await get_lang('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">(' + await get_lang('add') + ')</a>'
  73. return await render_template(
  74. title,
  75. div,
  76. 0,
  77. [['manager/1', await get_lang('return')]]
  78. )