Thanks to pccsq1 for his work in upgrading it to work for 4.3 and the original author whoever they might be
There is another script that has been re-written here. Take your pick
Code: Select all
<?php
//MySQL Information:
$mysql_host = "localhost"; //Host Name
$mysql_user = ""; //Username
$mysql_pass = ""; //Password
$mysql_db = "hmailserver"; //Database
//General Configuration:
$form_title = "signup"; //Name for this form
$account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)
$admin_notify = 1; //1 = yes & 0 = no
$admin_email = ""; //Administrators email to send notifications)
$admin_default_activate = 1; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$encryption = 2; //Password encryption level
//DO NOT EDIT BELOW!//
// Protect the Database and MD5 the password.
$strName = addslashes( $_POST['name'] );
$strUser = addslashes( $_POST['user'] );
$strDomain = addslashes( $_POST['domain'] );
$strPass1 = addslashes( $_POST['pass1'] );
$strMD5Pass = md5( $strPass1 );
error_reporting(E_ALL ^ E_NOTICE);
//Next two lines connect to database using information from above.
$open = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$select = mysql_select_db($mysql_db);
IF (!$open || !$select)
{
echo "Unable to open database, contact your administrator!";
}
ELSE
{
echo "<font size=\"+2\">$form_title</font><br><br>"; //Display form title from above
//Decide On What Path To Take
SWITCH ($_GET['mode'])
{
CASE "do":
//#### PAGE IF FORM FILLED OUT ####//
$q=mysql_query("SELECT * FROM `hm_domains` WHERE `domainid` = '{$strDomain}' LIMIT 1"); //Load Domain Into memory (internal use)
WHILE ($v=mysql_fetch_array($q))
{
$temp_domain = $v['1'];
} //Apply information
$q2=mysql_query("SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$temp_domain' LIMIT 1"); //Check if account exists
$v2=mysql_num_rows($q2); //Gets number of accounts that exist with that profile (should be less than or equal to one)
IF ($v2 == 1)
{
echo "A user with this username already exists! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
IF (!$_POST['pass1'] || !$_POST['pass2'])
{
echo "You did not enter both passwords! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSEIF ($_POST['pass1'] <> $_POST['pass2'])
{
echo "Your passwords do not match! <a href=\"javascript:history.go(-1)\">Go Back</a>";
}
ELSE
{
$q3=mysql_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());
}
}
IF ($q3)
{
IF ($admin_default_activate == 0)
{
echo "Your account has been created <b>however requires administrator activation.</b> You should receive a message soon regarding this.";
}
ELSE
{
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";
$subject = "Welcome To MYWEBSITE!";
$message = "This is confirmation that your account has been created.";
mail("{$_POST['user']}@$temp_domain", $subject, $message); //Send welcome message
}
}
ELSE
{
echo "Database error, unable to add account. Please contact your administrator!";
}
IF ($admin_default_activate == 0 && $admin_notify == 0)
{
$admin_mail_subject = "Account Requires Activation!";
$admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']} and needs to be activated!";
mail($admin_email, $admin_mail_subject, $admin_mail_message);
}
ELSEIF ($admin_default_activate == 1 && $admin_notify == 1)
{
$admin_mail_subject = "New Account Created!";
$admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
mail($admin_email, $admin_mail_subject, $admin_mail_message);
}
ELSEIF ($admin_default_activate == 0 && $admin_notify == 1)
{
$admin_mail_subject = "New Account Created!";
$admin_mail_message = "{$_POST['user']}@$temp_domain has been created by {$_POST['name']}!";
mail($admin_email, $admin_mail_subject, $admin_mail_message);
}
break;
DEFAULT:
}
}
//#### MAIN PAGE IF FORM NOT FILLED OUT ####//
echo "
<form action=\"?mode=do\" method=\"POST\">
Your Name: <input type=\"text\" name=\"name\" size=\"21\"><br>
E-Mail: <input type=\"text\" name=\"user\" size=\"21\"> @ <select name=\"domain\">
";
$q2=mysql_query("SELECT * FROM `hm_domains` WHERE `domainactive` = '1' ORDER BY `domainname` DESC"); //Load avaliable domains into memory
WHILE ($v2=mysql_fetch_array($q2)) //Display avaliable domains
{
echo "<option value=\"{$v2['0']}\">{$v2['1']}</option>";
}
echo "
</select><br>
Password: <input type=\"password\" name=\"pass1\" size=\"21\"><br>
Password: <input type=\"password\" name=\"pass2\" size=\"21\"> (For Confirmation)<br><br>
<input type=\"submit\" value=\"Create Account\">
</form>
";
?>
Cheers