Subversion Repositories ALCASAR

Rev

Rev 3022 | Rev 3026 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3022 Rev 3023
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'];
-
 
53
 
52
 
54
/****************************************
53
/****************************************
55
*			Choice of language			*
54
*			Choice of language			*
56
*****************************************/
55
*****************************************/
57
$Language = 'en';
56
$Language = 'en';
58
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
57
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
59
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
58
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
60
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
59
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
61
}
60
}
62
if ($Language === 'fr') {
61
if ($Language === 'fr') {
63
	$l_invalid_Email = "L'adresse email est invalide";
62
	$l_invalid_Email = "L'adresse email est invalide";
64
	$l_domain = "Le domaine";
63
	$l_domain = "Le domaine";
65
	$l_not_authorized = "n'est pas autorisé";
64
	$l_not_authorized = "n'est pas autorisé";
66
	$l_Email_already_used = "Cette adresse email est déjà utilisée.";
65
	$l_Email_already_used = "Cette adresse email est déjà utilisée.";
67
	$l_subject = "Activation de votre compte ALCASAR";
66
	$l_subject = "Activation de votre compte ALCASAR";
68
	$l_hello = "Bonjour";
67
	$l_hello = "Bonjour";
69
	$l_automatic_mail = "Ceci est un e-mail automatique provenant d'un portail ALCASAR";
68
	$l_automatic_mail = "Ceci est un e-mail automatique provenant d'un portail ALCASAR";
70
	$l_login = "Vos indentifiants de connexion :";
69
	$l_login = "Vos indentifiants de connexion :";
71
	$l_email = "Adresse e-mail";
70
	$l_email = "Adresse e-mail";
72
	$l_password = "Mot de passe";
71
	$l_password = "Mot de passe";
73
	$l_go_home = "Rendez-vous sur la page d'accueil";
72
	$l_go_home = "Rendez-vous sur la page d'accueil";
74
	$l_mail_error = "Erreur lors de l'envoi du mail. Renouvelez votre inscription ou contactez votre administrateur.";
73
	$l_mail_error = "Erreur lors de l'envoi du mail. Renouvelez votre inscription ou contactez votre administrateur.";
75
} else {
74
} else {
76
	$l_invalid_Email = "Invalid Email address";
75
	$l_invalid_Email = "Invalid Email address";
77
	$l_domain = "The domain";
76
	$l_domain = "The domain";
78
	$l_not_authorized = "is not authorized";
77
	$l_not_authorized = "is not authorized";
79
	$l_Email_already_used = "This Email address is already used.";
78
	$l_Email_already_used = "This Email address is already used.";
80
	$l_subject = "Activation of your ALCASAR account";
79
	$l_subject = "Activation of your ALCASAR account";
81
	$l_hello = "Hello";
80
	$l_hello = "Hello";
82
	$l_automatic_mail = "This is an automatic e-mail from an ALCASAR portal";
81
	$l_automatic_mail = "This is an automatic e-mail from an ALCASAR portal";
83
	$l_login = "Your login credentials :";
82
	$l_login = "Your login credentials :";
84
	$l_email = "e-mail address";
83
	$l_email = "e-mail address";
85
	$l_password = "Password";
84
	$l_password = "Password";
86
	$l_go_home = "Go to the home page";
85
	$l_go_home = "Go to the home page";
87
	$l_mail_error = "Error while sending the email. Renew your registration or contact your administrator.";
86
	$l_mail_error = "Error while sending the email. Renew your registration or contact your administrator.";
88
}
87
}
89
 
88
 
90
if (is_file("acc/manager/lib/langues.php"))
89
if (is_file("acc/manager/lib/langues.php"))
91
	include("acc/manager/lib/langues.php");
90
	include("acc/manager/lib/langues.php");
92
 
91
 
93
if(!isset($create)) $create=0;
92
if(!isset($create)) $create=0;
94
if(!isset($show)) $show=0;
93
if(!isset($show)) $show=0;
95
if(!isset($login)) $login = '';
94
if(!isset($login)) $login = '';
96
if(!isset($cn)) $cn = '';
95
if(!isset($cn)) $cn = '';
97
if(!isset($mail)) $mail = '';
96
if(!isset($mail)) $mail = '';
98
if(!isset($langue_imp)) $langue_imp = '';
97
if(!isset($langue_imp)) $langue_imp = '';
99
if(!isset($selected)) $selected = array();
98
if(!isset($selected)) $selected = array();
100
if(!isset($selected['='])) $selected['='] = '';
99
if(!isset($selected['='])) $selected['='] = '';
101
 
100
 
102
require('/etc/freeradius-web/config.php');
101
require('/etc/freeradius-web/config.php');
103
require('acc/manager/lib/attrshow.php');
102
require('acc/manager/lib/attrshow.php');
104
require('acc/manager/lib/defaults.php');
103
require('acc/manager/lib/defaults.php');
105
 
104
 
106
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
105
if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
107
	$colspan = 2;
106
	$colspan = 2;
108
	$show_ops = 1;
107
	$show_ops = 1;
109
	require('acc/manager/lib/operators.php');
108
	require('acc/manager/lib/operators.php');
110
} else {
109
} else {
111
	$show_ops = 0;
110
	$show_ops = 0;
112
	$colspan = 1;
111
	$colspan = 1;
113
}
112
}
114
 
113
 
115
if (is_file("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php"))
114
if (is_file("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php"))
116
	require("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php");
115
	require("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php");
117
else{
116
else{
118
	echo "<b>Could not include SQL library</b><br />\n";
117
	echo "<b>Could not include SQL library</b><br />\n";
119
	exit();
118
	exit();
120
}
119
}
121
 
120
 
122
require('acc/manager/lib/functions.php');
121
require('acc/manager/lib/functions.php');
123
if ($config['sql_use_operators'] == 'true'){
122
if ($config['sql_use_operators'] == 'true'){
124
	include_once("acc/manager/lib/operators.php");
123
	include_once("acc/manager/lib/operators.php");
125
	$text = ',op';
124
	$text = ',op';
126
	$passwd_op = ",':='";
125
	$passwd_op = ",':='";
127
}
126
}
128
 
127
 
129
$da_abort=0;
128
$da_abort=0;
130
$op_val2 = '';
129
$op_val2 = '';
131
 
130
 
132
function GenPassword($nb_car="8")
131
function GenPassword($nb_car="8")
133
{
132
{
134
// Random password
133
// Random password
135
	$password = "";
134
	$password = "";
136
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
135
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
137
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
136
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
138
	while($nb_car != 0) {
137
	while($nb_car != 0) {
139
		//$i = rand(0,71);
138
		//$i = rand(0,71);
140
		// Bug corrigé
139
		// Bug corrigé
141
		$i = rand(0,66);
140
		$i = rand(0,66);
142
		$password .= $chaine[$i];
141
		$password .= $chaine[$i];
143
		$nb_car--;
142
		$nb_car--;
144
	}
143
	}
145
	return $password;
144
	return $password;
146
}
145
}
147
 
146
 
148
if(isset($_POST['Fmail'])){
147
if(isset($_POST['Fmail'])){
149
	extract($_POST);
148
	extract($_POST);
150
	$Fmail = htmlentities(strtolower(trim($Fmail)));
149
	$Fmail = htmlentities(strtolower(trim($Fmail)));
151
	if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){  
150
	if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){  
152
		echo "<b>$l_invalid_Email</b><br />\n";
151
		echo "<b>$l_invalid_Email</b><br />\n";
153
		exit();
152
		exit();
154
	}
153
	}
155
	
154
	
156
	// Retrieve the domainName of the new user
155
	// Retrieve the domainName of the new user
157
	list($user, $domain) = explode('@', $Fmail);
156
	list($user, $domain) = explode('@', $Fmail);
158
 
157
 
159
	// check if the domainName is in the whitelist
158
	// check if the domainName is in the whitelist
160
	if (!empty($whiteDomain)){
159
	if (!empty($whiteDomain)){
161
		if (!in_array($domain, $whiteDomain)){
160
		if (!in_array($domain, $whiteDomain)){
162
			echo "$l_domain $domain $l_not_authorized";
161
			echo "$l_domain $domain $l_not_authorized";
163
			exit();
162
			exit();
164
		}
163
		}
165
	}
164
	}
166
	$login  = $Fmail;
165
	$login  = $Fmail;
167
	
166
	
168
	// check if the new user already exist
167
	// check if the new user already exist
169
	$link = @da_sql_pconnect($config);
168
	$link = @da_sql_pconnect($config);
170
	if ($link) {
169
	if ($link) {
171
		$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';";
170
		$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';";
172
		$res = @da_sql_query($link,$config, $sql);
171
		$res = @da_sql_query($link,$config, $sql);
173
	}
172
	}
174
	$login_check = da_sql_num_rows($res,$config);
173
	$login_check = da_sql_num_rows($res,$config);
175
	da_sql_close($link,$config);
174
	da_sql_close($link,$config);
176
	
175
	
177
	// check if the new user is already in the profile of an existing user 
176
	// check if the new user is already in the profile of an existing user 
178
	$link = @da_sql_pconnect($config);
177
	$link = @da_sql_pconnect($config);
179
	if ($link) {
178
	if ($link) {
180
		$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';";
179
		$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';";
181
		$res = @da_sql_query($link,$config, $sql);
180
		$res = @da_sql_query($link,$config, $sql);
182
	}
181
	}
183
	$email_check = da_sql_num_rows($res,$config);
182
	$email_check = da_sql_num_rows($res,$config);
184
	da_sql_close($link,$config);
183
	da_sql_close($link,$config);
185
	if($login_check > 0) { // user already exist
184
	if($login_check > 0) { // user already exist
186
		echo "<b>$l_Email_already_used</b><br />\n";
185
		echo "<b>$l_Email_already_used</b><br />\n";
187
	} else if($email_check > 0) { // email already used
186
	} else if($email_check > 0) { // email already used
188
		echo "<b>$l_Email_already_used</b><br />\n";
187
		echo "<b>$l_Email_already_used</b><br />\n";
189
	} else {
188
	} else {
190
		$password = GenPassword();
189
		$password = GenPassword();
191
		
190
		
192
		// if we want to enrich the new user profile
191
		// if we want to enrich the new user profile
193
/*		$Fcn = "$prenom".".$nom";
192
/*		$Fcn = "$prenom".".$nom";
194
		$Fou = "";
193
		$Fou = "";
195
		$Fhomephone = "";
194
		$Fhomephone = "";
196
		$Ftelephonenumber = "";
195
		$Ftelephonenumber = "";
197
		$Fmobile = "";
196
		$Fmobile = "";
198
*/
197
*/
199
		$link = da_sql_pconnect($config);
198
		$link = da_sql_pconnect($config);
200
		if ($link){
199
		if ($link){
201
			mysqli_set_charset($link,"utf8");
200
			mysqli_set_charset($link,"utf8");
202
			if (is_file("acc/manager/lib/crypt/$config[general_encryption_method].php")){
201
			if (is_file("acc/manager/lib/crypt/$config[general_encryption_method].php")){
203
				include_once("acc/manager/lib/crypt/$config[general_encryption_method].php");
202
				include_once("acc/manager/lib/crypt/$config[general_encryption_method].php");
204
 
203
 
205
				$passwd = da_encrypt($password);
204
				$passwd = da_encrypt($password);
206
				$passwd = da_sql_escape_string($link, $passwd);
205
				$passwd = da_sql_escape_string($link, $passwd);
207
				$res = da_sql_query($link,$config,
206
				$res = da_sql_query($link,$config,
208
				"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
207
				"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
209
				VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
208
				VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
210
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
209
				if (!$res || !da_sql_affected_rows($link,$res,$config)){
211
					echo "<b>Erreur lors de la création de l'utilisateur $login: " . da_sql_error($link,$config) . "</b><br />\n";
210
					echo "<b>Erreur lors de la création de l'utilisateur $login: " . da_sql_error($link,$config) . "</b><br />\n";
212
					$da_abort=1;
211
					$da_abort=1;
213
				}
212
				}
214
 
213
 
215
				if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
214
				if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
216
					$res = da_sql_query($link,$config,
215
					$res = da_sql_query($link,$config,
217
					"SELECT username FROM $config[sql_user_info_table] WHERE
216
					"SELECT username FROM $config[sql_user_info_table] WHERE
218
					username = '$login';");
217
					username = '$login';");
219
					if ($res){
218
					if ($res){
220
						if (!da_sql_num_rows($res,$config)){
219
						if (!da_sql_num_rows($res,$config)){
221
							$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
220
							$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
222
							$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
221
							$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
223
							$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
222
							$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
224
							$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
223
							$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
225
							$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
224
							$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
226
							$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
225
							$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
227
							$res = da_sql_query($link,$config,
226
							$res = da_sql_query($link,$config,
228
							"INSERT INTO $config[sql_user_info_table]
227
							"INSERT INTO $config[sql_user_info_table]
229
							(username,name,mail,department,homephone,workphone,mobile) VALUES
228
							(username,name,mail,department,homephone,workphone,mobile) VALUES
230
							('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
229
							('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
231
							if (!$res || !da_sql_affected_rows($link,$res,$config))
230
							if (!$res || !da_sql_affected_rows($link,$res,$config))
232
								// Erreur sql à supprimer : l'info ne devrait pas être communiquer au client.
231
								// Erreur sql à supprimer : l'info ne devrait pas être communiquer au client.
233
								echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
232
								echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
234
						}
233
						}
235
						else
234
						else
236
							echo "<b>User already exist</b><br />\n";
235
							echo "<b>User already exist</b><br />\n";
237
					}
236
					}
238
					else
237
					else
239
						echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
238
						echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
240
				}
239
				}
241
				// if the new user must be in a group
240
				// if the new user must be in a group
242
				if (isset($Fgroup) && $Fgroup != ''){
241
				if (isset($Fgroup) && $Fgroup != ''){
243
					$Fgroup = da_sql_escape_string($link, $Fgroup);
242
					$Fgroup = da_sql_escape_string($link, $Fgroup);
244
					$res = da_sql_query($link,$config,
243
					$res = da_sql_query($link,$config,
245
					"SELECT username FROM $config[sql_usergroup_table]
244
					"SELECT username FROM $config[sql_usergroup_table]
246
					WHERE username = '$login' AND groupname = '$Fgroup';");
245
					WHERE username = '$login' AND groupname = '$Fgroup';");
247
					if ($res){
246
					if ($res){
248
						if (!da_sql_num_rows($res,$config)){
247
						if (!da_sql_num_rows($res,$config)){
249
							$res = da_sql_query($link,$config,
248
							$res = da_sql_query($link,$config,
250
							"INSERT INTO $config[sql_usergroup_table]
249
							"INSERT INTO $config[sql_usergroup_table]
251
							(username,groupname) VALUES ('$login','$Fgroup');");
250
							(username,groupname) VALUES ('$login','$Fgroup');");
252
							if (!$res || !da_sql_affected_rows($link,$res,$config))
251
							if (!$res || !da_sql_affected_rows($link,$res,$config))
253
								echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup.</b><br />\n";
252
								echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup.</b><br />\n";
254
						}
253
						}
255
						else
254
						else
256
							echo "<b>L'utilisateur est déjà présent dans le groupe $Fgroup</b><br />\n";
255
							echo "<b>L'utilisateur est déjà présent dans le groupe $Fgroup</b><br />\n";
257
					}
256
					}
258
					else
257
					else
259
						echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n";
258
						echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n";
260
				}
259
				}
261
/*
260
/*
262
				if (!$da_abort){
261
				if (!$da_abort){
263
					if (isset($Fgroup) && $Fgroup != '')
262
					if (isset($Fgroup) && $Fgroup != '')
264
						require('acc/manager/lib/defaults.php');
263
						require('acc/manager/lib/defaults.php');
265
					foreach($show_attrs as $key => $attr){
264
					foreach($show_attrs as $key => $attr){
266
						if ($attrmap["$key"] == 'none')
265
						if ($attrmap["$key"] == 'none')
267
							continue;
266
							continue;
268
						if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
267
						if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
269
							continue;
268
							continue;
270
						if ($attrmap["$key"] == ''){
269
						if ($attrmap["$key"] == ''){
271
							$attrmap["$key"] = $key;
270
							$attrmap["$key"] = $key;
272
							$attr_type["$key"] = 'replyItem';
271
							$attr_type["$key"] = 'replyItem';
273
							$rev_attrmap["$key"] = $key;
272
							$rev_attrmap["$key"] = $key;
274
						}
273
						}
275
						if (isset($attr_type["$key"]) && $attr_type["$key"] == 'checkItem'){
274
						if (isset($attr_type["$key"]) && $attr_type["$key"] == 'checkItem'){
276
							$table = "$config[sql_check_table]";
275
							$table = "$config[sql_check_table]";
277
							$type = 1;
276
							$type = 1;
278
						}
277
						}
279
						else if (isset($attr_type["$key"]) && $attr_type["$key"] == 'replyItem'){
278
						else if (isset($attr_type["$key"]) && $attr_type["$key"] == 'replyItem'){
280
							$table = "$config[sql_reply_table]";
279
							$table = "$config[sql_reply_table]";
281
							$type = 2;
280
							$type = 2;
282
						}
281
						}
283
						$val = (isset($_POST[$attrmap["$key"]])) ? $_POST[$attrmap["$key"]] : '';
282
						$val = (isset($_POST[$attrmap["$key"]])) ? $_POST[$attrmap["$key"]] : '';
284
						$val = da_sql_escape_string($link, $val);
283
						$val = da_sql_escape_string($link, $val);
285
						$op_name = $attrmap["$key"] . '_op';
284
						$op_name = $attrmap["$key"] . '_op';
286
						$op_val = (isset($$op_name)) ? $$op_name : '';
285
						$op_val = (isset($$op_name)) ? $$op_name : '';
287
						if ($op_val != ''){
286
						if ($op_val != ''){
288
							$op_val = da_sql_escape_string($link, $op_val);
287
							$op_val = da_sql_escape_string($link, $op_val);
289
							if (check_operator($op_val,$type) == -1){
288
							if (check_operator($op_val,$type) == -1){
290
								echo "<b>Invalid operator ($op_val) for attribute $key</b><br />\n";
289
								echo "<b>Invalid operator ($op_val) for attribute $key</b><br />\n";
291
								continue;
290
								continue;
292
							}
291
							}
293
							$op_val2 = ",'$op_val'";
292
							$op_val2 = ",'$op_val'";
294
						}
293
						}
295
						$chkdef = (isset($default_vals["$key"])) ? check_defaults($val,$op_val,$default_vals["$key"]) : 0;
294
						$chkdef = (isset($default_vals["$key"])) ? check_defaults($val,$op_val,$default_vals["$key"]) : 0;
296
						if ($val == '' || $chkdef)
295
						if ($val == '' || $chkdef)
297
							continue;
296
							continue;
298
						$sqlquery = "INSERT INTO $table (attribute,value,username $text)
297
						$sqlquery = "INSERT INTO $table (attribute,value,username $text)
299
							VALUES ('$attrmap[$key]','$val','$login' $op_val2);";
298
							VALUES ('$attrmap[$key]','$val','$login' $op_val2);";
300
						$res = da_sql_query($link,$config,$sqlquery);
299
						$res = da_sql_query($link,$config,$sqlquery);
301
						if (!$res || !da_sql_affected_rows($link,$res,$config))
300
						if (!$res || !da_sql_affected_rows($link,$res,$config))
302
							echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br />\n";
301
							echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br />\n";
303
					}
302
					}
304
				}
303
				}
305
*/
304
*/
306
				// Creation of the email with the new user login & passwd
305
				// Creation of the email with the new user login & passwd
307
				$ip = $_SERVER['REMOTE_ADDR'];
306
				$ip = $_SERVER['REMOTE_ADDR'];
308
				$time = date_create('now')->format('d-m-Y H:i:s');
307
				$time = date_create('now')->format('d-m-Y H:i:s');
309
				$domain = $conf["DOMAIN"];
308
				$domain = $conf["DOMAIN"];
310
				$hostname  = $conf["HOSTNAME"];
309
				$hostname  = $conf["HOSTNAME"];
311
				$to = $Fmail;
310
				$to = $Fmail;
312
				$from = "administrator";
311
				$from = $conf["MAIL_ADDR"];
313
				$subject = $l_subject;
312
				$subject = $l_subject;
314
				$message = "<!DOCTYPE html>
313
				$message = "<!DOCTYPE html>
315
						<html>
314
						<html>
316
							<head>	
315
							<head>	
317
								<meta charset=\"UTF-8\" />
316
								<meta charset=\"UTF-8\" />
318
							</head>
317
							</head>
319
							<body>
318
							<body>
320
								$l_hello,<br/><br/>
319
								$l_hello,<br/><br/>
321
								<p>$l_automatic_mail ($hostname.$domain)<br/>
320
								<p>$l_automatic_mail ($hostname.$domain)<br/>
322
								<h4>$l_login</h4>
321
								<h4>$l_login</h4>
323
								<pre>
322
								<pre>
324
									$l_email : $Fmail 
323
									$l_email : $Fmail 
325
									Login : $login
324
									Login : $login
326
									$l_password : $password
325
									$l_password : $password
327
								</pre>
326
								</pre>
328
								<p>$l_go_home : <a href=\"https://$hostname.$domain\"></a></p>
327
								<p>$l_go_home : <a href=\"https://$hostname.$domain\"></a></p>
329
							</body>
328
							</body>
330
						</html>";
329
						</html>";
331
				$header = "From: $from\n";
330
				$header = "From: $from\n";
332
				$header .= "MIME-Version: 1.0\n";
331
				$header .= "MIME-Version: 1.0\n";
333
				$header .= "Content-type: text/html; charset=utf-8\n";
332
				$header .= "Content-type: text/html; charset=utf-8\n";
334
				if(mail($to, $subject, $message, $header)){
333
				if(mail($to, $subject, $message, $header)){
335
					echo "<center>success : <b>Vous y êtes presque ! $l_user '$login' $l_created</b></center><br />";
334
					echo "<center>success : <b>Vous y êtes presque ! $l_user '$login' $l_created</b></center><br />";
336
					echo "<center>success : <b>Un email contenant vos informations de connexion vient de vous être envoyé.</b></center><br />";
335
					echo "<center>success : <b>Un email contenant vos informations de connexion vient de vous être envoyé.</b></center><br />";
337
					// Creation of the email for the administrator (if enabled)
336
					// Creation of the email for the administrator (if enabled)
338
					if (!empty($adminMail)){
337
					if (!empty($conf['MAIL_ADMIN']){
339
						$to = $adminMail;
338
						$to = $conf['MAIL_ADMIN'];
340
						$from = "administrator";
339
						$from = $conf["MAIL_ADDR"];
341
						$subject = "New registration on ALCASAR";
340
						$subject = "New registration on ALCASAR";
342
						$message = "<!DOCTYPE html>
341
						$message = "<!DOCTYPE html>
343
							<html>
342
							<html>
344
								<head>	
343
								<head>	
345
									<meta charset=\"UTF-8\" />
344
									<meta charset=\"UTF-8\" />
346
								</head>
345
								</head>
347
								<body>
346
								<body>
348
									Hello,<br/><br/>
347
									Hello,<br/><br/>
349
									<p>This is an automatic e-mail from an ALCASAR portal.<br/>
348
									<p>This is an automatic e-mail from an ALCASAR portal.<br/>
350
									<h3>A new registration on <strong>$hostname.$domain</strong> has been made :</h3>
349
									<h3>A new registration on <strong>$hostname.$domain</strong> has been made :</h3>
351
									<pre>
350
									<pre>
352
										@IP   :	$ip
351
										@IP   :	$ip
353
										Hour :	$time
352
										Hour :	$time
354
										Login :	$login
353
										Login :	$login
355
										Email :	$Fmail 
354
										Email :	$Fmail 
356
									</pre>
355
									</pre>
357
									<p><a href=\"https://$hostname\">$domain</a></p>
356
									<p><a href=\"https://$hostname\">$domain</a></p>
358
								</body>
357
								</body>
359
							</html>";
358
							</html>";
360
						$header = "From: $from\n";
359
						$header = "From: $from\n";
361
						$header .= "MIME-Version: 1.0\n";
360
						$header .= "MIME-Version: 1.0\n";
362
						$header .= "Content-type: text/html; charset=utf-8\n";
361
						$header .= "Content-type: text/html; charset=utf-8\n";
363
						mail($to, $subject, $message, $header);
362
						mail($to, $subject, $message, $header);
364
					}
363
					}
365
				} else {
364
				} else {
366
					// On smtp error, we remove the new user
365
					// On smtp error, we remove the new user
367
					$link = da_sql_pconnect($config);
366
					$link = da_sql_pconnect($config);
368
					$res2 = da_sql_query($link,$config,
367
					$res2 = da_sql_query($link,$config,
369
						"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
368
						"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
370
					$res3 = da_sql_query($link,$config,
369
					$res3 = da_sql_query($link,$config,
371
						"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
370
						"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
372
					echo "<b>$l_mail_error</b><br />\n";
371
					echo "<b>$l_mail_error</b><br />\n";
373
				}
372
				}
374
			}
373
			}
375
			else // Could not open encryption library file
374
			else // Could not open encryption library file
376
				echo "<b>Error during the account creation process</b><br />\n";
375
				echo "<b>Error during the account creation process</b><br />\n";
377
		}
376
		}
378
		else // Could not connect to SQL database
377
		else // Could not connect to SQL database
379
			echo "<b>Error during the account creation process</b><br />\n";
378
			echo "<b>Error during the account creation process</b><br />\n";
380
		da_sql_close($link,$config);
379
		da_sql_close($link,$config);
381
	}
380
	}
382
}
381
}
383
?>
382
?>
384
 
383