Subversion Repositories ALCASAR

Rev

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

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