DNSMockFunction.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. use MGModule\DNSManager2\mgLibs\custom\dns\utils as main;
  3. /**
  4. * This function is invoked to get DNS Records to display them in DNS Management section
  5. * @param Array $params Collection of WHMCS parameters
  6. * @return Array Array with error key is returned in case of error. With success key otherwise
  7. */
  8. if(!function_exists('%module_name%_GetDNS'))
  9. {
  10. function %module_name%_GetDNS($params)
  11. {
  12. $domainId = null;
  13. if(isset($params['domainid']))
  14. {
  15. $domainId = $params['domainid'];
  16. }
  17. if(empty($domainId))
  18. {
  19. $id = $_GET["id"];
  20. if (empty($id))
  21. {
  22. $id = $_GET['domainid'];
  23. }
  24. $domainId = $id;
  25. }
  26. try
  27. {
  28. $registrarHelper = new main\CustomDnsRegistrarHelper($domainId);
  29. $dns = $registrarHelper->getDNSRecords($domainId);
  30. }
  31. catch(Exception $e)
  32. {
  33. return array('error' => $e->getMessage());
  34. }
  35. return $dns;
  36. }
  37. }
  38. /**
  39. * This function is invoked when user tries to save DNS Records form DNS Management section
  40. * @param Array $params Collection of WHMCS parameters
  41. * @return Array Array with error key is returned in case of error. With success key otherwise
  42. */
  43. if(!function_exists('%module_name%_SaveDNS'))
  44. {
  45. function %module_name%_SaveDNS($params)
  46. {
  47. $domainId = null;
  48. if(isset($params['domainid']))
  49. {
  50. $domainId = $params['domainid'];
  51. }
  52. if(empty($domainId))
  53. {
  54. $id = $_GET["id"];
  55. if(empty($id))
  56. {
  57. $id = $_GET['domainid'];
  58. }
  59. $domainId = $id;
  60. }
  61. try
  62. {
  63. $registrarHelper = new main\CustomDnsRegistrarHelper($domainId);
  64. $registrarHelper->saveDNSRecords();
  65. }
  66. catch(Exception $ex)
  67. {
  68. return array(
  69. 'error' => $ex->getMessage()
  70. );
  71. }
  72. return array("success" => true);
  73. }
  74. }