Advertisement
kakatoji

Create whm

Jul 25th, 2017
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. <?php
  2.  
  3. ###############################################################
  4. # cPanel WHM Account Creator 1.1
  5. ###############################################################
  6. # Dont change by kakatoji
  7. ###############################################################
  8. # Required parameters:
  9. # - domain - new account domain
  10. # - user - new account username
  11. # - password - new account password
  12. # - package - new account hosting package (plan)
  13. # - email - contact email
  14. #
  15. # Sample run: create-whm-account.php?domain=reseller.com&user=hosting&password=manager&package=unix_500
  16. #
  17. # If no parameters passed then input form will be shown to enter data.
  18. #
  19. # This script can also be run from another PHP script. This may
  20. # be helpful if you have some user interface already in place and
  21. # want to automatically create WHM accounts from there.
  22. # In this case you have to setup following variables instead of
  23. # passing them as parameters:
  24. # - $user_domain - new account domain
  25. # - $user_name - new account username
  26. # - $user_pass - new account password
  27. # - $user_plan - new account hosting package (plan)
  28. # - $user_email - contact email
  29. #
  30. ###############################################################
  31.  
  32. /////// YOUR WHM LOGIN DATA
  33. $whm_user = "root"; // reseller username
  34. $whm_pass = "password"; // the password you use to login to WHM
  35.  
  36. #####################################################################################
  37. ############## END OF SETTINGS. DO NOT EDIT BELOW #######################
  38. #####################################################################################
  39.  
  40. $whm_host = $_SERVER['HTTP_HOST'];
  41.  
  42. function getVar($name, $def = '') {
  43. if (isset($_REQUEST[$name]))
  44. return $_REQUEST[$name];
  45. else
  46. return $def;
  47. }
  48.  
  49. // Domain name of new hosting account
  50. // To create subdomain just pass full subdomain name
  51. // Example: newuser.kakatoji.com
  52. if (!isset($user_domain)) {
  53. $user_domain = getVar('domain');
  54. }
  55.  
  56. // Username of the new hosting account
  57. if (!isset($user_name)) {
  58. $user_name = getVar('user');
  59. }
  60.  
  61. // Password for the new hosting account
  62. if (!isset($user_pass)) {
  63. $user_pass = getVar('password');
  64. }
  65.  
  66. // New hosting account Package
  67. if (!isset($user_plan)) {
  68. $user_plan = getVar('package');
  69. }
  70.  
  71. // Contact email
  72. if (!isset($user_email)) {
  73. $user_email = getVar('email');
  74. }
  75.  
  76. // if parameters passed then create account
  77. if (!empty($user_name)) {
  78.  
  79. // create account on the cPanel server
  80. $script = "http://{$whm_user}:{$whm_pass}@{$whm_host}:2086/scripts/wwwacct";
  81. $params = "?plan={$user_plan}&domain={$user_domain}&username={$user_name}&password={$user_pass}&contactemail={$user_email}";
  82. $result = file_get_contents($script.$params);
  83.  
  84. // output result
  85. echo "RESULT: " . $result;
  86. }
  87. // otherwise show input form
  88. else {
  89. $frm = <<<EOD
  90. <html>
  91. <head>
  92. <title>cPanel/WHM Account Creator</title>
  93. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  94. <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
  95. </head>
  96. <body>
  97. <style>
  98. input { border: 1px solid black; }
  99. </style>
  100. <form method="post">
  101. <h3>cPanel/WHM Account Creator</h3>
  102. <table border="0">
  103. <tr><td>Domain:</td><td><input name="domain" size="30"></td><td>Subdomain or domain, without www</td></tr>
  104. <tr><td>Username:</td><td><input name="user" size="30"></td><td>Username to be created</td></tr>
  105. <tr><td>Password:</td><td><input name="password" size="30"></td><td></td></tr>
  106. <tr><td>Package:</td><td><input name="package" size="30"></td><td>Package (hosting plan) name. Make sure you cpecify existing package</td></tr>
  107. <tr><td>Contact Email:</td><td><input name="email" size="30"></td><td></td></tr>
  108. <tr><td colspan="3"><br /><input type="submit" value="Create Account"></td></tr>
  109. </table>
  110. </form>
  111. </body>
  112. </html>
  113. EOD;
  114. echo $frm;
  115. }
  116.  
  117. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement