21 require_once(
"$MODDIR/lib/php/common-cli.php");
23 require_once(
"$MODDIR/lib/php/common-users.php");
25 error_reporting(E_ALL);
27 $usage =
"Usage: " . basename($argv[0]) .
" [options] 28 --username = admin/user with license-admin permissions 30 --delimiter = delimiter, default is ',' 31 --enclosure = enclosure, default is '\"' 32 --csv = csv file to import 34 $opts = getopt(
"h", array(
'username:',
'password:',
'delimiter:',
'enclosure:',
"csv:"));
36 if (array_key_exists(
'h',$opts)) {
41 if (!array_key_exists(
'csv',$opts)) {
42 print
"no input file given\n";
46 $filename = $opts[
'csv'];
49 $username = array_key_exists(
"username", $opts) ? $opts[
"username"] : null;
50 $passwd = array_key_exists(
"password", $opts) ? $opts[
"password"] : null;
52 $delimiter = array_key_exists(
"delimiter", $opts) ? $opts[
"delimiter"] :
',';
53 $enclosure = array_key_exists(
"enclosure", $opts) ? $opts[
"enclosure"] :
'"';
56 print
"Fossology login failure\n";
59 print
"Logged in as user $username\n";
63 $userDao = $GLOBALS[
'container']->get(
"dao.user");
64 $adminRow = $userDao->getUserByName($username);
66 print
"You have no permission to admin the licenses\n";
72 $licenseCsvImport = $GLOBALS[
'container']->get(
'app.license_csv_import');
73 $licenseCsvImport->setDelimiter($delimiter);
74 $licenseCsvImport->setEnclosure($enclosure);
75 $import = $licenseCsvImport->handleFile($filename);
77 if ($import !== null) {
account_check(&$user, &$passwd, &$group="")
check if this account is correct
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...