<?php
error_reporting(E_ALL & ~E_NOTICE);
//MySQL database connection information
//MySQL connection information:
$mysql_host = "localhost"; //Host Name
$mysql_user = "User"; //Username
$mysql_pass = "User4812A"; //Password
$mysql_db = "mailserver"; //Database
//General Configuration:
$account_max = "10000000"; //Maximum size per account (1000000 = 1MB -> Do not uses spaces or commas!)
$admin_notIfy = "1"; //1 = yes & 0 = no
$from_add = "info@openmail.se";
$admin_email = "info@sonexa.se"; //Administrators email to send notifications)
$admin_Default_activate = "1"; //1 = yes & 0 = no -> If no, the administrator has to authorise the account
$accountisad = 0; // account is AD-account? 0 = no (default), 1 = yws;
$encryption = 2; //Password encryption level - 2 means md5;
$domain = 'openmail.se'; // the domain, where the account should be added too
$date = date('Y-m-d H:i:s');
$msg="";
$a="";
$serv_webmail_url = 'http://webmail.openmail.se'; // full URL to the webmail-application
$url = $_SERVER["HTTP_HOST"];
$domain = (empty($domain))? $_SERVER["HTTP_HOST"] : $domain;
$domain = (substr($domain,0,4) == "www.")? strstr($domain, ".") : $domain;
// Protect database entries and use MD5 encryption
$strName = (isset($_POST['name']))? addslashes( $_POST['name'] ) : '';
$strUser = (isset($_POST['user']))? addslashes( $_POST['user'] ) : '';
$strDomain = addslashes( "$domain" );
$strPass1 = (isset($_POST['pass1']))? addslashes( $_POST['pass1'] ) : '';
//Connect to database using information from above
$Conn = mysqli_connect("$mysql_host", "$mysql_user", "$mysql_pass", "$mysql_db");
if (!$Conn)
{
echo $a;
print_r(error_get_last());
$msg = "Unable to open database, contact your administrator!";
} else {
if ( isset($_POST['submit']) && $_POST['submit'] == 'create account' )
{
//Check to see if email account exists, if not process signup
$account_res = mysqli_query($Conn, "SELECT * FROM `hm_accounts` WHERE `accountaddress` = '{$strUser}@$strDomain' LIMIT 1");
$v1 = mysql_num_rows($account_res);
If ($v1 >= 1)
{
// Account exists
$msg = "En abonnent med det användarnamnet finns redan!<br><br>Vänligen <a href=\"javascript:history.go(-1)\">klicka här </a> för att gå tillbaka.";
return false;
} else {
if ( !$_POST['pass1'] || !$_POST['pass2'] )
{
// User did not enter both passwords
$msg = "Du angav inte bägge lösenorden!<br><br>Vänligen <a href=\"javascript:history.go(-1)\">klicka här</a> för att gå tillbaka.";
}
elseif ( $_POST['pass1'] != $_POST['pass2'] )
{
// Passwords do not match
$msg = "Lösenorden som du angav matchar inte!<br><br>Vänligen <a href=\"javascript:history.go(-1)\">klicka här</a> för att gå tillbaka.";
} else {
$domain_id = $domain_info['domainid'];
$account_pass = ($encryption == 2)? md5( $strPass1 ) : $strPass1;
// Everything seems ok, insert values into database
$account_add = mysqli_query($Conn, "INSERT INTO `hm_accounts` (`accountdomainid`,`accountadminlevel`,`accountaddress`,`accountpassword`,`accountactive`,`accountlastlogontime`,`accountvacationexpiredate`,`accountmaxsize`,`accountpwencryption`)
VALUES ('$domain_id','0','$strUser@$strDomain','$account_pass','1','$date','$date','$account_max','$encryption')");
// Get the accountid from that last input
$rt = mysqli_query($Conn, "SELECT MAX(accountid) FROM hm_accounts");
$row = mysql_fetch_row($rt);
// Create folder INBOX in DB
$account_add = mysqli_query($Conn, "INSERT INTO `hm_imapfolders` (`folderaccountid`,`folderparentid`,`foldername`,`folderissubscribed`,`foldercreationtime`,`foldercurrentuid`)
VALUES ('$row[0]','-1','INBOX','1','$date','0')");
// Create folder TRASH in DB
$account_add = mysqli_query($Conn, "INSERT INTO `hm_imapfolders` (`folderaccountid`,`folderparentid`,`foldername`,`folderissubscribed`,`foldercreationtime`,`foldercurrentuid`)
VALUES ('$row[0]','-1','Trash','1','$date','0')");
// Create folder SENT in DB
$account_add = mysqli_query($Conn, "INSERT INTO `hm_imapfolders` (`folderaccountid`,`folderparentid`,`foldername`,`folderissubscribed`,`foldercreationtime`,`foldercurrentuid`)
VALUES ('$row[0]','-1','Sent','1','$date','0')");
// Create folder DRAFTS in DB
$account_add = mysqli_query($Conn, "INSERT INTO `hm_imapfolders` (`folderaccountid`,`folderparentid`,`foldername`,`folderissubscribed`,`foldercreationtime`,`foldercurrentuid`)
VALUES ('$row[0]','-1','Drafts','1','$date','0')");
}
}
if (!$account_add)
{
// Database error, could not create account
die('<br><br>Databasfel, kunde inte lägga till konto. Vänligen kontakta en administratör!<br> ' . mysqli_error($Conn));
}
If ($admin_Default_activate == 0)
{
// Account created but requires verification
$message = "Ditt konto har skapats men <b>kräver aktivering</b> av en administratör.";
$message .= "Så fort ditt konto har blivit godkänt, kommer du att få ett meddelande om detta.<br><br>";
} else {
// Account created, sending all account info to user
$subject = "Välkommen till $strDomain !";
$message = "Tack! Din nya e-postadress är nu registrerad hos oss.<br><br>Du är välkommen att logga in via http://webmail.openmail.se eller<br>med hjälp av nedanstående kontouppgifter.<br><br>";
$message .= "E-postadress: $strUser@$strDomain<br><br>";
$message .= "POP3: mail.openmail.se<br>";
$message .= "IMAP: mail.openmail.se<br>";
$message .= "SMTP: mail.openmail.se<br><br>";
$message .= "Frågor gällande ditt e-postkontot besvaras enklast av<br>vår supportavdelning som du når på support@openmail.se.<br><br>Välkommen till oss...<br><br>";
$message .= "OpenMail is powered by Sonexa IT<br>info@sonexa.se | http://www.sonexa.se";
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=UTF-8 \r\n";
$headers .= "From: $from_add \r\n";
$headers .= "Reply-To: $from_add \r\n";
$headers .= "Return-Path: $from_add\r\n";
$headers .= "X-Mailer: PHP \r\n";
//Check if email is sent to user
if(mail("{$_POST['user']}@$strDomain", "$subject", "$message", "$headers", "From: $from_add"))
{
//Success
$msg ="Registreringen lyckades - 1";
}
else
{
//Fail
$msg ="Registreringen misslyckades - 1!";
}
}
//Notify admin about new email and request activation
if ($admin_Default_activate == 0 && $admin_notIfy == 1)
{
$admin_mail_subject = "E-postkonto kräver aktivering!";
$admin_mail_message = "E-postkontot {$_POST['user']}@$strDomain har skapats av {$_POST['name']} och kräver aktivering av en administratör!\r\n\r\nVänligen logga in på kontrollpanelen för att verifiera och aktivera e-postkontot.\r\n\r\n";
//Check if email activation notice is sent to admin
if(mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $from_add"))
{
//Success
$msg ="Registreringen lyckades - 2";
}
else
{
//Fail
$msg ="Registreringen misslyckades - 2!";
}
}
//Notify admin about new email
elseif ($admin_Default_activate == 1 && $admin_notIfy == 1)
{
$admin_mail_subject = "Nytt e-postkonto skapat!";
$admin_mail_message = "{$_POST['user']}@$strDomain har skapats av {$_POST['name']}!";
//Check if email notification is sent to admin
if(mail($admin_email, "$admin_mail_subject", "$admin_mail_message", "From: $from_add"))
{
//Success
$msg ="Registreringen lyckades - 3";
}
else
{
//Fail
$msg ="Registreringen misslyckades - 3!";
}
}
}
}
//Email account signup page
echo "
<table width=\"350\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">
<form action=\"\" method=\"POST\">
<tr><td>Full Name:</td><td><input type=\"text\" name=\"name\" size=\"21\">".$msg."</td></tr>
<tr><td>E-Mail:</td><td><input type=\"text\" name=\"user\" size=\"21\"> @ ".$domain."</td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"pass1\" size=\"21\"></td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"pass2\" size=\"21\"> (For Confirmation)</td></tr>
<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"create account\" style=\"width: 98%\"></td></tr>
</form>
</table>";
?>
Warning: Undefined array key "HTTP_HOST" in /in/XoRWP on line 25
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/XoRWP:37
Stack trace:
#0 {main}
thrown in /in/XoRWP on line 37
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Warning: Undefined array key "HTTP_HOST" in /in/XoRWP on line 25
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/XoRWP:37
Stack trace:
#0 {main}
thrown in /in/XoRWP on line 37
Process exited with code 255.
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /in/XoRWP:37
Stack trace:
#0 {main}
thrown in /in/XoRWP on line 37
Process exited with code 255.