Advertisement
Guest User

Untitled

a guest
Oct 10th, 2018
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.35 KB | None | 0 0
  1. <?php
  2. //$msg = "";
  3. //SINGLE DOMAIN SIGNUP
  4. //---------------------------------------
  5.  
  6. //MySQL Information:
  7. $mysql_host = "localhost"; //Host Name
  8. $mysql_user = "root"; //Username
  9. $mysql_pass = ""; //Password
  10. $mysql_db = "mail"; //Database
  11.  
  12. //General Configuration:
  13. $account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)
  14.  
  15. $admin_notify = 1; //1 = yes & 0 = no
  16. $admin_email = ""; //Administrators email to send notifications)
  17. $admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
  18. $encryption = 2; //Password encryption level
  19.  
  20. $url = $_SERVER["HTTP_HOST"];
  21. $domain = $_SERVER["HTTP_HOST"];
  22.  
  23. if (substr($domain,0,4) == "www.")
  24. {
  25. $domain = strstr($domain, ".");
  26. $domain = substr($domain, 1);
  27. }
  28.  
  29. // Protect the Database and MD5 the password.
  30. $strName = addslashes( $_POST['name'] );
  31. $strUser = addslashes( $_POST['user'] );
  32. $strDomain = addslashes( $_POST['domain'] );
  33. $strPass1 = addslashes( $_POST['pass1'] );
  34. $strMD5Pass = md5( $strPass1 );
  35.  
  36. error_reporting(E_ALL ^ E_NOTICE);
  37. //Next two lines connect to database using information from above.
  38. $con = new mysqli('localhost', 'hmailserver', 'hmailserver', 'mail');
  39. ///$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
  40. ///$select = mysql_select_db($mysql_db);
  41.  
  42. IF (!$con)
  43. {
  44. echo "Unable to open database, contact your administrator!";
  45. }
  46. ELSE
  47. {
  48. echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above
  49. //Decide On What Path To Take
  50. SWITCH ($_GET['mode'])
  51. {
  52. CASE "do":
  53. //#### PAGE IF FORM FILLED OUT ####//
  54. $q=mysqli_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use)
  55. WHILE ($v=mysqli_fetch_array($q))
  56. {
  57. $temp_domain = $v['1'];
  58.  
  59. } //Apply information
  60.  
  61. $q2=mysqli_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists
  62. $v2=mysqli_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one)
  63.  
  64. IF ($v2 == 1)
  65. {
  66. echo "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>";
  67. }
  68. ELSE
  69. {
  70. IF (!$_POST['pass1'] || !$_POST['pass2'])
  71. {
  72. echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>";
  73. }
  74. ELSEIF ($_POST['pass1'] <> $_POST['pass2'])
  75. {
  76. echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>";
  77. }
  78. ELSE
  79. {
  80. $q3=mysqli_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$strDomain','$strUser@$temp_domain','$strMD5Pass','$admin_default_activate','0','$account_max','$encryption')") or die(mysql_error());
  81. }
  82. }
  83.  
  84. IF ($q3)
  85. {
  86. IF ($admin_default_activate == 0)
  87. {
  88. echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this.";
  89. }
  90. ELSE
  91. {
  92. echo "Your account has been created and is ready for use!<br><br>Username: $strUser@$temp_domain<br><br>Webmail: <a href=\"$serv_webmail/webmail\">www.$temp_domain/webmail</a><br>POP3: mail.$temp_domain<br>IMAP: mail.$temp_domain<br><br>SMTP: mail.$temp_domain";
  93. $subject = "Welcome To MYWEBSITE!";
  94. $message = "This is confirmation that your account has been created.";
  95.  
  96. mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message
  97. }
  98. }
  99. ELSE
  100. {
  101. echo "Database error, unable to add account. Please contact your administrator!";
  102. }
  103.  
  104. IF ($admin_default_activate == 0 && $admin_notify == 0)
  105. {
  106. $admin_mail_subject = "Account Requires Activation!";
  107. $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!";
  108. mail($admin_email, $admin_mail_subject, $admin_mail_message);
  109. }
  110. ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
  111. {
  112. $admin_mail_subject = "New Account Created!";
  113. $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
  114. mail($admin_email, $admin_mail_subject, $admin_mail_message);
  115. }
  116. ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
  117. {
  118. $admin_mail_subject = "New Account Created!";
  119. $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
  120. mail($admin_email, $admin_mail_subject, $admin_mail_message);
  121. }
  122. ELSEIF ($admin_default_activate == 0 && $admin_notify == 1)
  123. {
  124. $admin_mail_subject = "New Account Created!";
  125. $admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
  126. mail($admin_email, $admin_mail_subject, $admin_mail_message);
  127. }
  128. break;
  129.  
  130. DEFAULT:
  131. }
  132. }
  133.  
  134. ?>
  135.  
  136. <!DOCTYPE html>
  137. <html>
  138. <head>
  139. <meta charset="utf-8" />
  140. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  141. <title>Sign Up | MM Security</title>
  142. <link rel="icon" href="../img/icon.ico">
  143. <meta name="viewport" content="width=device-width, initial-scale=1">
  144. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
  145. integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  146. <link rel="stylesheet" type="text/css" media="screen" href="style/reg.css"/>
  147. <meta name="description" content="Sign up in MMSecurity">
  148. </head>
  149. <body>
  150. <div class="container" style="margin-top: 100px;">
  151. <div class="row justify-content-center">
  152. <div class="col-md-6 col-md-offset-3" align="center">
  153.  
  154. <img src="../img/logo.png"><br><br>
  155.  
  156. <?php //if ($msg != "") echo $msg . "<br><br>" ?>
  157. <form method="POST" action="?mode=do">
  158. <input class="form-control" name="name" type="text" placeholder="Your Name"><br>
  159. <input class="form-control" name="user" type="text" placeholder="Email" width="300px;"> <br>@ <select name="domain"><?php
  160. $q2=mysqli_query($con ,"SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
  161. WHILE ($v2=mysqli_fetch_array($q2)) //Display avaliable domains
  162. {
  163. echo "<option value=\"{$v2['0']}\">$domain</option>";
  164. }
  165. ?><br>
  166. <input class="form-control" name="pass1" type="password" placeholder="Password"><br>
  167. <input class="form-control" name="pass2" type="password" placeholder="Confirm Password"><br>
  168. <input class="btn btn-primary" type="submit" name="submit" value="Create Account">
  169. </form>
  170. </body>
  171. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement