3,7 → 3,8 |
/************************************************************************ |
* ALCASAR INSCRIPTION * |
* * |
* By K@M3L & T3RRY LaPlateforme * |
* By K@M3L & T3RRY LaPlateforme |
* By Rexy * |
* * |
* Partie back de la page d'inscription des utilisateurs * |
* Récupère les infos de "email_registration_front.php * |
16,6 → 17,43 |
* * |
*************************************************************************/ |
|
/**************************************************************** |
* GLOBAL FILE PATHS * |
*****************************************************************/ |
define('CONF_FILE', '/usr/local/etc/alcasar.conf'); |
/**************************************************************** |
* Conf files reading test * |
*****************************************************************/ |
$conf_files = array(CONF_FILE); |
foreach ($conf_files as $file) { |
if (!file_exists($file)) { |
exit("Fichier $file non présent"); |
} |
if (!is_readable($file)) { |
exit("Vous n'avez pas les droits de lecture sur le fichier $file"); |
} |
} |
/**************************************************************** |
* Read CONF_FILE * |
*****************************************************************/ |
$file_conf = fopen(CONF_FILE, 'r'); |
if (!$file_conf) { |
exit('Error opening the file '.CONF_FILE); |
} |
while (!feof($file_conf)) { |
$buffer = fgets($file_conf, 4096); |
if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) { |
$tmp = explode('=', $buffer, 2); |
$conf[trim($tmp[0])] = trim($tmp[1]); |
} |
} |
fclose($file_conf); |
$whiteDomain = explode(" ", strtolower(trim($conf['MAIL_WHITEDOMAIN']))); |
$adminMail = $conf['MAIL_ADMIN']; |
|
/**************************************** |
* Choice of language * |
*****************************************/ |
$Language = 'en'; |
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); |
26,11 → 64,27 |
$l_domain = "Le domaine"; |
$l_not_authorized = "n'est pas autorisé"; |
$l_Email_already_used = "Cette adresse email est déjà utilisée."; |
$l_subject = "Activation de votre compte ALCASAR"; |
$l_hello = "Bonjour"; |
$l_automatic_mail = "Ceci est un e-mail automatique provenant d'un portail ALCASAR"; |
$l_login = "Vos indentifiants de connexion :"; |
$l_email = "Adresse e-mail"; |
$l_password = "Mot de passe"; |
$l_go_home = "Rendez-vous sur la page d'accueil"; |
$l_mail_error = "Erreur lors de l'envoi du mail. Renouvelez votre inscription ou contactez votre administrateur."; |
} else { |
$l_invalid_Email = "Invalid Email address"; |
$l_domain = "The domain"; |
$l_not_authorized = "is not authorized"; |
$l_Email_already_used = "This Email address is already used."; |
$l_subject = "Activation of your ALCASAR account"; |
$l_hello = "Hello"; |
$l_automatic_mail = "This is an automatic e-mail from an ALCASAR portal"; |
$l_login = "Your login credentials :"; |
$l_email = "e-mail address"; |
$l_password = "Password"; |
$l_go_home = "Go to the home page"; |
$l_mail_error = "Error while sending the email. Renew your registration or contact your administrator."; |
} |
|
if (is_file("acc/manager/lib/langues.php")) |
91,40 → 145,18 |
return $password; |
} |
|
// Lecture du fichier de configuration, récupération des listes WLD et l'email de l'admin |
$alcasar_Conf_File = "/usr/local/etc/alcasar.conf"; |
if (is_file ($alcasar_Conf_File)){ |
$tab=file($alcasar_Conf_File); |
if ($tab){ |
foreach ($tab as $line){ |
$field=explode("=", $line); |
switch ($field[0]){ |
case 'MAIL_WHITEDOMAIN': |
$whiteDomain = explode(" ", strtolower(trim($field[1]))); |
break; |
case 'MAIL_ADMIN': |
$adminMail = $field[1]; |
break; |
} |
} |
} |
} |
|
if(isset($_POST['Fmail'])){ |
|
extract($_POST); |
|
$Fmail = htmlentities(strtolower(trim($Fmail))); |
|
if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){ |
echo "<b>$l_invalid_Email</b><br />\n"; |
exit(); |
} |
|
// on récupère le nom de domaine du mail@domain.com |
// Retrieve the domainName of the new user |
list($user, $domain) = explode('@', $Fmail); |
|
// on vérifie si le domaine est dans la WLD, sinon on bloque |
// check if the domainName is in the whitelist |
if (!empty($whiteDomain)){ |
if (!in_array($domain, $whiteDomain)){ |
echo "$l_domain $domain $l_not_authorized"; |
131,40 → 163,33 |
exit(); |
} |
} |
|
$login = $Fmail; |
|
// si le login est présent |
// check if the new user already exist |
$link = @da_sql_pconnect($config); |
if ($link) { |
$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';"; |
$res = @da_sql_query($link,$config, $sql); |
} |
$login_check = da_sql_num_rows($res,$config); |
da_sql_close($link,$config); |
|
$login_check = da_sql_num_rows($res,$config); |
|
// da_sql_close($link,$config) |
|
// si le mail est présent |
// check if the new user is already in the profile of an existing user |
$link = @da_sql_pconnect($config); |
if ($link) { |
$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';"; |
$res = @da_sql_query($link,$config, $sql); |
} |
|
$email_check = da_sql_num_rows($res,$config); |
|
// da_sql_close($link,$config) |
|
|
if($login_check > 0) { //Adresse email utilisée en tant que login |
$email_check = da_sql_num_rows($res,$config); |
da_sql_close($link,$config); |
if($login_check > 0) { // user already exist |
echo "<b>$l_Email_already_used</b><br />\n"; |
} else if($email_check > 0) { //Adresse email utilisée dans les infos utilisateur |
} else if($email_check > 0) { // email already used |
echo "<b>$l_Email_already_used</b><br />\n"; |
} else { |
$password = GenPassword(); |
|
// si on ajoute des inputs pour les infos user |
// if we want to enrich the new user profile |
/* $Fcn = "$prenom".".$nom"; |
$Fou = ""; |
$Fhomephone = ""; |
208,12 → 233,12 |
echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n"; |
} |
else |
echo "<b>L'utilisateur existe déjà</b><br />\n"; |
echo "<b>User already exist</b><br />\n"; |
} |
else |
echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n"; |
} |
// si on veut ajouter les nouveau utilisateurs a un groupe par défaut, autre que celui par défaut d'alcasar |
// if the new user must be in a group |
if (isset($Fgroup) && $Fgroup != ''){ |
$Fgroup = da_sql_escape_string($link, $Fgroup); |
$res = da_sql_query($link,$config, |
233,6 → 258,7 |
else |
echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n"; |
} |
/* |
if (!$da_abort){ |
if (isset($Fgroup) && $Fgroup != '') |
require('acc/manager/lib/defaults.php'); |
276,16 → 302,15 |
echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br />\n"; |
} |
} |
// L'utilisateur est ajouter dans la radcheck, ses info dans la userinfo, on envoi le mail avec identifiant et passwd |
|
*/ |
// Creation of the email with the new user login & passwd |
$ip = $_SERVER['REMOTE_ADDR']; |
$time = date_create('now')->format('d-m-Y H:i:s'); |
$domain = $conf["DOMAIN"]; |
$hostname = $conf["HOSTNAME"].'.'.$domain; |
|
$hostname = $conf["HOSTNAME"]; |
$to = $Fmail; |
$from = "alcasar@$domain"; |
$subject = "Activation de votre compte ALCASAR"; |
$from = "administrator"; |
$subject = $l_subject; |
$message = "<!DOCTYPE html> |
<html> |
<head> |
292,33 → 317,28 |
<meta charset=\"UTF-8\" /> |
</head> |
<body> |
Bonjour,<br/><br/> |
<h3>Bienvenue sur ALCASAR @ $domain</h3> |
<p>Ceci est un email automatique avec vos identifiants, veuillez changer votre mot de passe.<br/> |
<h4>Indentifiants de connexion:</h4> |
<pre> |
Adresse e-mail : $Fmail |
Login : $login |
Mot de passe : $password |
</pre> |
<p>Rendez-vous sur le portail <a href=\"https://$hostname\">$domain</a></p> |
$l_hello,<br/><br/> |
<p>$l_automatic_mail ($hostname.$domain)<br/> |
<h4>$l_login</h4> |
<pre> |
$l_email : $Fmail |
Login : $login |
$l_password : $password |
</pre> |
<p>$l_go_home : <a href=\"https://$hostname.$domain\"></a></p> |
</body> |
</html>"; |
|
$header = "From: $from\n"; |
$header .= "MIME-Version: 1.0\n"; |
$header .= "Content-type: text/html; charset=utf-8\n"; |
|
if(mail($to, $subject, $message, $header)){ |
echo "<center>success : <b>Vous y êtes presque ! $l_user '$login' $l_created</b></center><br />"; |
echo "<center>success : <b>Un email contenant vos informations de connexion vient de vous être envoyé.</b></center><br />"; |
|
// le mail pour l'uitilisateur est envoyé, si l'admin a configuré son mail, on lui envoi |
// une notification d'inscription avec l'ip, l'heure, et le login de l'utilisateur |
// Creation of the email for the administrator (if enabled) |
if (!empty($adminMail)){ |
$to = $adminMail; |
$from = "alcasar@$domain"; |
$subject = "Nouvelle inscription sur ALCASAR"; |
$from = "administrator"; |
$subject = "New registration on ALCASAR"; |
$message = "<!DOCTYPE html> |
<html> |
<head> |
325,19 → 345,16 |
<meta charset=\"UTF-8\" /> |
</head> |
<body> |
Bonjour,<br/><br/> |
|
<p>Ceci est un mail automatique.<br/> |
<h3>Une nouvelle inscription à <strong>ALCASR $domain</strong> a été faite.</h3> |
|
<h4>Indentifiants de connexion:</h4> |
<pre> |
Adresse IP : $ip |
Heure : $time; |
Login : $login |
Email : $Fmail |
</pre> |
<p>ALCASAR <a href=\"https://$hostname\">$domain</a></p> |
Hello,<br/><br/> |
<p>This is an automatic e-mail from an ALCASAR portal.<br/> |
<h3>A new registration on <strong>$hostname.$domain</strong> has been made :</h3> |
<pre> |
@IP : $ip |
Hour : $time |
Login : $login |
Email : $Fmail |
</pre> |
<p><a href=\"https://$hostname\">$domain</a></p> |
</body> |
</html>"; |
$header = "From: $from\n"; |
345,27 → 362,22 |
$header .= "Content-type: text/html; charset=utf-8\n"; |
mail($to, $subject, $message, $header); |
} |
|
} else { |
//Le mot de passe est généré aléatoirement, si le mail n'est pas envoyé, on supprime le compte de la bdd ou on lui demande d'utiliser la page reset |
/* $link = da_sql_pconnect($config); |
|
// On smtp error, we remove the new user |
$link = da_sql_pconnect($config); |
$res2 = da_sql_query($link,$config, |
"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';"); |
|
"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';"); |
$res3 = da_sql_query($link,$config, |
"DELETE FROM $config[sql_check_table] WHERE username = '$login';"); |
|
// da_sql_close($link,$config) |
*/ |
echo "<b>Erreur lors de l'envoi du mail, veuillez renouveler votre inscription. Utilisez le formulaire de réinitialisation, ou contactez votre administrateur.</b><br />\n"; |
echo "<b>$l_mail_error</b><br />\n"; |
} |
} |
else // Could not open encryption library file |
echo "<b>Erreur lors de la création du compte</b><br />\n"; |
echo "<b>Error during the account creation process</b><br />\n"; |
} |
else // Could not connect to SQL database |
echo "<b>Erreur lors de la création du compte</b><br />\n"; |
echo "<b>Error during the account creation process</b><br />\n"; |
da_sql_close($link,$config); |
} |
} |
?> |