Ejemplo n.º 1
0
 /**
  * \brief Display the tagging page.
  */
 function ShowTaggingPage($ShowMenu = 0, $ShowHeader = 0, $action)
 {
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     if (empty($Item) || empty($Upload)) {
         return;
     }
     /**********************************
        Display micro header
        **********************************/
     if ($ShowHeader) {
         $V .= Dir2Browse("browse", $Item, NULL, 1, "Browse");
     }
     // if ShowHeader
     /* Display exist tags for this file */
     $V .= $this->ShowExistTags($Upload, $Item);
     /* Add AJAX script */
     $V .= $this->ShowAjaxPage();
     if ($action == 'edit') {
         $V .= $this->ShowEditTagPage($Upload, $Item);
     } else {
         /* Show create tag page */
         $perm = GetUploadPerm($Upload);
         if ($perm >= PERM_WRITE) {
             $V .= $this->ShowCreateTagPage($Upload, $Item);
         } else {
             $nopermtext = _("You do not have permission to tag this upload.");
             $V .= $nopermtext;
         }
         /* Show delete tag page removing
            $V .= $this->ShowDeleteTagPage($Upload,$Item);
            */
     }
     return $V;
 }
Ejemplo n.º 2
0
 /**
  * \brief Display the tagging page.
  * @param string $action
  * @param int $ShowHeader
  */
 function ShowTaggingPage($action, $ShowHeader = 0)
 {
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     if (empty($Item) || empty($Upload)) {
         return;
     }
     /**********************************
        Display micro header
        **********************************/
     if ($ShowHeader) {
         $V .= Dir2Browse("browse", $Item, NULL, 1, "Browse");
     }
     $V .= $this->ShowExistTags($Upload, $Item);
     $V .= $this->ShowAjaxPage();
     if ($action == 'edit') {
         $V .= $this->ShowEditTagPage($Upload, $Item);
     } else {
         /* Show create tag page */
         if ($this->uploadDao->isEditable($Upload, Auth::getGroupId())) {
             $V .= $this->ShowCreateTagPage($Upload, $Item);
         } else {
             $nopermtext = _("You do not have permission to tag this upload.");
             $V .= $nopermtext;
         }
     }
     return $V;
 }
Ejemplo n.º 3
0
 /**
  * @brief extends standard Output to handle empty uploads
  */
 function Output()
 {
     if ($this->invalidParm) {
         $this->vars['content'] = 'This upload contains no files!<br><a href="' . Traceback_uri() . '?mod=browse">Go back to browse view</a>';
         return $this->render("include/base.html.twig");
     }
     $uploadId = GetParm("upload", PARM_INTEGER);
     if (empty($uploadId)) {
         return new Response("", Response::HTTP_BAD_REQUEST);
     }
     $uploadTreeId = GetParm("item", PARM_INTEGER);
     if (empty($uploadTreeId)) {
         return new Response("", Response::HTTP_BAD_REQUEST);
     }
     $userId = Auth::getUserId();
     $groupId = Auth::getGroupId();
     $lastItem = GetParm("lastItem", PARM_INTEGER);
     if (!empty($lastItem)) {
         $this->updateLastItem($userId, $groupId, $lastItem);
     }
     $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
     $itemTreeBounds = $this->uploadDao->getItemTreeBounds($uploadTreeId, $uploadTreeTableName);
     $this->vars['micromenu'] = Dir2Browse('license', $uploadTreeId, NULL, $showBox = 0, "View", -1, '', '', $uploadTreeTableName);
     global $Plugins;
     /** @var ui_view $view */
     $view =& $Plugins[plugin_find_id("view")];
     $licenseId = GetParm("licenseId", PARM_INTEGER);
     $selectedAgentId = GetParm("agentId", PARM_INTEGER);
     $highlightId = GetParm("highlightId", PARM_INTEGER);
     $clearingId = GetParm("clearingId", PARM_INTEGER);
     if ($clearingId !== null) {
         $highlightId = -1;
     } else {
         if ($highlightId !== null) {
             $clearingId = -1;
         }
     }
     $baseUri = Traceback_uri();
     $this->vars['baseuri'] = $baseUri;
     $this->vars['uri'] = $baseUri . "?mod=" . $this->Name . Traceback_parm_keep(array('upload', 'folder'));
     $this->vars['bulkHistoryHighlightUri'] = $this->vars['uri'];
     $this->vars['optionName'] = "skipFile";
     $this->vars['formName'] = "uiClearingForm";
     $this->vars['ajaxAction'] = "setNextPrev";
     $highlights = $this->getSelectedHighlighting($itemTreeBounds, $licenseId, $selectedAgentId, $highlightId, $clearingId, $uploadId);
     $isSingleFile = !$itemTreeBounds->containsFiles();
     $hasWritePermission = $this->uploadDao->isEditable($uploadId, $groupId);
     $clearingDecisions = null;
     if ($isSingleFile || $hasWritePermission) {
         $clearingDecisions = $this->clearingDao->getFileClearings($itemTreeBounds, $groupId, false);
     }
     if ($isSingleFile && $hasWritePermission) {
         $this->vars['bulkUri'] = Traceback_uri() . "?mod=popup-license";
         $licenseArray = $this->licenseDao->getLicenseArray($groupId);
         // $clearingDecision = $this->clearingDao->getRelevantClearingDecision($itemTreeBounds, $groupId);
         list($addedResults, $removedResults) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION);
         if (count($addedResults) + count($removedResults) > 0) {
             array_unshift($licenseArray, array('id' => 0, 'fullname' => '', 'shortname' => '------'));
         }
         /** @var ClearingResult $result */
         foreach ($removedResults as $result) {
             array_unshift($licenseArray, array('id' => $result->getLicenseId(), 'fullname' => $result->getLicenseFullName(), 'shortname' => $result->getLicenseShortName()));
         }
         /** @var ClearingResult $result */
         foreach ($addedResults as $result) {
             array_unshift($licenseArray, array('id' => $result->getLicenseId(), 'fullname' => $result->getLicenseFullName(), 'shortname' => $result->getLicenseShortName()));
         }
         $this->vars['licenseArray'] = $licenseArray;
     } elseif ($isSingleFile) {
         $this->vars['auditDenied'] = true;
     }
     $clearingHistory = array();
     $selectedClearingType = false;
     if ($hasWritePermission) {
         $clearingHistory = $this->getClearingHistory($clearingDecisions);
     }
     if (count($clearingHistory) > 0) {
         $selectedClearingType = $this->decisionTypes->getTypeByName($clearingHistory[0]['type']);
     }
     $bulkHistory = $this->clearingDao->getBulkHistory($itemTreeBounds, $groupId);
     $ModBack = GetParm("modback", PARM_STRING) ?: "license";
     list($pageMenu, $textView) = $view->getView(NULL, $ModBack, 0, "", $highlights, false, true);
     $this->vars['uploadId'] = $uploadId;
     $this->vars['itemId'] = $uploadTreeId;
     $this->vars['pageMenu'] = $pageMenu;
     $this->vars['textView'] = $textView;
     $this->vars['legendData'] = $this->highlightRenderer->getLegendData($selectedAgentId || $clearingId);
     $this->vars['clearingTypes'] = $this->decisionTypes->getMap();
     $this->vars['selectedClearingType'] = $selectedClearingType;
     $this->vars['tmpClearingType'] = $this->clearingDao->isDecisionWip($uploadTreeId, $groupId);
     $this->vars['clearingHistory'] = $clearingHistory;
     $this->vars['bulkHistory'] = $bulkHistory;
     $noLicenseUploadTreeView = new UploadTreeProxy($uploadId, $options = array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense", UploadTreeProxy::OPT_GROUP_ID => $groupId), $uploadTreeTableName, $viewName = 'no_license_uploadtree' . $uploadId);
     $filesOfInterest = $noLicenseUploadTreeView->count();
     $nonClearedUploadTreeView = new UploadTreeProxy($uploadId, $options = array(UploadTreeProxy::OPT_SKIP_THESE => "alreadyCleared", UploadTreeProxy::OPT_GROUP_ID => $groupId), $uploadTreeTableName, $viewName = 'already_cleared_uploadtree' . $uploadId);
     $filesToBeCleared = $nonClearedUploadTreeView->count();
     $filesAlreadyCleared = $filesOfInterest - $filesToBeCleared;
     $this->vars['message'] = _("Cleared") . ": {$filesAlreadyCleared}/{$filesOfInterest}";
     return $this->render("ui-clearing-view.html.twig");
 }
Ejemplo n.º 4
0
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     $uTime = microtime(true);
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Folder = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     switch (GetParm("show", PARM_STRING)) {
         case 'detail':
             $Show = 'detail';
             break;
         case 'summary':
         default:
             $Show = 'summary';
             break;
     }
     /* Use Traceback_parm_keep to ensure that all parameters are in order */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "folder")) . "&show={$Show}";
     if ($this->UpdCache != 0) {
         $V = "";
         $Err = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (empty($V)) {
         switch ($this->OutputType) {
             case "XML":
                 break;
             case "HTML":
                 $V .= "<font class='text'>\n";
                 /************************/
                 /* Show the folder path */
                 /************************/
                 $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse") . "<P />\n";
                 /******************************/
                 /* Get the folder description */
                 /******************************/
                 if (!empty($Folder)) {
                     // $V .= $this->ShowFolder($Folder);
                 }
                 if (!empty($Upload)) {
                     $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                     $V .= $this->ShowUploadHist($Upload, $Item, $Uri);
                 }
                 $V .= "</font>\n";
                 break;
             case "Text":
                 break;
             default:
                 break;
         }
         $Cached = false;
         /*  Cache Report if this took longer than 1 seconds */
         if ($Time > 1) {
             ReportCachePut($CacheKey, $V);
         }
     } else {
         $Cached = true;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     $text = _("cached");
     $text1 = _("Update");
     if ($Cached) {
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     }
     return;
 }
Ejemplo n.º 5
0
 /**
  * \brief This function returns the scheduler status.
  */
 public function Output()
 {
     $uTime = microtime(true);
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     /** @var UploadDao $uploadDao */
     $uploadDao = $GLOBALS['container']->get('dao.upload');
     if (!$uploadDao->isAccessible($Upload, Auth::getGroupId())) {
         $text = _("Permission Denied");
         return "<h2>{$text}</h2>";
     }
     $Item = GetParm("item", PARM_INTEGER);
     if (!$Item) {
         return _('No item selected');
     }
     $updcache = GetParm("updcache", PARM_INTEGER);
     $tagbucket = GetParm("tagbucket", PARM_INTEGER);
     $this->uploadtree_tablename = GetUploadtreeTableName($Upload);
     /* Remove "updcache" from the GET args and set $this->UpdCache
      * This way all the url's based on the input args won't be
      * polluted with updcache
      * Use Traceback_parm_keep to ensure that all parameters are in order 
      */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "folder", "ars"));
     if ($updcache) {
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (!empty($tagbucket)) {
         $bucketagent_pk = GetParm("bapk", PARM_INTEGER);
         $bucket_pk = GetParm("bpk", PARM_INTEGER);
         $bucketpool_pk = GetParm("bp", PARM_INTEGER);
         $nomosagent_pk = GetParm("napk", PARM_INTEGER);
         $this->TagBucket($Upload, $Item, $bucketagent_pk, $bucket_pk, $bucketpool_pk, $nomosagent_pk);
     }
     $Cached = !empty($V);
     if (!$Cached) {
         $V .= "<font class='text'>\n";
         $Children = GetNonArtifactChildren($Item, $this->uploadtree_tablename);
         if (count($Children) == 0) {
             // no children, display View-Meta micromenu
             $V .= Dir2Browse($this->Name, $Item, NULL, 1, "View-Meta", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
         } else {
             // has children, display Browse micormenu
             $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
         }
         if (!empty($Upload)) {
             $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
             $V .= $this->ShowUploadHist($Item, $Uri);
         }
         $V .= "</font>\n";
         $text = _("Loading...");
     }
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     $V .= sprintf("<p><small>{$text}</small>", $Time);
     if ($Cached) {
         $text = _("cached");
         $text1 = _("Update");
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     } else {
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return $V;
 }
Ejemplo n.º 6
0
 /**
  * \brief Generate the view contents in HTML
  *
  * @param resource $inputFile
  * @param string $BackMod
  * @param int $ShowMenu
  * @param int $ShowHeader
  * @param null $ShowText
  * @param bool $ViewOnly
  * @param bool $DispView
  * @param Highlight[] $highlightEntries
  * @param bool $insertBacklink
  *
  * \note This function is intended to be called from other plugins.
  */
 function getView($inputFile = NULL, $BackMod = "browse", $ShowHeader = 1, $ShowText = NULL, $highlightEntries = array(), $insertBacklink = false, $getPageMenuInline = false)
 {
     if ($this->State != PLUGIN_STATE_READY) {
         $output = "Invalid plugin state: " . $this->State;
         return $getPageMenuInline ? array("Error", $output) : $output;
     }
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Upload) && !$this->uploadDao->isAccessible($Upload, Auth::getGroupId())) {
         $output = "Access denied";
         return $getPageMenuInline ? array("Error", $output) : $output;
     }
     $Item = GetParm("item", PARM_INTEGER);
     $Page = GetParm("page", PARM_INTEGER);
     $licenseId = GetParm("licenseId", PARM_INTEGER);
     if (!$inputFile && empty($Item)) {
         $output = "invalid input file";
         return $getPageMenuInline ? array("Error", $output) : $output;
     }
     $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($Upload);
     if ($ShowHeader) {
         $Uri = Traceback_uri() . "?mod=browse" . Traceback_parm_keep(array('item', 'show', 'folder', 'upload'));
         /* No item */
         $header = Dir2Browse($BackMod, $Item, NULL, $showBox = 0, "View", -1, '', '', $uploadtree_tablename);
         $this->vars['micromenu'] = $header;
     }
     /* Display file contents */
     $output = "";
     $openedFin = False;
     $Format = $this->microMenu->getFormatParameter($Item);
     if (empty($inputFile)) {
         $inputFile = @fopen(RepPathItem($Item), "rb");
         if ($inputFile) {
             $openedFin = true;
         }
         if (empty($inputFile)) {
             $output = $this->outputWhenFileNotInRepo($Upload, $Item);
             return $getPageMenuInline ? array("Error", $output) : $output;
         }
     }
     rewind($inputFile);
     $Uri = preg_replace('/&page=[0-9]*/', '', Traceback());
     $blockSize = $Format == 'hex' ? $this->blockSizeHex : $this->blockSizeText;
     if (!isset($Page) && !empty($licenseId)) {
         $startPos = -1;
         foreach ($highlightEntries as $highlightEntry) {
             if ($highlightEntry->getLicenseId() == $licenseId && ($startPos == -1 || $startPos > $highlightEntry->getStart())) {
                 $startPos = $highlightEntry->getStart();
             }
         }
         if ($startPos != -1) {
             $Page = floor($startPos / $blockSize);
         }
     }
     if (!empty($ShowText)) {
         echo $ShowText, "<hr>";
     }
     $PageMenu = $this->GetFileJumpMenu($inputFile, $Page, $blockSize, $Uri);
     $PageSize = $blockSize * $Page;
     if (!empty($PageMenu) and !$getPageMenuInline) {
         $output .= "<center>{$PageMenu}</center><br>\n";
     }
     $startAt = $PageSize;
     $endAt = $PageSize + $blockSize;
     $relevantHighlightEntries = array();
     foreach ($highlightEntries as $highlightEntry) {
         if ($highlightEntry->getStart() < $endAt && $highlightEntry->getEnd() >= $startAt) {
             $relevantHighlightEntries[] = $highlightEntry;
         }
     }
     $this->highlightProcessor->sortHighlights($relevantHighlightEntries);
     $splitPositions = $this->highlightProcessor->calculateSplitPositions($relevantHighlightEntries);
     if ($Format == 'hex') {
         $output .= $this->getHex($inputFile, $PageSize, $this->blockSizeHex, $splitPositions);
     } else {
         $output .= $this->getText($inputFile, $PageSize, $Format == 'text' ? 0 : 1, $this->blockSizeText, $splitPositions, $insertBacklink);
     }
     if (!empty($PageMenu) and !$getPageMenuInline) {
         $output .= "<P /><center>{$PageMenu}</center><br>\n";
     }
     if ($openedFin) {
         fclose($inputFile);
     }
     return $getPageMenuInline ? array($PageMenu, $output) : $output;
 }
Ejemplo n.º 7
0
 public function Output()
 {
     $uploadId = GetParm("upload", PARM_INTEGER);
     if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
         return;
     }
     $itemId = GetParm("item", PARM_INTEGER);
     $this->vars['micromenu'] = Dir2Browse("browse", $itemId, NULL, $showBox = 0, "View-Meta");
     $V = "";
     $V .= $this->ShowTagInfo($uploadId, $itemId);
     $V .= $this->ShowPackageinfo($uploadId, $itemId, 1);
     $V .= $this->ShowMetaView($uploadId, $itemId);
     $V .= $this->ShowSightings($uploadId, $itemId);
     $V .= $this->ShowView($uploadId, $itemId);
     return $V;
 }
Ejemplo n.º 8
0
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Folder = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     if (empty($Item)) {
         return;
     }
     switch ($this->OutputType) {
         case "CSV":
             $text = _("License Count|License Summary|Path");
             print "{$text}\n";
             $this->ShowLicenseTree($Upload, $Item, $Uri);
             break;
         case "XML":
             break;
         case "HTML":
             $V .= "<font class='text'>\n";
             /************************/
             /* Show the folder path */
             /************************/
             $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse") . "<P />\n";
             /******************************/
             /* Get the folder description */
             /******************************/
             if (!empty($Folder)) {
                 // $V .= $this->ShowFolder($Folder);
             }
             if (!empty($Upload)) {
                 print $V;
                 $V = "";
                 $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                 print "<table border='0' width='100%'>";
                 $this->ShowLicenseTree($Upload, $Item, $Uri);
                 print "</table>";
             }
             $V .= "</font>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $rf_shortname = GetParm("lic", PARM_RAW);
     $tag_pk = GetParm("tag", PARM_INTEGER);
     $Excl = GetParm("excl", PARM_RAW);
     $Exclic = GetParm("exclic", PARM_RAW);
     if (empty($uploadtree_pk) || empty($rf_shortname)) {
         $text = _("is missing required parameters.");
         return $this->Name . " {$text}";
     }
     $Max = 50;
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     // Get upload_pk and $uploadtree_tablename
     $UploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk={$uploadtree_pk}");
     global $container;
     /** @var UploadDao */
     $uploadDao = $container->get('dao.upload');
     $uploadtree_tablename = $uploadDao->getUploadtreeTableName($UploadtreeRec['upload_fk']);
     // micro menus
     $V = menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
     /* Load licenses */
     $Offset = $Page < 0 ? 0 : $Page * $Max;
     $order = "";
     $PkgsOnly = false;
     // Count is uploadtree recs, not pfiles
     $agentId = GetParm('agentId', PARM_INTEGER);
     if (empty($agentId)) {
         $agentId = "any";
     }
     $CountArray = $this->countFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk, $tag_pk, $uploadtree_tablename);
     if (empty($CountArray)) {
         $V .= _("<b> No files found for license {$rf_shortname} !</b>\n");
     } else {
         $Count = $CountArray['count'];
         $Unique = $CountArray['unique'];
         $text = _("files found");
         $text2 = _("with license");
         $V .= "{$Unique} {$text} {$text2} <b>{$rf_shortname}</b>";
         if ($Count < $Max) {
             $Max = $Count;
         }
         $limit = $Page < 0 ? "ALL" : $Max;
         $order = " order by ufile_name asc";
         /** should delete $filesresult yourself */
         $filesresult = GetFilesWithLicense($agentId, $rf_shortname, $uploadtree_pk, $PkgsOnly, $Offset, $limit, $order, $tag_pk, $uploadtree_tablename);
         $NumFiles = pg_num_rows($filesresult);
         $file_result_temp = pg_fetch_all($filesresult);
         $sorted_file_result = array();
         // the final file list will display
         $max_num = $NumFiles;
         /** sorting by ufile_name from DB, then reorder the duplicates indented */
         for ($i = 0; $i < $max_num; $i++) {
             $row = $file_result_temp[$i];
             if (empty($row)) {
                 continue;
             }
             array_push($sorted_file_result, $row);
             for ($j = $i + 1; $j < $max_num; $j++) {
                 $row_next = $file_result_temp[$j];
                 if (!empty($row_next) && $row['pfile_fk'] == $row_next['pfile_fk']) {
                     array_push($sorted_file_result, $row_next);
                     $file_result_temp[$j] = null;
                 }
             }
         }
         $text = _("Display");
         $text1 = _("excludes");
         $text2 = _("files with these extensions");
         if (!empty($Excl)) {
             $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Excl}";
         }
         $text2 = _("files with these licenses");
         if (!empty($Exclic)) {
             $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Exclic}";
         }
         /* Get the page menu */
         if ($Max > 0 && $Count >= $Max && $Page >= 0) {
             $VM = "<P />\n" . MenuEndlessPage($Page, intval(($Count + $Offset) / $Max)) . "<P />\n";
             $V .= $VM;
         } else {
             $VM = "";
         }
         /* Offset is +1 to start numbering from 1 instead of zero */
         $RowNum = $Offset;
         $LinkLast = "view-license";
         $ShowBox = 1;
         $ShowMicro = NULL;
         // base url
         $ushortname = rawurlencode($rf_shortname);
         $baseURL = "?mod=" . $this->Name . "&item={$uploadtree_pk}&lic={$ushortname}&page=-1";
         $V .= "<table>";
         $text = _("File");
         $V .= "<tr><th>{$text}</th><th>&nbsp";
         $LastPfilePk = -1;
         $ExclArray = explode(":", $Excl);
         $ExclicArray = explode(":", $Exclic);
         foreach ($sorted_file_result as $row) {
             $pfile_pk = $row['pfile_fk'];
             $licstring = GetFileLicenses_string($row['agent_pk'], $pfile_pk, $row['uploadtree_pk'], $uploadtree_tablename);
             $URLlicstring = urlencode($licstring);
             // Allow user to exclude files with this extension
             $FileExt = GetFileExt($row['ufile_name']);
             $URL = $baseURL;
             if (!empty($Excl)) {
                 $URL .= "&excl={$Excl}:{$FileExt}";
             } else {
                 $URL .= "&excl={$FileExt}";
             }
             if (!empty($Exclic)) {
                 $URL .= "&exclic=" . urlencode($Exclic);
             }
             $text = _("Exclude this file type.");
             $Header = "<a href={$URL}>{$text}</a>";
             /* Allow user to exclude files with this exact license list */
             $URL = $baseURL;
             if (!empty($Exclic)) {
                 $URL .= "&exclic=" . urlencode($Exclic) . ":" . $URLlicstring;
             } else {
                 $URL .= "&exclic={$URLlicstring}";
             }
             if (!empty($Excl)) {
                 $URL .= "&excl={$Excl}";
             }
             $text = _("Exclude files with license");
             $Header .= "<br><a href={$URL}>{$text}: {$licstring}.</a>";
             $excludeByType = $Excl && in_array($FileExt, $ExclArray);
             $excludeByLicense = $Exclic && in_array($licstring, $ExclicArray);
             if (!empty($licstring) && !$excludeByType && !$excludeByLicense) {
                 $V .= "<tr><td>";
                 /* Tack on pfile to url - information only */
                 $LinkLastpfile = $LinkLast . "&pfile={$pfile_pk}";
                 if ($LastPfilePk == $pfile_pk) {
                     $indent = "<div style='margin-left:2em;'>";
                     $outdent = "</div>";
                 } else {
                     $indent = "";
                     $outdent = "";
                 }
                 $V .= $indent;
                 $V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLastpfile, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename);
                 $V .= $outdent;
                 $V .= "</td>";
                 $V .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                 $V .= "<td>{$row['agent_name']}: {$licstring}</td></tr>";
                 $V .= "<tr><td colspan=3><hr></td></tr>";
             }
             $LastPfilePk = $pfile_pk;
         }
         pg_free_result($filesresult);
         $V .= "</table>";
         if (!empty($VM)) {
             $V .= $VM . "\n";
         }
     }
     return $V;
 }
Ejemplo n.º 10
0
 /**
  * @param int $uploadTreeId
  * @param int $Folder
  * @param int $Upload
  * @return string
  */
 function outputItemHtml($uploadTreeId, $Folder, $Upload)
 {
     global $container;
     $dbManager = $container->get('db.manager');
     $show = 'quick';
     $html = '';
     $uploadtree_tablename = "";
     if (!empty($uploadTreeId)) {
         $sql = "SELECT ufile_mode, upload_fk FROM uploadtree WHERE uploadtree_pk = \$1";
         $row = $dbManager->getSingleRow($sql, array($uploadTreeId));
         $Upload = $row['upload_fk'];
         if (!$this->uploadDao->isAccessible($Upload, Auth::getGroupId())) {
             $this->vars['message'] = _("Permission Denied");
             return $this->render('include/base.html.twig');
         }
         if (!Iscontainer($row['ufile_mode'])) {
             global $Plugins;
             $View =& $Plugins[plugin_find_id("view")];
             if (!empty($View)) {
                 $this->vars['content'] = $View->ShowView(NULL, "browse");
                 return $this->render('include/base.html.twig');
             }
         }
         $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($row['upload_fk']);
         $html .= Dir2Browse($this->Name, $uploadTreeId, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "\n";
     } else {
         if (!empty($Upload)) {
             $uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($Upload);
             $html .= Dir2BrowseUpload($this->Name, $Upload, NULL, 1, "Browse", $uploadtree_tablename) . "\n";
         }
     }
     if (empty($Upload)) {
         $this->vars['show'] = $show;
         $this->ShowFolder($Folder);
         return $html;
     }
     if (empty($uploadTreeId)) {
         try {
             $uploadTreeId = $this->uploadDao->getUploadParent($Upload);
         } catch (Exception $e) {
             $this->vars['message'] = $e->getMessage();
             return $this->render('include/base.html.twig');
         }
     }
     $html .= $this->ShowItem($Upload, $uploadTreeId, $show, $Folder, $uploadtree_tablename);
     $this->vars['content'] = $html;
     return $this->render('include/base.html.twig');
 }
Ejemplo n.º 11
0
 /**
  * \brief Generate the view contents in HTML and sends it
  *  to stdout.
  *
  * \param $Name - the name for this plugin.
  * 
  * \note This function is intended to be called from other plugins.
  */
 function ShowView($Fin = NULL, $BackMod = "browse", $ShowMenu = 1, $ShowHeader = 1, $ShowText = NULL, $ViewOnly = False, $DispView = True)
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     global $Plugins;
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Upload)) {
         $UploadPerm = GetUploadPerm($Upload);
         if ($UploadPerm < PERM_READ) {
             return;
         }
     }
     $Folder = GetParm("folder", PARM_INTEGER);
     $Show = GetParm("show", PARM_STRING);
     $Item = GetParm("item", PARM_INTEGER);
     $nomosagent_pk = GetParm("napk", PARM_INTEGER);
     $Page = GetParm("page", PARM_INTEGER);
     $bucketagent_pk = GetParm("bapk", PARM_INTEGER);
     if (!$Fin && (empty($Item) || empty($Upload))) {
         return;
     }
     if (empty($Page)) {
         $Page = 0;
     }
     /* Get uploadtree table name */
     $uploadtree_tablename = "uploadtree";
     if (!empty($Upload)) {
         $uploadtree_tablename = GetUploadtreeTablename($Upload);
     }
     switch (GetParm("format", PARM_STRING)) {
         case 'hex':
             $Format = 'hex';
             break;
         case 'text':
             $Format = 'text';
             break;
         case 'flow':
             $Format = 'flow';
             break;
         default:
             /* Determine default show based on mime type */
             if (empty($Item)) {
                 $Format = 'text';
             } else {
                 $Meta = GetMimeType($Item);
                 list($Type, $Junk) = explode("/", $Meta, 2);
                 if ($Type == 'text') {
                     $Format = 'flow';
                 } else {
                     switch ($Meta) {
                         case "application/octet-string":
                         case "application/x-awk":
                         case "application/x-csh":
                         case "application/x-javascript":
                         case "application/x-perl":
                         case "application/x-shellscript":
                         case "application/x-rpm-spec":
                         case "application/xml":
                         case "message/rfc822":
                             $Format = 'flow';
                             break;
                         default:
                             $Format = 'flow';
                     }
                 }
             }
             break;
     }
     /**********************************
        Display micro header
        **********************************/
     if ($ShowHeader) {
         $Uri = Traceback_uri() . "?mod=browse";
         $Opt = "";
         if (!empty($Item)) {
             $Opt .= "&item={$Item}";
         }
         if (!empty($Upload)) {
             $Opt .= "&upload={$Upload}";
         }
         if (!empty($Folder)) {
             $Opt .= "&folder={$Folder}";
         }
         if (!empty($Show)) {
             $Opt .= "&show={$Show}";
         }
         /* No item */
         $V .= Dir2Browse($BackMod, $Item, NULL, 1, "View", -1, '', '', $uploadtree_tablename) . "<P />\n";
     }
     // if ShowHeader
     $this->SortHighlightMenu();
     /***********************************
        Display file contents
        ***********************************/
     print $V;
     $V = "";
     $openedFin = False;
     if (empty($Fin)) {
         $Fin = @fopen(RepPathItem($Item), "rb");
         if ($Fin) {
             $openedFin = true;
         }
         if (empty($Fin)) {
             /* Added by vincent implement when view files which not in repository, ask user if want to reunpack*/
             /** BEGIN **/
             /* If this is a POST, then process the request. */
             $uploadunpack = GetParm('uploadunpack', PARM_INTEGER);
             $uploadpk = $Upload;
             $flag = 0;
             $P =& $Plugins[plugin_find_id("ui_reunpack")];
             $state = $P->CheckStatus($uploadpk, "reunpack", "ununpack");
             //print "<p>$state</p>";
             if ($state == 0 || $state == 2) {
                 if (!empty($uploadunpack)) {
                     $rc = $P->AgentAdd($uploadpk);
                     if (empty($rc)) {
                         /* Need to refresh the screen */
                         $text = _("Unpack added to job queue");
                         $V .= displayMessage($text);
                         $flag = 1;
                         $text = _("Reunpack job is running: you can see it in");
                         $text1 = _("jobqueue");
                         print "<p> <font color=red>{$text} <a href='" . Traceback_uri() . "?mod=showjobs'>{$text1}</a></font></p>";
                     } else {
                         $text = _("Unpack of Upload failed");
                         $V .= displayMessage("{$text}: {$rc}");
                     }
                     print $V;
                 }
             } else {
                 $flag = 1;
                 $text = _("Reunpack job is running: you can see it in");
                 $text1 = _("jobqueue");
                 print "<p> <font color=red>{$text} <a href='" . Traceback_uri() . "?mod=showjobs'>{$text1}</a></font></p>";
             }
             $text = _("File contents are not available in the repository.");
             print "{$text}\n";
             $P =& $Plugins[plugin_find_id("ui_reunpack")];
             print $P->ShowReunpackView($Item, $flag);
             return;
         }
         /** END **/
     }
     rewind($Fin);
     $Pages = "";
     $Uri = preg_replace('/&page=[0-9]*/', '', Traceback());
     $HighlightMenu = "";
     $HighlightMenu .= "</center>";
     // some fcn left a dangling center
     if ($Format == 'hex') {
         $HighlightMenu .= $this->GetHighlightMenu(VIEW_BLOCK_HEX, $ViewOnly, $DispView);
         if (!empty($HighlightMenu)) {
             print "<center>{$HighlightMenu}</center><hr>\n";
         }
         $PageMenu = $this->GetFileJumpMenu($Fin, $Page, VIEW_BLOCK_HEX, $Uri);
         $PageSize = VIEW_BLOCK_HEX * $Page;
         if (!empty($PageMenu)) {
             print "<center>{$PageMenu}</center><br>\n";
         }
         $this->ShowHex($Fin, $PageSize, VIEW_BLOCK_HEX);
         if (!empty($PageMenu)) {
             print "<P /><center>{$PageMenu}</center><br>\n";
         }
     } else {
         if ($Format == 'text') {
             $HighlightMenu .= $this->GetHighlightMenu(VIEW_BLOCK_TEXT, $ViewOnly, $DispView);
             if (!empty($HighlightMenu)) {
                 print "<center>{$HighlightMenu}</center><hr>\n";
             }
             $PageMenu = $this->GetFileJumpMenu($Fin, $Page, VIEW_BLOCK_TEXT, $Uri);
             $PageSize = VIEW_BLOCK_TEXT * $Page;
             if (!empty($PageMenu)) {
                 print "<center>{$PageMenu}</center><br>\n";
             }
             $this->ShowText($Fin, $PageSize, 0, VIEW_BLOCK_TEXT);
             if (!empty($PageMenu)) {
                 print "<P /><center>{$PageMenu}</center><br>\n";
             }
         } else {
             if ($Format == 'flow') {
                 $HighlightMenu .= $this->GetHighlightMenu(VIEW_BLOCK_TEXT, $ViewOnly, $DispView);
                 if (!empty($HighlightMenu)) {
                     print "<center>{$HighlightMenu}</center><hr>\n";
                 }
                 $PageMenu = $this->GetFileJumpMenu($Fin, $Page, VIEW_BLOCK_TEXT, $Uri);
                 $PageSize = VIEW_BLOCK_TEXT * $Page;
                 if (!empty($PageMenu)) {
                     print "<center>{$PageMenu}</center><br>\n";
                 }
                 if (!empty($ShowText)) {
                     echo $ShowText, "<hr>";
                 }
                 $this->ShowText($Fin, $PageSize, 1, VIEW_BLOCK_TEXT);
                 if (!empty($PageMenu)) {
                     print "<P /><center>{$PageMenu}</center><br>\n";
                 }
             }
         }
     }
     if ($openedFin) {
         fclose($Fin);
     }
     return;
 }
Ejemplo n.º 12
0
 /** 
  * \brief display the license changing page
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $ObjectiveLicense = GetParm("object_license", PARM_TEXT);
     $ObjectiveLicense = trim($ObjectiveLicense);
     $Reason = GetParm("change_reason", PARM_TEXT);
     $Reason = trim($Reason);
     $Agent_pk = GetParm("napk", PARM_STRING);
     $upload_fk = GetParm("upload", PARM_STRING);
     $uploadtree_pk = GetParm("item", PARM_STRING);
     $fl_pk = GetParm("fl_pk", PARM_STRING);
     $OriginalLicense = "";
     $FileName = "";
     $V = "";
     /* Get uploadtree table name */
     $uploadtree_tablename = GetUploadtreeTablename($upload_fk);
     $V .= Dir2Browse('browse', $uploadtree_pk, NULL, 1, "View", -1, '', '', $uploadtree_tablename) . "<P />\n";
     /** if failed to change the license, set $ObjectiveLicense as empty */
     if ($this->Change($OriginalLicense, $ObjectiveLicense, $Reason, $FileName) === -1) {
         $ObjectiveLicense = "";
     }
     /** check if the current user has the permission to change license */
     $permission = GetUploadPerm($upload_fk);
     $text = _("Change License");
     $V .= "<H2>{$text}</H2>\n";
     if ($permission >= PERM_WRITE) {
         $V .= "<form enctype='multipart/form-data' method='post'>\n";
         $V .= "<table border='1'>\n";
         $text = _("License");
         $text1 = _("Change To");
         $text2 = _("Reason");
         $V .= "<tr><th width='20%'>{$text}</th><th width='20%'>{$text1}</th><th>{$text2}</th></tr>\n";
         $V .= "<tr>\n";
         /** after the original license is changed, on the UI, the origial license is changed to the object one */
         if (!empty($ObjectiveLicense)) {
             $OriginalLicense = $ObjectiveLicense;
         }
         $V .= "<td>{$OriginalLicense}</td>\n";
         // $V .= "<td> <input type='text' style='width:100%' name='object_license'></td>\n";
         $V .= "<td> <select name='object_license'>\n";
         $V .= $this->LicenseList();
         $V .= "</select></td>";
         $V .= "<td> <input type='text' style='width:100%' name='change_reason'></td>\n";
         $V .= "</tr>\n";
         $V .= "</table><br>\n";
         $V .= "<input type='submit' value='Submit'>";
         $V .= "</form>\n";
     } else {
         $text = _("Sorry, you are an administrator, also have no write and above permission on this upload, have can not change the license of this file.");
         $V .= "<b>{$text}</b>";
     }
     $V .= "<br>";
     if ($this->IsChanged($fl_pk)) {
         // if this license has been changed, display the change trail
         $V .= $this->ViewLicenseAuditTrail($fl_pk, $upload_fk, $uploadtree_pk);
     }
     print $V;
 }
Ejemplo n.º 13
0
 /**
  * \brief This function returns the output html
  */
 function Output()
 {
     global $PG_CONN;
     global $Plugins;
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $folder_pk = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     // upload_pk to browse
     $Item = GetParm("item", PARM_INTEGER);
     // uploadtree_pk to browse
     /* check permission if $Upload is given */
     if (!empty($Upload)) {
         $UploadPerm = GetUploadPerm($Upload);
         if ($UploadPerm < PERM_READ) {
             $text = _("Permission Denied");
             echo "<h2>{$text}<h2>";
             return;
         }
     }
     /* kludge for plugins not supplying a folder parameter.
      * Find what folder this upload is in.  Error if in multiple folders.
      */
     if (empty($folder_pk)) {
         if (empty($Upload)) {
             $folder_pk = GetUserRootFolder();
         } else {
             /* Make sure the upload record exists */
             $sql = "select upload_pk from upload where upload_pk={$Upload}";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             if (pg_num_rows($result) < 1) {
                 echo "This upload no longer exists on this system.";
                 return;
             }
             $sql = "select parent_fk from foldercontents where child_id={$Upload} and foldercontents_mode=2";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             if (pg_num_rows($result) > 1) {
                 Fatal("Upload {$Upload} found in multiple folders.", __FILE__, __LINE__);
             }
             if (pg_num_rows($result) < 1) {
                 Fatal("Upload {$Upload} missing from foldercontents.", __FILE__, __LINE__);
             }
             $row = pg_fetch_assoc($result);
             $folder_pk = $row['parent_fk'];
             pg_free_result($result);
         }
     }
     $Folder = $folder_pk;
     $Show = 'detail';
     // always use detail
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /************************/
             /* Show the folder path */
             /************************/
             $uploadtree_tablename = "";
             if (!empty($Item)) {
                 /* Make sure the item is not a file */
                 $sql = "SELECT ufile_mode, upload_fk FROM uploadtree WHERE uploadtree_pk = '{$Item}';";
                 $result = pg_query($PG_CONN, $sql);
                 DBCheckResult($result, $sql, __FILE__, __LINE__);
                 $row = pg_fetch_assoc($result);
                 pg_free_result($result);
                 $Upload = $row['upload_fk'];
                 $UploadPerm = GetUploadPerm($Upload);
                 if ($UploadPerm < PERM_READ) {
                     $text = _("Permission Denied");
                     echo "<h2>{$text}<h2>";
                     return;
                 }
                 if (!Iscontainer($row['ufile_mode'])) {
                     /* Not a container! */
                     $View =& $Plugins[plugin_find_id("view")];
                     if (!empty($View)) {
                         return $View->ShowView(NULL, "browse");
                     }
                 }
                 $V .= "<font class='text'>\n";
                 $uploadtree_tablename = GetUploadtreeTableName($row['upload_fk']);
                 $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "\n";
             } else {
                 if (!empty($Upload)) {
                     $V .= "<font class='text'>\n";
                     $uploadtree_tablename = GetUploadtreeTableName($Upload);
                     $V .= Dir2BrowseUpload($this->Name, $Upload, NULL, 1, "Browse", $uploadtree_tablename) . "\n";
                 } else {
                     $V .= "<font class='text'>\n";
                 }
             }
             /******************************/
             /* Get the folder description */
             /******************************/
             if (!empty($Upload)) {
                 if (empty($Item)) {
                     $sql = "select uploadtree_pk from uploadtree\n                where parent is NULL and upload_fk={$Upload} ";
                     $result = pg_query($PG_CONN, $sql);
                     DBCheckResult($result, $sql, __FILE__, __LINE__);
                     if (pg_num_rows($result)) {
                         $row = pg_fetch_assoc($result);
                         $Item = $row['uploadtree_pk'];
                     } else {
                         $text = _("Missing upload tree parent for upload");
                         $V .= "<hr><h2>{$text} {$Upload}</h2><hr>";
                         break;
                     }
                     pg_free_result($result);
                 }
                 $V .= $this->ShowItem($Upload, $Item, $Show, $Folder, $uploadtree_tablename);
             } else {
                 $V .= $this->ShowFolder($Folder, $Show);
             }
             $V .= "</font>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     global $Plugins;
     $V = "";
     $Time = time();
     $Max = 50;
     /*  Input parameters */
     $nomosagent_pk = GetParm("napk", PARM_INTEGER);
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $rf_shortname = GetParm("lic", PARM_RAW);
     $tag_pk = GetParm("tag", PARM_INTEGER);
     $Excl = GetParm("excl", PARM_RAW);
     $Exclic = GetParm("exclic", PARM_RAW);
     $rf_shortname = rawurldecode($rf_shortname);
     if (empty($uploadtree_pk) || empty($rf_shortname)) {
         $text = _("is missing required parameters.");
         echo $this->Name . " {$text}";
         return;
     }
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     // Get upload_pk and $uploadtree_tablename
     $UploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk={$uploadtree_pk}");
     $UploadRec = GetSingleRec("upload", "where upload_pk={$UploadtreeRec['upload_fk']}");
     $uploadtree_tablename = $UploadRec['uploadtree_tablename'];
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             // micro menus
             $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             /* Load licenses */
             $Offset = $Page < 0 ? 0 : $Page * $Max;
             $order = "";
             $PkgsOnly = false;
             $CheckOnly = false;
             // Count is uploadtree recs, not pfiles
             $CountArray = CountFilesWithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly, $CheckOnly, $tag_pk, $uploadtree_tablename);
             $Count = $CountArray['count'];
             $Unique = $CountArray['unique'];
             $text = _("files found");
             $text1 = _("unique");
             $text2 = _("with license");
             $V .= "{$Count} {$text} ({$Unique} {$text1}) {$text2} <b>{$rf_shortname}</b>";
             if ($Count < $Max) {
                 $Max = $Count;
             }
             $limit = $Page < 0 ? "ALL" : $Max;
             $order = " order by ufile_name asc";
             /** should delete $filesresult yourself */
             $filesresult = GetFilesWithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, $PkgsOnly, $Offset, $limit, $order, $tag_pk, $uploadtree_tablename);
             $NumFiles = pg_num_rows($filesresult);
             $file_result_temp = pg_fetch_all($filesresult);
             $sorted_file_result = array();
             // the final file list will display
             $max_num = $NumFiles;
             /** sorting by ufile_name from DB, then reorder the duplicates indented */
             for ($i = 0; $i < $max_num; $i++) {
                 $row = $file_result_temp[$i];
                 if (empty($row)) {
                     continue;
                 }
                 array_push($sorted_file_result, $row);
                 for ($j = $i + 1; $j < $max_num; $j++) {
                     $row_next = $file_result_temp[$j];
                     if (!empty($row_next) && $row['pfile_fk'] == $row_next['pfile_fk']) {
                         array_push($sorted_file_result, $row_next);
                         $file_result_temp[$j] = null;
                     }
                 }
             }
             $text = _("Display");
             $text1 = _("excludes");
             $text2 = _("files with these extensions");
             if (!empty($Excl)) {
                 $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Excl}";
             }
             $text2 = _("files with these licenses");
             if (!empty($Exclic)) {
                 $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Exclic}";
             }
             /* Get the page menu */
             if ($Max > 0 && $Count >= $Max && $Page >= 0) {
                 $VM = "<P />\n" . MenuEndlessPage($Page, intval(($Count + $Offset) / $Max)) . "<P />\n";
                 $V .= $VM;
             } else {
                 $VM = "";
             }
             /* Offset is +1 to start numbering from 1 instead of zero */
             $RowNum = $Offset;
             $LinkLast = "view-license&napk={$nomosagent_pk}";
             $ShowBox = 1;
             $ShowMicro = NULL;
             // base url
             $ushortname = rawurlencode($rf_shortname);
             $baseURL = "?mod=" . $this->Name . "&napk={$nomosagent_pk}&item={$uploadtree_pk}&lic={$ushortname}&page=-1";
             $V .= "<table>";
             $text = _("File");
             $V .= "<tr><th>{$text}</th><th>&nbsp";
             $LastPfilePk = -1;
             $ExclArray = explode(":", $Excl);
             $ExclicArray = explode(":", $Exclic);
             foreach ($sorted_file_result as $row) {
                 $pfile_pk = $row['pfile_fk'];
                 $licstring = GetFileLicenses_string($nomosagent_pk, $pfile_pk, $row['uploadtree_pk'], $uploadtree_tablename);
                 $URLlicstring = urlencode($licstring);
                 // Allow user to exclude files with this extension
                 $FileExt = GetFileExt($row['ufile_name']);
                 $URL = $baseURL;
                 if (!empty($Excl)) {
                     $URL .= "&excl={$Excl}:{$FileExt}";
                 } else {
                     $URL .= "&excl={$FileExt}";
                 }
                 if (!empty($Exclic)) {
                     $URL .= "&exclic=" . urlencode($Exclic);
                 }
                 $text = _("Exclude this file type.");
                 $Header = "<a href={$URL}>{$text}</a>";
                 /* Allow user to exclude files with this exact license list */
                 $URL = $baseURL;
                 if (!empty($Exclic)) {
                     $URL .= "&exclic=" . urlencode($Exclic) . ":" . $URLlicstring;
                 } else {
                     $URL .= "&exclic={$URLlicstring}";
                 }
                 if (!empty($Excl)) {
                     $URL .= "&excl={$Excl}";
                 }
                 $text = _("Exclude files with license");
                 $Header .= "<br><a href={$URL}>{$text}: {$licstring}.</a>";
                 $ok = true;
                 /* exclude by type */
                 if ($Excl) {
                     if (in_array($FileExt, $ExclArray)) {
                         $ok = false;
                     }
                 }
                 /* exclude by license */
                 if ($Exclic) {
                     if (in_array($licstring, $ExclicArray)) {
                         $ok = false;
                     }
                 }
                 if (empty($licstring)) {
                     $ok = false;
                 }
                 if ($ok) {
                     $V .= "<tr><td>";
                     /* Tack on pfile to url - information only */
                     $LinkLastpfile = $LinkLast . "&pfile={$pfile_pk}";
                     if ($LastPfilePk == $pfile_pk) {
                         $indent = "<div style='margin-left:2em;'>";
                         $outdent = "</div>";
                     } else {
                         $indent = "";
                         $outdent = "";
                     }
                     $V .= $indent;
                     $V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLastpfile, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename);
                     $V .= $outdent;
                     $V .= "</td>";
                     $V .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                     // spaces to seperate licenses
                     // show the entire license list as a single string with links to the files
                     // in this container with that license.
                     $V .= "<td>{$licstring}</td></tr>";
                     $V .= "<tr><td colspan=3><hr></td></tr>";
                     // separate files
                 }
                 $LastPfilePk = $pfile_pk;
             }
             pg_free_result($filesresult);
             $V .= "</table>";
             if (!empty($VM)) {
                 $V .= $VM . "\n";
             }
             $V .= "<hr>\n";
             $Time = time() - $Time;
             $text = _("Elapsed time");
             $text1 = _("seconds");
             $V .= "<small>{$text}: {$Time} {$text1}</small>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }
Ejemplo n.º 15
0
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     $uTime = microtime(true);
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $OutBuf = "";
     $Folder = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     $Item = GetParm("item", PARM_INTEGER);
     $filter = GetParm("filter", PARM_STRING);
     /* check upload permissions */
     $UploadPerm = GetUploadPerm($Upload);
     if ($UploadPerm < PERM_READ) {
         $text = _("Permission Denied");
         echo "<h2>{$text}<h2>";
         return;
     }
     /* Get uploadtree_tablename */
     $uploadtree_tablename = GetUploadtreeTableName($Upload);
     $this->uploadtree_tablename = $uploadtree_tablename;
     /* Use Traceback_parm_keep to ensure that all parameters are in order */
     /********  disable cache to see if this is fast enough without it *****
         $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload","item","folder", "orderBy", "orderc", "ordercp")) . "&show=$Show";
        if ($this->UpdCache != 0)
        {
        $OutBuf .= "";
        $Err = ReportCachePurgeByKey($CacheKey);
        }
        else
        $OutBuf .= ReportCacheGet($CacheKey);
        ***********************************************/
     if (empty($OutBuf)) {
         switch ($this->OutputType) {
             case "XML":
                 break;
             case "HTML":
                 $OutBuf .= "\n<script language='javascript'>\n";
                 /* function to replace this page specifying a new filter parameter */
                 $OutBuf .= "function ChangeFilter(selectObj, upload, item){";
                 $OutBuf .= "  var selectidx = selectObj.selectedIndex;";
                 $OutBuf .= "  var filter = selectObj.options[selectidx].value;";
                 $OutBuf .= '  window.location.assign("?mod=' . $this->Name . '&upload="+upload+"&item="+item +"&filter=" + filter); ';
                 $OutBuf .= "}</script>\n";
                 $OutBuf .= "<font class='text'>\n";
                 /************************/
                 /* Show the folder path */
                 /************************/
                 $OutBuf .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename) . "<P />\n";
                 if (!empty($Upload)) {
                     /** advanced interface allowing user to select dataset (agent version) */
                     $Agent_name = "copyright";
                     $dataset = "copyright_dataset";
                     $arstable = "copyright_ars";
                     /** get proper agent_id */
                     $Agent_pk = GetParm("agent", PARM_INTEGER);
                     if (empty($Agent_pk)) {
                         $Agent_pk = LatestAgentpk($Upload, $arstable);
                     }
                     if ($Agent_pk == 0) {
                         $text = _("No data available.  Use Jobs > Agents to schedule a copyright scan.");
                         $Msg = "<b>{$text}</b><p>";
                         $OutBuf .= $Msg;
                         break;
                     }
                     $AgentSelect = AgentSelect($Agent_name, $Upload, true, $dataset, $dataset, $Agent_pk, "onchange=\"addArsGo('newds', 'copyright_dataset');\"");
                     /** change the copyright  result when selecting one version of copyright */
                     if (!empty($AgentSelect)) {
                         $action = Traceback_uri() . "?mod=copyrighthist&upload={$Upload}&item={$Item}";
                         $OutBuf .= "<script type='text/javascript'>\n                function addArsGo(formid, selectid)\n                {\n                  var selectobj = document.getElementById(selectid);\n                  var Agent_pk = selectobj.options[selectobj.selectedIndex].value;\n                  document.getElementById(formid).action='{$action}'+'&agent='+Agent_pk;\n                  document.getElementById(formid).submit();\n                  return;\n                }\n              </script>";
                         /* form to select new dataset, show dataset */
                         $OutBuf .= "<form action='{$action}' id='newds' method='POST'>\n";
                         $OutBuf .= $AgentSelect;
                         $OutBuf .= "</form>";
                     }
                     $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                     /* Select list for filters */
                     $SelectFilter = "<select name='view_filter' id='view_filter' onchange='ChangeFilter(this,{$Upload}, {$Item})'>";
                     $text = _("Show all");
                     $Selected = $filter == 'none' ? "selected" : "";
                     $SelectFilter .= "<option {$Selected} value='none'>{$text}";
                     $text = _("Show files without licenses");
                     $Selected = $filter == 'nolics' ? "selected" : "";
                     $SelectFilter .= "<option {$Selected} value='nolics'>{$text}";
                     $SelectFilter .= "</select>";
                     $OutBuf .= $SelectFilter;
                     $OutBuf .= $this->ShowUploadHist($Item, $Uri, $filter, $uploadtree_tablename, $Agent_pk);
                 }
                 $OutBuf .= "</font>\n";
                 break;
             case "Text":
                 break;
             default:
         }
         /*  Cache Report */
         /********  disable cache to see if this is fast enough without it *****
             $Cached = false;
            ReportCachePut($CacheKey, $OutBuf);
            **************************************************/
     } else {
         $Cached = true;
     }
     if (!$this->OutputToStdout) {
         return $OutBuf;
     }
     print "{$OutBuf}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     /********  disable cache to see if this is fast enough without it *****
         $text = _("cached");
        $text1 = _("Update");
        if ($Cached) echo " <i>$text</i>   <a href=\"$_SERVER[REQUEST_URI]&updcache=1\"> $text1 </a>";
        **************************************************/
     return;
 }
Ejemplo n.º 16
0
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     global $Plugins;
     global $PG_CONN;
     // make sure there is a db connection
     if (!$PG_CONN) {
         echo _("NO DB connection");
     }
     $OutBuf = "";
     $Time = microtime(true);
     $Max = 50;
     /*  Input parameters */
     $agent_pk = GetParm("agent", PARM_INTEGER);
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $hash = GetParm("hash", PARM_RAW);
     $type = GetParm("type", PARM_RAW);
     $excl = GetParm("excl", PARM_RAW);
     $filter = GetParm("filter", PARM_RAW);
     if (empty($uploadtree_pk) || empty($hash) || empty($type) || empty($agent_pk)) {
         $text = _("is missing required parameters");
         echo $this->Name . " {$text}.";
         return;
     }
     /* Check item1 and item2 upload permissions */
     $Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$uploadtree_pk}");
     $UploadPerm = GetUploadPerm($Row['upload_fk']);
     if ($UploadPerm < PERM_READ) {
         $text = _("Permission Denied");
         echo "<h2>{$text}<h2>";
         return;
     }
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     /* get all rows */
     $rows = $this->GetRows($uploadtree_pk, $agent_pk, $upload_pk);
     /* Get uploadtree_tablename */
     $uploadtree_tablename = GetUploadtreeTableName($upload_pk);
     /* slim down to all rows with this hash and type,  and filter */
     $NumInstances = 0;
     $rows = $this->GetRequestedRows($rows, $hash, $type, $excl, $NumInstances, $filter);
     //debugprint($rows, "rows");
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             // micro menus
             $OutBuf .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             $RowCount = count($rows);
             if ($RowCount) {
                 $Content = htmlentities($rows[0]['content']);
                 $Offset = $Page < 0 ? 0 : $Page * $Max;
                 $PkgsOnly = false;
                 $text = _("files");
                 $text1 = _("unique");
                 $text3 = _("copyright");
                 $text4 = _("email");
                 $text5 = _("url");
                 switch ($type) {
                     case "statement":
                         $TypeStr = "{$text3}";
                         break;
                     case "email":
                         $TypeStr = "{$text4}";
                         break;
                     case "url":
                         $TypeStr = "{$text5}";
                         break;
                 }
                 $OutBuf .= "{$NumInstances} {$TypeStr} instances found in {$RowCount}  {$text}";
                 $OutBuf .= ": <b>{$Content}</b>";
                 $text = _("Display excludes files with these extensions");
                 if (!empty($excl)) {
                     $OutBuf .= "<br>{$text}: {$excl}";
                 }
                 /* Get the page menu */
                 if ($RowCount >= $Max && $Page >= 0) {
                     $PagingMenu = "<P />\n" . MenuEndlessPage($Page, intval(($RowCount + $Offset) / $Max)) . "<P />\n";
                     $OutBuf .= $PagingMenu;
                 } else {
                     $PagingMenu = "";
                 }
                 /* Offset is +1 to start numbering from 1 instead of zero */
                 $RowNum = $Offset;
                 $LinkLast = "copyrightview&agent={$agent_pk}";
                 $ShowBox = 1;
                 $ShowMicro = NULL;
                 // base url
                 $ucontent = rawurlencode($Content);
                 $baseURL = "?mod=" . $this->Name . "&agent={$agent_pk}&item={$uploadtree_pk}&hash={$hash}&type={$type}&page=-1";
                 // display rows
                 foreach ($rows as $row) {
                     // Allow user to exclude files with this extension
                     $FileExt = GetFileExt($row['ufile_name']);
                     if (empty($excl)) {
                         $URL = $baseURL . "&excl={$FileExt}";
                     } else {
                         $URL = $baseURL . "&excl={$excl}:{$FileExt}";
                     }
                     $text = _("Exclude this file type");
                     $Header = "<a href={$URL}>{$text}.</a>";
                     $ok = true;
                     if ($excl) {
                         $ExclArray = explode(":", $excl);
                         if (in_array($FileExt, $ExclArray)) {
                             $ok = false;
                         }
                     }
                     if ($ok) {
                         $OutBuf .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLast, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename);
                     }
                 }
             } else {
                 $OutBuf .= _("No files found");
             }
             if (!empty($PagingMenu)) {
                 $OutBuf .= $PagingMenu . "\n";
             }
             $OutBuf .= "<hr>\n";
             $Time = microtime(true) - $Time;
             $text = _("Elapsed time");
             $text1 = _("seconds");
             $OutBuf .= sprintf("<small>{$text}: %.2f {$text1}</small>\n", $Time);
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $OutBuf;
     }
     print $OutBuf;
     return;
 }
Ejemplo n.º 17
0
 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $upload = intval($request->get("upload"));
     $groupId = Auth::getGroupId();
     if (!$this->uploadDao->isAccessible($upload, $groupId)) {
         return $this->flushContent(_("Permission Denied"));
     }
     $item = intval($request->get("item"));
     $vars['baseuri'] = Traceback_uri();
     $vars['uploadId'] = $upload;
     $this->uploadtree_tablename = $this->uploadDao->getUploadtreeTableName($upload);
     if ($request->get('show') == 'quick') {
         $item = $this->uploadDao->getFatItemId($item, $upload, $this->uploadtree_tablename);
     }
     $vars['itemId'] = $item;
     $vars['micromenu'] = Dir2Browse($this->Name, $item, NULL, $showBox = 0, "Browse", -1, '', '', $this->uploadtree_tablename);
     $vars['licenseArray'] = $this->licenseDao->getLicenseArray();
     $itemTreeBounds = $this->uploadDao->getItemTreeBounds($item, $this->uploadtree_tablename);
     $left = $itemTreeBounds->getLeft();
     if (empty($left)) {
         return $this->flushContent(_("Job unpack/adj2nest hasn't completed."));
     }
     $histVars = $this->showUploadHist($itemTreeBounds);
     if (is_a($histVars, 'Symfony\\Component\\HttpFoundation\\RedirectResponse')) {
         return $histVars;
     }
     $vars = array_merge($vars, $histVars);
     $vars['content'] = js_url();
     return $this->render("browse.html.twig", $this->mergeWithDefault($vars));
 }
Ejemplo n.º 18
0
 protected function handle(Request $request)
 {
     $vars = array();
     $uploadId = intval($request->get('upload'));
     $uploadTreeId = intval($request->get('item'));
     if (empty($uploadTreeId) || empty($uploadId)) {
         $text = _("Empty Input");
         $vars['message'] = "<h2>{$text}</h2>";
         return $this->responseBad($vars);
     }
     if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
         $text = _("Permission Denied");
         $vars['message'] = "<h2>{$text}</h2>";
         return $this->responseBad();
     }
     $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
     $uploadEntry = $this->uploadDao->getUploadEntry($uploadTreeId, $uploadTreeTableName);
     if (Isdir($uploadEntry['ufile_mode']) || Iscontainer($uploadEntry['ufile_mode'])) {
         $parent = $this->uploadDao->getUploadParent($uploadEntry['upload_fk']);
         if (!isset($parent)) {
             return $this->responseBad();
         }
         $uploadTree = $this->uploadDao->getNextItem($uploadEntry['upload_fk'], $parent);
         if ($uploadTree === UploadDao::NOT_FOUND) {
             return $this->responseBad();
         }
         $uploadTreeId = $uploadTree->getId();
         return new RedirectResponse(Traceback_uri() . '?mod=' . $this->getName() . Traceback_parm_keep(array('show', 'upload')) . "&item={$uploadTreeId}");
     }
     if (empty($uploadTreeId)) {
         return $this->responseBad('No item selected.');
     }
     $copyrightDecisionMap = $this->decisionTypes->getMap();
     $vars['micromenu'] = Dir2Browse($this->modBack, $uploadTreeId, NULL, $showBox = 0, "View", -1, '', '', $uploadTreeTableName);
     $lastItem = GetParm("lastItem", PARM_INTEGER);
     $changed = GetParm("changedSomething", PARM_STRING);
     $userId = Auth::getUserId();
     if (!empty($lastItem) && $changed == "true") {
         $lastUploadEntry = $this->uploadDao->getUploadEntry($lastItem, $uploadTreeTableName);
         $clearingType = $_POST['clearingTypes'];
         $description = $_POST['description'];
         $textFinding = $_POST['textFinding'];
         $comment = $_POST['comment'];
         $this->copyrightDao->saveDecision($this->decisionTableName, $lastUploadEntry['pfile_fk'], $userId, $clearingType, $description, $textFinding, $comment);
     }
     $scanJobProxy = new ScanJobProxy($this->agentDao, $uploadId);
     $scanJobProxy->createAgentStatus(array($this->agentName));
     $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
     $highlights = array();
     if (array_key_exists($this->agentName, $selectedScanners)) {
         $latestXpAgentId = $selectedScanners[$this->agentName];
         $highlights = $this->copyrightDao->getHighlights($uploadTreeId, $this->tableName, $latestXpAgentId, $this->typeToHighlightTypeMap);
     }
     if (count($highlights) < 1) {
         $vars['message'] = _("No ") . $this->tableName . _(" data is available for this file.");
     }
     /* @var $view ui_view */
     $view = plugin_find("view");
     $theView = $view->getView(null, null, $showHeader = 0, "", $highlights, false, true);
     list($pageMenu, $textView) = $theView;
     list($description, $textFinding, $comment, $decisionType) = $this->copyrightDao->getDecision($this->decisionTableName, $uploadEntry['pfile_fk']);
     $vars['description'] = $description;
     $vars['textFinding'] = $textFinding;
     $vars['comment'] = $comment;
     $vars['itemId'] = $uploadTreeId;
     $vars['uploadId'] = $uploadId;
     $vars['pageMenu'] = $pageMenu;
     $vars['textView'] = $textView;
     $vars['legendBox'] = $this->legendBox();
     $vars['uri'] = Traceback_uri() . "?mod=" . $this->Name;
     $vars['optionName'] = $this->optionName;
     $vars['formName'] = "CopyRightForm";
     $vars['ajaxAction'] = $this->ajaxAction;
     $vars['skipOption'] = $this->skipOption;
     $vars['selectedClearingType'] = $decisionType;
     $vars['clearingTypes'] = $copyrightDecisionMap;
     $vars['xptext'] = $this->xptext;
     $agentId = intval($request->get("agent"));
     $vars = array_merge($vars, $this->additionalVars($uploadId, $uploadTreeId, $agentId));
     return $this->render('ui-cp-view.html.twig', $this->mergeWithDefault($vars));
 }
Ejemplo n.º 19
0
 /**
  * \brief This function returns the scheduler status.
  */
 function Output()
 {
     $uTime = microtime(true);
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Upload = GetParm("upload", PARM_INTEGER);
     $UploadPerm = GetUploadPerm($Upload);
     if ($UploadPerm < PERM_READ) {
         $text = _("Permission Denied");
         echo "<h2>{$text}<h2>";
         return;
     }
     $Item = GetParm("item", PARM_INTEGER);
     $tag_pk = GetParm("tag", PARM_INTEGER);
     $updcache = GetParm("updcache", PARM_INTEGER);
     $this->uploadtree_tablename = GetUploadtreeTableName($Upload);
     /* Remove "updcache" from the GET args.
      * This way all the url's based on the input args won't be
      * polluted with updcache
      * Use Traceback_parm_keep to ensure that all parameters are in order */
     $CacheKey = "?mod=" . $this->Name . Traceback_parm_keep(array("upload", "item", "tag", "agent", "orderBy", "orderl", "orderc"));
     if ($updcache) {
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     if (empty($V)) {
         switch ($this->OutputType) {
             case "XML":
                 break;
             case "HTML":
                 $V .= "<font class='text'>\n";
                 /************************/
                 /* Show the folder path */
                 /************************/
                 $V .= Dir2Browse($this->Name, $Item, NULL, 1, "Browse", -1, '', '', $this->uploadtree_tablename) . "<P />\n";
                 if (!empty($Upload)) {
                     $Uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
                     $V .= js_url();
                     $V .= $this->ShowUploadHist($Item, $Uri, $tag_pk);
                 }
                 $V .= "</font>\n";
                 $text = _("Loading...");
                 /*$V .= "<div id='ajax_waiting'><img src='images/ajax-loader.gif'>$text</div>"; */
                 break;
             case "Text":
                 break;
             default:
         }
         $Cached = false;
     } else {
         $Cached = true;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     $Time = microtime(true) - $uTime;
     // convert usecs to secs
     $text = _("Elapsed time: %.2f seconds");
     printf("<small>{$text}</small>", $Time);
     if ($Cached) {
         $text = _("cached");
         $text1 = _("Update");
         echo " <i>{$text}</i>   <a href=\"{$_SERVER['REQUEST_URI']}&updcache=1\"> {$text1} </a>";
     } else {
         /*  Cache Report if this took longer than 1/2 second*/
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return;
 }
Ejemplo n.º 20
0
 /**
  * \brief This function is called when user output is
  * requested.  This function is responsible for content.
  * (OutputOpen and Output are separated so one plugin
  * can call another plugin's Output.)
  * This uses $OutputType.
  * The $ToStdout flag is "1" if output should go to stdout, and
  * 0 if it should be returned as a string.  (Strings may be parsed
  * and used by other plugins.)
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $Folder = GetParm("folder", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     $UploadPerm = GetUploadPerm($Upload);
     if ($UploadPerm < PERM_READ) {
         return;
     }
     $Item = GetParm("item", PARM_INTEGER);
     $V = "";
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             $V .= Dir2Browse("browse", $Item, NULL, 1, "View-Meta");
             $V .= $this->ShowTagInfo($Upload, $Item);
             $V .= $this->ShowPackageinfo($Upload, $Item, 1);
             $V .= $this->ShowMetaView($Upload, $Item);
             $V .= $this->ShowSightings($Upload, $Item);
             $V .= $this->ShowView($Upload, $Item);
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
Ejemplo n.º 21
0
 public function Output()
 {
     $OutBuf = "";
     $uploadId = GetParm("upload", PARM_INTEGER);
     $item = GetParm("item", PARM_INTEGER);
     $filter = GetParm("filter", PARM_STRING);
     /* check upload permissions */
     if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
         $text = _("Permission Denied");
         return "<h2>{$text}</h2>";
     }
     /* Get uploadtree_tablename */
     $uploadtree_tablename = GetUploadtreeTableName($uploadId);
     $this->uploadtree_tablename = $uploadtree_tablename;
     /************************/
     /* Show the folder path */
     /************************/
     $this->vars['dir2browse'] = Dir2Browse($this->Name, $item, NULL, 1, "Browse", -1, '', '', $uploadtree_tablename);
     if (empty($uploadId)) {
         return 'no item selected';
     }
     /** advanced interface allowing user to select dataset (agent version) */
     $dataset = $this->agentName . "_dataset";
     $arstable = $this->agentName . "_ars";
     /** get proper agent_id */
     $agentId = GetParm("agent", PARM_INTEGER);
     if (empty($agentId)) {
         $agentId = LatestAgentpk($uploadId, $arstable);
     }
     if ($agentId == 0) {
         /** schedule copyright */
         $OutBuf .= ActiveHTTPscript("Schedule");
         $OutBuf .= "<script language='javascript'>\n";
         $OutBuf .= "function Schedule_Reply()\n";
         $OutBuf .= "  {\n";
         $OutBuf .= "  if ((Schedule.readyState==4) && (Schedule.status==200 || Schedule.status==400))\n";
         $OutBuf .= "    document.getElementById('msgdiv').innerHTML = Schedule.responseText;\n";
         $OutBuf .= "  }\n";
         $OutBuf .= "</script>\n";
         $OutBuf .= "<form name='formy' method='post'>\n";
         $OutBuf .= "<div id='msgdiv'>\n";
         $OutBuf .= _("No data available.");
         $OutBuf .= "<input type='button' name='scheduleAgent' value='Schedule Agent'";
         $OutBuf .= "onClick=\"Schedule_Get('" . Traceback_uri() . "?mod=schedule_agent&upload={$uploadId}&agent=agent_{$this->agentName}')\">\n";
         $OutBuf .= "</input>";
         $OutBuf .= "</div> \n";
         $OutBuf .= "</form>\n";
         $this->vars['pageContent'] = $OutBuf;
         return;
     }
     $AgentSelect = AgentSelect($this->agentName, $uploadId, $dataset, $agentId, "onchange=\"addArsGo('newds', 'copyright_dataset');\"");
     /** change the copyright  result when selecting one version of copyright */
     if (!empty($AgentSelect)) {
         $action = Traceback_uri() . '?mod=' . GetParm('mod', PARM_RAW) . Traceback_parm_keep(array('upload', 'item'));
         $OutBuf .= "<script type='text/javascript'>\n        function addArsGo(formid, selectid)\n        {\n          var selectobj = document.getElementById(selectid);\n          var Agent_pk = selectobj.options[selectobj.selectedIndex].value;\n          document.getElementById(formid).action='{$action}'+'&agent='+Agent_pk;\n          document.getElementById(formid).submit();\n          return;\n        }\n      </script>";
         $OutBuf .= "<form action=\"{$action}\" id=\"newds\" method=\"POST\">{$AgentSelect}</form>";
     }
     $selectKey = $filter == 'nolic' ? 'nolic' : 'all';
     $OutBuf .= "<select name='view_filter' id='view_filter' onchange='ChangeFilter(this,{$uploadId}, {$item});'>";
     foreach (array('all' => _("Show all"), 'nolic' => _("Show files without licenses")) as $key => $text) {
         $selected = $selectKey == $key ? "selected" : "";
         $OutBuf .= "<option {$selected} value=\"{$key}\">{$text}</option>";
     }
     $OutBuf .= "</select>";
     $uri = preg_replace("/&item=([0-9]*)/", "", Traceback());
     list($tables, $tableVars) = $this->ShowUploadHist($uploadId, $item, $uri, $selectKey, $uploadtree_tablename, $agentId);
     $this->vars['tables'] = $tableVars;
     $this->vars['pageContent'] = $OutBuf . $tables;
     $this->vars['scriptBlock'] = $this->createScriptBlock();
     return;
 }
Ejemplo n.º 22
0
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     if ($this->OutputType != 'HTML') {
         return;
     }
     $this->vars['baseuri'] = Traceback_uri();
     $CriteriaCount = 0;
     $GETvars = "";
     $Item = GetParm("item", PARM_INTEGER);
     /* Show path if searching an item tree  (don't show on global searches) */
     if ($Item) {
         $this->vars['pathOfItem'] = Dir2Browse($this->Name, $Item, NULL, 1, NULL) . "<P />\n";
         $GETvars .= "&item={$Item}";
     }
     $searchtype = GetParm("searchtype", PARM_STRING);
     $GETvars .= "&searchtype=" . urlencode($searchtype);
     if ($searchtype == 'containers') {
         $this->vars["ContainersChecked"] = "checked=\"checked\"";
     } else {
         if ($searchtype == 'directory') {
             $this->vars["DirectoryChecked"] = "checked=\"checked\"";
         } else {
             $this->vars["AllFilesChecked"] = "checked=\"checked\"";
         }
     }
     $Filename = GetParm("filename", PARM_RAW);
     if (!empty($Filename)) {
         $CriteriaCount++;
         $GETvars .= "&filename=" . urlencode($Filename);
         $this->vars["Filename"] = $Filename;
     }
     $tag = GetParm("tag", PARM_RAW);
     if (!empty($tag)) {
         $CriteriaCount++;
         $GETvars .= "&tag=" . urlencode($tag);
         $this->vars["tag"] = $tag;
     }
     $SizeMin = GetParm("sizemin", PARM_TEXT);
     if (!empty($SizeMin) && $SizeMin >= 0) {
         $SizeMin = intval($SizeMin);
         $CriteriaCount++;
         $GETvars .= "&sizemin={$SizeMin}";
         $this->vars["SizeMin"] = $SizeMin;
     }
     $SizeMax = GetParm("sizemax", PARM_TEXT);
     if (!empty($SizeMax) && $SizeMax >= 0) {
         $SizeMax = intval($SizeMax);
         $CriteriaCount++;
         $GETvars .= "&sizemax={$SizeMax}";
         $this->vars["SizeMax"] = $SizeMax;
     }
     $License = GetParm("license", PARM_RAW);
     if (!empty($License)) {
         $CriteriaCount++;
         $GETvars .= "&license=" . urlencode($License);
         $this->vars["License"] = $License;
     }
     $Copyright = GetParm("copyright", PARM_RAW);
     if (!empty($Copyright)) {
         $CriteriaCount++;
         $GETvars .= "&copyright=" . urlencode($Copyright);
         $this->vars["Copyright"] = $Copyright;
     }
     $Page = GetParm("page", PARM_INTEGER);
     $this->vars["postUrl"] = Traceback_uri() . "?mod=" . self::getName();
     if ($CriteriaCount) {
         if (empty($Page)) {
             $Page = 0;
         }
         $html = "<hr>\n";
         $text = _("Files matching");
         $html .= "<H2>{$text} " . htmlentities($Filename) . "</H2>\n";
         $UploadtreeRecs = $this->GetResults($Item, $Filename, $tag, $Page, $SizeMin, $SizeMax, $searchtype, $License, $Copyright);
         $html .= $this->HTMLResults($UploadtreeRecs, $Page, $GETvars, $License, $Copyright);
         $this->vars["result"] = $html;
     }
 }
Ejemplo n.º 23
0
/**
 * \brief Given an array of pfiles/uploadtree, sorted by
 *  pfile, list all of the breadcrumbs for each file.
 *  If the pfile is a duplicate, then indent it.
 *
 * \param $Listing = array from a database selection.  The SQL query should
 *	use "ORDER BY pfile_fk" so that the listing can indent duplicate pfiles
 * \param $IfDirPlugin = string containing plugin name to use if this is a directory or any other container
 * \param $IfFilePlugin = string containing plugin name to use if this is a file
 * \param $Count = first number for indexing the entries (may be -1 for no count)
 * \param $ShowPhrase Obsolete from bsam
 *
 * \return string containing the listing.
 */
function UploadtreeFileList($Listing, $IfDirPlugin, $IfFilePlugin, $Count = -1, $ShowPhrase = 0)
{
    $LastPfilePk = -1;
    $V = "";
    foreach ($Listing as $R) {
        if (array_key_exists("licenses", $R)) {
            $Licenses = $R["licenses"];
        } else {
            $Licenses = '';
        }
        $Phrase = '';
        if ($ShowPhrase && !empty($R['phrase_text'])) {
            $text = _("Phrase");
            $Phrase = "<b>{$text}:</b> " . htmlentities($R['phrase_text']);
        }
        $uploadtree_tablename = GetUploadtreeTableName($R['upload_fk']);
        if (IsDir($R['ufile_mode']) || Iscontainer($R['ufile_mode'])) {
            $V .= "<P />\n";
            $V .= Dir2Browse("browse", $R['uploadtree_pk'], $IfDirPlugin, 1, NULL, $Count, $Phrase, $Licenses, $uploadtree_tablename) . "\n";
        } else {
            if ($R['pfile_fk'] != $LastPfilePk) {
                $V .= "<P />\n";
                $V .= Dir2Browse("browse", $R['uploadtree_pk'], $IfFilePlugin, 1, NULL, $Count, $Phrase, $Licenses, $uploadtree_tablename) . "\n";
                $LastPfilePk = $R['pfile_fk'];
            } else {
                $V .= "<div style='margin-left:2em;'>";
                $V .= Dir2Browse("browse", $R['uploadtree_pk'], $IfFilePlugin, 1, NULL, $Count, $Phrase, $Licenses, $uploadtree_tablename) . "\n";
                $V .= "</div>";
            }
        }
        $Count++;
    }
    return $V;
}
Ejemplo n.º 24
0
 /** 
  * \brief create the HTML to display the form showing the found projects
  * \param $acme_project_array
  * \param $upload_pk
  * \return HTML to display results
  */
 function HTMLForm($acme_project_array, $upload_pk)
 {
     $Outbuf = "";
     $uploadtreeRec = GetSingleRec("uploadtree", "where upload_fk={$upload_pk} and parent is null");
     $Outbuf .= Dir2Browse($this->Name, $uploadtreeRec['uploadtree_pk'], NULL, 1, "acme");
     $Outbuf .= "<p>";
     $URI = "?mod=" . $this->Name . Traceback_parm_keep(array("page", "upload", "folic", "detail"));
     $Outbuf .= "<form action='" . $URI . "' method='POST'>\n";
     $Outbuf .= "<table border=1>";
     $Outbuf .= "<tr>";
     $text = _('Include');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('Project');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('Files');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('URL');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('Description');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('License');
     $Outbuf .= "<th>{$text}</th>";
     $text = _('Version');
     $Outbuf .= "<th>{$text}</th>";
     $Outbuf .= "</tr>";
     /* For alternating row background colors */
     $RowStyle1 = "style='background-color:lavender'";
     $RowStyle2 = "style='background-color:lightyellow'";
     $ColorSpanRows = 1;
     // Alternate background color every $ColorSpanRows
     $RowNum = 0;
     foreach ($acme_project_array as $project) {
         /* Set alternating row background color - repeats every $ColorSpanRows rows */
         $RowStyle = $RowNum++ % (2 * $ColorSpanRows) < $ColorSpanRows ? $RowStyle1 : $RowStyle2;
         $Outbuf .= "<tr {$RowStyle}>";
         $Checked = $project['include'] == 't' ? "checked=\"checked\"" : '';
         $Outbuf .= "<td><input type='checkbox' name='includeproj[{$project['acme_project_pk']}]' {$Checked}></td>\n";
         $Outbuf .= "<td>{$project['project_name']}</td>";
         $ProjectListURL = Traceback_uri() . "?mod=" . $this->Name . "&acme_project={$project['acme_project_pk']}&upload={$upload_pk}";
         $Outbuf .= "<td><a href='{$ProjectListURL}'>{$project['count']}</a></td>";
         $Outbuf .= "<td><a href='{$project['url']}'>{$project['url']}</a></td>";
         $Outbuf .= "<td>" . htmlentities($project['description']) . "</td>";
         $Outbuf .= "<td>{$project['licenses']}</td>";
         $Outbuf .= "<td>{$project['version']}</td>";
         $Outbuf .= "</tr>";
     }
     $Outbuf .= "</table>";
     $Outbuf .= "{$RowNum} rows found<br>";
     $text = _("Save and Generate SPDX file");
     $Outbuf .= "<p><input type='submit' value='{$text}' name='spdxbtn'>\n";
     $text = _("Save");
     $Outbuf .= "&nbsp;&nbsp;&nbsp;<input type='submit' value='{$text}' name='savebtn'>\n";
     $Outbuf .= "</form>\n";
     /*******  END Input form  *******/
     return $Outbuf;
 }
Ejemplo n.º 25
0
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     global $Plugins;
     $CriteriaCount = 0;
     $V = "";
     $GETvars = "";
     $Item = GetParm("item", PARM_INTEGER);
     if ($this->OutputType != 'HTML') {
         return;
     }
     /* Show path if searching an item tree  (don't show on global searches) */
     if ($Item) {
         $V .= Dir2Browse($this->Name, $Item, NULL, 1, NULL) . "<P />\n";
         $GETvars .= "&item={$Item}";
     }
     $searchtype = GetParm("searchtype", PARM_STRING);
     $GETvars .= "&searchtype=" . urlencode($searchtype);
     $Filename = GetParm("filename", PARM_RAW);
     if (!empty($Filename)) {
         $CriteriaCount++;
         $GETvars .= "&filename=" . urlencode($Filename);
     }
     $tag = GetParm("tag", PARM_RAW);
     if (!empty($tag)) {
         $CriteriaCount++;
         $GETvars .= "&tag=" . urlencode($tag);
     }
     $SizeMin = GetParm("sizemin", PARM_TEXT);
     if (!empty($SizeMin) && $SizeMin >= 0) {
         $SizeMin = intval($SizeMin);
         $CriteriaCount++;
         $GETvars .= "&sizemin={$SizeMin}";
     }
     $SizeMax = GetParm("sizemax", PARM_TEXT);
     if (!empty($SizeMax) && $SizeMax >= 0) {
         $SizeMax = intval($SizeMax);
         $CriteriaCount++;
         $GETvars .= "&sizemax={$SizeMax}";
     }
     $License = GetParm("license", PARM_RAW);
     if (!empty($License)) {
         $CriteriaCount++;
         $GETvars .= "&license=" . urlencode($License);
     }
     $Copyright = GetParm("copyright", PARM_RAW);
     if (!empty($Copyright)) {
         $CriteriaCount++;
         $GETvars .= "&copyright=" . urlencode($Copyright);
     }
     $Page = GetParm("page", PARM_INTEGER);
     /*******  Input form  *******/
     $V .= "<form action='" . Traceback_uri() . "?mod=" . $this->Name . "' method='POST'>\n";
     /* searchtype:  'allfiles' or 'containers' */
     $ContainersChecked = "";
     $DirectoryChecked = "";
     $AllFilesChecked = "";
     if ($searchtype == 'containers') {
         $ContainersChecked = "checked=\"checked\"";
     } else {
         if ($searchtype == 'directory') {
             $DirectoryChecked = "checked=\"checked\"";
         } else {
             $AllFilesChecked = "checked=\"checked\"";
         }
     }
     $text = _("Limit search to (Note: can not limit license and copyright search on containers)");
     $text1 = _("Containers only (rpms, tars, isos, etc), including directories.");
     $V .= "<u><i><b>{$text}:</b></i></u><br> <input type='radio' name='searchtype' value='containers' {$ContainersChecked}><b>{$text1}</b>\n";
     $text2 = _("Containers only (rpms, tars, isos, etc), excluding directories.");
     $V .= "<br> <input type='radio' name='searchtype' value='directory' {$DirectoryChecked}><b>{$text2}</b>\n";
     $text3 = _("All Files");
     $V .= "<br> <input type='radio' name='searchtype' value='allfiles' {$AllFilesChecked}><b>{$text3}</b>\n";
     $V .= "<p><u><i><b>" . _("You must choose one or more search criteria (not case sensitive).") . "</b></i></u>";
     $V .= "<ul>\n";
     /* filename */
     $text = _("Enter the filename to find: ");
     $V .= "<li><b>{$text}</b>";
     $V .= "<INPUT type='text' name='filename' size='40' value='" . htmlentities($Filename) . "'>\n";
     $V .= "<br>" . _("You can use '%' as a wild-card. ");
     $V .= _("For example, '%v3.war', or 'mypkg%.tar'.");
     /* tag  */
     $text = _("Tag to find");
     $V .= "<li><b>{$text}:</b>  <input name='tag' size='30' value='" . htmlentities($tag) . "'>\n";
     /* file size >= */
     $text = _("File size is");
     $text1 = _(" bytes\n");
     $V .= "<li><b>{$text} &ge; </b><input name='sizemin' size=10 value='{$SizeMin}'>{$text1}";
     /* file size <= */
     $text = _("File size is");
     $text1 = _(" bytes\n");
     $V .= "<li><b>{$text} &le; </b><input name='sizemax' size=10 value='{$SizeMax}'>{$text1}";
     $V .= "</ul>\n";
     $V .= "<ul>\n";
     $V .= "<p><u><i><b>" . _("You may also choose one or more optional search filters (not case sensitive).") . "</b></i></u>";
     /* license */
     $text = _("License");
     $V .= "<li><b>{$text}: </b><input name='license' value='{$License}'>";
     $V .= "<br>" . _("For example, 'AGPL%'.");
     $text = _("Copyright");
     $V .= "<li><b>{$text}: </b><input name='copyright' value='{$Copyright}'>";
     $V .= "<br>" . _("For example, 'fsf'.");
     $V .= "</ul>\n";
     $V .= "<input type='hidden' name='item' value='{$Item}'>\n";
     $text = _("Search");
     $V .= "<input type='submit' value='{$text}'>\n";
     $V .= "</form>\n";
     /*******  END Input form  *******/
     if ($CriteriaCount) {
         if (empty($Page)) {
             $Page = 0;
         }
         $V .= "<hr>\n";
         $text = _("Files matching");
         $V .= "<H2>{$text} " . htmlentities($Filename) . "</H2>\n";
         $UploadtreeRecs = $this->GetResults($Item, $Filename, $tag, $Page, $SizeMin, $SizeMax, $searchtype, $License, $Copyright);
         $V .= $this->HTMLResults($UploadtreeRecs, $Page, $GETvars, $License, $Copyright);
     }
     $this->vars['content'] = $V;
 }
 /**
  * \brief Display all the files for a bucket in this subtree.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     global $Plugins;
     global $PG_CONN;
     /*  Input parameters */
     $bucketagent_pk = GetParm("bapk", PARM_INTEGER);
     $uploadtree_pk = GetParm("item", PARM_INTEGER);
     $bucket_pk = GetParm("bpk", PARM_INTEGER);
     $bucketpool_pk = GetParm("bp", PARM_INTEGER);
     $nomosagent_pk = GetParm("napk", PARM_INTEGER);
     $BinNoSrc = GetParm("bns", PARM_INTEGER);
     // 1 if requesting binary with no src
     $Excl = GetParm("excl", PARM_RAW);
     if (empty($uploadtree_pk) || empty($bucket_pk) || empty($bucketpool_pk)) {
         $text = _("is missing required parameters.");
         echo $this->Name . " {$text}";
         return;
     }
     /* Check upload permission */
     $Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$uploadtree_pk}");
     $UploadPerm = GetUploadPerm($Row['upload_fk']);
     if ($UploadPerm < PERM_READ) {
         $text = _("Permission Denied");
         echo "<h2>{$text} item 1<h2>";
         return;
     }
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     $V = "";
     $Time = time();
     $Max = 200;
     // Create cache of bucket_pk => bucket_name
     // Since we are going to do a lot of lookups
     $sql = "select bucket_pk, bucket_name from bucket_def where bucketpool_fk={$bucketpool_pk}";
     $result_name = pg_query($PG_CONN, $sql);
     DBCheckResult($result_name, $sql, __FILE__, __LINE__);
     $bucketNameCache = array();
     while ($name_row = pg_fetch_assoc($result_name)) {
         $bucketNameCache[$name_row['bucket_pk']] = $name_row['bucket_name'];
     }
     pg_free_result($result_name);
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             // micro menus
             $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             /* Get all the files under this uploadtree_pk with this bucket */
             $V .= _("The following files are in bucket: '<b>");
             $V .= $bucketNameCache[$bucket_pk];
             $V .= "</b>'.\n";
             $text = _("Display");
             $text1 = _("excludes");
             $text2 = _("files with these licenses");
             if (!empty($Excl)) {
                 $V .= "<br>{$text} <b>{$text1}</b> {$text2}: {$Excl}";
             }
             $Offset = $Page <= 0 ? 0 : $Page * $Max;
             $PkgsOnly = false;
             // Get bounds of subtree (lft, rgt) for this uploadtree_pk
             $sql = "SELECT lft,rgt,upload_fk FROM uploadtree\n              WHERE uploadtree_pk = {$uploadtree_pk}";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             $row = pg_fetch_assoc($result);
             $lft = $row["lft"];
             $rgt = $row["rgt"];
             $upload_pk = $row["upload_fk"];
             pg_free_result($result);
             /* Get uploadtree table */
             $uploadtree_tablename = GetUploadtreeTableName($upload_pk);
             /* If $BinNoSrc, then only list binary packages in this subtree
              * that do not have Source packages.
              * Else list files in the asked for bucket.
              */
             if ($BinNoSrc) {
             } else {
                 $Offset = $Page < 0 ? 0 : $Page * $Max;
                 $limit = $Page < 0 ? "ALL" : $Max;
                 // Get all the uploadtree_pk's with this bucket (for this agent and bucketpool)
                 // in this subtree.
                 // It would be best to sort by pfile_pk, so that the duplicate pfiles are
                 // correctly indented, but pfile_pk has no meaning to the user.  So a compromise,
                 // sorting by ufile_name is used.
                 $sql = "select uploadtree.*, bucket_file.nomosagent_fk as nomosagent_fk\n               from uploadtree, bucket_file, bucket_def\n               where upload_fk={$upload_pk} and uploadtree.lft between {$lft} and {$rgt}\n                 and ((ufile_mode & (1<<28)) = 0)\n                 and ((ufile_mode & (1<<29))=0)\n                 and uploadtree.pfile_fk=bucket_file.pfile_fk\n                 and agent_fk={$bucketagent_pk}\n                 and bucket_fk={$bucket_pk}\n                 and bucketpool_fk={$bucketpool_pk}\n                 and bucket_pk=bucket_fk \n                 order by uploadtree.ufile_name\n                 limit {$limit} offset {$Offset}";
                 $fileresult = pg_query($PG_CONN, $sql);
                 DBCheckResult($fileresult, $sql, __FILE__, __LINE__);
                 $Count = pg_num_rows($fileresult);
             }
             $file_result_temp = pg_fetch_all($fileresult);
             $sourted_file_result = array();
             // the final file list will display
             $max_num = $Count;
             /** sorting by ufile_name from DB, then reorder the duplicates indented */
             for ($i = 0; $i < $max_num; $i++) {
                 $row = $file_result_temp[$i];
                 if (empty($row)) {
                     continue;
                 }
                 array_push($sourted_file_result, $row);
                 for ($j = $i + 1; $j < $max_num; $j++) {
                     $row_next = $file_result_temp[$j];
                     if (!empty($row_next) && $row['pfile_fk'] == $row_next['pfile_fk']) {
                         array_push($sourted_file_result, $row_next);
                         $file_result_temp[$j] = null;
                     }
                 }
             }
             if ($Count < 1.25 * $Max) {
                 $Max = $Count;
             }
             if ($Max < 1) {
                 $Max = 1;
             }
             // prevent div by zero in corner case of no files
             /* Get the page menu */
             if ($Count >= $Max && $Page >= 0) {
                 $VM = "<P />\n" . MenuEndlessPage($Page, intval(($Count + $Offset) / $Max)) . "<P />\n";
                 $V .= $VM;
             } else {
                 $VM = "";
             }
             // base url
             $baseURL = "?mod=" . $this->Name . "&bapk={$bucketagent_pk}&item={$uploadtree_pk}&bpk={$bucket_pk}&bp={$bucketpool_pk}&napk={$nomosagent_pk}&page=-1";
             // for each uploadtree rec ($fileresult), find all the licenses in it and it's children
             $ShowBox = 1;
             $ShowMicro = NULL;
             $RowNum = $Offset;
             $Header = "";
             $LinkLast = "list_bucket_files&bapk={$bucketagent_pk}";
             /* file display loop/table */
             $V .= "<table>";
             $text = _("File");
             $V .= "<tr><th>{$text}</th><th>&nbsp";
             $ExclArray = explode(":", $Excl);
             $ItemNumb = 0;
             $PrevPfile_pk = 0;
             if ($Count > 0) {
                 foreach ($sourted_file_result as $row) {
                     // get all the licenses in this subtree (bucket uploadtree_pk)
                     $pfile_pk = $row['pfile_fk'];
                     $licstring = GetFileLicenses_string($nomosagent_pk, $row['pfile_fk'], $row['uploadtree_pk'], $uploadtree_tablename);
                     if (empty($licstring)) {
                         $licstring = '-';
                     }
                     $URLlicstring = urlencode($licstring);
                     /* Allow user to exclude files with this exact license list */
                     if (!empty($Excl)) {
                         $URL = $baseURL . "&excl=" . urlencode($Excl) . ":" . $URLlicstring;
                     } else {
                         $URL = $baseURL . "&excl={$URLlicstring}";
                     }
                     $text = _("Exclude files with license");
                     $Header = "<a href={$URL}>{$text}: {$licstring}.</a>";
                     $ok = true;
                     if ($Excl) {
                         if (in_array($licstring, $ExclArray)) {
                             $ok = false;
                         }
                     }
                     if ($ok) {
                         $nomosagent_pk = $row['nomosagent_fk'];
                         $LinkLast = "view-license&bapk={$bucketagent_pk}&napk={$nomosagent_pk}";
                         $V .= "<tr><td>";
                         if ($PrevPfile_pk == $pfile_pk) {
                             $V .= "<div style='margin-left:2em;'>";
                         } else {
                             $V .= "<div>";
                         }
                         $V .= Dir2Browse("browse", $row['uploadtree_pk'], $LinkLast, $ShowBox, $ShowMicro, ++$RowNum, $Header, '', $uploadtree_tablename);
                         $V .= "</div>";
                         $V .= "</td>";
                         $V .= "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>";
                         // spaces to seperate licenses
                         // show the entire license list as a single string with links to the files
                         // in this container with that license.
                         $V .= "<td>{$licstring}</td></tr>";
                         $V .= "<tr><td colspan=3><hr></td></tr>";
                         // separate files
                     }
                     $PrevPfile_pk = $pfile_pk;
                 }
             }
             pg_free_result($fileresult);
             $V .= "</table>";
             if (!empty($VM)) {
                 $V .= $VM . "\n";
             }
             $V .= "<hr>\n";
             $Time = time() - $Time;
             $text = _("Elapsed time");
             $text1 = _("seconds");
             $V .= "<small>{$text}: {$Time} {$text1}</small>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }