Subversion Repositories ALCASAR

Rev

Rev 1835 | Rev 2415 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 1835 Rev 2414
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
<HTML><!-- Written by Rexy, Romero P. & 3abTux -->
2
<HTML><!-- Written by Rexy, Romero P. & 3abTux -->
3
<HEAD>
3
<HEAD>
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
<TITLE>Users import</TITLE>
5
<TITLE>Users import</TITLE>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
7
</HEAD>
7
</HEAD>
8
<body>
8
<body>
9
<?php
9
<?php
10
// Choice of language
10
// Choice of language
11
$Language = 'en';
11
$Language = 'en';
12
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
12
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
13
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
13
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
14
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
15
if($Language == 'fr'){
15
if($Language == 'fr'){
16
  $l_title = "Importer et vider la base des usagers";
16
  $l_title = "Importer et vider la base des usagers";
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";
19
  $l_text_import = "Importer à partir d'un fichier texte";
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_group = "Définissez leur groupe (conseillé)";
22
  $l_users_group = "Définissez leur groupe (conseillé)";
23
  $l_send = "Importer";
23
  $l_send = "Importer";
24
  $l_empty = "Vider";
24
  $l_empty = "Vider";
25
  $l_empty_warn = "Vous êtes sur le point de vider entièrement la base de donnée des utilisateurs... Souhaitez vous continuer?";
25
  $l_empty_warn = "Vous êtes sur le point de vider entièrement la base de donnée des utilisateurs... Souhaitez vous continuer?";
26
  $l_imported_files = "Fichiers des identifiants/mot_de_passe import&eacute;s durant les derni&egrave;res 24h :";
26
  $l_imported_files = "Fichiers des identifiants/mot_de_passe import&eacute;s durant les derni&egrave;res 24h :";
27
  $l_db_import = "Importer à partir d'une sauvegarde de la base d'usagers";
27
  $l_db_import = "Importer à partir d'une sauvegarde de la base d'usagers";
28
  $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.";
28
  $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.";
29
  $l_db_reset = "Vider la base des usagers";
29
  $l_db_reset = "Vider la base des usagers";
30
  $l_error_ext_txt = "Erreur! Veuillez sélectionner un fichier avec l'extension '.csv' ou '.txt'";
30
  $l_error_ext_txt = "Erreur! Veuillez sélectionner un fichier avec l'extension '.csv' ou '.txt'";
31
  $l_error_ext_sql = "Erreur! Veuillez sélectionner un fichier avec l'extension '.sql' ou '.sql.gz'";
31
  $l_error_ext_sql = "Erreur! Veuillez sélectionner un fichier avec l'extension '.sql' ou '.sql.gz'";
32
  $l_group_empty = "La liste des groupes est vide";
32
  $l_group_empty = "La liste des groupes est vide";
33
  $l_out_title = "   ---  Accès à Internet via ALCASAR  ---  ";
33
  $l_out_title = "   ---  Accès à Internet via ALCASAR  ---  ";
34
  $l_out_login = "Nom de connexion :";
34
  $l_out_login = "Nom de connexion :";
35
  $l_out_passwd = "Mot de passe :";
35
  $l_out_passwd = "Mot de passe :";
36
  $l_out_mind = "Pensez à changer votre mot de passe (lien sur la page d'authentification)";
36
  $l_out_mind = "Pensez à changer votre mot de passe (lien sur la page d'authentification)";
37
}
37
}
38
else {
38
else {
39
  $l_title = "Import and empty the users database";
39
  $l_title = "Import and empty the users database";
40
  $l_database_state ="State of the database : number of groups =";
40
  $l_database_state ="State of the database : number of groups =";
41
  $l_number_of_users = "Number of users";
41
  $l_number_of_users = "Number of users";
42
  $l_text_import = "Import from a text file";
42
  $l_text_import = "Import from a text file";
43
  $l_text_import_help = "In this file, you must write only the user login one below the other.";
43
  $l_text_import_help = "In this file, you must write only the user login one below the other.";
44
  $l_file = "File";
44
  $l_file = "File";
45
  $l_users_group = "Define their group (advisable)";
45
  $l_users_group = "Define their group (advisable)";
46
  $l_send = "Import";
46
  $l_send = "Import";
47
  $l_empty = "Empty";
47
  $l_empty = "Empty";
48
  $l_empty_warn = "You are close to empty the whole user database... Would you like to proceed?";
48
  $l_empty_warn = "You are close to empty the whole user database... Would you like to proceed?";
49
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
49
  $l_imported_files = "Logins/passwords file imported during the last 24h :";
50
  $l_db_import = "Import from a saved users database file";
50
  $l_db_import = "Import from a saved users database file";
51
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
51
  $l_db_import_help = "In order to impute the last connections, the actual users database will be automaticly saved.";
52
  $l_db_reset = "Empty the users database";
52
  $l_db_reset = "Empty the users database";
53
  $l_error_ext_txt = "Error! Please select a file with '.txt' or '.csv' extension";
53
  $l_error_ext_txt = "Error! Please select a file with '.txt' or '.csv' extension";
54
  $l_error_ext_sql = "Error! Please select a file with '.sql' or '.sql.gz' extension";
54
  $l_error_ext_sql = "Error! Please select a file with '.sql' or '.sql.gz' extension";
55
  $l_group_empty = "The group list is empty";
55
  $l_group_empty = "The group list is empty";
56
  $l_out_title = "   ---  Internet access via ALCASAR  ---  ";
56
  $l_out_title = "   ---  Internet access via ALCASAR  ---  ";
57
  $l_out_login = "Login :";
57
  $l_out_login = "Login :";
58
  $l_out_passwd = "Password :";
58
  $l_out_passwd = "Password :";
59
  $l_out_mind = "Don't forget to change your password (a link is on the authentication window)";
59
  $l_out_mind = "Don't forget to change your password (a link is on the authentication window)";
60
}
60
}
-
 
61
 
-
 
62
require('/etc/freeradius-web/config.php');
-
 
63
 
61
function getImportFileList(){
64
function getImportFileList(){
62
	$importFile = array();
65
	$importFile = array();
63
	if ($handle = opendir('/tmp')) {
66
	if ($handle = opendir('/tmp')) {
64
		while (false !== ($file = readdir($handle))) {
67
		while (false !== ($file = readdir($handle))) {
65
			if ($file != "." && $file != "..") {
68
			if ($file != "." && $file != "..") {
66
				$ext = pathinfo($file ,PATHINFO_EXTENSION);
69
				$ext = pathinfo($file ,PATHINFO_EXTENSION);
67
				$name = substr($file, 0, -(strlen($ext)+1)); //Retirer les lettres de l'extension ET le point
70
				$name = substr($file, 0, -(strlen($ext)+1)); //Retirer les lettres de l'extension ET le point
68
				if ($ext=="pwd"){
71
				if ($ext=="pwd"){
69
				$importFile[] = $name;
72
				$importFile[] = $name;
70
				}
73
				}
71
			}
74
			}
72
		}
75
		}
73
		closedir($handle);
76
		closedir($handle);
74
	}
77
	}
75
	return $importFile;
78
	return $importFile;
76
}
79
}
-
 
80
 
77
function GenPassword($nb_car="8")
81
function GenPassword($nb_car="8")
78
	{
82
{
79
// Random password
83
// Random password
80
	$password = "";
84
	$password = "";
81
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
85
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
82
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
86
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
83
	while($nb_car != 0)
87
	while($nb_car != 0) {
84
		{
-
 
85
		$i = rand(0,71);
88
		$i = rand(0,71);
86
		$password .= $chaine[$i];
89
		$password .= $chaine[$i];
87
		$nb_car --;
90
		$nb_car--;
88
		}
91
	}
89
	return $password ;
92
	return $password;
90
	}
93
}
-
 
94
 
-
 
95
function freeradiusweb_removeDisallowedChars($login)
-
 
96
{
-
 
97
	if ($login != '')
-
 
98
	{
-
 
99
		$accent = "âêôûéàèùîáâãäçèéêëìíîïñòóôõöùúûü";
-
 
100
		$login = preg_replace("/[^\w$accent\.\/\@\:\-]/",'',$login);
-
 
101
	}
-
 
102
	if ($login != '' && $config['general_strip_realms'] == 'yes'){
-
 
103
		$realm_del = ($config['general_realm_delimiter'] != '') ? $config['general_realm_delimiter'] : '@';
-
 
104
		$realm_for = ($config['general_realm_format'] != '') ? $config['general_realm_format'] : 'suffix';
-
 
105
		$new = explode($realm_del,$login,2);
-
 
106
		if (count($new) == 2)
-
 
107
			$login = ($realm_for == 'suffix') ? $new[0] : $new[1];
-
 
108
	}
-
 
109
 
-
 
110
	return $login;
-
 
111
}
-
 
112
 
91
?>
113
?>
92
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
114
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
93
<tr><th><? echo "$l_title"; ?></th></tr>
115
<tr><th><? echo "$l_title"; ?></th></tr>
94
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
116
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
95
</TABLE>
117
</TABLE>
96
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
118
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
97
<tr><td valign="middle" align="left">
119
<tr><td valign="middle" align="left">
98
<CENTER><H3> 
120
<CENTER><H3> 
99
<?php
121
<?php
100
echo "$l_database_state";
122
echo "$l_database_state";
101
 
123
 
102
$LIBpath = "../lib/";
124
$LIBpath = "../lib/";
103
require('/etc/freeradius-web/config.php');
-
 
104
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
125
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
105
	{
126
	{
106
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
127
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
107
	}
128
	}
108
else
129
else
109
	{
130
	{
110
	echo "<b>Could not include SQL library</b><br>\n";
131
	echo "<b>Could not include SQL library</b><br>\n";
111
	exit();
132
	exit();
112
	}
133
	}
113
include_once($LIBpath.'functions.php');
134
include_once($LIBpath.'functions.php');
114
if ($config['sql_use_operators'] == 'true')
135
if ($config['sql_use_operators'] == 'true')
115
	{
136
	{
116
	include($LIBpath."operators.php");
137
	include($LIBpath."operators.php");
117
	$text = ',op';
138
	$text = ',op';
118
	$passwd_op = ",':='";
139
	$passwd_op = ",':='";
119
	}
140
	}
120
$link = @da_sql_pconnect($config);
141
$link = @da_sql_pconnect($config);
121
if (isset ($_POST ['choix'])) {	$choix = $_POST ['choix']; }
142
if (isset ($_POST ['choix'])) {	$choix = $_POST ['choix']; }
122
	else { $choix = ''; }
143
	else { $choix = ''; }
123
if ($choix == "raz")
144
if ($choix == "raz")
124
	{
145
	{
125
	exec ("sudo /usr/local/bin/alcasar-logout.sh all");
146
	exec ("sudo /usr/local/bin/alcasar-logout.sh all");
126
	exec ("sudo /usr/local/bin/alcasar-mysql.sh --raz");
147
	exec ("sudo /usr/local/bin/alcasar-mysql.sh --raz");
127
	}
148
	}
128
// a file is downloaded
149
// a file is downloaded
129
if(isset($_FILES['import-users']) && ($_FILES['import-users']['name'] !=""))
150
if(isset($_FILES['import-users']) && ($_FILES['import-users']['name'] !=""))
130
	{
151
	{
131
	unset($result);
152
	unset($result);
132
	if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
153
	if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
133
	list($file_name , $extension) = explode("." , $_FILES['import-users']['name'] , 2); 
154
	list($file_name , $extension) = explode("." , $_FILES['import-users']['name'] , 2); 
134
	if ($choix == "csv") // import of a txt file
155
	if ($choix == "csv") // import of a txt file
135
		{
156
		{
136
		if (($extension != 'csv') && ($extension != 'txt')) $result = $l_error_ext_txt;
157
		if (($extension != 'csv') && ($extension != 'txt')) $result = $l_error_ext_txt;
137
		else 
158
		else 
138
			{
159
			{
139
			$destination = '/tmp/import_file.txt';
160
			$destination = '/tmp/import_file.txt';
140
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --dump");
161
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --dump");
141
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
162
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
142
			$RS_in   = file ($destination);
163
			$RS_in   = file ($destination);
143
			$da_abort=0;
164
			$da_abort=0;
144
			if ($link)
165
			if ($link)
145
				{
166
				{
146
				if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
167
				if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
147
					{
168
					{
148
					include($LIBpath."crypt/$config[general_encryption_method].php");			
169
					include($LIBpath."crypt/$config[general_encryption_method].php");			
149
					$tmpdate = date("Ymd-his");
170
					$tmpdate = date("Ymd-his");
150
					$file_out = "/tmp/$tmpdate-$file_name.pwd" ;
171
					$file_out = "/tmp/$tmpdate-$file_name.pwd" ;
151
					$RS_out = fopen ("$file_out", "wb");
172
					$RS_out = fopen ("$file_out", "wb");
152
					foreach ($RS_in as $no => $ligne)
173
					foreach ($RS_in as $no => $ligne)
153
						{
174
						{
154
						if (substr($ligne,0,3) == pack('CCC',239,187,191)) # remove UTF8-BOM 
175
						if (substr($ligne,0,3) == pack('CCC',239,187,191)) # remove UTF8-BOM 
155
							{
176
							{
156
								$ligne = substr ($ligne,3);
177
								$ligne = substr ($ligne,3);
157
							}
178
							}
158
						$tligne = split(" ",$ligne);
179
						$tligne = split(" ",$ligne);
159
						$login = trim ($tligne[0]);
180
						$login = trim ($tligne[0]);
160
						$password = trim ($tligne[1]);
181
						$password = trim ($tligne[1]);
161
						if ($login != '')
182
						if ($login != '')
162
							{
183
							{
163
							if ($password == "")
184
							if ($password == "")
164
								{
185
								{
165
								$password = GenPassword();
186
								$password = GenPassword();
166
								}	
187
								}
-
 
188
							$login = freeradiusweb_removeDisallowedChars($login);
167
							$login = da_sql_escape_string($link,$login);
189
							$login = da_sql_escape_string($link,$login);
168
							$passwd = da_sql_escape_string($link,$passwd);
190
							$passwd = da_sql_escape_string($link,$passwd);
169
							$passwd = da_encrypt($password);
191
							$passwd = da_encrypt($password);
170
// insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe)
192
// insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe)
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);");
193
							$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);");
172
							if (!$res || !@da_sql_affected_rows($link,$res,$config))
194
							if (!$res || !@da_sql_affected_rows($link,$res,$config))
173
								{
195
								{
174
								echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
196
								echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
175
								$da_abort=1;
197
								$da_abort=1;
176
								}
198
								}
177
							else
199
							else
178
								{
200
								{
179
// create the user informations file
201
// create the user informations file
180
								fputs($RS_out,"$l_out_title\r\n\r\n");
202
								fputs($RS_out,"$l_out_title\r\n\r\n");
181
								fputs($RS_out,"$l_out_login $login   |   $l_out_passwd $password\r\n\r\n");
203
								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");
204
								fputs($RS_out,"$l_out_mind\r\n\r\n");
183
								fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
205
								fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
184
								}	
206
								}	
185
// insertion de l'usager dans la table "userinfo"
207
// insertion de l'usager dans la table "userinfo"
186
							if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
208
							if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
187
								{
209
								{
188
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
210
							$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
189
							if ($res)
211
							if ($res)
190
								{
212
								{
191
								if (!@da_sql_num_rows($res,$config))
213
								if (!@da_sql_num_rows($res,$config))
192
									{
214
									{
193
									$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_user_info_table] (username) VALUES ('$login');");
215
									$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))
216
									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";
217
										echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
196
									}	
218
									}	
197
								else
219
								else
198
									echo "<b>User already exists in user info table.</b><br>\n";
220
									echo "<b>User already exists in user info table.</b><br>\n";
199
								}
221
								}
200
							else
222
							else
201
								echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
223
								echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
202
								if ($group != '')
224
								if ($group != '')
203
									{
225
									{
204
									$group = da_sql_escape_string($link,$group);
226
									$group = da_sql_escape_string($link,$group);
205
									$res = @da_sql_query($link,$config,"SELECT username FROM $config[sql_usergroup_table] WHERE username = '$login' AND groupname = '$group';");
227
									$res = @da_sql_query($link,$config,"SELECT username FROM $config[sql_usergroup_table] WHERE username = '$login' AND groupname = '$group';");
206
									if ($res)
228
									if ($res)
207
										{
229
										{
208
										if (!@da_sql_num_rows($res,$config))
230
										if (!@da_sql_num_rows($res,$config))
209
											{
231
											{
210
											$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_usergroup_table] (username,groupname) VALUES ('$login','$group');");
232
											$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_usergroup_table] (username,groupname) VALUES ('$login','$group');");
211
											if (!$res || !@da_sql_affected_rows($link,$res,$config))
233
											if (!$res || !@da_sql_affected_rows($link,$res,$config))
212
												echo "<b>Could not add user to group $group. SQL Error</b><br>\n";
234
												echo "<b>Could not add user to group $group. SQL Error</b><br>\n";
213
											} # end if 
235
											} # end if 
214
										else
236
										else
215
											echo "<b>User already is a member of group $group</b><br>\n";
237
											echo "<b>User already is a member of group $group</b><br>\n";
216
										} # end if
238
										} # end if
217
									else
239
									else
218
										echo "<b>Could not add user to group $group: " . da_sql_error($link,$config) . "</b><br>\n";
240
										echo "<b>Could not add user to group $group: " . da_sql_error($link,$config) . "</b><br>\n";
219
									} // end if ($group)
241
									} // end if ($group)
220
						 		} // end if ($config)		
242
						 		} // end if ($config)		
221
							} // end if ($login !='')
243
							} // end if ($login !='')
222
						} // end foreach
244
						} // end foreach
223
					fclose($RS_out);
245
					fclose($RS_out);
224
					} // end if (is file)
246
					} // end if (is file)
225
				} // end if (link)
247
				} // end if (link)
226
			unlink ($destination);
248
			unlink ($destination);
227
			} // end if (extension = (txt or cvs))
249
			} // end if (extension = (txt or cvs))
228
		}
250
		}
229
	else if ($choix == "bdd") // database import
251
	else if ($choix == "bdd") // database import
230
		{
252
		{
231
		if (($extension == 'sql') || ($extension == 'sql.gz')) 
253
		if (($extension == 'sql') || ($extension == 'sql.gz')) 
232
			{
254
			{
233
			$destination = '/tmp/import_file.'.$extension;
255
			$destination = '/tmp/import_file.'.$extension;
234
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --dump");
256
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --dump");
235
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
257
			move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
236
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --import $destination");
258
			exec ("sudo /usr/local/bin/alcasar-mysql.sh --import $destination");
237
			//echo "OK : $destination";
259
			//echo "OK : $destination";
238
			unlink ($destination);
260
			unlink ($destination);
239
			}
261
			}
240
		else $result = $l_error_ext_sql;
262
		else $result = $l_error_ext_sql;
241
		}
263
		}
242
	}
264
	}
243
if ($link)
265
if ($link)
244
	{
266
	{
245
	$res = @da_sql_query($link,$config,"SELECT GroupName FROM radusergroup GROUP BY GroupName");
267
	$res = @da_sql_query($link,$config,"SELECT GroupName FROM radusergroup GROUP BY GroupName");
246
	if ($res)
268
	if ($res)
247
		{
269
		{
248
		$nb_group = @da_sql_num_rows($res,$config);
270
		$nb_group = @da_sql_num_rows($res,$config);
249
		echo $nb_group;
271
		echo $nb_group;
250
		}
272
		}
251
	}
273
	}
252
echo ", $l_number_of_users = ";
274
echo ", $l_number_of_users = ";
253
if ($link)
275
if ($link)
254
	{
276
	{
255
	$res = @da_sql_query($link,$config,"SELECT UserName FROM userinfo");
277
	$res = @da_sql_query($link,$config,"SELECT UserName FROM userinfo");
256
	if ($res)
278
	if ($res)
257
		{
279
		{
258
		$nb_user = @da_sql_num_rows($res,$config);
280
		$nb_user = @da_sql_num_rows($res,$config);
259
		echo "$nb_user";
281
		echo "$nb_user";
260
		}
282
		}
261
	}
283
	}
262
echo "</td></tr><tr><td>";
284
echo "</td></tr><tr><td>";
263
echo "<TABLE width=\"100%\" border=0 cellspacing=0 cellpadding=1>";
285
echo "<TABLE width=\"100%\" border=0 cellspacing=0 cellpadding=1>";
264
echo "<tr><td valign=\"middle\" align=\"left\" colspan=\"2\">";
286
echo "<tr><td valign=\"middle\" align=\"left\" colspan=\"2\">";
265
echo "<CENTER><H3>$l_text_import</H3></CENTER></td></tr>";
287
echo "<CENTER><H3>$l_text_import</H3></CENTER></td></tr>";
266
echo "<tr><td valign=\"middle\" align=\"left\">";
288
echo "<tr><td valign=\"middle\" align=\"left\">";
267
echo "$l_text_import_help<br>";
289
echo "$l_text_import_help<br>";
268
echo "<tr><td valign=\"middle\" align=\"left\">";
290
echo "<tr><td valign=\"middle\" align=\"left\">";
269
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
291
echo "<br><FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
270
echo "$l_file (.txt or .csv) : <input type=\"file\" name=\"import-users\"><br>";
292
echo "$l_file (.txt or .csv) : <input type=\"file\" name=\"import-users\"><br>";
271
echo "$l_users_group : ";
293
echo "$l_users_group : ";
272
require("../lib/defaults.php");
294
require("../lib/defaults.php");
273
include_once("../lib/$config[general_lib_type]/group_info.php");
295
include_once("../lib/$config[general_lib_type]/group_info.php");
274
if (isset($existing_groups)){
296
if (isset($existing_groups)){
275
	echo "<select name=\"groupe\">";
297
	echo "<select name=\"groupe\">";
276
	echo "<option value=\"\" selected>";
298
	echo "<option value=\"\" selected>";
277
	foreach ($member_groups as $group)
299
	foreach ($member_groups as $group)
278
		echo "<option value=\"$group\">$group\n";
300
		echo "<option value=\"$group\">$group\n";
279
	echo " </select>";
301
	echo " </select>";
280
	}
302
	}
281
else echo "$l_group_empty";
303
else echo "$l_group_empty";
282
echo "<br>";
304
echo "<br>";
283
echo "<input type='hidden' name='choix' value='csv'>";
305
echo "<input type='hidden' name='choix' value='csv'>";
284
if (($choix == "csv") && isset($result)) echo "<b>".$result."</b><BR>";
306
if (($choix == "csv") && isset($result)) echo "<b>".$result."</b><BR>";
285
echo "<input type=\"submit\" value=\"$l_send\">";
307
echo "<input type=\"submit\" value=\"$l_send\">";
286
echo "</FORM></td>";
308
echo "</FORM></td>";
287
echo "<td>";
309
echo "<td>";
288
$ImportFileList = getImportFileList();
310
$ImportFileList = getImportFileList();
289
if (count($ImportFileList) > 0){
311
if (count($ImportFileList) > 0){
290
	echo "$l_imported_files";
312
	echo "$l_imported_files";
291
	echo "<ul>";
313
	echo "<ul>";
292
	foreach ( $ImportFileList as $ImportFile ) //on parcours le tableau 
314
	foreach ( $ImportFileList as $ImportFile ) //on parcours le tableau 
293
	{
315
	{
294
	echo "<li>".$ImportFile." ( <a href=\"import_file.php?file=$ImportFile\">txt</a> - <a href=\"import_file.php?file=$ImportFile&format=pdf\">pdf</a> )</li>";
316
	echo "<li>".$ImportFile." ( <a href=\"import_file.php?file=$ImportFile\">txt</a> - <a href=\"import_file.php?file=$ImportFile&format=pdf\">pdf</a> )</li>";
295
	} 
317
	} 
296
	echo "</ul>";
318
	echo "</ul>";
297
} else {
319
} else {
298
	echo "<br>";
320
	echo "<br>";
299
}
321
}
300
echo "</td></tr></table>";
322
echo "</td></tr></table>";
301
echo "<tr><td valign=\"middle\" align=\"left\">";
323
echo "<tr><td valign=\"middle\" align=\"left\">";
302
echo "<H3><CENTER>$l_db_import</CENTER></H3>";
324
echo "<H3><CENTER>$l_db_import</CENTER></H3>";
303
echo "$l_db_import_help <br><br>";
325
echo "$l_db_import_help <br><br>";
304
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
326
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST ENCTYPE=\"multipart/form-data\">";
305
echo "$l_file (.sql or .sql.gz) : <input type=\"file\" name=\"import-users\"><br>";
327
echo "$l_file (.sql or .sql.gz) : <input type=\"file\" name=\"import-users\"><br>";
306
echo "<input type='hidden' name='choix' value='bdd'>";
328
echo "<input type='hidden' name='choix' value='bdd'>";
307
if (($choix == "bdd") && isset($result)) echo "<b>".$result."</b><BR>";
329
if (($choix == "bdd") && isset($result)) echo "<b>".$result."</b><BR>";
308
echo "<input type=\"submit\" value=\"$l_send\">";
330
echo "<input type=\"submit\" value=\"$l_send\">";
309
echo "</FORM>";
331
echo "</FORM>";
310
echo "</td></tr>";
332
echo "</td></tr>";
311
echo "<tr><td valign=\"middle\" align=\"left\">";
333
echo "<tr><td valign=\"middle\" align=\"left\">";
312
echo "<H3><CENTER>$l_db_reset</CENTER></H3>";
334
echo "<H3><CENTER>$l_db_reset</CENTER></H3>";
313
echo "$l_db_import_help<br><br>";
335
echo "$l_db_import_help<br><br>";
314
echo "<FORM onsubmit=\"return confirm('$l_empty_warn');\" action='$_SERVER[PHP_SELF]' method=POST>";
336
echo "<FORM onsubmit=\"return confirm('$l_empty_warn');\" action='$_SERVER[PHP_SELF]' method=POST>";
315
echo "<input type='hidden' name='choix' value='raz'>";
337
echo "<input type='hidden' name='choix' value='raz'>";
316
echo "<input type=\"submit\" value=\"$l_empty\">";
338
echo "<input type=\"submit\" value=\"$l_empty\">";
317
echo "</FORM>";
339
echo "</FORM>";
318
echo "</TD></TR></TABLE>";
340
echo "</TD></TR></TABLE>";
319
?>
341
?>
320
</BODY>
342
</BODY>
321
</HTML>
343
</HTML>
322
 
344