recent_change.py 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. from .tool.func import *
  2. def recent_change_2(conn, name, tool):
  3. curs = conn.cursor()
  4. if flask.request.method == 'POST':
  5. return redirect(
  6. '/diff/' + url_pas(name) +
  7. '?first=' + flask.request.form.get('b', '1') +
  8. '&second=' + flask.request.form.get('a', '1')
  9. )
  10. else:
  11. ban = ''
  12. select = ''
  13. sub = ''
  14. admin_6 = admin_check(6)
  15. admin = admin_check()
  16. div = '''
  17. <table id="main_table_set">
  18. <tbody>
  19. <tr id="main_table_top_tr">
  20. '''
  21. num = int(number_check(flask.request.args.get('num', '1')))
  22. sql_num = (num * 50 - 50) if num * 50 > 0 else 0
  23. if name:
  24. if tool == 'history':
  25. sub += ' (' + load_lang('history') + ')'
  26. div += '''
  27. <td id="main_table_width">''' + load_lang('version') + '''</td>
  28. <td id="main_table_width">''' + load_lang('editor') + '''</td>
  29. <td id="main_table_width">''' + load_lang('time') + '''</td>
  30. '''
  31. set_type = flask.request.args.get('set', 'normal')
  32. set_type = '' if set_type == 'edit' else set_type
  33. if set_type != 'normal':
  34. curs.execute(db_change('' + \
  35. 'select id, title, date, ip, send, leng, hide from history ' + \
  36. 'where title = ? and type = ? ' + \
  37. 'order by id + 0 desc ' + \
  38. "limit ?, 50" + \
  39. ''), [name, set_type, sql_num])
  40. else:
  41. curs.execute(db_change('' + \
  42. 'select id, title, date, ip, send, leng, hide from history ' + \
  43. 'where title = ? ' + \
  44. 'order by id + 0 desc ' + \
  45. "limit ?, 50" + \
  46. ''), [name, sql_num])
  47. data_list = curs.fetchall()
  48. else:
  49. div += '''
  50. <td id="main_table_width">''' + load_lang('document_name') + '''</td>
  51. <td id="main_table_width">''' + load_lang('editor') + '''</td>
  52. <td id="main_table_width">''' + load_lang('time') + '''</td>
  53. '''
  54. curs.execute(db_change('' + \
  55. 'select id, title, date, ip, send, leng, hide from history ' + \
  56. "where ip = ? order by date desc limit ?, 50" + \
  57. ''), [name, sql_num])
  58. data_list = curs.fetchall()
  59. else:
  60. div += '''
  61. <td id="main_table_width">''' + load_lang('document_name') + '''</td>
  62. <td id="main_table_width">''' + load_lang('editor') + '''</td>
  63. <td id="main_table_width">''' + load_lang('time') + '''</td>
  64. '''
  65. sub = ''
  66. set_type = flask.request.args.get('set', 'normal')
  67. set_type = '' if set_type == 'edit' else set_type
  68. data_list = []
  69. curs.execute(db_change('select id, title from rc where type = ? order by date desc'), [set_type])
  70. for i in curs.fetchall():
  71. curs.execute(db_change('select id, title, date, ip, send, leng, hide from history where id = ? and title = ?'), i)
  72. data_list += curs.fetchall()
  73. div += '</tr>'
  74. all_ip = ip_pas([i[3] for i in data_list])
  75. for data in data_list:
  76. select += '<option value="' + data[0] + '">' + data[0] + '</option>'
  77. send = '<br>'
  78. if data[4]:
  79. if not re.search(r"^(?: +)$", data[4]):
  80. send = data[4]
  81. if re.search(r"\+", data[5]):
  82. leng = '<span style="color:green;">(' + data[5] + ')</span>'
  83. elif re.search(r"\-", data[5]):
  84. leng = '<span style="color:red;">(' + data[5] + ')</span>'
  85. else:
  86. leng = '<span style="color:gray;">(' + data[5] + ')</span>'
  87. ip = all_ip[data[3]]
  88. m_tool = '<a href="/history/tool/' + data[0] + '/' + url_pas(data[1]) + '">(' + load_lang('tool') + ')</a>'
  89. style = ['', '']
  90. date = data[2]
  91. if data[6] == 'O':
  92. if admin == 1:
  93. style[0] = 'id="toron_color_grey"'
  94. style[1] = 'id="toron_color_grey"'
  95. else:
  96. ip = ''
  97. ban = ''
  98. date = ''
  99. style[0] = 'style="display: none;"'
  100. style[1] = 'id="toron_color_grey"'
  101. if tool == 'history':
  102. title = '<a href="/w/' + url_pas(name) + '?num=' + data[0] + '">r' + data[0] + '</a> '
  103. else:
  104. title = '<a href="/w/' + url_pas(data[1]) + '">' + html.escape(data[1]) + '</a> '
  105. if int(data[0]) < 2:
  106. title += '<a href="/history/' + url_pas(data[1]) + '">(r' + data[0] + ')</a> '
  107. else:
  108. title += '<a href="/diff/' + url_pas(data[1]) + '?first=' + str(int(data[0]) - 1) + '&second=' + data[0] + '">(r' + data[0] + ')</a> '
  109. div += '''
  110. <tr ''' + style[0] + '''>
  111. <td>''' + title + m_tool + ' ' + leng + '''</td>
  112. <td>''' + ip + ban + '''</td>
  113. <td>''' + date + '''</td>
  114. </tr>
  115. <tr ''' + style[1] + '''>
  116. <td class="send_content" colspan="3">''' + html.escape(send) + '''</td>
  117. </tr>
  118. '''
  119. div += '''
  120. </tbody>
  121. </table>
  122. <script>send_render();</script>
  123. '''
  124. if name:
  125. if tool == 'history':
  126. div = '' + \
  127. '<a href="?set=normal">(' + load_lang('normal') + ')</a> ' + \
  128. '<a href="?set=edit">(' + load_lang('edit') + ')</a> ' + \
  129. '<a href="?set=move">(' + load_lang('move') + ')</a> ' + \
  130. '<a href="?set=delete">(' + load_lang('delete') + ')</a> ' + \
  131. '<a href="?set=revert">(' + load_lang('revert') + ')</a>' + \
  132. '<hr class="main_hr">' + div + \
  133. ''
  134. menu = [['w/' + url_pas(name), load_lang('return')]]
  135. if set_type == 'normal':
  136. div = '''
  137. <form method="post">
  138. <select name="a">''' + select + '''</select> <select name="b">''' + select + '''</select>
  139. <button type="submit">''' + load_lang('compare') + '''</button>
  140. </form>
  141. <hr class=\"main_hr\">
  142. ''' + div
  143. if admin == 1:
  144. menu += [
  145. ['history/add/' + url_pas(name), load_lang('history_add')],
  146. ['history/reset/' + url_pas(name), load_lang('history_reset')]
  147. ]
  148. title = name
  149. div += next_fix('/history/' + url_pas(name) + '?tool=' + set_type + '&num=', num, data_list)
  150. else:
  151. title = load_lang('edit_record')
  152. menu = [
  153. ['other', load_lang('other')],
  154. ['user', load_lang('user')],
  155. ['record/reset/' + url_pas(name), load_lang('record_reset')]
  156. ]
  157. div += next_fix('/record/' + url_pas(name) + '?num=', num, data_list)
  158. else:
  159. div = '' + \
  160. '<a href="?set=normal">(' + load_lang('normal') + ')</a> ' + \
  161. '<a href="?set=edit">(' + load_lang('edit') + ')</a> ' + \
  162. '<a href="?set=user">(' + load_lang('user_document') + ')</a> ' + \
  163. '<a href="?set=move">(' + load_lang('move') + ')</a> ' + \
  164. '<a href="?set=delete">(' + load_lang('delete') + ')</a> ' + \
  165. '<a href="?set=revert">(' + load_lang('revert') + ')</a>' + \
  166. '<hr class="main_hr">' + div + \
  167. ''
  168. menu = 0
  169. title = load_lang('recent_change')
  170. if sub == '':
  171. sub = 0
  172. return easy_minify(flask.render_template(skin_check(),
  173. imp = [title, wiki_set(), wiki_custom(), wiki_css([sub, 0])],
  174. data = div,
  175. menu = menu
  176. ))