23 require_once(
"$MODDIR/lib/php/common-cli.php");
26 $Usage =
"Usage: " . basename($argv[0]) .
" 27 -u upload id :: upload id 28 -t uploadtree id :: uploadtree id 29 -c sysconfdir :: Specify the directory for the system configuration 30 --username username :: username 31 --password password :: password 32 --container :: include container or not, 1: yes, 0: no (default) 33 -x :: do not show files which have unuseful license 'No_license_found' or no license 34 -X excluding :: Exclude files containing [free text] in the path. 35 'mac/' should exclude all files in the mac directory. 36 'mac' and it should exclude all files in any directory containing the substring 'mac' 37 '/mac' and it should exclude all files in any directory that starts with 'mac' 43 $ignoreFilesWithoutLicense = 0;
46 $longopts = array(
"username:",
"password:",
"container:");
47 $options = getopt(
"c:u:t:hxX:", $longopts);
48 if (empty($options) || !is_array($options)) {
54 foreach ($options as $option => $value) {
74 $showContainer = $value;
77 $ignoreFilesWithoutLicense = 1;
83 print
"unknown option $option\n";
89 if (is_numeric($item) && !is_numeric($upload)) {
94 if (!is_numeric($upload) || (!empty($item) && !is_numeric($item))) {
95 print
"Upload ID or Uploadtree ID is not digital number\n";
103 if (empty($return_value)) {
104 $text = _(
"The user '$user' has no permission to read the information of upload $upload\n");
119 function GetLicenseList($uploadtree_pk, $upload_pk, $showContainer, $excluding, $ignore)
122 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
124 $uploadDao = $GLOBALS[
'container']->get(
"dao.upload");
126 $licenseDao = $GLOBALS[
'container']->get(
"dao.license");
128 if (empty($uploadtree_pk)) {
129 $uploadtreeRec = $dbManager->getSingleRow(
'SELECT uploadtree_pk FROM uploadtree WHERE parent IS NULL AND upload_fk=$1',
131 __METHOD__.
'.find.uploadtree.to.use.in.browse.link' );
132 $uploadtree_pk = $uploadtreeRec[
'uploadtree_pk'];
136 $AgentRec = AgentARSList(
"nomos_ars", $upload_pk, 1);
137 if ($AgentRec ===
false) {
138 echo _(
"No data available\n");
141 $agent_pk = $AgentRec[0][
"agent_fk"];
143 $uploadtreeTablename = getUploadtreeTableName($upload_pk);
145 $itemTreeBounds = $uploadDao->getItemTreeBounds($uploadtree_pk, $uploadtreeTablename);
146 $licensesPerFileName = $licenseDao->getLicensesPerFileNameForAgentId(
147 $itemTreeBounds, array($agent_pk),
true, $excluding, $ignore);
149 foreach ($licensesPerFileName as $fileName => $licenseData) {
150 if ($licenseData ==
false) {
151 if ($showContainer) {
152 print($fileName.
"\n");
157 if (! array_key_exists(
'scanResults', $licenseData) || empty($licenseData[
'scanResults'])) {
161 $licenseNames = $licenseData[
'scanResults'];
162 if (($ignore && $licenseNames !== array())) {
166 print($fileName .
': '.implode($licenseNames,
', ').
"\n");
171 GetLicenseList($item, $upload, $showContainer, $excluding, $ignoreFilesWithoutLicense);
account_check(&$user, &$passwd, &$group="")
check if this account is correct
GetUploadID($uploadtreeid)
Get upload id through uploadtreeid.
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload...