2
0

give_user_check.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. if num * 50 > 0:
  13. sql_num = num * 50 - 50
  14. else:
  15. sql_num = 0
  16. div = ''
  17. plus_id = flask.request.args.get('plus', None)
  18. if ip_or_user(name) == 0:
  19. curs.execute(db_change("select data from user_set where name = \"approval_question\" and id = ?"), [name])
  20. approval_question = curs.fetchall()
  21. if approval_question and approval_question[0][0]:
  22. curs.execute(db_change("select data from user_set where name = \"approval_question_answer\" and id = ?"), [name])
  23. approval_question_answer = curs.fetchall()
  24. if approval_question_answer and approval_question_answer[0]:
  25. div = '''
  26. <table id="main_table_set">
  27. <tbody>
  28. <tr>
  29. <td>Q</td>
  30. <td>''' + approval_question[0][0] + '''</td>
  31. <td>A</td>
  32. <td>''' + approval_question_answer[0][0] + '''</td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. <hr class=\"main_hr\">
  37. '''
  38. if plus_id:
  39. plus = "or " + ('ip' if ip_or_user(plus_id) == 1 else 'name') + " = ? "
  40. set_list = [name, plus_id, sql_num]
  41. else:
  42. plus = ''
  43. set_list = [name, sql_num]
  44. curs.execute(db_change("" + \
  45. "select name, ip, ua, today from ua_d " + \
  46. "where " + ('ip' if ip_or_user(name) == 1 else 'name') + " = ? " + \
  47. plus + \
  48. "order by today desc limit ?, 50" + \
  49. ""), set_list)
  50. record = curs.fetchall()
  51. if record:
  52. if not plus_id:
  53. div = '' + \
  54. '<a href="/manager/14?plus=' + url_pas(name) + '">(' + load_lang('compare') + ')</a>' + \
  55. '<hr class=\"main_hr\">' + \
  56. '' + div
  57. else:
  58. div = '' + \
  59. '<a href="/check/' + url_pas(name) + '">(' + name + ')</a> ' + \
  60. '<a href="/check/' + url_pas(plus_id) + '">(' + plus_id + ')</a>' + \
  61. '<hr class=\"main_hr\">' + \
  62. '' + div
  63. div += '''
  64. <table id="main_table_set">
  65. <tbody>
  66. <tr>
  67. <td id="main_table_width">''' + load_lang('name') + '''</td>
  68. <td id="main_table_width">''' + load_lang('ip') + '''</td>
  69. <td id="main_table_width">''' + load_lang('time') + '''</td>
  70. </tr>
  71. '''
  72. set_n = 0
  73. for data in record:
  74. if data[2]:
  75. if len(data[2]) > 300:
  76. ua = '' + \
  77. '<a href="javascript:void();" onclick="document.getElementById(\'check_' + str(set_n) + '\').style.display=\'block\';">(300+)</a>' + \
  78. '<div id="check_' + str(set_n) + '" style="display:none;">' + html.escape(data[2]) + '</div>' + \
  79. ''
  80. set_n += 1
  81. else:
  82. ua = html.escape(data[2])
  83. else:
  84. ua = '<br>'
  85. div += '''
  86. <tr>
  87. <td>''' + ip_pas(data[0]) + '''</td>
  88. <td>''' + ip_pas(data[1]) + '''</td>
  89. <td>''' + data[3] + '''</td>
  90. </tr>
  91. <tr>
  92. <td colspan="3">''' + ua + '''</td>
  93. </tr>
  94. '''
  95. div += '''
  96. </tbody>
  97. </table>
  98. '''
  99. else:
  100. return re_error('/error/2')
  101. div += next_fix(
  102. '/check/' + url_pas(name) + ('?plus=' + plus_id if plus_id else '') + '&num=',
  103. num,
  104. record
  105. )
  106. return easy_minify(flask.render_template(skin_check(),
  107. imp = [load_lang('check'), wiki_set(), custom(), other2([0, 0])],
  108. data = div,
  109. menu = [['manager', load_lang('return')]]
  110. ))