give_user_check.py 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. from .tool.func import *
  2. def give_user_check_2(conn, name):
  3. curs = conn.cursor()
  4. plus_id = flask.request.args.get('plus', None)
  5. if admin_check('all', None, name) == 1 or (plus_id and admin_check('all', None, plus_id) == 1):
  6. if admin_check() != 1:
  7. return re_error('/error/4')
  8. num = int(number_check(flask.request.args.get('num', '1')))
  9. sql_num = (num * 50 - 50) if num * 50 > 0 else 0
  10. div = ''
  11. check_type = flask.request.args.get('type', '')
  12. if admin_check(4, (check_type + ' ' if check_type != '' else '') + 'check (' + name + ')') != 1:
  13. return re_error('/error/3')
  14. if check_type == '':
  15. if ip_or_user(name) == 0:
  16. curs.execute(db_change("select data from user_set where name = \"approval_question\" and id = ?"), [name])
  17. approval_question = curs.fetchall()
  18. if approval_question and approval_question[0][0]:
  19. curs.execute(db_change("select data from user_set where name = \"approval_question_answer\" and id = ?"), [name])
  20. approval_question_answer = curs.fetchall()
  21. if approval_question_answer and approval_question_answer[0]:
  22. div += '''
  23. <table id="main_table_set">
  24. <tbody>
  25. <tr>
  26. <td>Q</td>
  27. <td>''' + approval_question[0][0] + '''</td>
  28. <td>A</td>
  29. <td>''' + approval_question_answer[0][0] + '''</td>
  30. </tr>
  31. </tbody>
  32. </table>
  33. <hr class="main_hr">
  34. '''
  35. if plus_id:
  36. plus = "or " + ('ip' if ip_or_user(plus_id) == 1 else 'name') + " = ? "
  37. set_list = [name, plus_id, sql_num]
  38. if num == 1:
  39. curs.execute(db_change("" + \
  40. "select distinct ip from ua_d " + \
  41. "where " + ('ip' if ip_or_user(name) == 1 else 'name') + " = ? or " + ('ip' if ip_or_user(plus_id) == 1 else 'name') + " = ? "
  42. ""), [name, plus_id])
  43. all_ip_count = len(curs.fetchall())
  44. curs.execute(db_change("" + \
  45. "select distinct ip from ua_d " + \
  46. "where " + ('ip' if ip_or_user(name) == 1 else 'name') + " = ?" + \
  47. ""), [name])
  48. a_ip_count = len(curs.fetchall())
  49. curs.execute(db_change("" + \
  50. "select distinct ip from ua_d " + \
  51. "where " + ('ip' if ip_or_user(plus_id) == 1 else 'name') + " = ? "
  52. ""), [plus_id])
  53. b_ip_count = len(curs.fetchall())
  54. if a_ip_count + b_ip_count != all_ip_count:
  55. div += load_lang('same_ip_exist') + '<hr class="main_hr">'
  56. else:
  57. plus = ''
  58. set_list = [name, sql_num]
  59. curs.execute(db_change("" + \
  60. "select name, ip, ua, today from ua_d " + \
  61. "where " + ('ip' if ip_or_user(name) == 1 else 'name') + " = ? " + \
  62. plus + \
  63. "order by today desc limit ?, 50" + \
  64. ""), set_list)
  65. record = curs.fetchall()
  66. if record:
  67. if not plus_id:
  68. div = '' + \
  69. '<a href="/manager/14?plus=' + url_pas(name) + '">(' + load_lang('compare') + ')</a> ' + \
  70. '<a href="/check/' + url_pas(name) + '?type=simple">(' + load_lang('simple_check') + ')</a>' + \
  71. '<hr class="main_hr">' + \
  72. '' + div
  73. else:
  74. div = '' + \
  75. '<a href="/check/' + url_pas(name) + '">(' + name + ')</a> ' + \
  76. '<a href="/check/' + url_pas(plus_id) + '">(' + plus_id + ')</a>' + \
  77. '<hr class="main_hr">' + \
  78. '' + div
  79. div += '''
  80. <table id="main_table_set">
  81. <tbody>
  82. <tr>
  83. <td id="main_table_width">''' + load_lang('name') + '''</td>
  84. <td id="main_table_width">''' + load_lang('ip') + '''</td>
  85. <td id="main_table_width">''' + load_lang('time') + '''</td>
  86. </tr>
  87. '''
  88. set_n = 0
  89. for data in record:
  90. if data[2]:
  91. if len(data[2]) > 300:
  92. ua = '' + \
  93. '<a href="javascript:void();" onclick="document.getElementById(\'check_' + str(set_n) + '\').style.display=\'block\';">(300+)</a>' + \
  94. '<div id="check_' + str(set_n) + '" style="display:none;">' + html.escape(data[2]) + '</div>' + \
  95. ''
  96. set_n += 1
  97. else:
  98. ua = html.escape(data[2])
  99. else:
  100. ua = '<br>'
  101. div += '''
  102. <tr>
  103. <td><a href="/check/''' + url_pas(data[0]) + '''">''' + data[0] + '''</a></td>
  104. <td><a href="/check/''' + url_pas(data[1]) + '''">''' + data[1] + '''</a></td>
  105. <td>''' + data[3] + '''</td>
  106. </tr>
  107. <tr>
  108. <td colspan="3">''' + ua + '''</td>
  109. </tr>
  110. '''
  111. div += '''
  112. </tbody>
  113. </table>
  114. '''
  115. else:
  116. return re_error('/error/2')
  117. div += next_fix(
  118. '/check/' + url_pas(name) + ('?plus=' + plus_id + '&num=' if plus_id else '?num='),
  119. num,
  120. record
  121. )
  122. return easy_minify(flask.render_template(skin_check(),
  123. imp = [load_lang('check'), wiki_set(), custom(), other2([0, 0])],
  124. data = div,
  125. menu = [['manager', load_lang('return')]]
  126. ))
  127. else:
  128. curs.execute(db_change("" + \
  129. "select distinct " + ('name' if ip_or_user(name) == 1 else 'ip') + " from ua_d " + \
  130. "where " + ('ip' if ip_or_user(name) == 1 else 'name') + " = ? "
  131. "order by today desc limit ?, 50" + \
  132. ""), [name, sql_num])
  133. record = curs.fetchall()
  134. div = ''
  135. for i in record:
  136. div += '<li><a href="/check/' + url_pas(i[0]) + '?type=simple">' + i[0] + '</a></li>'
  137. if div != '':
  138. div = '<ul>' + div + '</ul>'
  139. div += next_fix(
  140. '/check/' + url_pas(name) + '?type=' + check_type + '&num=',
  141. num,
  142. record
  143. )
  144. return easy_minify(flask.render_template(skin_check(),
  145. imp = [name, wiki_set(), custom(), other2(['(' + load_lang('simple_check') + ')', 0])],
  146. data = div,
  147. menu = [['check/' + url_pas(name), load_lang('return')]]
  148. ))