Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1507 → Rev 1508

/web/acc/manager/htdocs/import_user.php
7,7 → 7,7
</HEAD>
<body>
<?php
# Choice of language
// Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
74,7 → 74,7
}
function GenPassword($nb_car="8")
{
/* generation aléatoire du mot de passe */
// Random password
$password = "";
$chaine = "aAzZeErRtTyYuUIopP152346897mMLkK";
$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
122,7 → 122,7
{
exec ("sudo /usr/local/sbin/alcasar-mysql.sh --raz");
}
# un fichier est importé
// a file is downloaded
if(isset($_FILES['import-users']) && ($_FILES['import-users']['name'] !=""))
{
unset($result);
130,11 → 130,10
if (isset ($_POST['groupe'])) $group = $_POST ['groupe'];
$destination = '/tmp/import_file.txt';
list($file_name , $extension) = explode("." , $_FILES['import-users']['name']);
$extension = strstr($_FILES['import-users']['name'], '.');
if ($choix == "csv")
//import d'un fichier txt
echo "choix = ".$choix.", service = ".$service.", groupe = ".$group.", file_name = ".$file_name.", extension = ".$extension;
if ($choix == "csv") // import of a txt file
{
if (($extension != '.csv') && ($extension != '.txt')) $result = $l_error_ext_txt;
if (($extension != 'csv') && ($extension != 'txt')) $result = $l_error_ext_txt;
else
{
exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
167,7 → 166,7
$login = da_sql_escape_string($login);
$passwd = da_sql_escape_string($passwd);
$passwd = da_encrypt($password);
/* insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe) */
// insertion (login + password) dans la table "radcheck" (si l'usager existe --> changement de mot de passe)
$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);");
if (!$res || !@da_sql_affected_rows($link,$res,$config))
{
176,7 → 175,7
}
else
{
/* create the user informations file */
// create the user informations file
fputs($RS_out,"$l_out_title\r\n\r\n");
if ($service != "" ) { fputs($RS_out,"Service : $service\r\n\r\n");}
fputs($RS_out,"$l_out_login $login | $l_out_passwd $password\r\n\r\n");
183,7 → 182,7
fputs($RS_out,"$l_out_mind\r\n\r\n");
fputs($RS_out,"--------------------------------------------------------------------------------\r\n\r\n");
}
/* insertion de l'usager dans la table "userinfo" */
// insertion de l'usager dans la table "userinfo"
if ($config[sql_use_user_info_table] == 'true' && !$da_abort)
{
$res = @da_sql_query($link,$config, "SELECT username FROM $config[sql_user_info_table] WHERE username = '$login';");
217,24 → 216,24
} # end if
else
echo "<b>Could not add user to group $group: " . da_sql_error($link,$config) . "</b><br>\n";
} # end if ($group)
} # end if ($config)
} # end if ($login !='')
} # end foreach
} // end if ($group)
} // end if ($config)
} // end if ($login !='')
} // end foreach
fclose($RS_out);
} # end if (is file)
} # end if (link)
} // end if (is file)
} // end if (link)
}
}
else if ($choix == "bdd")
//import d'une Bdd
else if ($choix == "bdd") // database import
{
if ($extension != '.sql') $result = $l_error_ext_sql;
if ($extension != 'sql') $result = $l_error_ext_sql;
else
{
exec ("sudo /usr/local/sbin/alcasar-mysql.sh --dump");
move_uploaded_file($_FILES['import-users']['tmp_name'], $destination);
exec ("sudo /usr/local/sbin/alcasar-mysql.sh --import $destination");
echo "OK : $destination";
}
}
}