recent_discuss.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. from .tool.func import *
  2. def recent_discuss(tool):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. div = ''
  6. admin_auth = admin_check(3)
  7. if tool == 'normal':
  8. div += '<a href="/recent_discuss/close">(' + load_lang('close_discussion') + ')</a> '
  9. div += '<a href="/recent_discuss/open">(' + load_lang('open_discussion_list') + ')</a>'
  10. m_sub = 0
  11. elif tool == 'close':
  12. div += '<a href="/recent_discuss">(' + load_lang('normal') + ')</a>'
  13. m_sub = ' (' + load_lang('closed') + ')'
  14. else:
  15. div += '<a href="/recent_discuss">(' + load_lang('normal') + ')</a>'
  16. m_sub = ' (' + load_lang('open_discussion_list') + ')'
  17. div += '''
  18. <hr class="main_hr">
  19. <table id="main_table_set">
  20. <tbody>
  21. <tr id="main_table_top_tr">
  22. <td id="main_table_width">''' + load_lang('discussion_name') + '''</td>
  23. <td id="main_table_width">''' + load_lang('editor') + '''</td>
  24. <td id="main_table_width">''' + load_lang('time') + '''</td>
  25. </tr>
  26. '''
  27. if tool == 'normal':
  28. curs.execute(db_change("select title, sub, date, code from rd where not stop = 'O' order by date desc limit 50"))
  29. elif tool == 'close':
  30. curs.execute(db_change("select title, sub, date, code from rd where stop = 'O' order by date desc limit 50"))
  31. else:
  32. curs.execute(db_change('select title, sub, date, code from rd where stop != "O" order by date asc limit 50'))
  33. db_data = curs.fetchall()
  34. last_editor = []
  35. for for_a in db_data:
  36. curs.execute(db_change("select ip from topic where code = ? order by id + 0 desc limit 1"), [for_a[3]])
  37. db_data_2 = curs.fetchall()
  38. if db_data_2:
  39. last_editor += [db_data_2[0][0]]
  40. else:
  41. last_editor += ['']
  42. last_editor_ip_pas = ip_pas(last_editor)
  43. count = 0
  44. for data in db_data:
  45. div += '' + \
  46. '<tr>' + \
  47. '<td>' + \
  48. '<a href="/thread/' + data[3] + '">' + html.escape(data[1]) + '</a> ' + \
  49. '<a href="/topic/' + url_pas(data[0]) + '">(' + html.escape(data[0]) + ')</a>' + \
  50. (' <a href="/thread/' + data[3] + '/tool">(' + load_lang('tool') + ')</a>' if admin_auth == 1 else '') + \
  51. '</td>' + \
  52. '<td>' + last_editor_ip_pas[last_editor[count]] + '</td>' + \
  53. '<td>' + data[2] + '</td>' + \
  54. '</tr>' + \
  55. ''
  56. count += 1
  57. div += '' + \
  58. '</tbody>' + \
  59. '</table>' + \
  60. ''
  61. return easy_minify(flask.render_template(skin_check(),
  62. imp = [load_lang('recent_discussion'), wiki_set(), wiki_custom(), wiki_css([m_sub, 0])],
  63. data = div,
  64. menu = [['other', load_lang('return')]]
  65. ))