| 2990 | 
           rexy | 
           1 | 
           <?php 
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           /********************************************************************************									*										*
  | 
        
        
            | 
            | 
           4 | 
           *			ALCASAR INSCRIPTION					*
  | 
        
        
            | 
            | 
           5 | 
           *										*
  | 
        
        
            | 
            | 
           6 | 
           *	By K@M3L 1101130512.1901090409 & T3RRY LaPlateforme_.			*
  | 
        
        
            | 
            | 
           7 | 
           *	V 1.0 June 2021.							*
  | 
        
        
            | 
            | 
           8 | 
           *										*
  | 
        
        
            | 
            | 
           9 | 
           *	Partie back de la page d'inscription des utilisateurs			*
  | 
        
        
            | 
            | 
           10 | 
           *	elle traite les infos de la partie front de l'inscription		*
  | 
        
        
            | 
            | 
           11 | 
           *	-Lit le fichier de configuration /usr/local/etc/alcasar-mail.conf.	*
  | 
        
        
            | 
            | 
           12 | 
           *	-Verifie si le login est présent dans la radcheck.			*
  | 
        
        
            | 
            | 
           13 | 
           *	-Verifie si le mail est présent dans la userinfo.			*
  | 
        
        
            | 
            | 
           14 | 
           *	-Verifie si le domaine du mail est sur WLD (optionnel).			*
  | 
        
        
            | 
            | 
           15 | 
           *	-Inscrit l'utilisateur avec mot de passe aléatoire.			*
  | 
        
        
            | 
            | 
           16 | 
           *	-Envoi l'email à l'utilisaeur, et à l'admin avec date et IP.		*
  | 
        
        
            | 
            | 
           17 | 
           *										*
  | 
        
        
            | 
            | 
           18 | 
           *********************************************************************************/
  | 
        
        
            | 
            | 
           19 | 
              | 
        
        
            | 
            | 
           20 | 
           if (is_file("acc/manager/lib/langues.php"))
  | 
        
        
            | 
            | 
           21 | 
           	include("acc/manager/lib/langues.php");
  | 
        
        
            | 
            | 
           22 | 
              | 
        
        
            | 
            | 
           23 | 
           if(!isset($create)) $create=0;
  | 
        
        
            | 
            | 
           24 | 
           if(!isset($show)) $show=0;
  | 
        
        
            | 
            | 
           25 | 
           if(!isset($login)) $login = '';
  | 
        
        
            | 
            | 
           26 | 
           if(!isset($cn)) $cn = '';
  | 
        
        
            | 
            | 
           27 | 
           if(!isset($mail)) $mail = '';
  | 
        
        
            | 
            | 
           28 | 
           if(!isset($langue_imp)) $langue_imp = '';
  | 
        
        
            | 
            | 
           29 | 
           if(!isset($selected)) $selected = array();
  | 
        
        
            | 
            | 
           30 | 
           if(!isset($selected['='])) $selected['='] = '';
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
              | 
        
        
            | 
            | 
           33 | 
           require('/etc/freeradius-web/config.php');
  | 
        
        
            | 
            | 
           34 | 
           require('acc/manager/lib/attrshow.php');
  | 
        
        
            | 
            | 
           35 | 
           require('acc/manager/lib/defaults.php');
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
           if (false && /* Hide operator column */ $config['general_lib_type'] == 'sql' && $config['sql_use_operators'] == 'true') {
  | 
        
        
            | 
            | 
           38 | 
           	$colspan = 2;
  | 
        
        
            | 
            | 
           39 | 
           	$show_ops = 1;
  | 
        
        
            | 
            | 
           40 | 
           	require('acc/manager/lib/operators.php');
  | 
        
        
            | 
            | 
           41 | 
           } else {
  | 
        
        
            | 
            | 
           42 | 
           	$show_ops = 0;
  | 
        
        
            | 
            | 
           43 | 
           	$colspan = 1;
  | 
        
        
            | 
            | 
           44 | 
           }
  | 
        
        
            | 
            | 
           45 | 
              | 
        
        
            | 
            | 
           46 | 
           if (is_file("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php"))
  | 
        
        
            | 
            | 
           47 | 
           	require("acc/manager/lib/sql/drivers/$config[sql_type]/functions.php");
  | 
        
        
            | 
            | 
           48 | 
           else{
  | 
        
        
            | 
            | 
           49 | 
           	echo "<b>Could not include SQL library</b><br />\n";
  | 
        
        
            | 
            | 
           50 | 
           	exit();
  | 
        
        
            | 
            | 
           51 | 
           }
  | 
        
        
            | 
            | 
           52 | 
              | 
        
        
            | 
            | 
           53 | 
           require('acc/manager/lib/functions.php');
  | 
        
        
            | 
            | 
           54 | 
           if ($config['sql_use_operators'] == 'true'){
  | 
        
        
            | 
            | 
           55 | 
           	include_once("acc/manager/lib/operators.php");
  | 
        
        
            | 
            | 
           56 | 
           	$text = ',op';
  | 
        
        
            | 
            | 
           57 | 
           	$passwd_op = ",':='";
  | 
        
        
            | 
            | 
           58 | 
           }
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
           $da_abort=0;
  | 
        
        
            | 
            | 
           61 | 
           $op_val2 = '';
  | 
        
        
            | 
            | 
           62 | 
              | 
        
        
            | 
            | 
           63 | 
              | 
        
        
            | 
            | 
           64 | 
           function GenPassword($nb_car="8")
  | 
        
        
            | 
            | 
           65 | 
           {
  | 
        
        
            | 
            | 
           66 | 
           // Random password
  | 
        
        
            | 
            | 
           67 | 
           	$password = "";
  | 
        
        
            | 
            | 
           68 | 
           	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
  | 
        
        
            | 
            | 
           69 | 
           	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
  | 
        
        
            | 
            | 
           70 | 
           	while($nb_car != 0) {
  | 
        
        
            | 
            | 
           71 | 
           		//$i = rand(0,71);
  | 
        
        
            | 
            | 
           72 | 
           		// Bug corrigé
  | 
        
        
            | 
            | 
           73 | 
           		$i = rand(0,66);
  | 
        
        
            | 
            | 
           74 | 
           		$password .= $chaine[$i];
  | 
        
        
            | 
            | 
           75 | 
           		$nb_car--;
  | 
        
        
            | 
            | 
           76 | 
           	}
  | 
        
        
            | 
            | 
           77 | 
           	return $password;
  | 
        
        
            | 
            | 
           78 | 
           }
  | 
        
        
            | 
            | 
           79 | 
              | 
        
        
            | 
            | 
           80 | 
           // Lecture du fichier de configuration, récupération des listes WLD et l'email de l'admin
  | 
        
        
            | 
            | 
           81 | 
           $alcasarMailConf = "/usr/local/etc/alcasar-mail.conf";
  | 
        
        
            | 
            | 
           82 | 
           if (is_file ($alcasarMailConf)){
  | 
        
        
            | 
            | 
           83 | 
           	$tab=file($alcasarMailConf);
  | 
        
        
            | 
            | 
           84 | 
           	if ($tab){
  | 
        
        
            | 
            | 
           85 | 
           		foreach ($tab as $line){
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
            | 
            | 
           87 | 
           			$field=explode("=", $line);
  | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
           			switch ($field[0]){
  | 
        
        
            | 
            | 
           90 | 
           				case 'whiteDomain':
  | 
        
        
            | 
            | 
           91 | 
           					$whiteDomain = explode(" ", strtolower(trim($field[1])));
  | 
        
        
            | 
            | 
           92 | 
           				break;
  | 
        
        
            | 
            | 
           93 | 
           				case 'adminMail':
  | 
        
        
            | 
            | 
           94 | 
           					$adminMail = $field[1];
  | 
        
        
            | 
            | 
           95 | 
           				break;
  | 
        
        
            | 
            | 
           96 | 
           			}
  | 
        
        
            | 
            | 
           97 | 
           		}
  | 
        
        
            | 
            | 
           98 | 
           	}
  | 
        
        
            | 
            | 
           99 | 
           }
  | 
        
        
            | 
            | 
           100 | 
              | 
        
        
            | 
            | 
           101 | 
           if(isset($_POST['Fmail'])){
  | 
        
        
            | 
            | 
           102 | 
              | 
        
        
            | 
            | 
           103 | 
           	extract($_POST);
  | 
        
        
            | 
            | 
           104 | 
              | 
        
        
            | 
            | 
           105 | 
           	$Fmail = htmlentities(strtolower(trim($Fmail)));
  | 
        
        
            | 
            | 
           106 | 
              | 
        
        
            | 
            | 
           107 | 
           	if(!filter_var($Fmail, FILTER_VALIDATE_EMAIL)){  
  | 
        
        
            | 
            | 
           108 | 
           		echo "<b>L'adresse email est invalide</b><br />\n";
  | 
        
        
            | 
            | 
           109 | 
           		exit();
  | 
        
        
            | 
            | 
           110 | 
           	}
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
           	// on récupère le nom de domaine du mail@domain.com
  | 
        
        
            | 
            | 
           113 | 
           	list($user, $domain) = explode('@', $Fmail);
  | 
        
        
            | 
            | 
           114 | 
              | 
        
        
            | 
            | 
           115 | 
           	// on vérifie si le domaine est dans la WLD, sinon on bloque
  | 
        
        
            | 
            | 
           116 | 
           	if (!empty($whiteDomain)){
  | 
        
        
            | 
            | 
           117 | 
           		if (!in_array($domain, $whiteDomain)){
  | 
        
        
            | 
            | 
           118 | 
           			echo "Le domaine $domain n'est pas autorisé";
  | 
        
        
            | 
            | 
           119 | 
           			exit();
  | 
        
        
            | 
            | 
           120 | 
           		}
  | 
        
        
            | 
            | 
           121 | 
           	}
  | 
        
        
            | 
            | 
           122 | 
              | 
        
        
            | 
            | 
           123 | 
           	$login  = $Fmail;
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
            | 
            | 
           125 | 
           	// si le login est présent
  | 
        
        
            | 
            | 
           126 | 
           	$link = @da_sql_pconnect($config);
  | 
        
        
            | 
            | 
           127 | 
           	if ($link) {
  | 
        
        
            | 
            | 
           128 | 
           		$sql = "SELECT id FROM $config[sql_check_table] WHERE username = '$login';";
  | 
        
        
            | 
            | 
           129 | 
           		$res = @da_sql_query($link,$config, $sql);
  | 
        
        
            | 
            | 
           130 | 
           	}
  | 
        
        
            | 
            | 
           131 | 
              | 
        
        
            | 
            | 
           132 | 
           	$login_check = 	da_sql_num_rows($res,$config);
  | 
        
        
            | 
            | 
           133 | 
              | 
        
        
            | 
            | 
           134 | 
           //	da_sql_close($link,$config)
  | 
        
        
            | 
            | 
           135 | 
              | 
        
        
            | 
            | 
           136 | 
           	// si le mail est présent
  | 
        
        
            | 
            | 
           137 | 
           	$link = @da_sql_pconnect($config);
  | 
        
        
            | 
            | 
           138 | 
           	if ($link) {
  | 
        
        
            | 
            | 
           139 | 
           		$sql = "SELECT id FROM $config[sql_user_info_table] WHERE mail = '$Fmail';";
  | 
        
        
            | 
            | 
           140 | 
           		$res = @da_sql_query($link,$config, $sql);
  | 
        
        
            | 
            | 
           141 | 
           	}
  | 
        
        
            | 
            | 
           142 | 
              | 
        
        
            | 
            | 
           143 | 
           	$email_check = 	da_sql_num_rows($res,$config);
  | 
        
        
            | 
            | 
           144 | 
              | 
        
        
            | 
            | 
           145 | 
           //	da_sql_close($link,$config)
  | 
        
        
            | 
            | 
           146 | 
              | 
        
        
            | 
            | 
           147 | 
              | 
        
        
            | 
            | 
           148 | 
           	if($login_check > 0) {
  | 
        
        
            | 
            | 
           149 | 
           		//Adresse email utilisée en tant que login
  | 
        
        
            | 
            | 
           150 | 
           		echo "<b>L'adresse email est déjà utilisée.</b><br />\n";
  | 
        
        
            | 
            | 
           151 | 
           	} else if($email_check > 0) {
  | 
        
        
            | 
            | 
           152 | 
           		echo "<b>L'adresse mail est déjà utilisée.</b><br />\n";
  | 
        
        
            | 
            | 
           153 | 
           	} else {
  | 
        
        
            | 
            | 
           154 | 
              | 
        
        
            | 
            | 
           155 | 
           		$password = GenPassword();
  | 
        
        
            | 
            | 
           156 | 
              | 
        
        
            | 
            | 
           157 | 
           		// si on ajoute des inputs pour les infos user
  | 
        
        
            | 
            | 
           158 | 
           /*		$Fcn = "$prenom".".$nom";
  | 
        
        
            | 
            | 
           159 | 
           		$Fou = "";
  | 
        
        
            | 
            | 
           160 | 
           		$Fhomephone = "";
  | 
        
        
            | 
            | 
           161 | 
           		$Ftelephonenumber = "";
  | 
        
        
            | 
            | 
           162 | 
           		$Fmobile = "";
  | 
        
        
            | 
            | 
           163 | 
           */
  | 
        
        
            | 
            | 
           164 | 
              | 
        
        
            | 
            | 
           165 | 
           		$link = da_sql_pconnect($config);
  | 
        
        
            | 
            | 
           166 | 
           		if ($link){
  | 
        
        
            | 
            | 
           167 | 
           			mysqli_set_charset($link,"utf8");
  | 
        
        
            | 
            | 
           168 | 
           			if (is_file("acc/manager/lib/crypt/$config[general_encryption_method].php")){
  | 
        
        
            | 
            | 
           169 | 
           				include_once("acc/manager/lib/crypt/$config[general_encryption_method].php");
  | 
        
        
            | 
            | 
           170 | 
              | 
        
        
            | 
            | 
           171 | 
           				$passwd = da_encrypt($password);
  | 
        
        
            | 
            | 
           172 | 
           				$passwd = da_sql_escape_string($link, $passwd);
  | 
        
        
            | 
            | 
           173 | 
           				$res = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           174 | 
           				"INSERT INTO $config[sql_check_table] (attribute,value,username $text)
  | 
        
        
            | 
            | 
           175 | 
           				VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
  | 
        
        
            | 
            | 
           176 | 
           				if (!$res || !da_sql_affected_rows($link,$res,$config)){
  | 
        
        
            | 
            | 
           177 | 
           					echo "<b>Erreur lors de la création de l'utilisateur $login: " . da_sql_error($link,$config) . "</b><br />\n";
  | 
        
        
            | 
            | 
           178 | 
           					$da_abort=1;
  | 
        
        
            | 
            | 
           179 | 
           				}
  | 
        
        
            | 
            | 
           180 | 
              | 
        
        
            | 
            | 
           181 | 
           				if ($config['sql_use_user_info_table'] == 'true' && !$da_abort){
  | 
        
        
            | 
            | 
           182 | 
           					$res = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           183 | 
           					"SELECT username FROM $config[sql_user_info_table] WHERE
  | 
        
        
            | 
            | 
           184 | 
           					username = '$login';");
  | 
        
        
            | 
            | 
           185 | 
           					if ($res){
  | 
        
        
            | 
            | 
           186 | 
           						if (!da_sql_num_rows($res,$config)){
  | 
        
        
            | 
            | 
           187 | 
           							$Fcn = (isset($Fcn)) ? da_sql_escape_string($link, $Fcn) : '';
  | 
        
        
            | 
            | 
           188 | 
           							$Fmail = (isset($Fmail)) ? da_sql_escape_string($link, $Fmail) : '';
  | 
        
        
            | 
            | 
           189 | 
           							$Fou = (isset($Fou)) ? da_sql_escape_string($link, $Fou) : '';
  | 
        
        
            | 
            | 
           190 | 
           							$Fhomephone = (isset($Fhomephone)) ? da_sql_escape_string($link, $Fhomephone) : '';
  | 
        
        
            | 
            | 
           191 | 
           							$Ftelephonenumber = (isset($Ftelephonenumber)) ? da_sql_escape_string($link, $Ftelephonenumber) : '';
  | 
        
        
            | 
            | 
           192 | 
           							$Fmobile = (isset($Fmobile)) ? da_sql_escape_string($link, $Fmobile) : '';
  | 
        
        
            | 
            | 
           193 | 
           							$res = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           194 | 
           							"INSERT INTO $config[sql_user_info_table]
  | 
        
        
            | 
            | 
           195 | 
           							(username,name,mail,department,homephone,workphone,mobile) VALUES
  | 
        
        
            | 
            | 
           196 | 
           							('$login','$Fcn','$Fmail','$Fou','$Fhomephone','$Ftelephonenumber','$Fmobile');");
  | 
        
        
            | 
            | 
           197 | 
              | 
        
        
            | 
            | 
           198 | 
           							if (!$res || !da_sql_affected_rows($link,$res,$config))
  | 
        
        
            | 
            | 
           199 | 
           								// Erreur sql à supprimer : l'info ne devrait pas être communiquer au client.
  | 
        
        
            | 
            | 
           200 | 
           								echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
  | 
        
        
            | 
            | 
           201 | 
           						}
  | 
        
        
            | 
            | 
           202 | 
           						else
  | 
        
        
            | 
            | 
           203 | 
           							echo "<b>L'utilisateur existe déjà</b><br />\n";
  | 
        
        
            | 
            | 
           204 | 
           					}
  | 
        
        
            | 
            | 
           205 | 
           					else
  | 
        
        
            | 
            | 
           206 | 
           						echo "<b>Une erreur s'est produite lors de la création du compte : " . da_sql_error($link,$config) . "</b><br />\n";
  | 
        
        
            | 
            | 
           207 | 
           				}
  | 
        
        
            | 
            | 
           208 | 
           				// si on veut ajouter les nouveau utilisateurs a un groupe par défaut, autre que celui par défaut d'alcasar
  | 
        
        
            | 
            | 
           209 | 
           				if (isset($Fgroup) && $Fgroup != ''){
  | 
        
        
            | 
            | 
           210 | 
           					$Fgroup = da_sql_escape_string($link, $Fgroup);
  | 
        
        
            | 
            | 
           211 | 
           					$res = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           212 | 
           					"SELECT username FROM $config[sql_usergroup_table]
  | 
        
        
            | 
            | 
           213 | 
           					WHERE username = '$login' AND groupname = '$Fgroup';");
  | 
        
        
            | 
            | 
           214 | 
           					if ($res){
  | 
        
        
            | 
            | 
           215 | 
           						if (!da_sql_num_rows($res,$config)){
  | 
        
        
            | 
            | 
           216 | 
           							$res = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           217 | 
           							"INSERT INTO $config[sql_usergroup_table]
  | 
        
        
            | 
            | 
           218 | 
           							(username,groupname) VALUES ('$login','$Fgroup');");
  | 
        
        
            | 
            | 
           219 | 
           							if (!$res || !da_sql_affected_rows($link,$res,$config))
  | 
        
        
            | 
            | 
           220 | 
           								echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup.</b><br />\n";
  | 
        
        
            | 
            | 
           221 | 
           						}
  | 
        
        
            | 
            | 
           222 | 
           						else
  | 
        
        
            | 
            | 
           223 | 
           							echo "<b>L'utilisateur est déjà présent dans le groupe $Fgroup</b><br />\n";
  | 
        
        
            | 
            | 
           224 | 
           					}
  | 
        
        
            | 
            | 
           225 | 
           					else
  | 
        
        
            | 
            | 
           226 | 
           						echo "<b>Impossible d'ajouter l'utilisateur dans le groupe $Fgroup: " . da_sql_error($link,$config) . "</b><br />\n";
  | 
        
        
            | 
            | 
           227 | 
           				}
  | 
        
        
            | 
            | 
           228 | 
           				if (!$da_abort){
  | 
        
        
            | 
            | 
           229 | 
           					if (isset($Fgroup) && $Fgroup != '')
  | 
        
        
            | 
            | 
           230 | 
           						require('acc/manager/lib/defaults.php');
  | 
        
        
            | 
            | 
           231 | 
           					foreach($show_attrs as $key => $attr){
  | 
        
        
            | 
            | 
           232 | 
           						if ($attrmap["$key"] == 'none')
  | 
        
        
            | 
            | 
           233 | 
           							continue;
  | 
        
        
            | 
            | 
           234 | 
           						if ($key == "Filter-Id" && $$attrmap["$key"] == "None")
  | 
        
        
            | 
            | 
           235 | 
           							continue;
  | 
        
        
            | 
            | 
           236 | 
           						if ($attrmap["$key"] == ''){
  | 
        
        
            | 
            | 
           237 | 
           							$attrmap["$key"] = $key;
  | 
        
        
            | 
            | 
           238 | 
           							$attr_type["$key"] = 'replyItem';
  | 
        
        
            | 
            | 
           239 | 
           							$rev_attrmap["$key"] = $key;
  | 
        
        
            | 
            | 
           240 | 
           						}
  | 
        
        
            | 
            | 
           241 | 
           						if (isset($attr_type["$key"]) && $attr_type["$key"] == 'checkItem'){
  | 
        
        
            | 
            | 
           242 | 
           							$table = "$config[sql_check_table]";
  | 
        
        
            | 
            | 
           243 | 
           							$type = 1;
  | 
        
        
            | 
            | 
           244 | 
           						}
  | 
        
        
            | 
            | 
           245 | 
           						else if (isset($attr_type["$key"]) && $attr_type["$key"] == 'replyItem'){
  | 
        
        
            | 
            | 
           246 | 
           							$table = "$config[sql_reply_table]";
  | 
        
        
            | 
            | 
           247 | 
           							$type = 2;
  | 
        
        
            | 
            | 
           248 | 
           						}
  | 
        
        
            | 
            | 
           249 | 
           						$val = (isset($_POST[$attrmap["$key"]])) ? $_POST[$attrmap["$key"]] : '';
  | 
        
        
            | 
            | 
           250 | 
           						$val = da_sql_escape_string($link, $val);
  | 
        
        
            | 
            | 
           251 | 
           						$op_name = $attrmap["$key"] . '_op';
  | 
        
        
            | 
            | 
           252 | 
           						$op_val = (isset($$op_name)) ? $$op_name : '';
  | 
        
        
            | 
            | 
           253 | 
           						if ($op_val != ''){
  | 
        
        
            | 
            | 
           254 | 
           							$op_val = da_sql_escape_string($link, $op_val);
  | 
        
        
            | 
            | 
           255 | 
           							if (check_operator($op_val,$type) == -1){
  | 
        
        
            | 
            | 
           256 | 
           								echo "<b>Invalid operator ($op_val) for attribute $key</b><br />\n";
  | 
        
        
            | 
            | 
           257 | 
           								continue;
  | 
        
        
            | 
            | 
           258 | 
           							}
  | 
        
        
            | 
            | 
           259 | 
           							$op_val2 = ",'$op_val'";
  | 
        
        
            | 
            | 
           260 | 
           						}
  | 
        
        
            | 
            | 
           261 | 
           						$chkdef = (isset($default_vals["$key"])) ? check_defaults($val,$op_val,$default_vals["$key"]) : 0;
  | 
        
        
            | 
            | 
           262 | 
           						if ($val == '' || $chkdef)
  | 
        
        
            | 
            | 
           263 | 
           							continue;
  | 
        
        
            | 
            | 
           264 | 
           						$sqlquery = "INSERT INTO $table (attribute,value,username $text)
  | 
        
        
            | 
            | 
           265 | 
           							VALUES ('$attrmap[$key]','$val','$login' $op_val2);";
  | 
        
        
            | 
            | 
           266 | 
           						$res = da_sql_query($link,$config,$sqlquery);
  | 
        
        
            | 
            | 
           267 | 
           						if (!$res || !da_sql_affected_rows($link,$res,$config))
  | 
        
        
            | 
            | 
           268 | 
           							echo "<b>Query failed for attribute $key: " . da_sql_error($link,$config) . "</b><br />\n";
  | 
        
        
            | 
            | 
           269 | 
           					}
  | 
        
        
            | 
            | 
           270 | 
           				}
  | 
        
        
            | 
            | 
           271 | 
              | 
        
        
            | 
            | 
           272 | 
              | 
        
        
            | 
            | 
           273 | 
           				// L'utilisateur est ajouter dans la radcheck, ses info dans la userinfo, on envoi le mail avec identifiant et passwd
  | 
        
        
            | 
            | 
           274 | 
              | 
        
        
            | 
            | 
           275 | 
           				$ip = $_SERVER['REMOTE_ADDR'];
  | 
        
        
            | 
            | 
           276 | 
           				$time = date_create('now')->format('d-m-Y H:i:s');
  | 
        
        
            | 
            | 
           277 | 
           				$domain = $conf["DOMAIN"];
  | 
        
        
            | 
            | 
           278 | 
           				$hostname  = $conf["HOSTNAME"].'.'.$domain;
  | 
        
        
            | 
            | 
           279 | 
           				$hostname  = "alcasar.laplateforme.io";
  | 
        
        
            | 
            | 
           280 | 
              | 
        
        
            | 
            | 
           281 | 
           				$to = $Fmail;
  | 
        
        
            | 
            | 
           282 | 
           				$from = "alcasar@$domain";
  | 
        
        
            | 
            | 
           283 | 
           				$subject = "Activation de votre compte ALCASAR";
  | 
        
        
            | 
            | 
           284 | 
           				$message = "<!DOCTYPE html>
  | 
        
        
            | 
            | 
           285 | 
           						<html>
  | 
        
        
            | 
            | 
           286 | 
           							<head>	
  | 
        
        
            | 
            | 
           287 | 
           								<meta charset=\"UTF-8\" />
  | 
        
        
            | 
            | 
           288 | 
           							</head>
  | 
        
        
            | 
            | 
           289 | 
           							<body>
  | 
        
        
            | 
            | 
           290 | 
           								Bonjour,<br/><br/>
  | 
        
        
            | 
            | 
           291 | 
              | 
        
        
            | 
            | 
           292 | 
           								<h3>Bienvenue sur ALCASAR @ $domain</h3>
  | 
        
        
            | 
            | 
           293 | 
           								<p>Ceci est un email automatique avec vos identifiants, veuillez changer votre mot de passe.<br/>
  | 
        
        
            | 
            | 
           294 | 
              | 
        
        
            | 
            | 
           295 | 
           								<h4>Indentifiants de connexion:</h4>  
  | 
        
        
            | 
            | 
           296 | 
           								<pre>								
  | 
        
        
            | 
            | 
           297 | 
           									Adresse e-mail : $Fmail 
  | 
        
        
            | 
            | 
           298 | 
           									Login :		$login
  | 
        
        
            | 
            | 
           299 | 
           									Mot de passe :   $password
  | 
        
        
            | 
            | 
           300 | 
           								</pre> 
  | 
        
        
            | 
            | 
           301 | 
           								<p>Rendez-vous sur le portail <a href=\"https://$hostname\">$domain</a></p>
  | 
        
        
            | 
            | 
           302 | 
           							</body>
  | 
        
        
            | 
            | 
           303 | 
           						</html>";
  | 
        
        
            | 
            | 
           304 | 
              | 
        
        
            | 
            | 
           305 | 
           				$header = "From: $from\n";
  | 
        
        
            | 
            | 
           306 | 
           				$header .= "MIME-Version: 1.0\n";
  | 
        
        
            | 
            | 
           307 | 
           				$header .= "Content-type: text/html; charset=utf-8\n";
  | 
        
        
            | 
            | 
           308 | 
              | 
        
        
            | 
            | 
           309 | 
           				if(mail($to, $subject, $message, $header)){
  | 
        
        
            | 
            | 
           310 | 
           					echo "<center>success : <b>Vous y êtes presque ! $l_user '$login' $l_created</b></center><br />";
  | 
        
        
            | 
            | 
           311 | 
           					echo "<center>success : <b>Un email contenant vos informations de connexion vient de vous être envoyé.</b></center><br />";
  | 
        
        
            | 
            | 
           312 | 
              | 
        
        
            | 
            | 
           313 | 
              | 
        
        
            | 
            | 
           314 | 
           					// le mail pour l'uitilisateur est envoyé, si l'admin a configuré son mail, on lui envoi
  | 
        
        
            | 
            | 
           315 | 
           					// une notification d'inscription avec l'ip, l'heure, et le login de l'utilisateur
  | 
        
        
            | 
            | 
           316 | 
           					if (!empty($adminMail)){
  | 
        
        
            | 
            | 
           317 | 
           						$to = $adminMail;
  | 
        
        
            | 
            | 
           318 | 
           						$from = "alcasar@$domain";
  | 
        
        
            | 
            | 
           319 | 
           						$subject = "Nouvelle inscription sur ALCASAR";
  | 
        
        
            | 
            | 
           320 | 
           						$message = "<!DOCTYPE html>
  | 
        
        
            | 
            | 
           321 | 
           							<html>
  | 
        
        
            | 
            | 
           322 | 
           								<head>	
  | 
        
        
            | 
            | 
           323 | 
           									<meta charset=\"UTF-8\" />
  | 
        
        
            | 
            | 
           324 | 
           								</head>
  | 
        
        
            | 
            | 
           325 | 
           								<body>
  | 
        
        
            | 
            | 
           326 | 
           									Bonjour,<br/><br/>
  | 
        
        
            | 
            | 
           327 | 
              | 
        
        
            | 
            | 
           328 | 
           									<p>Ceci est un mail automatique.<br/>
  | 
        
        
            | 
            | 
           329 | 
           									<h3>Une nouvelle inscription à <strong>ALCASR $domain</strong> a été faite.</h3>
  | 
        
        
            | 
            | 
           330 | 
              | 
        
        
            | 
            | 
           331 | 
           									<h4>Indentifiants de connexion:</h4>  
  | 
        
        
            | 
            | 
           332 | 
           									<pre>								
  | 
        
        
            | 
            | 
           333 | 
           										Adresse IP :	$ip
  | 
        
        
            | 
            | 
           334 | 
           										Heure :		$time;
  | 
        
        
            | 
            | 
           335 | 
           										Login :		$login
  | 
        
        
            | 
            | 
           336 | 
           										Email :		$Fmail 
  | 
        
        
            | 
            | 
           337 | 
           									</pre> 
  | 
        
        
            | 
            | 
           338 | 
           									<p>ALCASAR <a href=\"https://$hostname\">$domain</a></p>
  | 
        
        
            | 
            | 
           339 | 
           								</body>
  | 
        
        
            | 
            | 
           340 | 
           							</html>";
  | 
        
        
            | 
            | 
           341 | 
              | 
        
        
            | 
            | 
           342 | 
           						$header = "From: $from\n";
  | 
        
        
            | 
            | 
           343 | 
           						$header .= "MIME-Version: 1.0\n";
  | 
        
        
            | 
            | 
           344 | 
           						$header .= "Content-type: text/html; charset=utf-8\n";
  | 
        
        
            | 
            | 
           345 | 
           						mail($to, $subject, $message, $header);
  | 
        
        
            | 
            | 
           346 | 
              | 
        
        
            | 
            | 
           347 | 
           					}
  | 
        
        
            | 
            | 
           348 | 
              | 
        
        
            | 
            | 
           349 | 
              | 
        
        
            | 
            | 
           350 | 
           				} else {
  | 
        
        
            | 
            | 
           351 | 
           					//Le mot de passe est généré aléatoirement, si le mail n'est pas envoyé, on supprime le compte de la bdd ou on lui demande d'utiliser la page reset
  | 
        
        
            | 
            | 
           352 | 
           /*					$link = da_sql_pconnect($config);
  | 
        
        
            | 
            | 
           353 | 
              | 
        
        
            | 
            | 
           354 | 
           					$res2 = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           355 | 
           					"DELETE FROM $config[sql_user_info_table] WHERE username = '$login';");
  | 
        
        
            | 
            | 
           356 | 
              | 
        
        
            | 
            | 
           357 | 
           					$res3 = da_sql_query($link,$config,
  | 
        
        
            | 
            | 
           358 | 
           						"DELETE FROM $config[sql_check_table] WHERE username = '$login';");
  | 
        
        
            | 
            | 
           359 | 
              | 
        
        
            | 
            | 
           360 | 
           //					da_sql_close($link,$config)
  | 
        
        
            | 
            | 
           361 | 
           */
  | 
        
        
            | 
            | 
           362 | 
           					echo "<b>Erreur lors de l'envoi du mail, veuillez renouveler votre inscription. Utilisez le formulaire de réinitialisation, ou contactez votre administrateur.</b><br />\n";
  | 
        
        
            | 
            | 
           363 | 
           				}
  | 
        
        
            | 
            | 
           364 | 
           			}
  | 
        
        
            | 
            | 
           365 | 
           			else // Could not open encryption library file
  | 
        
        
            | 
            | 
           366 | 
           				echo "<b>Erreur lors de la création du compte</b><br />\n";
  | 
        
        
            | 
            | 
           367 | 
           		}
  | 
        
        
            | 
            | 
           368 | 
           		else // Could not connect to SQL database
  | 
        
        
            | 
            | 
           369 | 
           			echo "<b>Erreur lors de la création du compte</b><br />\n";
  | 
        
        
            | 
            | 
           370 | 
           	}
  | 
        
        
            | 
            | 
           371 | 
           }
  | 
        
        
            | 
            | 
           372 | 
           ?>
  |