Subversion Repositories ALCASAR

Rev

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

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