Subversion Repositories ALCASAR

Rev

Rev 768 | Rev 885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 768 Rev 847
Line 24... Line 24...
24
  $l_send = "Envoyer";
24
  $l_send = "Envoyer";
25
  $l_imported_files = "Fichiers des identifiants/mot_de_passe importés durant les dernières 24h :";
25
  $l_imported_files = "Fichiers des identifiants/mot_de_passe importés durant les dernières 24h :";
26
  $l_db_import = "Importer à partir d'une sauvegarde de la base d'usagers (format SQL)";
26
  $l_db_import = "Importer à partir d'une sauvegarde de la base d'usagers (format SQL)";
27
  $l_db_import_help = "Afin de pouvoir imputer les dernière traces de connexion, une sauvegarde de la base actuelle sera automatiquement réalisée.";
27
  $l_db_import_help = "Afin de pouvoir imputer les dernière traces de connexion, une sauvegarde de la base actuelle sera automatiquement réalisée.";
28
  $l_db_reset = "Remise à zéro de la base usagers";
28
  $l_db_reset = "Remise à zéro de la base usagers";
29
  $l_error_ext_txt = "Erreur! Veuillez sélectionner un fichier de type csv ou txt";
29
  $l_error_ext_txt = "Erreur! Veuillez sélectionner un fichier avec l'extension '.csv' ou '.txt'";
30
  $l_error_ext_sql = "Erreur! Veuillez sélectionner un fichier de type sql";
30
  $l_error_ext_sql = "Erreur! Veuillez sélectionner un fichier avec l'extension '.sql'";
31
  $l_group_empty = "La liste des groupes est vide";
31
  $l_group_empty = "La liste des groupes est vide";
-
 
32
  $l_out_title = "   ---  Accès à Internet via ALCASAR  ---  ";
-
 
33
  $l_out_login = "Nom de connexion :";
-
 
34
  $l_out_passwd = "Mot de passe :";
-
 
35
  $l_out_mind = "Pensez à changer votre mot de passe (lien sur la page d'authentification)";
32
}
36
}
33
else {
37
else {
34
  $l_title = "Users import";
38
  $l_title = "Users import";
35
  $l_database_state ="State of the database : number of groups =";
39
  $l_database_state ="State of the database : number of groups =";
36
  $l_number_of_users = "Number of users";
40
  $l_number_of_users = "Number of users";
Line 42... Line 46...
42
  $l_send = "Send";
46
  $l_send = "Send";
43
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
47
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
44
  $l_db_import = "Import from a saved users database file (SQL format)";
48
  $l_db_import = "Import from a saved users database file (SQL format)";
45
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
49
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
46
  $l_db_reset = "Reset the users database";
50
  $l_db_reset = "Reset the users database";
47
  $l_error_ext_txt = "Error! Please select a txt or csv file";
51
  $l_error_ext_txt = "Error! Please select a file with '.txt' or '.csv' extension";
48
  $l_error_ext_sql = "Error! Please select a sql file";
52
  $l_error_ext_sql = "Error! Please select a file with '.sql' extension";
49
  $l_group_empty = "The group list is empty";
53
  $l_group_empty = "The group list is empty";
-
 
54
  $l_out_title = "   ---  Internet access via ALCASAR  ---  ";
-
 
55
  $l_out_login = "Login :";
-
 
56
  $l_out_passwd = "Password :";
-
 
57
  $l_out_mind = "Don't forget to change your password (a link is on the authentication window)";
50
}
58
}
51
function getImportFileList(){
59
function getImportFileList(){
52
	$importFile = array();
60
	$importFile = array();
53
	if ($handle = opendir('/tmp')) {
61
	if ($handle = opendir('/tmp')) {
54
		while (false !== ($file = readdir($handle))) {
62
		while (false !== ($file = readdir($handle))) {
Line 62... Line 70...
62
		}
70
		}
63
		closedir($handle);
71
		closedir($handle);
64
	}
72
	}
65
	return $importFile;
73
	return $importFile;
66
}
74
}
67
function creatlog ($login,$password,$service,$RS_out)
-
 
68
	{
-
 
69
 /* génère un fichier en sortie avec les info de connexion en clair */
-
 
70
	fputs($RS_out,"   ---  Accès à Internet via ALCASAR  ---  "."\r\n\r\n");
-
 
71
	fputs($RS_out,"Service          : $service"."\r\n\r\n");
-
 
72
	fputs($RS_out,"Nom de connexion : $login   |  Mot de passe : $password\r\n\r\n");
-
 
73
	fputs($RS_out,"Pensez à changer votre mot de passe (lien sur la page d'authentification)"."\r\n\r\n");
-
 
74
	fputs($RS_out,"--------------------------------------------------------------------------------"."\r\n\r\n");
-
 
75
	}
-
 
76
function GenPassword($nb_car="8")
75
function GenPassword($nb_car="8")
77
	{
76
	{
78
 /* generation aléatoire du mot de passe */
77
 /* generation aléatoire du mot de passe */
79
	$password = "";
78
	$password = "";
80
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
79
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
Line 136... Line 135...
136
//import d'un fichier txt
135
//import d'un fichier txt
137
		{
136
		{
138
		if (($extension != '.csv') && ($extension != '.txt')) $result = $l_error_ext_txt;
137
		if (($extension != '.csv') && ($extension != '.txt')) $result = $l_error_ext_txt;
139
		else 
138
		else 
140
			{
139
			{
141
			$tmpdate = date("Ymd-hms");
-
 
142
			$file_out = "/tmp/$tmpdate-$name_file.pwd" ;
-
 
143
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
140
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
144
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
141
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
145
			$RS_in   = file ($destination);
142
			$RS_in   = file ($destination);
146
			$da_abort=0;
143
			$da_abort=0;
147
			if ($link)
144
			if ($link)
148
				{
145
				{
149
				if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
146
				if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
150
					{
147
					{
151
					include($LIBpath."crypt/$config[general_encryption_method].php");			
148
					include($LIBpath."crypt/$config[general_encryption_method].php");			
-
 
149
					$tmpdate = date("Ymd-his");
-
 
150
					$file_out = "/tmp/$tmpdate-$name_file.pwd" ;
152
					$RS_out = fopen ("$file_out", "wb");
151
					$RS_out = fopen ("$file_out", "wb");
153
					foreach ($RS_in as $no => $ligne)
152
					foreach ($RS_in as $no => $ligne)
154
						{
153
						{
-
 
154
						if (substr($ligne,0,3) == pack('CCC',239,187,191)) # remove UTF8-BOM 
-
 
155
							{
-
 
156
								$ligne = substr ($ligne,3);
-
 
157
							}
155
						$tligne = split(" ",$ligne);
158
						$tligne = split(" ",$ligne);
156
						$login  = str_replace("%0D","",str_replace("%0A","",urlencode ($tligne[0])));
159
						$login = trim ($tligne[0]);
157
						$password  = str_replace("%0D","",str_replace("%0A","",urlencode ($tligne[1])));
160
						$password = trim ($tligne[1]);
158
						if ($login != '')
161
						if ($login != '')
159
							{
162
							{
160
							if ($password == "")
163
							if ($password == "")
161
								{
164
								{
162
								$password = GenPassword();
165
								$password = GenPassword();
163
								}	
166
								}	
164
							$passwd = da_encrypt($password);
167
							$login = da_sql_escape_string($login);
165
							$passwd = da_sql_escape_string($passwd);
168
							$passwd = da_sql_escape_string($passwd);
-
 
169
							$passwd = da_encrypt($password);
166
/* insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe) */
170
/* insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe) */
167
							$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_check_table] (attribute,value,username $text) VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
171
							$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_check_table] (attribute,value,username $text) VALUES ('$config[sql_password_attribute]','$passwd','$login' $passwd_op);");
168
							if (!$res || !@da_sql_affected_rows($link,$res,$config))
172
							if (!$res || !@da_sql_affected_rows($link,$res,$config))
169
								{
173
								{
170
								echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
174
								echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
171
								$da_abort=1;
175
								$da_abort=1;
172
								}
176
								}
173
							else
177
							else
174
								{
178
								{
-
 
179
/* create the user informations file */
-
 
180
								fputs($RS_out,"$l_out_title\r\n\r\n");
175
								creatlog ($login,$password,$service,$RS_out);
181
								fputs($RS_out,"Service          : $service\r\n\r\n");
-
 
182
								fputs($RS_out,"$l_out_login $login   |   $l_out_passwd $password\r\n\r\n");
176
								/*echo $login." : ".$password." , ";*/
183
								fputs($RS_out,"$l_out_mind\r\n\r\n");
-
 
184
								fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
177
								}	
185
								}	
178
/* insertion de l'usager dans la table "userinfo" */
186
/* insertion de l'usager dans la table "userinfo" */
179
							if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
187
							if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
180
								{
188
								{
181
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
189
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");