Advertisement
Guest User

signup

a guest
Jul 3rd, 2013
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.69 KB | None | 0 0
  1. <center>
  2. <body bgcolor="#ECE9E0">
  3. <?php
  4. session_start();
  5.  
  6. require_once( 'inc/config.inc.php' );
  7.  
  8. error_reporting(E_ALL & ~E_NOTICE);
  9.  
  10. $url = $_SERVER["HTTP_HOST"];
  11. $domain = (empty($domain))? $_SERVER["HTTP_HOST"] : $domain;
  12. $domain = (substr($domain,0,4) == "www.")? strstr($domain, ".") : $domain;
  13.  
  14. // Protect database entries and use MD5 encryption
  15. $strName    = (isset($_POST['name']))? addslashes( $_POST['name'] ) : '';
  16. $strUser    = (isset($_POST['user']))? addslashes( $_POST['user'] ) : '';
  17. $strKey     = (isset($_POST['code']))? addslashes( $_POST['code'] ) : '';
  18. $strEmail2  = (isset($_POST['email2']))? addslashes( $_POST['email2'] ) : '';
  19.  
  20.  
  21. $strDomain  = addslashes( "$domain" );
  22. $strPass1   = (isset($_POST['pass1']))? addslashes( $_POST['pass1'] ) : '';
  23.  
  24. //Connect to database using information from above
  25. $open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
  26. $select = mysql_select_db($mysql_db);
  27.  
  28. if (!$open || !$select)
  29. {
  30.   echo "Unable to open database, contact your administrator!";
  31. } else {
  32.   echo "<fieldset style=\"width:420px;font-size:12px;\"><legend style=\"font-size:30px;color:blue;width:100px;\">$form_title</legend>";
  33.  
  34.  
  35.   if ( isset($_POST['submit']) &&  $_POST['submit'] == 'create account' ){
  36.    if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
  37.     $domain_res = mysql_query("SELECT * FROM `hm_domains` WHERE `domainname` = '{$strDomain}' LIMIT 1");
  38.       if (!$domain_res)
  39.       {
  40.         die('Error while selecting data: ' . mysql_error());
  41.        }
  42.       $domain_info = mysql_fetch_array($domain_res, MYSQL_ASSOC);
  43.      
  44.  
  45.  
  46.     //Check to see if email account exists, if not process signup
  47.     $account_res = mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$strDomain' LIMIT 1");
  48.     $v1 = mysql_num_rows($account_res);
  49.        
  50.     If ($v1 >= 1)
  51.     {
  52.        echo "A subscriber with this email already exists!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset.";
  53.        return false;
  54.     } else {
  55.       if ( !$_POST['pass1'] || !$_POST['pass2'] )
  56.       {
  57.          echo "You did not enter both passwords!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset.";
  58.       }
  59.       elseif ( $_POST['pass1'] != $_POST['pass2'] )
  60.       {
  61.          echo "The passwords entered do not match!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset.";
  62.       } else {
  63.          $domain_id = $domain_info['domainid'];
  64.          $account_pass = ($encryption == 2)? md5( $strPass1 ) : $strPass1;
  65.  
  66.          $account_add = mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`,`code`,`email2`) VALUES ('$domain_id','$strUser@$strDomain','$account_pass','$admin_default_activate','$accountisad','$account_max','$encryption','$strKey','$strEmail2')");
  67.        
  68. // Find the accountid for the newly created account based off of domain id and account address
  69. $query = mysql_query("SELECT accountid FROM hm_accounts
  70. WHERE accountdomainid='$domain_id' AND accountaddress='$strUser@$strDomain'") or die(mysql_error());
  71. $col = mysql_fetch_array($query);
  72. $account_info = $col ['accountid'];
  73.  
  74. // Match folderaccountid with accountid
  75. $folderaccountid = $account_info;
  76. $folderparentid = '-1';
  77. $folderissubscribed = '1';
  78. $foldercurrentuid = '1';
  79.  
  80. // Build IMAP Folders
  81.   $imapfolders_add = mysql_query("
  82.   INSERT INTO hm_imapfolders (folderaccountid, folderparentid, foldername, folderissubscribed,foldercurrentuid)
  83.      SELECT '$folderaccountid', '$folderparentid', 'INBOX', '$folderissubscribed', '$foldercurrentuid'
  84.   UNION ALL
  85.      SELECT '$folderaccountid', '$folderparentid', 'Sent', '$folderissubscribed', '$foldercurrentuid'
  86.   UNION ALL
  87.      SELECT '$folderaccountid', '$folderparentid', 'Trash', '$folderissubscribed', '$foldercurrentuid'
  88.   UNION ALL
  89.      SELECT '$folderaccountid', '$folderparentid', 'Junk', '$folderissubscribed', '$foldercurrentuid'
  90.      ");
  91.       }
  92.     }
  93.    
  94.     if (!$account_add)
  95.       {
  96.         die('<br><br>Database error, unable to add account. Please contact your administrator!<br> ' . mysql_error());
  97.        }
  98.        
  99.     If ($admin_default_activate == 0)
  100.    {
  101.      echo "<div style=\"font-size:14px;color:red;\"><b>Your account has been created but <b>requires activation</b> by administration.";
  102.       echo "Once your application has been approved, you will receive a confirmation message.</div><br><br>";
  103.     } else {
  104.       echo "<div style=\"font-size:14px;color:red;\"><b>Your account has been created and is ready for use!</b><br>";
  105.       echo "<b>Username</b>:<i> $strUser@$strDomain</i><br>";
  106.       if ( !empty($serv_webmail_url) ) echo "<b>Webmail URL</b>: <a href=\"$serv_webmail_url\">www.$strDomain/</a></div><br>";
  107.      
  108.      
  109.       $subject = "Welcome To $strDomain Email!";
  110.       $message = "This is confirmation that your account has been created. You may now login to your account and start using it.";
  111.  
  112.       mail("{$_POST['user']}@$strDomain", "$subject", "$message", "From: $admin_email"); //Send welcome message
  113.     }
  114.        
  115.     if ($admin_default_activate == 0 && $admin_notify == 1)
  116.     {
  117.       $admin_mail_subject = "Account Requires Activation!";
  118.       $admin_mail_message = "The email account {$_POST['user']}@$strDomain has been created by {$_POST['name']} and requires administration activation!\r\n\r\nPlease login to the admin control panel to verIfy and activate user account.\r\n\r\n";
  119.       mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email");
  120.     }
  121.     elseif ($admin_default_activate == 1 && $admin_notify == 1)
  122.     {
  123.       $admin_mail_subject = "New Account Created!";
  124.       $admin_mail_message = "{$_POST['user']}@$strDomain has been created by {$_POST['name']}!";
  125.       mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email");
  126.      
  127.     }
  128.     unset($_SESSION['security_code']);
  129.   } else {
  130.         // Insert your code for showing an error message here
  131.         echo "<div style=\"font-size:13px;color:red;\"><b>Sorry, you have provided an invalid security code <br>Please <a href=\"javascript:history.go(-1)\">click here</a> to reset.</b></div>";
  132.    }
  133.  }
  134. }  
  135.    //Email account signup page
  136.   echo "<form action=\"\" method=\"POST\">
  137. <table style=\"font-size:14px;color:#535353;\"><tr>
  138.  <td width=\"100\"><b>Full Name:</b></td><td width=\"220\"><input type=\"text\" name=\"name\" size=\"18\"> </td></tr><tr>
  139.      <td><b>E-Mail:</td><td><input type=\"text\" name=\"user\" size=\"18\"><b><font color=red>@".$domain."</font></b> </td></tr><tr>
  140.      <td><b>Password:</td><td><input type=\"password\" name=\"pass1\" size=\"18\"> </td></tr><tr>
  141.      <td><b>Password:</td><td><input type=\"password\" name=\"pass2\" size=\"18\"> (For Confirmation)</td></tr>
  142.       <td><b><font color=red>Backup Email</font>:</td><td><input type=\"text\" name=\"email2\" size=\"18\"> (To Receive Reset Link)</td></tr>
  143.       <td><b><font color=red>Secret Word/Code</font>:</td><td><input type=\"password\" name=\"code\" size=\"18\"> (If you forget password)</td></tr>
  144.      
  145.       <tr><td>&nbsp;</td><td align=\"left\"><br />";
  146.   echo "<img src=\"CaptchaSecurityImages.php?width=150&height=35&characters=7\" /></td>
  147.         </tr><tr><td><label for=\"security_code\"><b>Security Code: </b></label></td><td><input id=\"security_code\" name=\"security_code\" type=\"text\" /><br /></td>
  148.     </tr><br><br><tr><td colspan=\"2\" align=\"center\"><input type=\"image\" src=\"button.png\" name=\"submit\" value=\"create account\" ></td></tr></table> </fieldset>
  149.   </form>";
  150.  
  151.  
  152.   ?>
  153.  
  154. </center></body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement