| Line 150... |
Line 150... |
| 150 |
$RS_out = fopen ("$file_out", "wb");
|
150 |
$RS_out = fopen ("$file_out", "wb");
|
| 151 |
foreach ($RS_in as $no => $ligne)
|
151 |
foreach ($RS_in as $no => $ligne)
|
| 152 |
{
|
152 |
{
|
| 153 |
$tligne = split(" ",$ligne);
|
153 |
$tligne = split(" ",$ligne);
|
| 154 |
$login = str_replace("%0D","",str_replace("%0A","",urlencode ($tligne[0])));
|
154 |
$login = str_replace("%0D","",str_replace("%0A","",urlencode ($tligne[0])));
|
| 155 |
$password = GenPassword();
|
- |
|
| 156 |
$passwd = da_encrypt($password);
|
- |
|
| 157 |
$passwd = da_sql_escape_string($passwd);
|
- |
|
| 158 |
/* insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe) */
|
- |
|
| 159 |
$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);");
|
- |
|
| 160 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
- |
|
| 161 |
{
|
- |
|
| 162 |
echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
|
- |
|
| 163 |
$da_abort=1;
|
155 |
if ($login != '')
|
| 164 |
}
|
- |
|
| 165 |
else
|
- |
|
| 166 |
{
|
- |
|
| 167 |
creatlog ($login,$password,$service,$RS_out);
|
- |
|
| 168 |
/*echo $login." : ".$password." , ";*/
|
- |
|
| 169 |
}
|
- |
|
| 170 |
/* insertion de l'usager dans la table "userinfo" */
|
- |
|
| 171 |
if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
|
- |
|
| 172 |
{
|
156 |
{
|
| 173 |
$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
|
157 |
$password = GenPassword();
|
| 174 |
if ($res)
|
158 |
$passwd = da_encrypt($password);
|
| 175 |
{
|
159 |
$passwd = da_sql_escape_string($passwd);
|
| - |
|
160 |
/* insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe) */
|
| - |
|
161 |
$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);");
|
| 176 |
if (!@da_sql_num_rows($res,$config))
|
162 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
| 177 |
{
|
163 |
{
|
| 178 |
$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_user_info_table] (username,department) VALUES ('$login','$service');");
|
- |
|
| 179 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
- |
|
| 180 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
164 |
echo "<b>Unable to add user $login: " . da_sql_error($link,$config) . "</b><br>\n";
|
| - |
|
165 |
$da_abort=1;
|
| 181 |
}
|
166 |
}
|
| 182 |
else
|
167 |
else
|
| 183 |
echo "<b>User already exists in user info table.</b><br>\n";
|
- |
|
| 184 |
}
|
- |
|
| 185 |
else
|
- |
|
| 186 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
- |
|
| 187 |
if ($group != '')
|
- |
|
| 188 |
{
|
168 |
{
|
| 189 |
$group = da_sql_escape_string($group);
|
169 |
creatlog ($login,$password,$service,$RS_out);
|
| - |
|
170 |
/*echo $login." : ".$password." , ";*/
|
| - |
|
171 |
}
|
| - |
|
172 |
/* insertion de l'usager dans la table "userinfo" */
|
| - |
|
173 |
if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
|
| - |
|
174 |
{
|
| 190 |
$res = @da_sql_query($link,$config,"SELECT username FROM $config[sql_usergroup_table] WHERE username = '$login' AND groupname = '$group';");
|
175 |
$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
|
| 191 |
if ($res)
|
176 |
if ($res)
|
| - |
|
177 |
{
|
| - |
|
178 |
if (!@da_sql_num_rows($res,$config))
|
| - |
|
179 |
{
|
| - |
|
180 |
$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_user_info_table] (username,department) VALUES ('$login','$service');");
|
| - |
|
181 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
| - |
|
182 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
| - |
|
183 |
}
|
| - |
|
184 |
else
|
| - |
|
185 |
echo "<b>User already exists in user info table.</b><br>\n";
|
| - |
|
186 |
}
|
| - |
|
187 |
else
|
| - |
|
188 |
echo "<b>Could not add user information in user info table: " . da_sql_error($link,$config) . "</b><br>\n";
|
| - |
|
189 |
if ($group != '')
|
| 192 |
{
|
190 |
{
|
| 193 |
if (!@da_sql_num_rows($res,$config))
|
191 |
$group = da_sql_escape_string($group);
|
| - |
|
192 |
$res = @da_sql_query($link,$config,"SELECT username FROM $config[sql_usergroup_table] WHERE username = '$login' AND groupname = '$group';");
|
| - |
|
193 |
if ($res)
|
| 194 |
{
|
194 |
{
|
| - |
|
195 |
if (!@da_sql_num_rows($res,$config))
|
| - |
|
196 |
{
|
| 195 |
$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_usergroup_table] (username,groupname) VALUES ('$login','$group');");
|
197 |
$res = @da_sql_query($link,$config,"INSERT INTO $config[sql_usergroup_table] (username,groupname) VALUES ('$login','$group');");
|
| 196 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
198 |
if (!$res || !@da_sql_affected_rows($link,$res,$config))
|
| 197 |
echo "<b>Could not add user to group $group. SQL Error</b><br>\n";
|
199 |
echo "<b>Could not add user to group $group. SQL Error</b><br>\n";
|
| 198 |
} # end if
|
200 |
} # end if
|
| 199 |
else
|
201 |
else
|
| 200 |
echo "<b>User already is a member of group $group</b><br>\n";
|
202 |
echo "<b>User already is a member of group $group</b><br>\n";
|
| 201 |
} # end if
|
203 |
} # end if
|
| 202 |
else
|
204 |
else
|
| 203 |
echo "<b>Could not add user to group $group: " . da_sql_error($link,$config) . "</b><br>\n";
|
205 |
echo "<b>Could not add user to group $group: " . da_sql_error($link,$config) . "</b><br>\n";
|
| 204 |
} # end if ($group)
|
206 |
} # end if ($group)
|
| 205 |
} # end if ($config)
|
207 |
} # end if ($config)
|
| - |
|
208 |
} # end if ($login !='')
|
| 206 |
} # end foreach
|
209 |
} # end foreach
|
| 207 |
fclose($RS_out);
|
210 |
fclose($RS_out);
|
| 208 |
}
|
211 |
} # end if (is file)
|
| 209 |
} # end if (is_file ...
|
212 |
} # end if (link)
|
| 210 |
}
|
213 |
}
|
| 211 |
}
|
214 |
}
|
| 212 |
else if ($choix == "bdd")
|
215 |
else if ($choix == "bdd")
|
| 213 |
//import d'une Bdd
|
216 |
//import d'une Bdd
|
| 214 |
{
|
217 |
{
|