plus_inter.py 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. from .tool.func import *
  2. def plus_inter_2(conn, tools, name):
  3. curs = conn.cursor()
  4. if flask.request.method == 'POST':
  5. if tools == 'plus_inter_wiki':
  6. curs.execute('insert into inter (title, link) values (?, ?)', [flask.request.form.get('title', None), flask.request.form.get('link', None)])
  7. admin_check(None, 'inter_wiki_plus')
  8. elif tools == 'plus_edit_filter':
  9. if admin_check(1, 'edit_filter edit') != 1:
  10. return re_error('/error/3')
  11. if flask.request.form.get('limitless', '') != '':
  12. end = 'X'
  13. else:
  14. end = flask.request.form.get('second', 'X')
  15. curs.execute("select name from filter where name = ?", [name])
  16. if curs.fetchall():
  17. curs.execute("update filter set regex = ?, sub = ? where name = ?", [flask.request.form.get('content', 'test'), end, name])
  18. else:
  19. curs.execute("insert into filter (name, regex, sub) values (?, ?, ?)", [name, flask.request.form.get('content', 'test'), end])
  20. else:
  21. if tools == 'plus_name_filter':
  22. admin_check(None, 'name_filter edit')
  23. type_d = 'name'
  24. else:
  25. admin_check(None, 'email_filter edit')
  26. type_d = 'email'
  27. curs.execute('insert into html_filter (html, kind) values (?, ?)', [flask.request.form.get('title', 'test'), type_d])
  28. conn.commit()
  29. return redirect('/' + re.sub('^plus_', '', tools))
  30. else:
  31. if admin_check(1) != 1:
  32. stat = 'disabled'
  33. else:
  34. stat = ''
  35. if tools == 'plus_inter_wiki':
  36. title = load_lang('interwiki_add')
  37. form_data = '''
  38. <input placeholder="''' + load_lang('name') + '''" type="text" name="title">
  39. <hr class=\"main_hr\">
  40. <input placeholder="link" type="text" name="link">
  41. '''
  42. elif tools == 'plus_edit_filter':
  43. curs.execute("select regex, sub from filter where name = ?", [name])
  44. exist = curs.fetchall()
  45. if exist:
  46. textarea = exist[0][0]
  47. if exist[0][1] == 'X':
  48. time_check = 'checked="checked"'
  49. time_data = ''
  50. else:
  51. time_check = ''
  52. time_data = exist[0][1]
  53. else:
  54. textarea = ''
  55. time_check = ''
  56. time_data = ''
  57. title = load_lang('edit_filter_add')
  58. form_data = '''
  59. <input placeholder="''' + load_lang('second') + '''" name="second" type="text" value="''' + html.escape(time_data) + '''">
  60. <hr class=\"main_hr\">
  61. <input ''' + stat + ''' type="checkbox" ''' + time_check + ''' name="limitless"> ''' + load_lang('limitless') + '''
  62. <hr class=\"main_hr\">
  63. <input ''' + stat + ''' placeholder="''' + load_lang('regex') + '''" name="content" value="''' + html.escape(textarea) + '''" type="text">
  64. '''
  65. elif tools == 'plus_name_filter':
  66. title = load_lang('id_filter_add')
  67. form_data = '<input placeholder="' + load_lang('id') + ' ' + load_lang('regex') + '" type="text" name="title">'
  68. else:
  69. title = load_lang('email_filter_add')
  70. form_data = '<input placeholder="email" type="text" name="title">'
  71. return easy_minify(flask.render_template(skin_check(),
  72. imp = [title, wiki_set(), custom(), other2([0, 0])],
  73. data = '''
  74. <form method="post">
  75. ''' + form_data + '''
  76. <hr class=\"main_hr\">
  77. <button ''' + stat + ''' type="submit">''' + load_lang('add') + '''</button>
  78. </form>
  79. ''',
  80. menu = [[re.sub('^plus_', '', tools), load_lang('return')]]
  81. ))