コード例 #1
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $tooltipText = _("View file information");
     menu_insert("Browse-Pfile::Info", 5, $this->Name, $tooltipText);
     // For the Browse menu, permit switching between detail and summary.
     $Parm = Traceback_parm_keep(array("upload", "item", "format"));
     $URI = $this->Name . $Parm;
     $menuPosition = 60;
     $menuText = "Info";
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("View::[BREAK]", 61);
         menu_insert("View::[BREAK]", 50);
         menu_insert("View::{$menuText}", $menuPosition);
         menu_insert("View-Meta::[BREAK]", 61);
         menu_insert("View-Meta::[BREAK]", 50);
         menu_insert("View-Meta::{$menuText}", $menuPosition);
         menu_insert("Browse::Info", -3);
     } else {
         $tooltipText = _("View information about this file");
         menu_insert("View::[BREAK]", 61);
         menu_insert("View::[BREAK]", 50);
         menu_insert("View::{$menuText}", $menuPosition, $URI, $tooltipText);
         menu_insert("View-Meta::[BREAK]", 61);
         menu_insert("View-Meta::[BREAK]", 50);
         menu_insert("View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
         menu_insert("Browse::Info", -3, $URI, $tooltipText);
     }
 }
コード例 #2
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $MenuDisplayString = _("License List");
     $MenuDisplayStringDL = _("License List Download");
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (empty($Item) || empty($Upload)) {
         return;
     }
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("Browse::{$MenuDisplayString}", 1);
         menu_insert("Browse::{$MenuDisplayStringDL}", 1, $URI . "&output=dltext");
     } else {
         menu_insert("Browse::{$MenuDisplayString}", 1, $URI, $MenuDisplayString);
         menu_insert("Browse::{$MenuDisplayStringDL}", 1, $URI . "&output=dltext", $MenuDisplayStringDL);
         /* bobg - This is to use a select list in the micro menu to replace the above List
             and Download, but put this select list in a form
             $LicChoices = array("Lic Download" => "Download", "Lic display" => "Display");
             $LicChoice = Array2SingleSelect($LicChoices, $SLName="LicDL");
             menu_insert("Browse::Nomos License List Download2", 1, $URI . "&output=dltext", NULL,NULL, $LicChoice);
            */
     }
 }
コード例 #3
0
ファイル: search.php プロジェクト: rlintu/fossology
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->MenuTarget);
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("page", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     if (!empty($Item)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::Search", 1);
         } else {
             menu_insert("Browse::Search", 1, $URI, $this->MenuList);
         }
     }
 }
コード例 #4
0
ファイル: ui-browse.php プロジェクト: DanielDobre/fossology
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     menu_insert("Main::" . $this->MenuList, $this->MenuOrder, $this->Name, $this->Name);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (empty($Upload)) {
         return;
     }
     // For the Browse menu, permit switching between detail and simple.
     $URI = $this->Name . Traceback_parm_keep(array("upload", "item"));
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("Browse::Browse", 1);
     } else {
         menu_insert("Browse::Browse", 1, $URI);
     }
     return $this->State == PLUGIN_STATE_READY;
 }
コード例 #5
0
ファイル: ecc-hist.php プロジェクト: DanielDobre/fossology
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::ECC", 1);
             menu_insert("Browse::[BREAK]", 100);
         } else {
             $text = _("View ECC histogram");
             menu_insert("Browse::ECC", 10, $URI, $text);
         }
     }
 }
コード例 #6
0
ファイル: showjobs.php プロジェクト: DanielDobre/fossology
 function RegisterMenus()
 {
     menu_insert("Main::Jobs::My Recent Jobs", $this->MenuOrder - 1, $this->Name, $this->MenuTarget);
     if ($_SESSION[Auth::USER_LEVEL] != PLUGIN_DB_ADMIN) {
         return;
     }
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         /* Set micro menu to select either all users or this user */
         $allusers = GetParm("allusers", PARM_INTEGER);
         if ($allusers == 0) {
             $text = _("Show uploads from all users");
             $URI = $this->Name . Traceback_parm_keep(array("page")) . "&allusers=1";
         } else {
             $text = _("Show only your own uploads");
             $URI = $this->Name . Traceback_parm_keep(array("page")) . "&allusers=0";
         }
         menu_insert("showjobs::{$text}", 1, $URI, $text);
     }
 }
コード例 #7
0
ファイル: EccView.php プロジェクト: DanielDobre/fossology
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $itemId = GetParm("item", PARM_INTEGER);
     $textFormat = $this->microMenu->getFormatParameter($itemId);
     $pageNumber = GetParm("page", PARM_INTEGER);
     $this->microMenu->addFormatMenuEntries($textFormat, $pageNumber);
     // For all other menus, permit coming back here.
     $uploadId = GetParm("upload", PARM_INTEGER);
     if (!empty($itemId) && !empty($uploadId)) {
         $menuText = "ECC";
         $tooltipText = "Export Control Classification";
         $menuPosition = 56;
         $URI = EccView::NAME . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
         $this->microMenu->insert(MicroMenu::TARGET_DEFAULT, $menuText, $menuPosition, $this->getName(), $URI, $tooltipText);
     }
     $licId = GetParm("lic", PARM_INTEGER);
     if (!empty($licId)) {
         $this->NoMenu = 1;
     }
 }
コード例 #8
0
ファイル: view.php プロジェクト: pombredanne/fossology-test
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("View::View Copyright/Email/Url", 1);
             menu_insert("View-Meta::View Copyright/Email/Url", 1);
         } else {
             $text = _("View Copyright/Email/Url info");
             menu_insert("View::View Copyright/Email/Url", 1, $URI, $text);
             menu_insert("View-Meta::View Copyright/Email/Url", 1, $URI, $text);
         }
     }
     $Lic = GetParm("lic", PARM_INTEGER);
     if (!empty($Lic)) {
         $this->NoMenu = 1;
     }
 }
コード例 #9
0
ファイル: bucket-diff.php プロジェクト: DanielDobre/fossology
 /**
 * @brief Output(): 
 * Requires:\n
        filter: optional filter to apply\n
        item1:  uploadtree_pk of the column 1 tree\n
        item2:  uploadtree_pk of the column 2 tree\n
        freeze: column number (1 or 2) to freeze
 */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $uTime = microtime(true);
     $V = "";
     $UpdCache = GetParm("updcache", PARM_INTEGER);
     /* 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("item1", "item2", "filter", "col", "freeze", "itemf"));
     if ($UpdCache) {
         $UpdCache = $_GET['updcache'];
         $_SERVER['REQUEST_URI'] = preg_replace("/&updcache=[0-9]*/", "", $_SERVER['REQUEST_URI']);
         unset($_GET['updcache']);
         $V = ReportCachePurgeByKey($CacheKey);
     } else {
         $V = ReportCacheGet($CacheKey);
     }
     $Cached = !empty($V);
     if (!$Cached) {
         $V = $this->htmlContent();
     }
     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 {
         if ($Time > 0.5) {
             ReportCachePut($CacheKey, $V);
         }
     }
     return;
 }
コード例 #10
0
    /**
    * @brief Output(): 
    * Requires:\n
           filter: optional filter to apply\n
           item1:  uploadtree_pk of the column 1 tree\n
           item2:  uploadtree_pk of the column 2 tree\n
           freeze: column number (1 or 2) to freeze
    */
    function Output()
    {
        if ($this->State != PLUGIN_STATE_READY) {
            return 0;
        }
        $uTime = microtime(true);
        $V = "";
        /**/
        $UpdCache = GetParm("updcache", PARM_INTEGER);
        /* 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("item1", "item2", "filter", "col", "freeze", "itemf"));
        if ($UpdCache) {
            $UpdCache = $_GET['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)) {
            $filter = GetParm("filter", PARM_STRING);
            if (empty($filter)) {
                $filter = "none";
            }
            $FreezeCol = GetParm("freeze", PARM_INTEGER);
            // which column to freeze?  1 or 2 or null
            $ClickedCol = GetParm("col", PARM_INTEGER);
            // which column was clicked on?  1 or 2 or null
            $ItemFrozen = GetParm("itemf", PARM_INTEGER);
            // frozen item or null
            $in_uploadtree_pk1 = GetParm("item1", PARM_INTEGER);
            $in_uploadtree_pk2 = GetParm("item2", PARM_INTEGER);
            if (empty($in_uploadtree_pk1) || empty($in_uploadtree_pk2)) {
                Fatal("Bad input parameters.  Both item1 and item2 must be specified.", __FILE__, __LINE__);
            }
            /* If you click on a item in a frozen column, then you are a dope so ignore $ItemFrozen */
            if ($FreezeCol == $ClickedCol) {
                $ItemFrozen = 0;
                $FreezeCol = 0;
            }
            /* Check item1 upload permission */
            $Item1Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$in_uploadtree_pk1}");
            $UploadPerm = GetUploadPerm($Item1Row['upload_fk']);
            if ($UploadPerm < PERM_READ) {
                $text = _("Permission Denied");
                echo "<h2>{$text} item 1<h2>";
                return;
            }
            /* Check item2 upload permission */
            $Item2Row = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$in_uploadtree_pk2}");
            $UploadPerm = GetUploadPerm($Item2Row['upload_fk']);
            if ($UploadPerm < PERM_READ) {
                $text = _("Permission Denied");
                echo "<h2>{$text} item 2<h2>";
                return;
            }
            $uploadtree_pk1 = $in_uploadtree_pk1;
            $uploadtree_pk2 = $in_uploadtree_pk2;
            if ($FreezeCol == 1) {
                $uploadtree_pk1 = $ItemFrozen;
            } else {
                if ($FreezeCol == 2) {
                    $uploadtree_pk2 = $ItemFrozen;
                }
            }
            $newURL = Traceback_dir() . "?mod=" . $this->Name . "&item1={$uploadtree_pk1}&item2={$uploadtree_pk2}";
            if (!empty($filter)) {
                $newURL .= "&filter={$filter}";
            }
            // rewrite page with new uploadtree_pks */
            if ($uploadtree_pk1 != $in_uploadtree_pk1 || $uploadtree_pk2 != $in_uploadtree_pk2) {
                print <<<JSOUT
<script type="text/javascript">
  window.location.assign('{$newURL}');
</script>
JSOUT;
            }
            $TreeInfo1 = $this->GetTreeInfo($uploadtree_pk1);
            $TreeInfo2 = $this->GetTreeInfo($uploadtree_pk2);
            $ErrText = _("No license data for tree %d.  Use Jobs > Agents to schedule a license scan.");
            $ErrMsg = '';
            if ($TreeInfo1['agent_pk'] == 0) {
                $ErrMsg = sprintf($ErrText, 1);
            } else {
                if ($TreeInfo2['agent_pk'] == 0) {
                    $ErrMsg = sprintf($ErrText, 2);
                } else {
                    $BucketDefArray = initBucketDefArray($TreeInfo1['bucketpool_pk']);
                    /* Get list of children */
                    $Children1 = GetNonArtifactChildren($uploadtree_pk1);
                    $Children2 = GetNonArtifactChildren($uploadtree_pk2);
                    /* Add fuzzyname to children */
                    FuzzyName($Children1);
                    // add fuzzyname to children
                    FuzzyName($Children2);
                    // add fuzzyname to children
                    /* add element licstr to children */
                    $this->AddBucketStr($TreeInfo1, $Children1, $BucketDefArray);
                    $this->AddBucketStr($TreeInfo2, $Children2, $BucketDefArray);
                    /* Master array of children, aligned.   */
                    $Master = MakeMaster($Children1, $Children2);
                    /* add linkurl to children */
                    FileList($Master, $TreeInfo1['agent_pk'], $TreeInfo2['agent_pk'], $filter, $this, $uploadtree_pk1, $uploadtree_pk2);
                    /* Apply filter */
                    $this->FilterChildren($filter, $Master, $BucketDefArray);
                }
            }
            switch ($this->OutputType) {
                case "XML":
                    break;
                case "HTML":
                    if ($ErrMsg) {
                        $V .= $ErrMsg;
                    } else {
                        $V .= $this->HTMLout($Master, $uploadtree_pk1, $uploadtree_pk2, $in_uploadtree_pk1, $in_uploadtree_pk2, $filter, $TreeInfo1, $TreeInfo2, $BucketDefArray);
                    }
                    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;
    }
コード例 #11
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;
 }
コード例 #12
0
ファイル: ui-view.php プロジェクト: rlintu/fossology
 /**
  * \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;
 }
コード例 #13
0
 /**
  * @param ItemTreeBounds $itemTreeBounds
  * @return array with keys 'isFlat','iTotalRecords','fileSwitch'
  */
 private function countFileListing(ItemTreeBounds $itemTreeBounds)
 {
     $isFlat = isset($_GET['flatten']);
     $vars['isFlat'] = $isFlat;
     $vars['iTotalRecords'] = $this->uploadDao->countNonArtifactDescendants($itemTreeBounds, $isFlat);
     $uri = Traceback_uri() . '?mod=' . $this->Name . Traceback_parm_keep(array('upload', 'folder', 'show', 'item'));
     $vars['fileSwitch'] = $isFlat ? $uri : $uri . "&flatten=yes";
     return $vars;
 }
コード例 #14
0
 /**
  * @param $tagId
  * @param ItemTreeBounds $itemTreeBounds
  * @param $UniqueTagArray
  * @param $selectedAgentId
  * @param int $groupId
  * @param ScanJobProxy $scanJobProxy
  * @return array
  */
 private function createFileListing($tagId, ItemTreeBounds $itemTreeBounds, &$UniqueTagArray, $selectedAgentId, $groupId, $scanJobProxy)
 {
     if (!empty($selectedAgentId)) {
         $agentName = $this->agentDao->getAgentName($selectedAgentId);
         $selectedScanners = array($agentName => $selectedAgentId);
     } else {
         $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
     }
     /** change the license result when selecting one version of nomos */
     $uploadId = $itemTreeBounds->getUploadId();
     $isFlat = isset($_GET['flatten']);
     if ($isFlat) {
         $options = array(UploadTreeProxy::OPT_RANGE => $itemTreeBounds);
     } else {
         $options = array(UploadTreeProxy::OPT_REALPARENT => $itemTreeBounds->getItemId());
     }
     $searchMap = array();
     foreach (explode(' ', GetParm('sSearch', PARM_RAW)) as $pair) {
         $a = explode(':', $pair);
         if (count($a) == 1) {
             $searchMap['head'] = $pair;
         } else {
             $searchMap[$a[0]] = $a[1];
         }
     }
     if (array_key_exists('ext', $searchMap) && strlen($searchMap['ext']) >= 1) {
         $options[UploadTreeProxy::OPT_EXT] = $searchMap['ext'];
     }
     if (array_key_exists('head', $searchMap) && strlen($searchMap['head']) >= 1) {
         $options[UploadTreeProxy::OPT_HEAD] = $searchMap['head'];
     }
     if (($rfId = GetParm('scanFilter', PARM_INTEGER)) > 0) {
         $options[UploadTreeProxy::OPT_AGENT_SET] = $selectedScanners;
         $options[UploadTreeProxy::OPT_SCAN_REF] = $rfId;
     }
     if (($rfId = GetParm('conFilter', PARM_INTEGER)) > 0) {
         $options[UploadTreeProxy::OPT_GROUP_ID] = Auth::getGroupId();
         $options[UploadTreeProxy::OPT_CONCLUDE_REF] = $rfId;
     }
     $openFilter = GetParm('openCBoxFilter', PARM_RAW);
     if ($openFilter == 'true' || $openFilter == 'checked') {
         $options[UploadTreeProxy::OPT_AGENT_SET] = $selectedScanners;
         $options[UploadTreeProxy::OPT_GROUP_ID] = Auth::getGroupId();
         $options[UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED] = true;
     }
     $descendantView = new UploadTreeProxy($uploadId, $options, $itemTreeBounds->getUploadTreeTableName(), 'uberItems');
     $vars['iTotalDisplayRecords'] = $descendantView->count();
     $columnNamesInDatabase = array($isFlat ? 'ufile_name' : 'lft');
     $defaultOrder = array(array(0, "asc"));
     $orderString = $this->getObject('utils.data_tables_utility')->getSortingString($_GET, $columnNamesInDatabase, $defaultOrder);
     $offset = GetParm('iDisplayStart', PARM_INTEGER);
     $limit = GetParm('iDisplayLength', PARM_INTEGER);
     if ($offset) {
         $orderString .= " OFFSET {$offset}";
     }
     if ($limit) {
         $orderString .= " LIMIT {$limit}";
     }
     /* Get ALL the items under this Uploadtree_pk */
     $sql = $descendantView->getDbViewQuery() . " {$orderString}";
     $dbManager = $this->getObject('db.manager');
     $dbManager->prepare($stmt = __METHOD__ . $orderString, $sql);
     $res = $dbManager->execute($stmt, $descendantView->getParams());
     $descendants = $dbManager->fetchAll($res);
     $dbManager->freeResult($res);
     /* Filter out Children that don't have tag */
     if (!empty($tagId)) {
         TagFilter($descendants, $tagId, $itemTreeBounds->getUploadTreeTableName());
     }
     if (empty($descendants)) {
         $vars['fileData'] = array();
         return $vars;
     }
     if ($isFlat) {
         $firstChild = reset($descendants);
         $lastChild = end($descendants);
         $nameRange = array($firstChild['ufile_name'], $lastChild['ufile_name']);
     } else {
         $nameRange = array();
     }
     /*******    File Listing     ************/
     $pfileLicenses = array();
     foreach ($selectedScanners as $agentName => $agentId) {
         $licensePerPfile = $this->licenseDao->getLicenseIdPerPfileForAgentId($itemTreeBounds, $agentId, $isFlat, $nameRange);
         foreach ($licensePerPfile as $pfile => $licenseRow) {
             foreach ($licenseRow as $licId => $row) {
                 $lic = $this->licenseProjector->getProjectedShortname($licId);
                 $pfileLicenses[$pfile][$lic][$agentName] = $row;
             }
         }
     }
     $alreadyClearedUploadTreeView = new UploadTreeProxy($itemTreeBounds->getUploadId(), $options = array(UploadTreeProxy::OPT_SKIP_THESE => UploadTreeProxy::OPT_SKIP_ALREADY_CLEARED, UploadTreeProxy::OPT_ITEM_FILTER => "AND (lft BETWEEN " . $itemTreeBounds->getLeft() . " AND " . $itemTreeBounds->getRight() . ")", UploadTreeProxy::OPT_GROUP_ID => $groupId), $itemTreeBounds->getUploadTreeTableName(), $viewName = 'already_cleared_uploadtree' . $itemTreeBounds->getUploadId());
     $alreadyClearedUploadTreeView->materialize();
     if (!$isFlat) {
         $this->filesThatShouldStillBeCleared = $alreadyClearedUploadTreeView->countMaskedNonArtifactChildren($itemTreeBounds->getItemId());
     } else {
         $this->filesThatShouldStillBeCleared = $alreadyClearedUploadTreeView->getNonArtifactDescendants($itemTreeBounds);
     }
     $alreadyClearedUploadTreeView->unmaterialize();
     $noLicenseUploadTreeView = new UploadTreeProxy($itemTreeBounds->getUploadId(), $options = array(UploadTreeProxy::OPT_SKIP_THESE => "noLicense", UploadTreeProxy::OPT_ITEM_FILTER => "AND (lft BETWEEN " . $itemTreeBounds->getLeft() . " AND " . $itemTreeBounds->getRight() . ")", UploadTreeProxy::OPT_GROUP_ID => $groupId), $itemTreeBounds->getUploadTreeTableName(), $viewName = 'no_license_uploadtree' . $itemTreeBounds->getUploadId());
     $noLicenseUploadTreeView->materialize();
     if (!$isFlat) {
         $this->filesToBeCleared = $noLicenseUploadTreeView->countMaskedNonArtifactChildren($itemTreeBounds->getItemId());
     } else {
         $this->filesToBeCleared = $noLicenseUploadTreeView->getNonArtifactDescendants($itemTreeBounds);
     }
     $noLicenseUploadTreeView->unmaterialize();
     $allDecisions = $this->clearingDao->getFileClearingsFolder($itemTreeBounds, $groupId, $isFlat);
     $editedMappedLicenses = $this->clearingFilter->filterCurrentClearingDecisions($allDecisions);
     $baseUri = Traceback_uri() . '?mod=license' . Traceback_parm_keep(array('upload', 'folder', 'show'));
     $tableData = array();
     global $Plugins;
     $ModLicView =& $Plugins[plugin_find_id("view-license")];
     $latestSuccessfulAgentIds = $scanJobProxy->getLatestSuccessfulAgentIds();
     foreach ($descendants as $child) {
         if (empty($child)) {
             continue;
         }
         $tableData[] = $this->createFileDataRow($child, $uploadId, $selectedAgentId, $pfileLicenses, $groupId, $editedMappedLicenses, $baseUri, $ModLicView, $UniqueTagArray, $isFlat, $latestSuccessfulAgentIds);
     }
     $vars['fileData'] = $tableData;
     return $vars;
 }
コード例 #15
0
 /**
  * \brief Change the type of output
  * based on user-supplied parameters.
  *
  * \return 1 on success.
  */
 function RegisterMenus()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $ShowHeader = GetParm('showheader', PARM_INTEGER);
     if (empty($ShowHeader)) {
         $ShowHeader = 0;
     }
     $ThisMod = GetParm("mod", PARM_STRING) == $this->Name ? 1 : 0;
     /*
      * This if stmt is true only for wget.
      * For wget, populate the $_FILES array, just like the UI post would do.
      * Sets the unlink_flag if there is a temp file.
      */
     if ($ThisMod && empty($_POST['showheader']) && $_SERVER['REQUEST_METHOD'] == "POST") {
         $Fin = fopen("php://input", "r");
         $Ftmp = tempnam(NULL, "fosslic-alo-");
         $Fout = fopen($Ftmp, "w");
         while (!feof($Fin)) {
             $Line = fgets($Fin);
             fwrite($Fout, $Line);
         }
         fclose($Fin);
         fclose($Fout);
         /* Populate _FILES from wget so the processing logic only has to look in one
          * place wether the data came from wget or the UI
          */
         if (filesize($Ftmp) > 0) {
             $_FILES['licfile']['tmp_name'] = $Ftmp;
             $_FILES['licfile']['size'] = filesize($Ftmp);
             $_FILES['licfile']['unlink_flag'] = 1;
             $this->NoHTML = 1;
         } else {
             unlink($Ftmp);
             /* If there is no input data, then something is wrong.
              * For example the php POST limit is too low and prevented
              * the data from coming through.  Or there was an apache redirect,
              * which removes the POST data.
              */
             $tooltipText = _("FATAL: your file did not get passed throught.  Make sure this page wasn't a result of a web server redirect, or that it didn't exceed your php POST limit.");
             echo $tooltipText;
         }
     }
     /* Only register with the menu system if the user is logged in. */
     if (!empty($_SESSION['User'])) {
         if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_WRITE) {
             menu_insert("Main::Upload::One-Shot Analysis", $this->MenuOrder, $this->Name, $this->MenuTarget);
         }
         // Debugging changes to license analysis
         if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_ADMIN) {
             $URI = $this->Name . Traceback_parm_keep(array("format", "item"));
             $menuText = "One-Shot License";
             $menuPosition = 100;
             $tooltipText = _("One-shot License, real-time license analysis");
             menu_insert("View::[BREAK]", $menuPosition);
             menu_insert("View::{$menuText}", $menuPosition + 1, $URI, $tooltipText);
             menu_insert("View-Meta::[BREAK]", $menuPosition);
             menu_insert("View-Meta::{$menuText}", $menuPosition + 1, $URI, $tooltipText);
         }
     }
 }
コード例 #16
0
 /**
  * @brief Returns an upload job status in html
  * @param $JobData
  * @return Returns an upload job status in html
  **/
 function Show($JobData, $Page)
 {
     global $PG_CONN;
     $OutBuf = '';
     $NumJobs = count($JobData);
     if ($NumJobs == 0) {
         return _("There are no jobs to display");
     }
     /* Next/Prev menu */
     $Next = $NumJobs > $this->MaxUploadsPerPage;
     if ($NumJobs > $this->MaxUploadsPerPage) {
         $OutBuf .= MenuEndlessPage($Page, $Next);
     }
     /*****************************************************************/
     /* Now display the summary */
     /*****************************************************************/
     $Job = -1;
     $Blocked = array();
     $First = 1;
     $Upload = "-1";
     $Uri = Traceback_uri() . "?mod=" . $this->Name;
     $UriFull = $Uri . Traceback_parm_keep(array("upload"));
     $uploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:white;'";
     $jobStyle = "style='font:bold 8pt verdana, arial, helvetica; background:lavender; color:black;'";
     $prevupload_pk = "";
     $OutBuf .= "<table class='text' border=1 width='100%' name='jobtable'>\n";
     $FirstJob = $Page * $this->MaxUploadsPerPage;
     $LastJob = $Page * $this->MaxUploadsPerPage + $this->MaxUploadsPerPage;
     $JobNumber = -1;
     /** if $single_browse is 1, represent alread has an upload browse link, if single_browse is 0, no upload browse link */
     $single_browse = 0;
     foreach ($JobData as $job_pk => $Job) {
         /* Upload  */
         if (!empty($Job["upload"])) {
             $UploadName = GetArrayVal("upload_filename", $Job["upload"]);
             $UploadDesc = GetArrayVal("upload_desc", $Job["upload"]);
             $upload_pk = GetArrayVal("upload_pk", $Job["upload"]);
             /** the column pfile_fk of the record in the table(upload) is NULL when this record is inserted */
             if (!empty($upload_pk) && $prevupload_pk != $upload_pk || empty($upload_pk) && 0 == $single_browse) {
                 $prevupload_pk = $upload_pk;
                 $JobNumber++;
                 /* Only display the jobs for this page */
                 if ($JobNumber >= $LastJob) {
                     break;
                 }
                 if ($JobNumber < $FirstJob) {
                     continue;
                 }
                 /* blank line separator between pfiles */
                 $OutBuf .= "<tr><td colspan=7> <hr> </td></tr>";
                 $OutBuf .= "<tr>";
                 $OutBuf .= "<th {$uploadStyle}></th>";
                 $OutBuf .= "<th colspan=4 {$uploadStyle}>";
                 if (!empty($Job['uploadtree'])) {
                     $uploadtree_pk = $Job['uploadtree']['uploadtree_pk'];
                     $OutBuf .= "<a title='Click to browse' href='" . Traceback_uri() . "?mod=browse&upload=" . $Job['job']['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>";
                 } else {
                     $OutBuf .= "<a title='Click to browse' href='" . Traceback_uri() . "?mod=browse'>";
                 }
                 /* get $UserName if all jobs are shown */
                 $UserName = "";
                 $allusers = GetParm("allusers", PARM_INTEGER);
                 if ($allusers > 0) {
                     $UploadRec = GetSingleRec("upload", "where upload_pk={$Job['job']['job_upload_fk']}");
                     if (!empty($UploadRec)) {
                         $UserRec = GetSingleRec("users", "where user_pk={$UploadRec['user_fk']}");
                         $UserName = "******";
                     } else {
                         $UserRec = GetSingleRec("users", "where user_pk={$Job['job']['job_user_fk']}");
                         $UserName = "******";
                     }
                 }
                 $OutBuf .= $UploadName . $UserName;
                 if (!empty($UploadDesc)) {
                     $OutBuf .= " (" . $UploadDesc . ")";
                 }
                 $OutBuf .= "</a>";
                 $OutBuf .= "</th>";
                 $OutBuf .= "<th {$uploadStyle}></th>";
                 $OutBuf .= "</tr>";
                 $single_browse = 1;
             } else {
                 if ($JobNumber < $FirstJob) {
                     continue;
                 }
             }
         } else {
             /* blank line separator between pfiles */
             $NoUploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:black;'";
             $OutBuf .= "<tr><td colspan=7> <hr> </td></tr>";
             $OutBuf .= "<tr>";
             $OutBuf .= "<th {$NoUploadStyle}></th>";
             $OutBuf .= "<th colspan=4 {$NoUploadStyle}>";
             $OutBuf .= $Job["job"]["job_name"];
             $OutBuf .= "</th>";
             $OutBuf .= "<th {$NoUploadStyle}></th>";
             $OutBuf .= "</tr>";
         }
         /* Job data */
         $OutBuf .= "<tr>";
         $OutBuf .= "<th {$jobStyle}>";
         $OutBuf .= _("Job/Dependency");
         $OutBuf .= "</th>";
         $OutBuf .= "<th {$jobStyle}>";
         $OutBuf .= _("Status");
         $OutBuf .= "</th>";
         $OutBuf .= "<th colspan=3 {$jobStyle}>";
         $OutBuf .= $Job["job"]["job_name"];
         $OutBuf .= "</th>";
         $OutBuf .= "<th {$jobStyle}>";
         $OutBuf .= "</th></tr>";
         /* Job queue */
         foreach ($Job['jobqueue'] as $jq_pk => $jobqueueRec) {
             $RowColor = $this->GetColor($jobqueueRec);
             $jobqueueStyle = $this->jobqueueStyle($RowColor);
             $OutBuf .= "<tr {$jobqueueStyle}>";
             /* Job/Dependency */
             $OutBuf .= "<td {$jobqueueStyle}>";
             $OutBuf .= "<a href='{$UriFull}&show=job&job=" . $jq_pk . "'>";
             $OutBuf .= $jq_pk;
             $OutBuf .= "</a>";
             $count = 0;
             if (!empty($jobqueueRec["depends"])) {
                 foreach ($jobqueueRec["depends"] as $depend_jq_pk) {
                     $OutBuf .= $count++ == 0 ? " / " : ", ";
                     $OutBuf .= "<a href='{$UriFull}&show=job&job=" . $depend_jq_pk . "'>";
                     $OutBuf .= $depend_jq_pk;
                     $OutBuf .= "</a>";
                 }
             }
             $OutBuf .= "</td>";
             /* status */
             $Status = $jobqueueRec["jq_endtext"];
             $OutBuf .= "<td style='text-align:center'>{$Status}</td>";
             $isPaused = $Status == "Paused" ? true : false;
             /* agent name */
             $OutBuf .= "<td>{$jobqueueRec['jq_type']}</td>";
             /* items processed */
             if ($jobqueueRec["jq_itemsprocessed"] > 0) {
                 $items = number_format($jobqueueRec['jq_itemsprocessed']);
                 $OutBuf .= "<td style='text-align:right'>{$items} items</td>";
             } else {
                 $OutBuf .= "<td></td>";
             }
             /* dates */
             $OutBuf .= "<td>";
             $OutBuf .= substr($jobqueueRec['jq_starttime'], 0, 16);
             if (!empty($jobqueueRec["jq_endtime"])) {
                 $OutBuf .= " - " . substr($jobqueueRec['jq_endtime'], 0, 16);
                 $NumSecs = strtotime($jobqueueRec['jq_endtime']) - strtotime($jobqueueRec['jq_starttime']);
             } else {
                 $NumSecs = time() - strtotime($jobqueueRec['jq_starttime']);
             }
             /* Don't display items/sec unless the job has started */
             if ($jobqueueRec['jq_starttime']) {
                 if ($NumSecs > 0) {
                     $ItemsPerSec = round($jobqueueRec['jq_itemsprocessed'] / $NumSecs);
                     if ($ItemsPerSec < 1) {
                         $OutBuf .= sprintf(" : (%01.2f items/sec)", $jobqueueRec['jq_itemsprocessed'] / $NumSecs);
                     } else {
                         $OutBuf .= sprintf(" : (%d items/sec)", $ItemsPerSec);
                     }
                 }
             }
             $OutBuf .= "</td>";
             /* actions, must be admin or own the upload  */
             if ($jobqueueRec['jq_end_bits'] == 0 && ($_SESSION["UserLevel"] == PLUGIN_DB_ADMIN || $_SESSION["UserId"] == $Job['job']['job_user_fk'])) {
                 $OutBuf .= "<th {$jobStyle}>";
                 if ($isPaused) {
                     $text = _("Unpause");
                     $OutBuf .= "<a href='{$UriFull}&action=restart&jobid={$jq_pk}' title='Un-Pause this job'>{$text}</a>";
                 } else {
                     $text = _("Pause");
                     $OutBuf .= "<a href='{$UriFull}&action=pause&jobid={$jq_pk}' title='Pause this job'>{$text}</a>";
                 }
                 $OutBuf .= " | ";
                 $text = _("Cancel");
                 $OutBuf .= "<a href='{$UriFull}&action=cancel&jobid={$jq_pk}' title='Cancel this job'>{$text}</a>";
             } else {
                 $OutBuf .= "<th>";
             }
             $OutBuf .= "</th></tr>";
         }
     }
     $OutBuf .= "</table>\n";
     if ($NumJobs > $this->MaxUploadsPerPage) {
         $OutBuf .= "<p>" . MenuEndlessPage($Page, $Next);
     }
     return $OutBuf;
 }
コード例 #17
0
ファイル: common-dir.php プロジェクト: DanielDobre/fossology
/**
 * \brief Get an html linked string of a file browse path.
 *
 * \param $Mod - Module name (e.g. "browse")
 * \param $UploadtreePk
 * \param $LinkLast - create link (a href) for last item and use LinkLast as the module name
 * \param $ShowBox - true to draw a box around the string
 * \param $ShowMicro - true to show micro menu
 * \param $Enumerate - if >= zero number the folder/file path (the stuff in the yellow bar)
 *   starting with the value $Enumerate
 * \param $PreText - optional additional text to preceed the folder path
 * \param $PostText - optional text to follow the folder path
 * \param $uploadtree_tablename
 *
 * \return string of browse paths
 */
function Dir2Browse($Mod, $UploadtreePk, $LinkLast = NULL, $ShowBox = 1, $ShowMicro = NULL, $Enumerate = -1, $PreText = '', $PostText = '', $uploadtree_tablename = "uploadtree")
{
    $V = "";
    if ($ShowBox) {
        $V .= "<div style='border: thin dotted gray; background-color:lightyellow'>\n";
    }
    if ($Enumerate >= 0) {
        $V .= "<table border=0 width='100%'><tr><td width='5%'>";
        $V .= "<font size='+2'>" . number_format($Enumerate, 0, "", ",") . ":</font>";
        $V .= "</td><td>";
    }
    $Opt = Traceback_parm_keep(array("folder", "show"));
    $Uri = Traceback_uri() . "?mod={$Mod}";
    /* Get array of upload recs for this path, in top down order.
       This does not contain artifacts.
       */
    $Path = Dir2Path($UploadtreePk, $uploadtree_tablename);
    $Last =& $Path[count($Path) - 1];
    $V .= "<font class='text'>\n";
    /* Add in additional text */
    if (!empty($PreText)) {
        $V .= "{$PreText}<br>\n";
    }
    /* Get the FOLDER list for the upload */
    $text = _("Folder");
    $V .= "<b>{$text}</b>: ";
    if (array_key_exists(0, $Path)) {
        $List = FolderGetFromUpload($Path[0]['upload_fk']);
        $Uri2 = Traceback_uri() . "?mod=browse" . Traceback_parm_keep(array("show"));
        for ($i = 0; $i < count($List); $i++) {
            $Folder = $List[$i]['folder_pk'];
            $FolderName = htmlentities($List[$i]['folder_name']);
            $V .= "<b><a href='{$Uri2}&folder={$Folder}'>{$FolderName}</a></b>/ ";
        }
    }
    $FirstPath = 1;
    /* every firstpath belongs on a new line */
    /* Print the upload, itself (on the next line since it is not a folder) */
    if (count($Path) == -1) {
        $Upload = $Path[0]['upload_fk'];
        $UploadName = htmlentities($Path[0]['ufile_name']);
        $UploadtreePk = $Path[0]['uploadtree_pk'];
        $V .= "<br><b><a href='{$Uri2}&folder={$Folder}&upload={$Upload}&item={$UploadtreePk}'>{$UploadName}</a></b>";
        // $FirstPath=0;
    } else {
        $V .= "<br>";
    }
    /* Show the path within the upload */
    if ($FirstPath != 0) {
        for ($p = 0; !empty($Path[$p]['uploadtree_pk']); $p++) {
            $P =& $Path[$p];
            if (empty($P['ufile_name'])) {
                continue;
            }
            $UploadtreePk = $P['uploadtree_pk'];
            if (!$FirstPath) {
                $V .= "/ ";
            }
            if (!empty($LinkLast) || $P != $Last) {
                if ($P == $Last) {
                    $Uri = Traceback_uri() . "?mod={$LinkLast}";
                }
                $V .= "<a href='{$Uri}&upload=" . $P['upload_fk'] . $Opt . "&item=" . $UploadtreePk . "'>";
            }
            if (Isdir($P['ufile_mode'])) {
                $V .= $P['ufile_name'];
            } else {
                if (!$FirstPath && Iscontainer($P['ufile_mode'])) {
                    $V .= "<br>\n&nbsp;&nbsp;";
                }
                $V .= "<b>" . $P['ufile_name'] . "</b>";
            }
            if (!empty($LinkLast) || $P != $Last) {
                $V .= "</a>";
            }
            $FirstPath = 0;
        }
    }
    $V .= "</font>\n";
    if (!empty($ShowMicro)) {
        $MenuDepth = 0;
        /* unused: depth of micro menu */
        $V .= menu_to_1html(menu_find($ShowMicro, $MenuDepth), 1);
    }
    if ($Enumerate >= 0) {
        if ($PostText) {
            $V .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$PostText}";
        }
        $V .= "</td></tr></table>";
    }
    if ($ShowBox) {
        $V .= "</div>\n";
    }
    return $V;
}
コード例 #18
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;
 }
コード例 #19
0
ファイル: Xpview.php プロジェクト: DanielDobre/fossology
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $tooltipText = _("Copyright/Email/Url/Author");
     menu_insert("Browse-Pfile::Copyright/Email/Url", 0, 'copyright-view', $tooltipText);
     $itemId = GetParm("item", PARM_INTEGER);
     $textFormat = $this->microMenu->getFormatParameter($itemId);
     $pageNumber = GetParm("page", PARM_INTEGER);
     $this->microMenu->addFormatMenuEntries($textFormat, $pageNumber);
     // For all other menus, permit coming back here.
     $uploadId = GetParm("upload", PARM_INTEGER);
     if (!empty($itemId) && !empty($uploadId)) {
         $menuText = "Copyright/Email/Url/Author";
         $menuPosition = 57;
         $tooltipText = _("View Copyright/Email/Url/Author info");
         $URI = $this->getName() . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
         $this->microMenu->insert(MicroMenu::TARGET_DEFAULT, $menuText, $menuPosition, $this->getName(), $URI, $tooltipText);
     }
     $licId = GetParm("lic", PARM_INTEGER);
     if (!empty($licId)) {
         $this->NoMenu = 1;
     }
 }
コード例 #20
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     // For all other menus, permit coming back here.
     $URI = $this->Name . Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     $Item = GetParm("item", PARM_INTEGER);
     $Upload = GetParm("upload", PARM_INTEGER);
     if (!empty($Item) && !empty($Upload)) {
         if (GetParm("mod", PARM_STRING) == $this->Name) {
             menu_insert("Browse::License Tree", -6);
             //menu_insert("Browse::[BREAK]", -4);
             menu_insert("Browse::CSV", -4, $URI . "&output=csv");
         } else {
             $text = _("View license tree");
             menu_insert("Browse::License Tree", -6, $URI, $text);
         }
     }
 }
コード例 #21
0
 /**
  * \brief Customize submenus.
  */
 function RegisterMenus()
 {
     $text = _("View file contents");
     menu_insert("Browse-Pfile::View", 10, $this->Name, $text);
     // For the Browse menu, permit switching between detail and summary.
     $Format = GetParm("format", PARM_STRING);
     $Page = GetParm("page", PARM_INTEGER);
     if (empty($Page)) {
         $Page = 0;
     }
     $URI = Traceback_parm();
     $URI = preg_replace("/&format=[a-zA-Z0-9]*/", "", $URI);
     $URI = preg_replace("/&page=[0-9]*/", "", $URI);
     $PageHex = NULL;
     $PageText = NULL;
     /***********************************
        If there is paging, compute page conversions.
        ***********************************/
     switch ($Format) {
         case 'hex':
             $PageHex = $Page;
             $PageText = intval($Page * VIEW_BLOCK_HEX / VIEW_BLOCK_TEXT);
             break;
         case 'text':
         case 'flow':
             $PageText = $Page;
             $PageHex = intval($Page * VIEW_BLOCK_TEXT / VIEW_BLOCK_HEX);
             break;
     }
     menu_insert("View::[BREAK]", -1);
     switch ($Format) {
         case "hex":
             $text = _("View as unformatted text");
             menu_insert("View::Hex", -10);
             menu_insert("View::Text", -11, "{$URI}&format=text&page={$PageText}", $text);
             $text = _("View as formatted text");
             menu_insert("View::Formatted", -12, "{$URI}&format=flow&page={$PageText}", $text);
             break;
         case "text":
             $text = _("View as a hex dump");
             menu_insert("View::Hex", -10, "{$URI}&format=hex&page={$PageHex}", $text);
             menu_insert("View::Text", -11);
             $text = _("View as formatted text");
             menu_insert("View::Formatted", -12, "{$URI}&format=flow&page={$PageText}", $text);
             break;
         case "flow":
             $text = _("View as a hex dump");
             menu_insert("View::Hex", -10, "{$URI}&format=hex&page={$PageHex}", $text);
             $text = _("View as unformatted text");
             menu_insert("View::Text", -11, "{$URI}&format=text&page={$PageText}", $text);
             menu_insert("View::Formatted", -12);
             break;
         default:
             $text = _("View as a hex dump");
             menu_insert("View::Hex", -10, "{$URI}&format=hex&page={$PageHex}", $text);
             $text = _("View as unformatted text");
             menu_insert("View::Text", -11, "{$URI}&format=text&page={$PageText}", $text);
             $text = _("View as formatted text");
             menu_insert("View::Formatted", -12, "{$URI}&format=flow&page={$PageText}", $text);
             break;
     }
     $URI = Traceback_parm_keep(array("show", "format", "page", "upload", "item"));
     if (GetParm("mod", PARM_STRING) == $this->Name) {
         menu_insert("View::View", 2);
         menu_insert("View-Meta::View", 2);
     } else {
         $text = _("View file contents");
         menu_insert("View::View", 2, $this->Name . $URI, $text);
         menu_insert("View-Meta::View", 2, $this->Name . $URI, $text);
         menu_insert("Browse::View", -2, $this->Name . $URI, $text);
         menu_insert("Browse::[BREAK]", -1);
     }
 }
コード例 #22
0
 /**
  * \brief test for Traceback_parm_keep()
  */
 function test_Traceback_parm_keep()
 {
     print "test function Traceback_parm_keep()\n";
     $List = array('parm1', 'parm2');
     $_GET['parm1'] = "parm1";
     $expected = "&parm1=parm1";
     $result = Traceback_parm_keep($List);
     $this->assertEquals($expected, $result);
 }
コード例 #23
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;
 }
コード例 #24
0
 /**
  * @param $tagId
  * @param ItemTreeBounds $itemTreeBounds
  * @param $UniqueTagArray
  * @param $selectedAgentId
  * @param int $groupId
  * @param ScanJobProxy $scanJobProxy
  * @return array
  */
 private function createFileListing($tagId, ItemTreeBounds $itemTreeBounds, &$UniqueTagArray, $selectedAgentId, $groupId, $scanJobProxy)
 {
     if (!empty($selectedAgentId)) {
         $agentName = $this->agentDao->getAgentName($selectedAgentId);
         $selectedScanners = array($agentName => $selectedAgentId);
     } else {
         $selectedScanners = $scanJobProxy->getLatestSuccessfulAgentIds();
     }
     /** change the license result when selecting one version of nomos */
     $uploadId = $itemTreeBounds->getUploadId();
     $isFlat = isset($_GET['flatten']);
     if ($isFlat) {
         $options = array(UploadTreeProxy::OPT_RANGE => $itemTreeBounds);
     } else {
         $options = array(UploadTreeProxy::OPT_REALPARENT => $itemTreeBounds->getItemId());
     }
     $descendantView = new UploadTreeProxy($uploadId, $options, $itemTreeBounds->getUploadTreeTableName(), 'uberItems');
     $vars['iTotalDisplayRecords'] = $descendantView->count();
     $columnNamesInDatabase = array($isFlat ? 'ufile_name' : 'lft');
     $defaultOrder = array(array(0, "asc"));
     $orderString = $this->getObject('utils.data_tables_utility')->getSortingString($_GET, $columnNamesInDatabase, $defaultOrder);
     $offset = GetParm('iDisplayStart', PARM_INTEGER);
     $limit = GetParm('iDisplayLength', PARM_INTEGER);
     if ($offset) {
         $orderString .= " OFFSET {$offset}";
     }
     if ($limit) {
         $orderString .= " LIMIT {$limit}";
     }
     /* Get ALL the items under this Uploadtree_pk */
     $sql = $descendantView->getDbViewQuery() . " {$orderString}";
     $dbManager = $this->getObject('db.manager');
     $dbManager->prepare($stmt = __METHOD__ . $orderString, $sql);
     $res = $dbManager->execute($stmt, $descendantView->getParams());
     $descendants = $dbManager->fetchAll($res);
     $dbManager->freeResult($res);
     /* Filter out Children that don't have tag */
     if (!empty($tagId)) {
         TagFilter($descendants, $tagId, $itemTreeBounds->getUploadTreeTableName());
     }
     if (empty($descendants)) {
         $vars['fileData'] = array();
         return $vars;
     }
     if ($isFlat) {
         $firstChild = reset($descendants);
         $lastChild = end($descendants);
         $nameRange = array($firstChild['ufile_name'], $lastChild['ufile_name']);
     } else {
         $nameRange = array();
     }
     /*******    File Listing     ************/
     $pfileLicenses = array();
     foreach ($selectedScanners as $agentName => $agentId) {
         $licensePerPfile = $this->licenseDao->getLicenseIdPerPfileForAgentId($itemTreeBounds, $agentId, $isFlat, $nameRange);
         foreach ($licensePerPfile as $pfile => $licenseRow) {
             foreach ($licenseRow as $licId => $row) {
                 $lic = $this->licenseProjector->getProjectedShortname($licId);
                 $pfileLicenses[$pfile][$lic][$agentName] = $row;
             }
         }
     }
     $baseUri = Traceback_uri() . '?mod=fileBrowse' . Traceback_parm_keep(array('upload', 'folder', 'show'));
     $tableData = array();
     global $Plugins;
     $latestSuccessfulAgentIds = $scanJobProxy->getLatestSuccessfulAgentIds();
     foreach ($descendants as $child) {
         if (empty($child)) {
             continue;
         }
         $tableData[] = $this->createFileDataRow($child, $uploadId, $selectedAgentId, $pfileLicenses, $groupId, $baseUri, $UniqueTagArray, $isFlat, $latestSuccessfulAgentIds);
     }
     $vars['fileData'] = $tableData;
     return $vars;
 }
コード例 #25
0
ファイル: acme_review.php プロジェクト: DanielDobre/fossology
 /** 
  * \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;
 }
コード例 #26
0
 function RegisterMenus()
 {
     $menuText = "Licenses";
     $menuPosition = 58;
     $uri = $this->Name . Traceback_parm_keep(array("upload", "item", "show"));
     $tooltipText = _("Set the concluded licenses for this upload");
     $this->microMenu->insert(array(MicroMenu::VIEW, MicroMenu::VIEW_META), $menuText, $menuPosition, $this->Name, $uri, $tooltipText);
     if (GetParm("mod", PARM_STRING) != $this->Name) {
         menu_insert("Browse-Pfile::{$menuText}", 0, $this->Name, $tooltipText);
     }
     return 0;
 }
コード例 #27
0
 /**
  * @brief Returns an upload job status in html
  * @param $jobData
  * @return Returns an upload job status in html
  **/
 protected function show($jobData, $page)
 {
     global $container;
     /** @var DbManager */
     $dbManager = $container->get('db.manager');
     $outBuf = '';
     $pagination = '';
     $numJobs = count($jobData);
     if ($numJobs == 0) {
         return array('showJobsData' => "There are no jobs to display");
     }
     $uri = Traceback_uri() . "?mod=showjobs";
     $uriFull = $uri . Traceback_parm_keep(array("upload"));
     $uriFullMenu = $uri . Traceback_parm_keep(array("allusers"));
     /* Next/Prev menu */
     $next = $numJobs > $this->maxUploadsPerPage;
     if ($numJobs > $this->maxUploadsPerPage) {
         $pagination .= MenuEndlessPage($page, $next, $uriFullMenu);
     }
     /*****************************************************************/
     /* Now display the summary */
     /*****************************************************************/
     $job = -1;
     $uploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:white;'";
     $noUploadStyle = "style='font:bold 10pt verdana, arial, helvetica; background:gold; color:black;'";
     $jobStyle = "style='font:bold 8pt verdana, arial, helvetica; background:lavender; color:black;'";
     $prevupload_pk = "";
     $firstJob = $page * $this->maxUploadsPerPage;
     $lastJob = $page * $this->maxUploadsPerPage + $this->maxUploadsPerPage;
     $jobNumber = -1;
     /** if $single_browse is 1, represent alread has an upload browse link, if single_browse is 0, no upload browse link */
     $single_browse = 0;
     foreach ($jobData as $job) {
         /* Upload  */
         if (!empty($job["upload"])) {
             $uploadName = GetArrayVal("upload_filename", $job["upload"]);
             $uploadDesc = GetArrayVal("upload_desc", $job["upload"]);
             $upload_pk = GetArrayVal("upload_pk", $job["upload"]);
             $jobId = GetArrayVal("job_pk", $job["job"]);
             /** the column pfile_fk of the record in the table(upload) is NULL when this record is inserted */
             if (!empty($upload_pk) && $prevupload_pk != $upload_pk || empty($upload_pk) && 0 == $single_browse) {
                 $prevupload_pk = $upload_pk;
                 $jobNumber++;
                 /* Only display the jobs for this page */
                 if ($jobNumber >= $lastJob) {
                     break;
                 }
                 if ($jobNumber < $firstJob) {
                     continue;
                 }
                 /* blank line separator between pfiles */
                 $outBuf .= "<tr><td colspan=8> <hr> </td></tr>";
                 $outBuf .= "<tr>";
                 $outBuf .= "<th {$uploadStyle}></th>";
                 $outBuf .= "<th colspan=6 {$uploadStyle}>";
                 if (!empty($job['uploadtree'])) {
                     $uploadtree_pk = $job['uploadtree']['uploadtree_pk'];
                     $outBuf .= "<a title='Click to browse' href='" . Traceback_uri() . "?mod=browse&upload=" . $job['job']['job_upload_fk'] . "&item=" . $uploadtree_pk . "'>";
                 } else {
                     $outBuf .= "<a {$noUploadStyle}>";
                 }
                 /* get $userName if all jobs are shown */
                 $userName = "";
                 $allusers = GetParm("allusers", PARM_INTEGER);
                 if ($allusers > 0) {
                     $statementName = __METHOD__ . "UploadRec";
                     $uploadRec = $dbManager->getSingleRow("select * from upload where upload_pk=\$1", array($job['job']['job_upload_fk']), $statementName);
                     if (!empty($uploadRec['user_fk'])) {
                         $statementName = __METHOD__ . "UserRec";
                         $userRec = $dbManager->getSingleRow("select * from users where user_pk=\$1", array($uploadRec['user_fk']), $statementName);
                         $userName = "******";
                     } else {
                         $statementName = __METHOD__ . "UserRec1";
                         $userRec = $dbManager->getSingleRow("select * from users where user_pk=\$1", array($job['job']['job_user_fk']), $statementName);
                         $userName = "******";
                     }
                 }
                 $outBuf .= $uploadName . $userName;
                 if (!empty($uploadDesc)) {
                     $outBuf .= " (" . $uploadDesc . ")";
                 }
                 $outBuf .= "</a>";
                 $outBuf .= "</th>";
                 $outBuf .= "<th {$uploadStyle}><a>" . $this->showJobsDao->getEstimatedTime($jobId) . "</a></th>";
                 $outBuf .= "</tr>";
                 $single_browse = 1;
             } else {
                 if ($jobNumber < $firstJob) {
                     continue;
                 }
             }
         } else {
             /* Show Jobs that are not attached to an upload */
             $jobNumber++;
             /* Only display the jobs for this page */
             if ($jobNumber >= $lastJob) {
                 break;
             }
             if ($jobNumber < $firstJob) {
                 continue;
             }
             /* blank line separator between pfiles */
             $outBuf .= "<tr><td colspan=8> <hr> </td></tr>";
             $outBuf .= "<tr>";
             $outBuf .= "<th {$noUploadStyle}></th>";
             $outBuf .= "<th colspan=6 {$noUploadStyle}>";
             $outBuf .= htmlentities($job["job"]["job_name"], ENT_QUOTES);
             $outBuf .= "</th>";
             $outBuf .= "<th {$noUploadStyle}></th>";
             $outBuf .= "</tr>";
         }
         /* Job data */
         $outBuf .= "<tr>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Job/Dependency");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Status");
         $outBuf .= "</th>";
         $outBuf .= "<th colspan=3 {$jobStyle}>";
         $outBuf .= htmlentities($job["job"]["job_name"], ENT_QUOTES);
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("Average items/sec");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= _("ETA");
         $outBuf .= "</th>";
         $outBuf .= "<th {$jobStyle}>";
         $outBuf .= "</th></tr>";
         /* Job queue */
         foreach ($job['jobqueue'] as $jq_pk => $jobqueueRec) {
             $varJobQueueRow = array('jqId' => $jq_pk, 'jobId' => $jobqueueRec['jq_job_fk'], 'class' => $this->getClass($jobqueueRec), 'uriFull' => $uriFull, 'depends' => $jobqueueRec['jdep_jq_depends_fk'] ? $jobqueueRec['depends'] : array(), 'status' => $jobqueueRec['jq_endtext'], 'agentName' => $jobqueueRec['jq_type'], 'itemsProcessed' => $jobqueueRec['jq_itemsprocessed'], 'startTime' => substr($jobqueueRec['jq_starttime'], 0, 16), 'endTime' => empty($jobqueueRec["jq_endtime"]) ? '' : substr($jobqueueRec['jq_endtime'], 0, 16), 'endText' => $jobqueueRec['jq_endtext']);
             if (!empty($jobqueueRec["jq_endtime"])) {
                 $numSecs = strtotime($jobqueueRec['jq_endtime']) - strtotime($jobqueueRec['jq_starttime']);
             } else {
                 $numSecs = time() - strtotime($jobqueueRec['jq_starttime']);
             }
             $itemsPerSec = null;
             if ($jobqueueRec['jq_starttime']) {
                 $itemsPerSec = $this->showJobsDao->getNumItemsPerSec($jobqueueRec['jq_itemsprocessed'], $numSecs);
                 $varJobQueueRow['itemsPerSec'] = $itemsPerSec;
             }
             if (empty($jobqueueRec['jq_endtime'])) {
                 $varJobQueueRow['eta'] = $this->showJobsDao->getEstimatedTime($jobId, $jobqueueRec['jq_type'], $itemsPerSec, $job['job']['job_upload_fk']);
             }
             $varJobQueueRow['canDoActions'] = $_SESSION[Auth::USER_LEVEL] == PLUGIN_DB_ADMIN || Auth::getUserId() == $job['job']['job_user_fk'];
             $varJobQueueRow['isInProgress'] = $jobqueueRec['jq_end_bits'] == 0;
             $varJobQueueRow['isReady'] = $jobqueueRec['jq_end_bits'] == 1;
             switch ($jobqueueRec['jq_type']) {
                 case 'readmeoss':
                     $varJobQueueRow['download'] = "ReadMeOss";
                     break;
                 case 'spdx2':
                     $varJobQueueRow['download'] = "SPDX2 report";
                     break;
                 case 'spdx2tv':
                     $varJobQueueRow['download'] = "SPDX2 tag/value report";
                     break;
                 case 'dep5':
                     $varJobQueueRow['download'] = "DEP5 copyright file";
                     break;
                 default:
                     $varJobQueueRow['download'] = "";
             }
             $outBuf .= $this->renderString('ui-showjobs-jobqueue-row.html.twig', $varJobQueueRow);
         }
     }
     if ($numJobs > $this->maxUploadsPerPage) {
         $pagination = "<p>" . MenuEndlessPage($page, $next, $uriFullMenu);
     }
     return array('showJobsData' => $outBuf, 'pagination' => $pagination);
 }
コード例 #28
0
ファイル: hist.php プロジェクト: pombredanne/fossology-test
 /**
  * \brief Given an $Uploadtree_pk, display: \n
  * (1) The histogram for the directory BY LICENSE. \n
  * (2) The file listing for the directory.
  *
  * \param $Uploadtree_pk
  * \param $Uri
  * \param $filter
  * \param $uploadtree_tablename
  * \param $Agent_pk - agent id
  */
 function ShowUploadHist($Uploadtree_pk, $Uri, $filter, $uploadtree_tablename, $Agent_pk)
 {
     global $PG_CONN;
     $VF = "";
     // return values for file listing
     $VLic = "";
     // return values for license histogram
     $V = "";
     // total return value
     $upload_pk = "";
     $VCopyright = '';
     global $Plugins;
     $ModLicView =& $Plugins[plugin_find_id("copyrightview")];
     $rows = $this->GetRows($Uploadtree_pk, $Agent_pk, $upload_pk, 0, $filter);
     if (!is_array($rows)) {
         return $rows;
     }
     $orderBy = array('count', 'copyright');
     static $ordercount = 1;
     static $ordercopyright = 1;
     $order = "";
     /** sorting by count/copyright statement */
     if (isset($_GET['orderBy']) && in_array($_GET['orderBy'], $orderBy)) {
         $order = $_GET['orderBy'];
         if (isset($_GET['orderc'])) {
             $ordercount = $_GET['orderc'];
         }
         if (isset($_GET['ordercp'])) {
             $ordercopyright = $_GET['ordercp'];
         }
         if ('count' == $order && 1 == $ordercount) {
             $ordercount = 0;
         } else {
             if ('count' == $order && 0 == $ordercount) {
                 $ordercount = 1;
             } else {
                 if ('copyright' == $order && 1 == $ordercopyright) {
                     $ordercopyright = 0;
                 } else {
                     if ('copyright' == $order && 0 == $ordercopyright) {
                         $ordercopyright = 1;
                     }
                 }
             }
         }
     }
     /* Write license histogram to $VLic  */
     $CopyrightCount = 0;
     $UniqueCopyrightCount = 0;
     $NoCopyrightFound = 0;
     $VCopyright = "";
     $VCopyright .= "<table border=1 width='100%' id='copyright'>\n";
     $text = _("Count");
     $text1 = _("Files");
     $text2 = _("Copyright Statements");
     $text3 = _("Email");
     $text4 = _("URL");
     $VCopyright .= "<tr><th>";
     $VCopyright .= "<a href=?mod=" . "{$this->Name}" . Traceback_parm_keep(array("upload", "item", "filter", "agent")) . "&orderBy=count&orderc={$ordercount}>{$text}</a>";
     $VCopyright .= "</th>";
     $VCopyright .= "<th width='10%'>{$text1}</th>";
     $VCopyright .= "<th>";
     $VCopyright .= "<a href=?mod=" . "{$this->Name}" . Traceback_parm_keep(array("upload", "item", "filter", "agent")) . "&orderBy=copyright&ordercp={$ordercopyright}>{$text2}</a>";
     $VCopyright .= "</th>";
     $VCopyright .= "</th></tr>\n";
     $EmailCount = 0;
     $UniqueEmailCount = 0;
     $NoEmailFound = 0;
     $VEmail = "<table border=1 width='100%'id='copyrightemail'>\n";
     $VEmail .= "<tr><th width='10%'>{$text}</th>";
     $VEmail .= "<th width='10%'>{$text1}</th>";
     $VEmail .= "<th>{$text3}</th></tr>\n";
     $UrlCount = 0;
     $UniqueUrlCount = 0;
     $NoUrlFound = 0;
     $VUrl = "<table border=1 width='100%' id='copyrighturl'>\n";
     $VUrl .= "<tr><th width='10%'>{$text}</th>";
     $VUrl .= "<th width='10%'>{$text1}</th>";
     $VUrl .= "<th>{$text4}</th></tr>\n";
     if (!is_array($rows)) {
         $VCopyright .= "<tr><td colspan=3>{$rows}</td></tr>";
     } else {
         foreach ($rows as $row) {
             $hash = $row['hash'];
             if ($row['type'] == 'statement') {
                 $UniqueCopyrightCount++;
                 $CopyrightCount += $row['copyright_count'];
                 $VCopyright .= "<tr><td align='right'>{$row['copyright_count']}</td>";
                 $VCopyright .= "<td align='center'><a href='";
                 $VCopyright .= Traceback_uri();
                 $URLargs = "?mod=copyrightlist&agent={$Agent_pk}&item={$Uploadtree_pk}&hash=" . $hash . "&type=" . $row['type'];
                 if (!empty($filter)) {
                     $URLargs .= "&filter={$filter}";
                 }
                 $VCopyright .= $URLargs . "'>Show</a></td>";
                 $VCopyright .= "<td align='left'>";
                 /* strip out characters we don't want to see
                     This is a hack until the agent stops writing these chars to the db.
                    */
                 $S = $row['content'];
                 $S = htmlentities($S);
                 $S = str_replace("&Acirc;", "", $S);
                 // comes from utf-8 copyright symbol
                 $VCopyright .= $S;
                 /* Debugging
                     $hex = bin2hex($S);
                    $VCopyright .= "<br>$hex" ;
                    End Debugging */
                 $VCopyright .= "</td>";
                 $VCopyright .= "</tr>\n";
             } else {
                 if ($row['type'] == 'email') {
                     $UniqueEmailCount++;
                     $EmailCount += $row['copyright_count'];
                     $VEmail .= "<tr><td align='right'>{$row['copyright_count']}</td>";
                     $VEmail .= "<td align='center'><a href='";
                     $VEmail .= Traceback_uri();
                     $VEmail .= "?mod=copyrightlist&agent={$Agent_pk}&item={$Uploadtree_pk}&hash=" . $hash . "&type=" . $row['type'] . "'>Show</a></td>";
                     $VEmail .= "<td align='left'>";
                     $VEmail .= htmlentities($row['content']);
                     $VEmail .= "</td>";
                     $VEmail .= "</tr>\n";
                 } else {
                     if ($row['type'] == 'url') {
                         $UniqueUrlCount++;
                         $UrlCount += $row['copyright_count'];
                         $VUrl .= "<tr><td align='right'>{$row['copyright_count']}</td>";
                         $VUrl .= "<td align='center'><a href='";
                         $VUrl .= Traceback_uri();
                         $VUrl .= "?mod=copyrightlist&agent={$Agent_pk}&item={$Uploadtree_pk}&hash=" . $hash . "&type=" . $row['type'] . "'>Show</a></td>";
                         $VUrl .= "<td align='left'>";
                         $VUrl .= htmlentities($row['content']);
                         $VUrl .= "</td>";
                         $VUrl .= "</tr>\n";
                     }
                 }
             }
         }
     }
     $VCopyright .= "</table>\n";
     $VCopyright .= "<p>\n";
     $text = _("Unique Copyrights");
     $text1 = _("Total Copyrights");
     $VCopyright .= "{$text}: {$UniqueCopyrightCount}<br>\n";
     $NetCopyright = $CopyrightCount;
     $VCopyright .= "{$text1}: {$NetCopyright}";
     $VEmail .= "</table>\n";
     $VEmail .= "<p>\n";
     $text = _("Unique Emails");
     $text1 = _("Total Emails");
     $VEmail .= "{$text}: {$UniqueEmailCount}<br>\n";
     $NetEmail = $EmailCount;
     $VEmail .= "{$text1}: {$NetEmail}";
     $VUrl .= "</table>\n";
     $VUrl .= "<p>\n";
     $text = _("Unique URLs");
     $text1 = _("Total URLs");
     $VUrl .= "{$text}: {$UniqueUrlCount}<br>\n";
     $NetUrl = $UrlCount;
     $VUrl .= "{$text1}: {$NetUrl}";
     /*******    File Listing     ************/
     /* Get ALL the items under this Uploadtree_pk */
     $Children = GetNonArtifactChildren($Uploadtree_pk, $uploadtree_tablename);
     $ChildCount = 0;
     $ChildLicCount = 0;
     $ChildDirCount = 0;
     /* total number of directory or containers */
     foreach ($Children as $C) {
         if (Iscontainer($C['ufile_mode'])) {
             $ChildDirCount++;
         }
     }
     $VF .= "<table border=0>";
     foreach ($Children as $C) {
         if (empty($C)) {
             continue;
         }
         $IsDir = Isdir($C['ufile_mode']);
         $IsContainer = Iscontainer($C['ufile_mode']);
         /* Determine the hyperlink for non-containers to view-license  */
         if (!empty($C['pfile_fk']) && !empty($ModLicView)) {
             $LinkUri = Traceback_uri();
             $LinkUri .= "?mod=view-license&agent={$Agent_pk}&upload={$upload_pk}&item={$C['uploadtree_pk']}";
         } else {
             $LinkUri = NULL;
         }
         /* Determine link for containers */
         if (Iscontainer($C['ufile_mode'])) {
             $uploadtree_pk = DirGetNonArtifact($C['uploadtree_pk'], $uploadtree_tablename);
             $LicUri = "{$Uri}&item=" . $uploadtree_pk;
         } else {
             $LicUri = NULL;
         }
         /* Populate the output ($VF) - file list */
         /* id of each element is its uploadtree_pk */
         $LicCount = 0;
         $VF .= "<tr><td id='{$C['uploadtree_pk']}' align='left'>";
         $HasHref = 0;
         $HasBold = 0;
         if ($IsContainer) {
             $VF .= "<a href='{$LicUri}'>";
             $HasHref = 1;
             $VF .= "<b>";
             $HasBold = 1;
         } else {
             if (!empty($LinkUri)) {
                 $VF .= "<a href='{$LinkUri}'>";
                 $HasHref = 1;
             }
         }
         $VF .= $C['ufile_name'];
         if ($IsDir) {
             $VF .= "/";
         }
         if ($HasBold) {
             $VF .= "</b>";
         }
         if ($HasHref) {
             $VF .= "</a>";
         }
         $VF .= "</td><td>";
         if ($LicCount) {
             $VF .= "[" . number_format($LicCount, 0, "", ",") . "&nbsp;";
             $VF .= "license" . ($LicCount == 1 ? "" : "s");
             $VF .= "</a>";
             $VF .= "]";
             $ChildLicCount += $LicCount;
         }
         $VF .= "</td>";
         $VF .= "</tr>\n";
         $ChildCount++;
     }
     $VF .= "</table>\n";
     /***************************************
         Problem: $ChildCount can be zero!
        This happens if you have a container that does not
        unpack to a directory.  For example:
        file.gz extracts to archive.txt that contains a license.
        Same problem seen with .pdf and .Z files.
        Solution: if $ChildCount == 0, then just view the license!
        $ChildCount can also be zero if the directory is empty.
        ***************************************/
     if ($ChildCount == 0) {
         $sql = "SELECT * FROM {$this->uploadtree_tablename} WHERE uploadtree_pk = '{$Uploadtree_pk}';";
         $result = pg_query($PG_CONN, $sql);
         DBCheckResult($result, $sql, __FILE__, __LINE__);
         $row = pg_fetch_assoc($result);
         pg_free_result($result);
         if (IsDir($row['ufile_mode'])) {
             return;
         }
         $ModLicView =& $Plugins[plugin_find_id("copyrightview")];
         return $ModLicView->Output();
     }
     /* Combine VF and VLic */
     $text = _("Jump to");
     $text1 = _("Emails");
     $text2 = _("Copyright Statements");
     $text3 = _("URLs");
     $V .= "<table border=0 width='100%'>\n";
     $V .= "<tr><td><a name=\"statements\"></a>{$text}: <a href=\"#emails\">{$text1}</a> | <a href=\"#urls\">{$text3}</a></td><td></td></tr>\n";
     $V .= "<tr><td valign='top' width='50%'>{$VCopyright}</td><td valign='top'>{$VF}</td></tr>\n";
     $V .= "<tr><td><a name=\"emails\"></a>Jump to: <a href=\"#statements\">{$text2}</a> | <a href=\"#urls\">{$text3}</a></td><td></td></tr>\n";
     $V .= "<tr><td valign='top' width='50%'>{$VEmail}</td><td valign='top'></td></tr>\n";
     $V .= "<tr><td><a name=\"urls\"></a>Jump To: <a href=\"#statements\">{$text2}</a> | <a href=\"#emails\">{$text1}</a></td><td></td></tr>\n";
     $V .= "<tr><td valign='top' width='50%'>{$VUrl}</td><td valign='top'></td></tr>\n";
     $V .= "</table>\n";
     $V .= "<hr />\n";
     return $V;
 }
コード例 #29
0
ファイル: ui-buckets.php プロジェクト: DanielDobre/fossology
 /**
  * \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;
 }
コード例 #30
0
 /**
  * @param string $action
  * @param int $uploadId
  * @param int $uploadTreeId
  * @param int $groupId
  * @return string
  */
 protected function doNextPrev($action, $uploadId, $uploadTreeId, $groupId)
 {
     switch ($action) {
         case "setNextPrev":
             $modName = "view-license";
             $opt = self::OPTION_SKIP_FILE;
             break;
         case "setNextPrevCopyRight":
             $modName = "copyright-view";
             $opt = self::OPTION_SKIP_FILE_COPYRIGHT;
             break;
         case "setNextPrevIp":
             $modName = "ip-view";
             $opt = self::OPTION_SKIP_FILE_IP;
             break;
         case "setNextPrevEcc":
             $modName = "ecc-view";
             $opt = self::OPTION_SKIP_FILE_ECC;
             break;
     }
     $options = array('skipThese' => GetParm($opt, PARM_STRING), 'groupId' => $groupId);
     $prevItem = $this->uploadDao->getPreviousItem($uploadId, $uploadTreeId, $options);
     $prevItemId = $prevItem ? $prevItem->getId() : null;
     $nextItem = $this->uploadDao->getNextItem($uploadId, $uploadTreeId, $options);
     $nextItemId = $nextItem ? $nextItem->getId() : null;
     return array('prev' => $prevItemId, 'next' => $nextItemId, 'uri' => Traceback_uri() . "?mod=" . $modName . Traceback_parm_keep(array('upload', 'folder')));
 }