api_bbs_w_set_put.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. )
  5. func Api_bbs_w_set_put(config tool.Config) string {
  6. db := tool.DB_connect()
  7. defer tool.DB_close(db)
  8. other_set := map[string]string{}
  9. json.Unmarshal([]byte(config.Other_set), &other_set)
  10. auth_info := tool.Check_acl(db, "", "", "owner_auth", config.IP)
  11. setting_acl := BBS_w_set_list()
  12. return_data := make(map[string]any)
  13. if _, ok := setting_acl[other_set["set_name"]]; ok {
  14. if auth_info {
  15. if _, ok := other_set["coverage"]; !ok {
  16. tool.Exec_DB(
  17. db,
  18. "delete from bbs_set where set_name = ? and set_id = ?",
  19. other_set["set_name"], other_set["set_id"],
  20. )
  21. }
  22. tool.Exec_DB(
  23. db,
  24. "insert into bbs_set (set_name, set_code, set_id, set_data) values (?, '', ?, ?)",
  25. other_set["set_name"], other_set["set_id"], other_set["data"],
  26. )
  27. return_data["response"] = "ok"
  28. } else {
  29. return_data["response"] = "require auth"
  30. }
  31. } else {
  32. return_data["response"] = "not exist"
  33. }
  34. json_data, _ := json.Marshal(return_data)
  35. return string(json_data)
  36. }