give_user_check.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. from .tool.func import *
  2. def give_user_check_2(conn, name):
  3. curs = conn.cursor()
  4. curs.execute(db_change("select acl from user where id = ? or id = ?"), [name, flask.request.args.get('plus', '-')])
  5. user = curs.fetchall()
  6. if user and user[0][0] != 'user':
  7. if admin_check() != 1:
  8. return re_error('/error/4')
  9. if admin_check(4, 'check (' + name + ')') != 1:
  10. return re_error('/error/3')
  11. num = int(number_check(flask.request.args.get('num', '1')))
  12. sql_num = (num * 50 - 50) if num * 50 > 0 else 0
  13. div = ''
  14. plus_id = flask.request.args.get('plus', None)
  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. '<hr class="main_hr">' + \
  71. '' + div
  72. else:
  73. div = '' + \
  74. '<a href="/check/' + url_pas(name) + '">(' + name + ')</a> ' + \
  75. '<a href="/check/' + url_pas(plus_id) + '">(' + plus_id + ')</a>' + \
  76. '<hr class="main_hr">' + \
  77. '' + div
  78. div += '''
  79. <table id="main_table_set">
  80. <tbody>
  81. <tr>
  82. <td id="main_table_width">''' + load_lang('name') + '''</td>
  83. <td id="main_table_width">''' + load_lang('ip') + '''</td>
  84. <td id="main_table_width">''' + load_lang('time') + '''</td>
  85. </tr>
  86. '''
  87. set_n = 0
  88. for data in record:
  89. if data[2]:
  90. if len(data[2]) > 300:
  91. ua = '' + \
  92. '<a href="javascript:void();" onclick="document.getElementById(\'check_' + str(set_n) + '\').style.display=\'block\';">(300+)</a>' + \
  93. '<div id="check_' + str(set_n) + '" style="display:none;">' + html.escape(data[2]) + '</div>' + \
  94. ''
  95. set_n += 1
  96. else:
  97. ua = html.escape(data[2])
  98. else:
  99. ua = '<br>'
  100. div += '''
  101. <tr>
  102. <td>''' + ip_pas(data[0]) + '''</td>
  103. <td>''' + ip_pas(data[1]) + '''</td>
  104. <td>''' + data[3] + '''</td>
  105. </tr>
  106. <tr>
  107. <td colspan="3">''' + ua + '''</td>
  108. </tr>
  109. '''
  110. div += '''
  111. </tbody>
  112. </table>
  113. '''
  114. else:
  115. return re_error('/error/2')
  116. div += next_fix(
  117. '/check/' + url_pas(name) + ('?plus=' + plus_id if plus_id else '') + '&num=',
  118. num,
  119. record
  120. )
  121. return easy_minify(flask.render_template(skin_check(),
  122. imp = [load_lang('check'), wiki_set(), custom(), other2([0, 0])],
  123. data = div,
  124. menu = [['manager', load_lang('return')]]
  125. ))