You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ActionAddDomain.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // Created by robin on 8/9/15.
  3. //
  4. #include "ActionAddDomain.h"
  5. ActionAddDomain::ActionAddDomain()
  6. {
  7. }
  8. const std::string &ActionAddDomain::getSoaNs() const
  9. {
  10. return _soaNs;
  11. }
  12. void ActionAddDomain::setSoaNs(const std::string &soaNs)
  13. {
  14. _soaNs = soaNs;
  15. }
  16. const std::string &ActionAddDomain::getSoaMail() const
  17. {
  18. return _soaMail;
  19. }
  20. void ActionAddDomain::setSoaMail(const std::string &soaMail)
  21. {
  22. _soaMail = soaMail;
  23. }
  24. int ActionAddDomain::getSoaRefresh() const
  25. {
  26. return _soaRefresh;
  27. }
  28. void ActionAddDomain::setSoaRefresh(int soaRefresh)
  29. {
  30. _soaRefresh = soaRefresh;
  31. }
  32. int ActionAddDomain::getSoaRetry() const
  33. {
  34. return _soaRetry;
  35. }
  36. void ActionAddDomain::setSoaRetry(int soaRetry)
  37. {
  38. _soaRetry = soaRetry;
  39. }
  40. int ActionAddDomain::getSoaExpire() const
  41. {
  42. return _soaExpire;
  43. }
  44. void ActionAddDomain::setSoaExpire(int soaExpire)
  45. {
  46. _soaExpire = soaExpire;
  47. }
  48. int ActionAddDomain::getSoaTtl() const
  49. {
  50. return _soaTtl;
  51. }
  52. void ActionAddDomain::setSoaTtl(int soaTtl)
  53. {
  54. _soaTtl = soaTtl;
  55. }
  56. int ActionAddDomain::getTtl() const
  57. {
  58. return _ttl;
  59. }
  60. void ActionAddDomain::setTtl(int ttl)
  61. {
  62. _ttl = ttl;
  63. }
  64. const std::string ActionAddDomain::getSql() const //ns.rthoni.com rthoni.hotmail.fr 2015080600 28800 7200 604800 86400
  65. {
  66. auto soa = _soaNs + " " + _soaMail + " " + std::to_string(time(nullptr)) + " " + std::to_string(_soaRefresh)
  67. + " " + std::to_string(_soaRetry)+ " " + std::to_string(_soaExpire) + " " + std::to_string(_soaTtl);
  68. return "INSERT INTO domains (name, type) VALUES (\"" + _domain + "\", \"MASTER\");\n"
  69. "SET @domain_id=(SELECT id FROM domains WHERE name=\"" + _domain + "\");\n"
  70. "INSERT INTO zones (domain_id, owner, zone_templ_id) VALUES (@domain_id, "
  71. "(SELECT id FROM users ORDER BY id LIMIT 1), 0);\n"
  72. "INSERT INTO records (domain_id, name, type, content, ttl, prio, change_date)\n"
  73. " VALUES(@domain_id, \"" + _domain + "\", \"SOA\","
  74. " \"" + soa + "\", " + std::to_string(_ttl) + ", 0, " + std::to_string(time(nullptr)) + ");\n";
  75. }