12 require_once(
"$MODDIR/lib/php/common-cli.php");
 
   15 $Usage = 
"Usage: " . basename($argv[0]) . 
" 
   16   -u upload id        :: upload id 
   17   -t uploadtree id    :: uploadtree id 
   18   -c sysconfdir       :: Specify the directory for the system configuration 
   19   --username username :: username 
   20   --password password :: password 
   21   --container         :: include container or not, 1: yes, 0: no (default) 
   22   -x                  :: do not show files which have unuseful license 'No_license_found' or no license 
   23   -X excluding        :: Exclude files containing [free text] in the path. 
   24                          'mac/' should exclude all files in the mac directory. 
   25                          'mac' and it should exclude all files in any directory containing the substring 'mac' 
   26                          '/mac' and it should exclude all files in any directory that starts with 'mac' 
   32 $ignoreFilesWithoutLicense = 0; 
 
   35 $longopts = array(
"username:", 
"password:", 
"container:");
 
   36 $options = getopt(
"c:u:t:hxX:", $longopts);
 
   37 if (empty($options) || !is_array($options)) {
 
   43 foreach ($options as $option => $value) {
 
   63       $showContainer = $value;
 
   66       $ignoreFilesWithoutLicense = 1;
 
   72       print 
"unknown option $option\n";
 
   78 if (is_numeric($item) && !is_numeric($upload)) {
 
   83 if (!is_numeric($upload) || (!empty($item) && !is_numeric($item))) {
 
   84   print 
"Upload ID or Uploadtree ID is not digital number\n";
 
   92 if (empty($return_value)) {
 
   93   $text = _(
"The user '$user' has no permission to read the information of upload $upload\n");
 
  108 function GetLicenseList($uploadtree_pk, $upload_pk, $showContainer, $excluding, $ignore)
 
  111   $dbManager = $GLOBALS[
'container']->get(
'db.manager');
 
  113   $uploadDao = $GLOBALS[
'container']->get(
"dao.upload");
 
  115   $licenseDao = $GLOBALS[
'container']->get(
"dao.license");
 
  117   if (empty($uploadtree_pk)) {
 
  118       $uploadtreeRec = $dbManager->getSingleRow(
'SELECT uploadtree_pk FROM uploadtree WHERE parent IS NULL AND upload_fk=$1',
 
  120               __METHOD__.
'.find.uploadtree.to.use.in.browse.link' );
 
  121       $uploadtree_pk = $uploadtreeRec[
'uploadtree_pk'];
 
  125   $AgentRec = AgentARSList(
"monk_ars", $upload_pk, 1);
 
  126   if ($AgentRec === 
false) {
 
  127     echo _(
"No data available \n");
 
  130   $agent_pk = $AgentRec[0][
"agent_fk"];
 
  134   $itemTreeBounds = $uploadDao->getItemTreeBounds($uploadtree_pk, $uploadtreeTablename);
 
  135   $licensesPerFileName = $licenseDao->getLicensesPerFileNameForAgentId(
 
  136     $itemTreeBounds, array($agent_pk), 
true, $excluding, $ignore);
 
  138   foreach ($licensesPerFileName as $fileName => $licenseData) {
 
  139     if ($licenseData == 
false) {
 
  140       if ($showContainer) {
 
  141         print($fileName.
"\n");
 
  146     if (! array_key_exists(
'scanResults', $licenseData) || empty($licenseData[
'scanResults'])) {
 
  150     $licenseNames = $licenseData[
'scanResults'];
 
  151     if ($ignore && $licenseNames !== array()) {
 
  155     print($fileName .
': '.implode($licenseNames,
', ').
"\n");
 
  160 GetLicenseList($item, $upload, $showContainer, $excluding, $ignoreFilesWithoutLicense);
 
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload.
account_check(&$user, &$passwd, &$group="")
check if this account is correct
cli_Init()
Initialize the fossology environment for CLI use. This routine loads the plugins so they can be use b...
GetUploadID($uploadtreeid)
Get upload id through uploadtreeid.
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".