Subversion Repositories ALCASAR

Rev

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

Rev 1508 Rev 1561
Line 17... Line 17...
17
  $l_database_state = "État actuel de la base : nombre de groupes =";
17
  $l_database_state = "État actuel de la base : nombre de groupes =";
18
  $l_number_of_users = "Nombre d'usagers";
18
  $l_number_of_users = "Nombre d'usagers";
19
  $l_text_import = "Importer à partir d'un fichier texte ('.txt')";
19
  $l_text_import = "Importer à partir d'un fichier texte ('.txt')";
20
  $l_text_import_help = "Ce fichier ne doit contenir que des noms d'usagers écrits les uns sous les autres.";
20
  $l_text_import_help = "Ce fichier ne doit contenir que des noms d'usagers écrits les uns sous les autres.";
21
  $l_file = "Fichier";
21
  $l_file = "Fichier";
22
  $l_users_service = "Définissez leur service (facultatif)";
-
 
23
  $l_users_group = "Définissez leur groupe (conseillé)";
22
  $l_users_group = "Définissez leur groupe (conseillé)";
24
  $l_send = "Envoyer";
23
  $l_send = "Envoyer";
25
  $l_imported_files = "Fichiers des identifiants/mot_de_passe importés durant les dernières 24h :";
24
  $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)";
25
  $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ères traces de connexion, une sauvegarde de la base actuelle sera automatiquement réalisée.";
26
  $l_db_import_help = "Afin de pouvoir imputer les dernières traces de connexion, une sauvegarde de la base actuelle sera automatiquement réalisée.";
Line 39... Line 38...
39
  $l_database_state ="State of the database : number of groups =";
38
  $l_database_state ="State of the database : number of groups =";
40
  $l_number_of_users = "Number of users";
39
  $l_number_of_users = "Number of users";
41
  $l_text_import = "Import from a text file ('.txt')";
40
  $l_text_import = "Import from a text file ('.txt')";
42
  $l_text_import_help = "In this file, you must write only the user login one below the other.";
41
  $l_text_import_help = "In this file, you must write only the user login one below the other.";
43
  $l_file = "File";
42
  $l_file = "File";
44
  $l_users_service = "Define their service (optional)";
-
 
45
  $l_users_group = "Define their group (advisable)";
43
  $l_users_group = "Define their group (advisable)";
46
  $l_send = "Send";
44
  $l_send = "Send";
47
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
45
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
48
  $l_db_import = "Import from a saved users database file (SQL format)";
46
  $l_db_import = "Import from a saved users database file (SQL format)";
49
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
47
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
Line 118... Line 116...
118
$link = @da_sql_pconnect($config);
116
$link = @da_sql_pconnect($config);
119
if (isset ($_POST ['choix'])) {	$choix = $_POST ['choix']; }
117
if (isset ($_POST ['choix'])) {	$choix = $_POST ['choix']; }
120
	else { $choix = ''; }
118
	else { $choix = ''; }
121
if ($choix == "raz")
119
if ($choix == "raz")
122
	{
120
	{
-
 
121
	exec ("sudo /usr/local/sbin/alcasar-logout.sh all");
123
	exec ("sudo /usr/local/sbin/alcasar-mysql.sh --raz");
122
	exec ("sudo /usr/local/sbin/alcasar-mysql.sh --raz");
124
	}
123
	}
125
// a file is downloaded
124
// a file is downloaded
126
if(isset($_FILES['import-users']) && ($_FILES['import-users']['name'] !=""))
125
if(isset($_FILES['import-users']) && ($_FILES['import-users']['name'] !=""))
127
	{
126
	{
128
	unset($result);
127
	unset($result);
129
	if (isset ($_POST['service'])) $service = $_POST['service'];
-
 
130
	if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
128
	if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
131
	$destination = '/tmp/import_file.txt';
129
	$destination = '/tmp/import_file.txt';
132
	list($file_name , $extension) = explode("." , $_FILES['import-users']['name']); 
130
	list($file_name , $extension) = explode("." , $_FILES['import-users']['name']); 
133
	echo "choix = ".$choix.", service = ".$service.", groupe = ".$group.", file_name = ".$file_name.", extension = ".$extension;
-
 
134
	if ($choix == "csv") // import of a txt file
131
	if ($choix == "csv") // import of a txt file
135
		{
132
		{
136
		if (($extension != 'csv') && ($extension != 'txt')) $result = $l_error_ext_txt;
133
		if (($extension != 'csv') && ($extension != 'txt')) $result = $l_error_ext_txt;
137
		else 
134
		else 
138
			{
135
			{
Line 175... Line 172...
175
								}
172
								}
176
							else
173
							else
177
								{
174
								{
178
// create the user informations file
175
// create the user informations file
179
								fputs($RS_out,"$l_out_title\r\n\r\n");
176
								fputs($RS_out,"$l_out_title\r\n\r\n");
180
								if ($service != "" ) { fputs($RS_out,"Service          : $service\r\n\r\n");}
-
 
181
								fputs($RS_out,"$l_out_login $login   |   $l_out_passwd $password\r\n\r\n");
177
								fputs($RS_out,"$l_out_login $login   |   $l_out_passwd $password\r\n\r\n");
182
								fputs($RS_out,"$l_out_mind\r\n\r\n");
178
								fputs($RS_out,"$l_out_mind\r\n\r\n");
183
								fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
179
								fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
184
								}	
180
								}	
185
// insertion de l'usager dans la table "userinfo"
181
// insertion de l'usager dans la table "userinfo"
Line 188... Line 184...
188
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
184
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
189
							if ($res)
185
							if ($res)
190
								{
186
								{
191
								if (!@da_sql_num_rows($res,$config))
187
								if (!@da_sql_num_rows($res,$config))
192
									{
188
									{
193
									$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_user_info_table] (username,department) VALUES ('$login','$service');");
189
									$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_user_info_table] (username) VALUES ('$login');");
194
									if (!$res || !@da_sql_affected_rows($link,$res,$config))
190
									if (!$res || !@da_sql_affected_rows($link,$res,$config))
195
										echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
191
										echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
196
									}	
192
									}	
197
								else
193
								else
198
									echo "<b>User already exists in user info table.</b><br>\n";
194
									echo "<b>User already exists in user info table.</b><br>\n";
Line 263... Line 259...
263
echo "<tr><td valign=\"middle\" align=\"left\">";
259
echo "<tr><td valign=\"middle\" align=\"left\">";
264
echo "$l_text_import_help<br>";
260
echo "$l_text_import_help<br>";
265
echo "<tr><td valign=\"middle\" align=\"left\">";
261
echo "<tr><td valign=\"middle\" align=\"left\">";
266
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
262
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
267
echo "$l_file (.txt) : <input type=\"file\" name=\"import-users\"><br>";
263
echo "$l_file (.txt) : <input type=\"file\" name=\"import-users\"><br>";
268
echo "$l_users_service : <input type=\"input\" name=\"service\" value=\"\"><br>";
-
 
269
echo "$l_users_group : ";
264
echo "$l_users_group : ";
270
require("../lib/defaults.php");
265
require("../lib/defaults.php");
271
include_once("../lib/$config[general_lib_type]/group_info.php");
266
include_once("../lib/$config[general_lib_type]/group_info.php");
272
if (isset($existing_groups)){
267
if (isset($existing_groups)){
273
	echo "<select name=\"groupe\">";
268
	echo "<select name=\"groupe\">";