· 9 years ago · Oct 11, 2016, 08:48 PM
1<?php
2
3require_once( 'inc/config.inc.php' );
4
5error_reporting(E_ALL & ~E_NOTICE);
6
7$url = $_SERVER["HTTP_HOST"];
8$domain = (empty($domain))? $_SERVER["HTTP_HOST"] : $domain;
9$domain = (substr($domain,0,4) == "www.")? strstr($domain, ".") : $domain;
10
11// Protect database entries and use MD5 encryption
12$strName = (isset($_POST['name']))? addslashes( $_POST['name'] ) : '';
13$strUser = (isset($_POST['user']))? addslashes( $_POST['user'] ) : '';
14
15$strDomain = addslashes( "$domain" );
16$strPass1 = (isset($_POST['pass1']))? addslashes( $_POST['pass1'] ) : '';
17
18
19//Connect to database using information from above
20$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
21$select = mysql_select_db($mysql_db);
22
23if (!$open || !$select)
24{
25 echo "Unable to open database, contact your administrator!";
26} else {
27 echo "<table width=\"355\" cellpadding=\"0\" cellspacing=\"0\" style=\"background:#F4F4F4;font-size:14px;border:1px solid #892E2E;\"><tr><td valign=\"top\" align=\"center\"><div style=\"border-bottom:1px solid #892E2E;padding:4px;text-align:left;background:#EDEDED;\"><font size=\"+1\">$form_title</font></div><br>";
28
29 if ( isset($_POST['submit']) && $_POST['submit'] == 'create account' )
30 {
31 $domain_res = mysql_query("SELECT * FROM `hm_domains` WHERE `domainname` = '{$strDomain}' LIMIT 1");
32 if (!$domain_res)
33 {
34 die('Error while selecting data: ' . mysql_error());
35 }
36 $domain_info = mysql_fetch_array($domain_res, MYSQL_ASSOC);
37
38////////////////////////////////////////////////////// <-added recaptcha section
39 // reCaptcha validation for reCaptcha form
40 require_once('recaptchalib.php');
41
42$privatekey = "Private";// you need to get a private key from http://recaptcha.net/ signup is free)
43
44$resp = recaptcha_check_answer ($privatekey,
45 $_SERVER["REMOTE_ADDR"],
46 $_POST["recaptcha_challenge_field"],
47 $_POST["recaptcha_response_field"]);
48
49if (!$resp->is_valid) {
50 die ("<table width=\"355\" height=\"285\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\" style=\"font-size:14px;\"><tr><td valign=\"top\" style=\"padding:4px;\">The security words weren't entered correctly. Go back and try it again." .
51 "(reCAPTCHA said: Incorrect Answer!)<br><br><div style=\"font-size:34px;text-align:center;\">Oops!!<br /></div><div style=\"text-align:center;\"><a href=\"javascript:history.go(-1)\" onMouseOver=\"self.status=document.referrer;return true\">Go Back</a></div>
52</td></tr></table>");
53}
54//////////////////////////////////////////////////////////
55
56 //Check to see if email account exists, if not process signup
57 $account_res = mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$strDomain' LIMIT 1");
58 $v1 = mysql_num_rows($account_res);
59
60 If ($v1 >= 1)
61 {
62 echo "A subscriber with this email already exists!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to go back.";
63 return false;
64 } else {
65 if ( !$_POST['pass1'] || !$_POST['pass2'] )
66 {
67 echo "You did not enter both passwords!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to go back.";
68 }
69 elseif ( $_POST['pass1'] != $_POST['pass2'] )
70 {
71 echo "The passwords entered do not match!<br><br>Please <a href=\"javascript:history.go(-1)\">click here</a> to go back.";
72 } else {
73 $domain_id = $domain_info['domainid'];
74 $account_pass = ($encryption == 2)? md5( $strPass1 ) : $strPass1;
75
76 $account_add = mysql_query("INSERT INTO `hm_accounts` (`accountdomainid`,`accountaddress`,`accountpassword`,`accountactive`,`accountisad`,`accountmaxsize`,`accountpwencryption`) VALUES ('$domain_id','$strUser@$strDomain','$account_pass','$admin_default_activate','$accountisad','$account_max','$encryption')");
77
78 }
79 }
80
81 if (!$account_add)
82 {
83 die('<br><br>Database error, unable to add account. Please contact your administrator!<br> ' . mysql_error());
84 }
85
86 If ($admin_default_activate == 0)
87 {
88 echo "Your account has been created but <b>requires activation</b> by administration.";
89 echo "Once your application has been approved, you will receive a confirmation message.<br><br>";
90 } else {
91 echo "<font color=\"red\" size=\"3\"><b>Your account has been created and is ready for use!</b></font><br>";
92 echo "<b>Username</b>:<i> $strUser@$strDomain</i><br>";
93 if ( !empty($serv_webmail_url) ) echo "<b>Webmail URL</b>: <a href=\"$serv_webmail_url\">www.$strDomain/webmail</a><br>";
94
95
96 $subject = "Welcome To $strDomain Email!";
97 $message = "This is confirmation that your account has been created. You may now login to your account and start using it.";
98
99 mail("{$_POST['user']}@$strDomain", "$subject", "$message", "From: $admin_email"); //Send welcome message
100 }
101
102 if ($admin_default_activate == 0 && $admin_notify == 1)
103 {
104 $admin_mail_subject = "Account Requires Activation!";
105 $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";
106 mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email");
107 }
108 elseif ($admin_default_activate == 1 && $admin_notify == 1)
109 {
110 $admin_mail_subject = "New Account Created!";
111 $admin_mail_message = "{$_POST['user']}@$strDomain has been created by {$_POST['name']}!";
112 mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $admin_email");
113 }
114 }
115}
116
117 //Email account signup page
118 echo "
119 <table width=\"355\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\" style=\"font-size:13px;\" valign=\"top\">
120 <form action=\"\" method=\"POST\">
121 <tr><td style=\"padding:4px;width:60px;\">Full Name:</td><td><input type=\"text\" name=\"name\" size=\"18\"></td></tr>
122 <tr><td style=\"padding:4px;width:60px;\">E-Mail:</td><td><input type=\"text\" name=\"user\" size=\"18\"><b> @ ".$domain."</b></td></tr>
123 <tr><td style=\"padding:4px;width:60px;\">Password:</td><td><input type=\"password\" name=\"pass1\" size=\"18\"></td></tr>
124 <tr><td style=\"padding:4px;width:60px;\">Password:</td><td><input type=\"password\" name=\"pass2\" size=\"18\"> (For Confirmation)</td></tr>
125 <tr><td colspan=\"2\" style=\"padding:4px;\">";
126//////////////////////////////////////////////////
127 require_once('recaptchalib.php');
128
129$publickey = "Private"; // Public key needed from http://recaptcha.net/ free signup
130
131echo recaptcha_get_html($publickey);
132
133//////////////////////////////////////////////////
134 echo "
135 </td></tr>
136 <tr><td style=\"width:60px;\"> </td><td align=\"left\"><input type=\"submit\" name=\"submit\" value=\"create account\" style=\"width: auto;\"></td></tr>
137 </form>
138 </table><br /></td></tr></table>";
139?>