Subversion Repositories ALCASAR

Rev

Rev 3070 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 3070 Rev 3173
1
<?php 
1
<?php 
2
 
2
 
3
/************************************************************************
3
/************************************************************************
4
*						ALCASAR INSCRIPTION								*
4
*						ALCASAR INSCRIPTION								*
5
*																		*
5
*																		*
6
*	By K@M3L & T3RRY LaPlateforme
6
*	By K@M3L & T3RRY LaPlateforme
7
*	By Rexy																*
7
*	By Rexy																*
8
*																		*
8
*																		*
9
*	Partie back de la page d'inscription des utilisateurs				*
9
*	Partie back de la page d'inscription des utilisateurs				*
10
*	Récupère les infos de "email_registration_front.php					*
10
*	Récupère les infos de "email_registration_front.php					*
11
*	- Lit le fichier de configuration /usr/local/etc/alcasar.conf		*
11
*	- Lit le fichier de configuration /usr/local/etc/alcasar.conf		*
12
*	- Verifie si le login est déjà présent dans la table "radcheck"		*
12
*	- Verifie si le login est déjà présent dans la table "radcheck"		*
13
*	- Vérifie si l'@ mail est présent dans la table "userinfo"			*
13
*	- Vérifie si l'@ mail est présent dans la table "userinfo"			*
14
*	- Vérifie que le domaine du mail est bien WLD (optionnel)			*
14
*	- Vérifie que le domaine du mail est bien WLD (optionnel)			*
15
*	- Crée l'utilisateur avec un mot de passe aléatoire					*
15
*	- Crée l'utilisateur avec un mot de passe aléatoire					*
16
*	- Envoi l'email à l'utilisaeur et à l'admin avec date et IP			*
16
*	- Envoi l'email à l'utilisaeur et à l'admin avec date et IP			*
17
*																		*
17
*																		*
18
*************************************************************************/
18
*************************************************************************/
19
 
19
 
20
/****************************************************************
20
/****************************************************************
21
*			GLOBAL FILE PATHS			*
21
*			GLOBAL FILE PATHS			*
22
*****************************************************************/
22
*****************************************************************/
23
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
23
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
24
/****************************************************************
24
/****************************************************************
25
*			Conf files reading test			*
25
*			Conf files reading test			*
26
*****************************************************************/
26
*****************************************************************/
27
$conf_files = array(CONF_FILE);
27
$conf_files = array(CONF_FILE);
28
foreach ($conf_files as $file) {
28
foreach ($conf_files as $file) {
29
	if (!file_exists($file)) {
29
	if (!file_exists($file)) {
30
		exit("Fichier $file non présent");
30
		exit("Fichier $file non présent");
31
	}
31
	}
32
	if (!is_readable($file)) {
32
	if (!is_readable($file)) {
33
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
33
		exit("Vous n'avez pas les droits de lecture sur le fichier $file");
34
	}
34
	}
35
}
35
}
36
/****************************************************************
36
/****************************************************************
37
*			Read CONF_FILE				*
37
*			Read CONF_FILE				*
38
*****************************************************************/
38
*****************************************************************/
39
$file_conf = fopen(CONF_FILE, 'r');
39
$file_conf = fopen(CONF_FILE, 'r');
40
if (!$file_conf) {
40
if (!$file_conf) {
41
	exit('Error opening the file '.CONF_FILE);
41
	exit('Error opening the file '.CONF_FILE);
42
}
42
}
43
while (!feof($file_conf)) {
43
while (!feof($file_conf)) {
44
	$buffer = fgets($file_conf, 4096);
44
	$buffer = fgets($file_conf, 4096);
45
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
45
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
46
		$tmp = explode('=', $buffer, 2);
46
		$tmp = explode('=', $buffer, 2);
47
		$conf[trim($tmp[0])] = trim($tmp[1]);
47
		$conf[trim($tmp[0])] = trim($tmp[1]);
48
	}
48
	}
49
}
49
}
50
fclose($file_conf);
50
fclose($file_conf);
51
$whiteDomain	= explode(" ", strtolower(trim($conf['MAIL_WHITEDOMAIN'])));
51
$whiteDomain	= explode(" ", strtolower(trim($conf['MAIL_WHITEDOMAIN'])));
52
$adminMail		= $conf['MAIL_ADMIN'];
52
$adminMail		= $conf['MAIL_ADMIN'];
53
$typeMail		= $conf['MAIL_TYPE'];
53
$typeMail		= $conf['MAIL_TYPE'];
54
$fromMail		= $conf['MAIL_ADDR'];
54
$fromMail		= $conf['MAIL_ADDR'];
55
$organism		= $conf['ORGANISM'];
55
$organism		= $conf['ORGANISM'];
56
 
56
 
57
/****************************************
57
/****************************************
58
*			Choice of language			*
58
*			Choice of language			*
59
*****************************************/
59
*****************************************/
60
$Language = 'en';
60
$Language = 'en';
61
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
61
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
62
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
62
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
63
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
63
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
64
}
64
}
65
if ($Language === 'fr') {
65
if ($Language === 'fr') {
66
	$l_invalid_Email = "L'adresse e-mail est invalide";
66
	$l_invalid_Email = "L'adresse e-mail est invalide";
67
	$l_domain = "Le domaine";
67
	$l_domain = "Le domaine";
68
	$l_not_authorized = "n'est pas autorisé";
68
	$l_not_authorized = "n'est pas autorisé";
69
	$l_Email_already_used = "Cette adresse e-mail est déjà utilisée.";
69
	$l_Email_already_used = "Cette adresse e-mail est déjà utilisée.";
70
	$l_subject = "Activation de votre compte ALCASAR";
70
	$l_subject = "Activation de votre compte ALCASAR";
71
	$l_hello = "Bonjour";
71
	$l_hello = "Bonjour";
72
	$l_automatic_mail = "Ceci est un e-mail automatique provenant du portail ALCASAR : $organism";
72
	$l_automatic_mail = "Ceci est un e-mail automatique provenant du portail ALCASAR : $organism";
73
	$l_login = "Voici vos indentifiants de connexion :";
73
	$l_login = "Voici vos indentifiants de connexion :";
74
	$l_password = "Mot de passe";
74
	$l_password = "Mot de passe";
75
	$l_mail_success = "Un mot de passe vient d'être envoyé à votre adresse e-mail.";
75
	$l_mail_success = "Un mot de passe vient d'être envoyé à votre adresse e-mail.";
76
	$l_mail_error = "Erreur lors de l'envoi du mail. Renouvelez votre inscription ou contactez votre administrateur.";
76
	$l_mail_error = "Erreur lors de l'envoi du mail. Renouvelez votre inscription ou contactez votre administrateur.";
77
} else if ($Language === 'es') {
77
} else if ($Language === 'es') {
78
	$l_invalid_Email = "Dirección de correo electrónico no válida";
78
	$l_invalid_Email = "Dirección de correo electrónico no válida";
79
	$l_domain = "El dominio";
79
	$l_domain = "El dominio";
80
	$l_not_authorized = "no está autorizado";
80
	$l_not_authorized = "no está autorizado";
81
	$l_Email_already_used = "Esta dirección de correo electrónico ya está utilizada.";
81
	$l_Email_already_used = "Esta dirección de correo electrónico ya está utilizada.";
82
	$l_subject = "Activación de su cuenta ALCASAR";
82
	$l_subject = "Activación de su cuenta ALCASAR";
83
	$l_hello = "Hola";
83
	$l_hello = "Hola";
84
	$l_automatic_mail = "Este es un correo electrónico automático del portal ALCASAR : $organism";
84
	$l_automatic_mail = "Este es un correo electrónico automático del portal ALCASAR : $organism";
85
	$l_login = "Estas son sus credenciales de acceso:";
85
	$l_login = "Estas son sus credenciales de acceso:";
86
	$l_password = "Contraseña";
86
	$l_password = "Contraseña";
87
	$l_mail_success = "Se ha enviado una contraseña a su dirección de correo electrónico.";
87
	$l_mail_success = "Se ha enviado una contraseña a su dirección de correo electrónico.";
88
	$l_mail_error = "Error al enviar el correo electrónico. Renueve su registro o póngase en contacto con su administrador.";
88
	$l_mail_error = "Error al enviar el correo electrónico. Renueve su registro o póngase en contacto con su administrador.";
89
} else {
89
} else {
90
	$l_invalid_Email = "Invalid Email address";
90
	$l_invalid_Email = "Invalid Email address";
91
	$l_domain = "The domain";
91
	$l_domain = "The domain";
92
	$l_not_authorized = "is not authorized";
92
	$l_not_authorized = "is not authorized";
93
	$l_Email_already_used = "This Email address is already used.";
93
	$l_Email_already_used = "This Email address is already used.";
94
	$l_subject = "Activation of your ALCASAR account";
94
	$l_subject = "Activation of your ALCASAR account";
95
	$l_hello = "Hello";
95
	$l_hello = "Hello";
96
	$l_automatic_mail = "This is an automatic e-mail from ALCASAR portal : $organism";
96
	$l_automatic_mail = "This is an automatic e-mail from ALCASAR portal : $organism";
97
	$l_login = "Here are your login credentials :";
97
	$l_login = "Here are your login credentials :";
98
	$l_password = "Password";
98
	$l_password = "Password";
99
	$l_mail_success = "A password has been sent to your e-mail address";
99
	$l_mail_success = "A password has been sent to your e-mail address";
100
	$l_mail_error = "Error while sending the email. Renew your registration or contact your administrator.";
100
	$l_mail_error = "Error while sending the email. Renew your registration or contact your administrator.";
101
}
101
}
102
 
102
 
103
if(!isset($create)) $create=0;
103
if(!isset($create)) $create=0;
104
if(!isset($show)) $show=0;
104
if(!isset($show)) $show=0;
105
if(!isset($login)) $login = '';
105
if(!isset($login)) $login = '';
106
if(!isset($cn)) $cn = '';
106
if(!isset($cn)) $cn = '';
107
if(!isset($mail)) $mail = '';
107
if(!isset($mail)) $mail = '';
108
if(!isset($langue_imp)) $langue_imp = '';
108
if(!isset($langue_imp)) $langue_imp = '';
109
if(!isset($selected)) $selected = array();
109
if(!isset($selected)) $selected = array();
110
if(!isset($selected['='])) $selected['='] = '';
110
if(!isset($selected['='])) $selected['='] = '';
111
 
111
 
112
require('/etc/freeradius-web/config.php');
112
require('/etc/freeradius-web/config.php');
113
require('acc/manager/lib/attrshow.php');
113
require('acc/manager/lib/attrshow.php');
114
require('acc/manager/lib/defaults.php');
114
require('acc/manager/lib/defaults.php');
115
 
115
 
116
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
116
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
117
	$colspan = 2;
117
	$colspan = 2;
118
	$show_ops = 1;
118
	$show_ops = 1;
119
	require('acc/manager/lib/operators.php');
119
	require('acc/manager/lib/operators.php');
120
} else {
120
} else {
121
	$show_ops = 0;
121
	$show_ops = 0;
122
	$colspan = 1;
122
	$colspan = 1;
123
}
123
}
124
 
124
 
125
if (is_file("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php"))
125
if (is_file("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php"))
126
	require("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php");
126
	require("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php");
127
else{
127
else{
128
	echo "<b>Could not include SQL library</b><br />\n";
128
	echo "<b>Could not include SQL library</b><br />\n";
129
	exit();
129
	exit();
130
}
130
}
131
 
131
 
132
require('acc/manager/lib/functions.php');
132
require('acc/manager/lib/functions.php');
133
if ($config['sql_use_operators'] == 'true'){
133
if ($config['sql_use_operators'] == 'true'){
134
	include_once("acc/manager/lib/operators.php");
134
	include_once("acc/manager/lib/operators.php");
135
	$text = ',op';
135
	$text = ',op';
136
	$passwd_op = ",':='";
136
	$passwd_op = ",':='";
137
}
137
}
138
 
138
 
139
$da_abort=0;
139
$da_abort=0;
140
$op_val2 = '';
140
$op_val2 = '';
141
 
141
 
142
function GenPassword($nb_car="8")
142
function GenPassword($nb_car="8")
143
{
143
{
144
// Random password
144
// Random password
145
	$password = "";
145
	$password = "";
146
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
146
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
147
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
147
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
148
	while($nb_car != 0) {
148
	while($nb_car != 0) {
149
		//$i = rand(0,71);
149
		//$i = rand(0,71);
150
		// Bug corrigé
150
		// Bug corrigé
151
		$i = rand(0,66);
151
		$i = rand(0,66);
152
		$password .= $chaine[$i];
152
		$password .= $chaine[$i];
153
		$nb_car--;
153
		$nb_car--;
154
	}
154
	}
155
	return $password;
155
	return $password;
156
}
156
}
157
 
157
 
158
if(isset($_POST['Fmail'])){
158
if(isset($_POST['Fmail'])){
159
	extract($_POST);
159
	$Fmail = $_POST[‘Fmail’];
160
	$Fmail = htmlentities(strtolower(trim($Fmail)));
160
	$Fmail = htmlentities(strtolower(trim($Fmail)));
161
	if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){  
161
	if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){  
162
		echo "<b>$l_invalid_Email</b><br />\n";
162
		echo "<b>$l_invalid_Email</b><br />\n";
163
		exit();
163
		exit();
164
	}
164
	}
165
	
165
	
166
	// Retrieve the domainName of the new user
166
	// Retrieve the domainName of the new user
167
	list($user, $domain) = explode('@', $Fmail);
167
	list($user, $domain) = explode('@', $Fmail);
168
 
168
 
169
	// check if the domainName is in the whitelist
169
	// check if the domainName is in the whitelist
170
	if (!empty($whiteDomain)){
170
	if (!empty($whiteDomain)){
171
		if (!in_array($domain, $whiteDomain)){
171
		if (!in_array($domain, $whiteDomain)){
172
			echo "$l_domain $domain $l_not_authorized";
172
			echo "$l_domain $domain $l_not_authorized";
173
			exit();
173
			exit();
174
		}
174
		}
175
	}
175
	}
176
	$login  = $Fmail;
176
	$login  = $Fmail;
177
	
177
	
178
	// check if the new user already exist
178
	// check if the new user already exist
179
	$link = @da_sql_pconnect($config);
179
	$link = @da_sql_pconnect($config);
180
	if ($link) {
180
	if ($link) {
181
		$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';";
181
		$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';";
182
		$res = @da_sql_query($link,$config, $sql);
182
		$res = @da_sql_query($link,$config, $sql);
183
	}
183
	}
184
	$login_check = da_sql_num_rows($res,$config);
184
	$login_check = da_sql_num_rows($res,$config);
185
	da_sql_close($link,$config);
185
	da_sql_close($link,$config);
186
	
186
	
187
	// check if the new user is already in the profile of an existing user 
187
	// check if the new user is already in the profile of an existing user 
188
	$link = @da_sql_pconnect($config);
188
	$link = @da_sql_pconnect($config);
189
	if ($link) {
189
	if ($link) {
190
		$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';";
190
		$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';";
191
		$res = @da_sql_query($link,$config, $sql);
191
		$res = @da_sql_query($link,$config, $sql);
192
	}
192
	}
193
	$email_check = da_sql_num_rows($res,$config);
193
	$email_check = da_sql_num_rows($res,$config);
194
	da_sql_close($link,$config);
194
	da_sql_close($link,$config);
195
	if($login_check > 0) { // user already exist
195
	if($login_check > 0) { // user already exist
196
		echo "<b>$l_Email_already_used</b><br />\n";
196
		echo "<b>$l_Email_already_used</b><br />\n";
197
	} else if($email_check > 0) { // email already used
197
	} else if($email_check > 0) { // email already used
198
		echo "<b>$l_Email_already_used</b><br />\n";
198
		echo "<b>$l_Email_already_used</b><br />\n";
199
	} else {
199
	} else {
200
		$password = GenPassword();
200
		$password = GenPassword();
201
		
201
		
202
		// if we want to enrich the new user profile
202
		// if we want to enrich the new user profile
203
/*		$Fcn = "$prenom".".$nom";
203
/*		$Fcn = "$prenom".".$nom";
204
		$Fou = "";
204
		$Fou = "";
205
		$Fhomephone = "";
205
		$Fhomephone = "";
206
		$Ftelephonenumber = "";
206
		$Ftelephonenumber = "";
207
		$Fmobile = "";
207
		$Fmobile = "";
208
*/
208
*/
209
		$link = da_sql_pconnect($config);
209
		$link = da_sql_pconnect($config);
210
		if ($link){
210
		if ($link){
211
			mysqli_set_charset($link,"utf8");
211
			mysqli_set_charset($link,"utf8");
212
			if (is_file("acc/manager/lib/crypt/$config[general_encryption_method].php")){
212
			if (is_file("acc/manager/lib/crypt/$config[general_encryption_method].php")){
213
				include_once("acc/manager/lib/crypt/$config[general_encryption_method].php");
213
				include_once("acc/manager/lib/crypt/$config[general_encryption_method].php");
214
 
214
 
215
				$passwd = da_encrypt($password);
215
				$passwd = da_encrypt($password);
216
				$passwd = da_sql_escape_string($link, $passwd);
216
				$passwd = da_sql_escape_string($link, $passwd);
217
				$res = da_sql_query($link,$config,
217
				$res = da_sql_query($link,$config,
218
				"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
218
				"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
219
				VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
219
				VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
220
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
220
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
221
					echo "<b>Erreur lors de la création de l'utilisateur $login: " . da_sql_error($link,$config) . "</b><br />\n";
221
					echo "<b>Erreur lors de la création de l'utilisateur $login: " . da_sql_error($link,$config) . "</b><br />\n";
222
					$da_abort=1;
222
					$da_abort=1;
223
				}
223
				}
224
 
224
 
225
				if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
225
				if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
226
					$res = da_sql_query($link,$config,
226
					$res = da_sql_query($link,$config,
227
					"SELECT username FROM $config[sql_user_info_table] WHERE
227
					"SELECT username FROM $config[sql_user_info_table] WHERE
228
					username = '$login';");
228
					username = '$login';");
229
					if ($res){
229
					if ($res){
230
						if (!da_sql_num_rows($res,$config)){
230
						if (!da_sql_num_rows($res,$config)){
231
							$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
231
							$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
232
							$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
232
							$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
233
							$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
233
							$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
234
							$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
234
							$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
235
							$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
235
							$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
236
							$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
236
							$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
237
							$res = da_sql_query($link,$config,
237
							$res = da_sql_query($link,$config,
238
							"INSERT INTO $config[sql_user_info_table]
238
							"INSERT INTO $config[sql_user_info_table]
239
							(username,name,mail,department,homephone,workphone,mobile) VALUES
239
							(username,name,mail,department,homephone,workphone,mobile) VALUES
240
							('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
240
							('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
241
							if (!$res || !da_sql_affected_rows($link,$res,$config))
241
							if (!$res || !da_sql_affected_rows($link,$res,$config))
242
								// Erreur sql à supprimer : l'info ne devrait pas être communiquer au client.
242
								// Erreur sql à supprimer : l'info ne devrait pas être communiquer au client.
243
								echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
243
								echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
244
						}
244
						}
245
						else
245
						else
246
							echo "<b>User already exist</b><br />\n";
246
							echo "<b>User already exist</b><br />\n";
247
					}
247
					}
248
					else
248
					else
249
						echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
249
						echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
250
				}
250
				}
251
				// if the new user must be in a group
251
				// if the new user must be in a group
252
				if (isset($Fgroup) && $Fgroup != ''){
252
				if (isset($Fgroup) && $Fgroup != ''){
253
					$Fgroup = da_sql_escape_string($link, $Fgroup);
253
					$Fgroup = da_sql_escape_string($link, $Fgroup);
254
					$res = da_sql_query($link,$config,
254
					$res = da_sql_query($link,$config,
255
					"SELECT username FROM $config[sql_usergroup_table]
255
					"SELECT username FROM $config[sql_usergroup_table]
256
					WHERE username = '$login' AND groupname = '$Fgroup';");
256
					WHERE username = '$login' AND groupname = '$Fgroup';");
257
					if ($res){
257
					if ($res){
258
						if (!da_sql_num_rows($res,$config)){
258
						if (!da_sql_num_rows($res,$config)){
259
							$res = da_sql_query($link,$config,
259
							$res = da_sql_query($link,$config,
260
							"INSERT INTO $config[sql_usergroup_table]
260
							"INSERT INTO $config[sql_usergroup_table]
261
							(username,groupname) VALUES ('$login','$Fgroup');");
261
							(username,groupname) VALUES ('$login','$Fgroup');");
262
							if (!$res || !da_sql_affected_rows($link,$res,$config))
262
							if (!$res || !da_sql_affected_rows($link,$res,$config))
263
								echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup.</b><br />\n";
263
								echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup.</b><br />\n";
264
						}
264
						}
265
						else
265
						else
266
							echo "<b>L'utilisateur est déjà présent dans le groupe $Fgroup</b><br />\n";
266
							echo "<b>L'utilisateur est déjà présent dans le groupe $Fgroup</b><br />\n";
267
					}
267
					}
268
					else
268
					else
269
						echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n";
269
						echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n";
270
				}
270
				}
271
				// Creation of the email with the new user login & passwd
271
				// Creation of the email with the new user login & passwd
272
				$ip = $_SERVER['REMOTE_ADDR'];
272
				$ip = $_SERVER['REMOTE_ADDR'];
273
				$time = date_create('now')->format('d-m-Y H:i:s');
273
				$time = date_create('now')->format('d-m-Y H:i:s');
274
				$domain = $conf["DOMAIN"];
274
				$domain = $conf["DOMAIN"];
275
				$hostname  = $conf["HOSTNAME"];
275
				$hostname  = $conf["HOSTNAME"];
276
				$to = $Fmail;
276
				$to = $Fmail;
277
				if ($typeMail == "3") { // using an existing @mail
277
				if ($typeMail == "3") { // using an existing @mail
278
					$from = $fromMail; }
278
					$from = $fromMail; }
279
				else {
279
				else {
280
					$from = "administrator";
280
					$from = "administrator";
281
				}
281
				}
282
				$subject = $l_subject;
282
				$subject = $l_subject;
283
				$message = "<!DOCTYPE html>
283
				$message = "<!DOCTYPE html>
284
<html>
284
<html>
285
	<head>
285
	<head>
286
		<meta charset=\"utf-8\">
286
		<meta charset=\"utf-8\">
287
	</head>
287
	</head>
288
		<body>
288
		<body>
289
			$l_hello,<br/>
289
			$l_hello,<br/>
290
			<p>$l_automatic_mail<br/>
290
			<p>$l_automatic_mail<br/>
291
			<h3>$l_login</h3>
291
			<h3>$l_login</h3>
292
			<pre>
292
			<pre>
293
				Login : $login
293
				Login : $login
294
				$l_password : $password
294
				$l_password : $password
295
			</pre>
295
			</pre>
296
		</body>
296
		</body>
297
</html>";
297
</html>";
298
				$header = "From: $from\n";
298
				$header = "From: $from\n";
299
				$header .= "MIME-Version: 1.0\n";
299
				$header .= "MIME-Version: 1.0\n";
300
				$header .= "Content-type: text/html; charset=utf-8\n";
300
				$header .= "Content-type: text/html; charset=utf-8\n";
301
				if(mail($to, $subject, $message, $header)){
301
				if(mail($to, $subject, $message, $header)){
302
					echo "<center>success : <b>$l_mail_success</b><br>";
302
					echo "<center>success : <b>$l_mail_success</b><br>";
303
					if (!empty($adminMail)){ // Creation of the email for the administrator (if enabled)
303
					if (!empty($adminMail)){ // Creation of the email for the administrator (if enabled)
304
						$to = $adminMail;
304
						$to = $adminMail;
305
						$subject = "New registration on ALCASAR";
305
						$subject = "New registration on ALCASAR";
306
						$message = "<!DOCTYPE html>
306
						$message = "<!DOCTYPE html>
307
<html>
307
<html>
308
	<head>
308
	<head>
309
		<meta charset=\"utf-8\">
309
		<meta charset=\"utf-8\">
310
	</head>
310
	</head>
311
	<body>
311
	<body>
312
		Hello,<br>
312
		Hello,<br>
313
		<p>$l_automatic_mail<br>
313
		<p>$l_automatic_mail<br>
314
		<h3>A new registration on ALCASAR '$organism' has been made :</h3>
314
		<h3>A new registration on ALCASAR '$organism' has been made :</h3>
315
		<pre>
315
		<pre>
316
			@IP   : $ip
316
			@IP   : $ip
317
			Hour  : $time
317
			Hour  : $time
318
			Login : $login
318
			Login : $login
319
			Email : $Fmail
319
			Email : $Fmail
320
		</pre>
320
		</pre>
321
	</body>
321
	</body>
322
</html>";
322
</html>";
323
						mail($to, $subject, $message, $header);
323
						mail($to, $subject, $message, $header);
324
					}
324
					}
325
				} else {
325
				} else {
326
					// On smtp error, we remove the new user
326
					// On smtp error, we remove the new user
327
					$link = da_sql_pconnect($config);
327
					$link = da_sql_pconnect($config);
328
					$res2 = da_sql_query($link,$config,
328
					$res2 = da_sql_query($link,$config,
329
						"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
329
						"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
330
					$res3 = da_sql_query($link,$config,
330
					$res3 = da_sql_query($link,$config,
331
						"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
331
						"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
332
					echo "<b>$l_mail_error</b><br />\n";
332
					echo "<b>$l_mail_error</b><br />\n";
333
				}
333
				}
334
			}
334
			}
335
			else // Could not open encryption library file
335
			else // Could not open encryption library file
336
				echo "<b>Error during the account creation process</b><br />\n";
336
				echo "<b>Error during the account creation process</b><br />\n";
337
		}
337
		}
338
		else // Could not connect to SQL database
338
		else // Could not connect to SQL database
339
			echo "<b>Error during the account creation process</b><br />\n";
339
			echo "<b>Error during the account creation process</b><br />\n";
340
		da_sql_close($link,$config);
340
		da_sql_close($link,$config);
341
	}
341
	}
342
}
342
}
343
?>
343
?>
344
 
344