zimbraSingle.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. ob_start();
  16. var_dump(get_defined_vars());
  17. $info = ob_get_contents();
  18. ob_end_clean();
  19. file_put_contents("debug_vardump.txt", $info);
  20. function zimbraSingle_TestConnection($params)
  21. {
  22. $auth = new Zm_Auth($params['serverip'], $params['serverusername'], $params['serverpassword'], "admin");
  23. $login = $auth->login();
  24. if(is_a($login, "Exception")) {
  25. logModuleCall(
  26. 'zimbrasingle',
  27. __FUNCTION__,
  28. $params,
  29. "Connection test to " . $params['serverip'] . " failed: Cannot login",
  30. $login->getMessage()
  31. );
  32. return array(
  33. 'success' => false,
  34. 'error' => "Connection test to " . $params['serverip'] . " failed, the error was: " . $login->getMessage(),
  35. );
  36. } else {
  37. return array(
  38. 'success' => true,
  39. 'error' => '',
  40. );
  41. }
  42. }
  43. function zimbraSingle_UsageUpdate($params)
  44. {
  45. }
  46. function zimbraSingle_ClientArea($params)
  47. {
  48. $response = zimbraSingleClientArea($params['customfields']);
  49. return array(
  50. 'templatefile' => 'clientarea',
  51. 'vars' => array(
  52. 'webmailURL' => $response[0]['DATA'],
  53. ),
  54. );
  55. }
  56. function zimbraSingle_ChangePassword($params)
  57. {
  58. $response = zimbraSingleChangePassword($params['customfields']);
  59. if($response) {
  60. return 'success';
  61. }
  62. return $response;
  63. }
  64. function zimbraSingle_CreateAccount($params)
  65. {
  66. $response = zimbraSingleCreateAccount($params['customfields']);
  67. if($response) {
  68. return 'success';
  69. }
  70. return 'Error creating account';
  71. }
  72. function zimbraSingle_SuspendAccount($params)
  73. {
  74. $response = zimbraSingleSuspendAccount($params['customfields']);
  75. if($response) {
  76. return 'success';
  77. }
  78. return 'Error suspending account';
  79. }
  80. function zimbraSingle_UnsuspendAccount($params)
  81. {
  82. $response = zimbraSingleUnsuspendAccount($params['customfields']);
  83. if($response) {
  84. return 'success';
  85. }
  86. return 'Error unsuspending account';
  87. }
  88. function zimbraSingle_TerminateAccount($params)
  89. {
  90. $response = zimbraSingleDeleteAccount($params['customfields']);
  91. if($response) {
  92. return 'success';
  93. }
  94. return 'Error deleting account';
  95. }
  96. function zimbraSingle_ChangePackage($params)
  97. {
  98. $response = zimbraSingleChangePackage($params['customfields']);
  99. if($response) {
  100. return 'success';
  101. }
  102. return 'Error changing package';
  103. }
  104. function zimbraSingle_ConfigOptions()
  105. {
  106. $response = zimbraSingleConfigOptions();
  107. if($response) {
  108. return $response;
  109. }
  110. return 'Error setting config options';
  111. }
  112. function zimbraSingle_genUsername($name)
  113. {
  114. /* $namelen = strlen($name);
  115. $result = select_query("tblhosting","COUNT(*)",array("username" => $name));
  116. $data = mysql_fetch_array($result);
  117. $username_exists = $data[0];
  118. $suffix=0;
  119. while ($username_exists > 0) {
  120. $suffix++;
  121. $name = substr($name,0,$namelen).$suffix;
  122. $result = select_query( "tblhosting", "COUNT(*)", array( "username" => $name ) );
  123. $data = mysql_fetch_array($result);
  124. $username_exists = $data[0];
  125. }
  126. return $name; */
  127. }