user_count.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from .tool.func import *
  2. def user_count(name = None):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. if name == None:
  6. that = ip_check()
  7. else:
  8. that = name
  9. curs.execute(db_change("select count(*) from history where ip = ?"), [that])
  10. count = curs.fetchall()
  11. if count:
  12. data = count[0][0]
  13. else:
  14. data = 0
  15. curs.execute(db_change("select count(*) from topic where ip = ?"), [that])
  16. count = curs.fetchall()
  17. if count:
  18. data_topic = count[0][0]
  19. else:
  20. data_topic = 0
  21. date = get_time()
  22. date = date.split()
  23. date = date[0]
  24. curs.execute(db_change("select count(*) from history where date like ? and ip = ?"), [date + '%', that])
  25. count = curs.fetchall()
  26. if count:
  27. data_today = count[0][0]
  28. else:
  29. data_today = 0
  30. data_today_len = 0
  31. curs.execute(db_change("select leng from history where date like ? and ip = ?"), [date + '%', that])
  32. db_data = curs.fetchall()
  33. for count in db_data:
  34. data_today_len += int(count[0][1:])
  35. # 한글 지원 필요
  36. return easy_minify(flask.render_template(skin_check(),
  37. imp = [load_lang('count'), wiki_set(), wiki_custom(), wiki_css([0, 0])],
  38. data = '''
  39. <ul class="inside_ul">
  40. <li><a href="/record/''' + url_pas(that) + '''">''' + load_lang('edit_record') + '''</a> : ''' + str(data) + '''</li>
  41. <li><a href="/record/topic/''' + url_pas(that) + '''">''' + load_lang('discussion_record') + '''</a> : ''' + str(data_topic) + '''</a></li>
  42. <hr>
  43. <li>(''' + load_lang('beta') + ''') TODAY : ''' + str(data_today) + '''</li>
  44. <li>(''' + load_lang('beta') + ''') TODAY LEN : ''' + str(data_today_len) + '''</li>
  45. </ul>
  46. ''',
  47. menu = [['user', load_lang('return')]]
  48. ))