2
0

watch_list_name.py 976 B

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