Subversion Repositories ALCASAR

Rev

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

Rev 411 Rev 534
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";
-
 
30
  $l_error_ext_sql = "Erreur! Veuillez sélectionner un fichier de type sql";
29
}
31
}
30
else {
32
else {
31
  $l_title = "Users import";
33
  $l_title = "Users import";
32
  $l_database_state ="State of the database : number of groups =";
34
  $l_database_state ="State of the database : number of groups =";
33
  $l_number_of_users = "Number of users";
35
  $l_number_of_users = "Number of users";
Line 39... Line 41...
39
  $l_send = "Send";
41
  $l_send = "Send";
40
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
42
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
41
  $l_db_import = "Import from a saved users database file (SQL format)";
43
  $l_db_import = "Import from a saved users database file (SQL format)";
42
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
44
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
43
  $l_db_reset = "Reset the users database";
45
  $l_db_reset = "Reset the users database";
-
 
46
  $l_error_ext_txt = "Error! Please select a txt or csv file";
-
 
47
  $l_error_ext_sql = "Error! Please select a sql file";
44
}
48
}
45
function getImportFileList(){
49
function getImportFileList(){
46
	$importFile = array();
50
	$importFile = array();
47
	if ($handle = opendir('/tmp')) {
51
	if ($handle = opendir('/tmp')) {
48
		while (false !== ($file = readdir($handle))) {
52
		while (false !== ($file = readdir($handle))) {
Line 119... Line 123...
119
	}
123
	}
120
# un fichier est importé
124
# un fichier est importé
121
if(isset($_FILES['import-users']))
125
if(isset($_FILES['import-users']))
122
	{
126
	{
123
	unset($result);
127
	unset($result);
124
	$service = $_POST['service'];
128
	if (isset ($_POST['service'])) $service = $_POST['service'];
125
	$group = $_POST ['groupe'];
129
	if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
126
	$destination = '/tmp/import_file.txt';
130
	$destination = '/tmp/import_file.txt';
127
	list($name_file , $extension) = explode("." , $_FILES['import-users']['name']); 
131
	list($name_file , $extension) = explode("." , $_FILES['import-users']['name']); 
128
	$extension = strstr($_FILES['import-users']['name'], '.');
132
	$extension = strstr($_FILES['import-users']['name'], '.');
129
	$tmpdate = date("Ymd-hms");
-
 
130
	$file_out = "/tmp/$tmpdate-$name_file.pwd" ;
-
 
131
	if ($choix == "csv")
133
	if ($choix == "csv")
132
//import d'un fichier txt
134
//import d'un fichier txt
133
		{
135
		{
134
		if (($extension != '.csv') && ($extension != '.txt')) $result = 'Veuillez sélectionner un fichier de type csv ou txt !';
136
		if (($extension != '.csv') && ($extension != '.txt')) $result = $l_error_ext_txt;
135
		else 
137
		else 
136
			{
138
			{
-
 
139
			$tmpdate = date("Ymd-hms");
-
 
140
			$file_out = "/tmp/$tmpdate-$name_file.pwd" ;
137
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
141
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
138
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
142
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
139
			$RS_in   = file ($destination);
143
			$RS_in   = file ($destination);
140
			$da_abort=0;
144
			$da_abort=0;
141
			if ($link)
145
			if ($link)
Line 206... Line 210...
206
			}
210
			}
207
		}
211
		}
208
	else if ($choix == "bdd")
212
	else if ($choix == "bdd")
209
//import d'une Bdd
213
//import d'une Bdd
210
		{
214
		{
211
		echo $extention;
-
 
212
		if ($extension != '.sql') $result = 'Veuillez sélectionner un fichier de type sql !';
215
		if ($extension != '.sql') $result = $l_error_ext_sql;
213
		else 
216
		else 
214
			{
217
			{
215
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
218
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
216
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
219
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
217
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --import $destination");
220
			exec ("sudo /usr/local/sbin/alcasar-mysql.sh --import $destination");
Line 247... Line 250...
247
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
250
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
248
echo "$l_file (.txt) : <input type=\"file\" name=\"import-users\"><br>";
251
echo "$l_file (.txt) : <input type=\"file\" name=\"import-users\"><br>";
249
echo "$l_users_service : <input type=\"input\" name=\"service\" value=\"\"><br>";
252
echo "$l_users_service : <input type=\"input\" name=\"service\" value=\"\"><br>";
250
echo "$l_users_group : <input type=\"input\" name=\"groupe\" value=\"\"><br>";
253
echo "$l_users_group : <input type=\"input\" name=\"groupe\" value=\"\"><br>";
251
echo "<input type='hidden' name='choix' value='csv'>";
254
echo "<input type='hidden' name='choix' value='csv'>";
252
if (($choix == "csv") && isset($result)) echo $result."<BR>";
255
if (($choix == "csv") && isset($result)) echo "<b>".$result."</b><BR>";
253
echo "<input type=\"submit\" value=\"$l_send\">";
256
echo "<input type=\"submit\" value=\"$l_send\">";
254
echo "</FORM></td>";
257
echo "</FORM></td>";
255
echo "<td>";
258
echo "<td>";
256
$ImportFileList = getImportFileList();
259
$ImportFileList = getImportFileList();
257
if (count($ImportFileList) > 0){
260
if (count($ImportFileList) > 0){
Line 270... Line 273...
270
echo "<H3><CENTER>$l_db_import</CENTER></H3>";
273
echo "<H3><CENTER>$l_db_import</CENTER></H3>";
271
echo "$l_db_import_help <br><br>";
274
echo "$l_db_import_help <br><br>";
272
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
275
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
273
echo "$l_file (.sql) : <input type=\"file\" name=\"import-users\"><br>";
276
echo "$l_file (.sql) : <input type=\"file\" name=\"import-users\"><br>";
274
echo "<input type='hidden' name='choix' value='bdd'>";
277
echo "<input type='hidden' name='choix' value='bdd'>";
275
if (($choix == "bdd") && isset($result)) echo $result."<BR>";
278
if (($choix == "bdd") && isset($result)) echo "<b>".$result."</b><BR>";
276
echo "<input type=\"submit\" value=\"$l_send\">";
279
echo "<input type=\"submit\" value=\"$l_send\">";
277
echo "</FORM>";
280
echo "</FORM>";
278
echo "</td></tr>";
281
echo "</td></tr>";
279
echo "<tr><td valign=\"middle\" align=\"left\">";
282
echo "<tr><td valign=\"middle\" align=\"left\">";
280
echo "<H3><CENTER>$l_db_reset</CENTER></H3>";
283
echo "<H3><CENTER>$l_db_reset</CENTER></H3>";