zimbraSingle.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * WHMCS Zimbra Provisioning Module
  4. *
  5. * Provisioning for private user accounts on the Zimbra Server
  6. *
  7. * @see https://www.zimbra.com
  8. * @copyright Copyright (c) Thurdata GmbH 2020
  9. * @license GPL
  10. */
  11. if (!defined("WHMCS")) {
  12. die("This file cannot be accessed directly");
  13. }
  14. require_once dirname(__FILE__) . '/zimbraSingle.inc';
  15. function zimbraSingle_TestConnection($params)
  16. {
  17. $auth = new Zm_Auth($params['serverip'], $params['serverusername'], $params['serverpassword'], "admin");
  18. $login = $auth->login();
  19. if(is_a($login, "Exception")) {
  20. logModuleCall(
  21. 'zimbrasingle',
  22. __FUNCTION__,
  23. $params,
  24. "Connection test to " . $params['serverip'] . " failed: Cannot login",
  25. $login->getMessage()
  26. );
  27. return array(
  28. 'success' => false,
  29. 'error' => "Connection test to " . $params['serverip'] . " failed, the error was: " . $login->getMessage(),
  30. );
  31. } else {
  32. return array(
  33. 'success' => true,
  34. 'error' => '',
  35. );
  36. }
  37. }
  38. function zimbraSingle_ClientArea($params)
  39. {
  40. $response = zimbraSingleClientArea($params['customfields']);
  41. return array(
  42. 'templatefile' => 'clientarea',
  43. 'vars' => $response
  44. );
  45. }
  46. function zimbraSingle_ChangePassword($params)
  47. {
  48. $response = zimbraSingleChangePassword($params['customfields']);
  49. if($response == 'success') {
  50. return 'success';
  51. }
  52. return $response;
  53. }
  54. function zimbraSingle_CreateAccount($params)
  55. {
  56. $response = zimbraSingleCreateAccount($params['customfields']);
  57. if($response) {
  58. return 'success';
  59. }
  60. return 'Error creating account';
  61. }
  62. function zimbraSingle_SuspendAccount($params)
  63. {
  64. $response = zimbraSingleSuspendAccount($params['customfields']);
  65. if($response) {
  66. return 'success';
  67. }
  68. return 'Error suspending account';
  69. }
  70. function zimbraSingle_UnsuspendAccount($params)
  71. {
  72. $response = zimbraSingleUnsuspendAccount($params['customfields']);
  73. if($response) {
  74. return 'success';
  75. }
  76. return 'Error unsuspending account';
  77. }
  78. function zimbraSingle_TerminateAccount($params)
  79. {
  80. $response = zimbraSingleDeleteAccount($params['customfields']);
  81. if($response == 'success') {
  82. return 'success';
  83. }
  84. return $response;
  85. }
  86. function zimbraSingle_ChangePackage($params)
  87. {
  88. $response = zimbraSingleChangePackage($params['customfields']);
  89. if($response) {
  90. return 'success';
  91. }
  92. return 'Error changing package';
  93. }
  94. function zimbraSingle_ConfigOptions($params)
  95. {
  96. if(isset($_POST['packageconfigoption'])) {
  97. zimbraSingleCreateCustomFields($_POST['packageconfigoption']);
  98. }
  99. $response = zimbraSingleConfigOptions($params);
  100. if($response) {
  101. return $response;
  102. }
  103. return 'Error setting config options';
  104. }
  105. function zimbraSingle_genUsername($name)
  106. {
  107. /* $namelen = strlen($name);
  108. $result = select_query("tblhosting","COUNT(*)",array("username" => $name));
  109. $data = mysql_fetch_array($result);
  110. $username_exists = $data[0];
  111. $suffix=0;
  112. while ($username_exists > 0) {
  113. $suffix++;
  114. $name = substr($name,0,$namelen).$suffix;
  115. $result = select_query( "tblhosting", "COUNT(*)", array( "username" => $name ) );
  116. $data = mysql_fetch_array($result);
  117. $username_exists = $data[0];
  118. }
  119. return $name; */
  120. }