user_watch_list_name.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. from .tool.func import *
  2. def user_watch_list_name(tool, name = 'Test'):
  3. with get_db_connect() as conn:
  4. curs = conn.cursor()
  5. ip = ip_check()
  6. if ip_or_user(ip) != 0:
  7. return redirect('/login')
  8. if tool == 'watch_list':
  9. type_data = ''
  10. else:
  11. type_data = 'star'
  12. curs.execute(db_change("select title from scan where user = ? and title = ? and type = ?"), [ip, name, type_data])
  13. if curs.fetchall():
  14. curs.execute(db_change("delete from scan where user = ? and title = ? and type = ?"), [ip, name, type_data])
  15. else:
  16. if tool == 'watch_list':
  17. curs.execute(db_change("select count(*) from scan where user = ?"), [ip])
  18. count = curs.fetchall()
  19. if count and count[0][0] > 10:
  20. return re_error('/error/28')
  21. curs.execute(db_change("insert into scan (user, title, type) values (?, ?, ?)"), [ip, name, type_data])
  22. conn.commit()
  23. if tool == 'watch_list':
  24. return redirect('/watch_list')
  25. else:
  26. return redirect('/star_doc')