/**
  * \brief Add an upload to multiple agents.
  *
  * \param $uploadpk 
  * \param $agentlist - list of agents
  * \return NULL on success, error message string on failure
  */
 function AgentsAdd($uploadpk, $agentlist)
 {
     global $Plugins;
     global $PG_CONN;
     global $SysConf;
     $rc = "";
     $Alist = array();
     /* Make sure the uploadpk is valid */
     if (!$uploadpk) {
         return "agent-add.php AgentsAdd(): No upload_pk specified";
     }
     $sql = "SELECT upload_pk, upload_filename FROM upload WHERE upload_pk = '{$uploadpk}';";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     if (pg_num_rows($result) < 1) {
         $ErrMsg = __FILE__ . ":" . __LINE__ . " " . _("Upload") . " " . $uploadpk . " " . _("not found");
         return $ErrMsg;
     }
     $UploadRow = pg_fetch_assoc($result);
     $ShortName = $UploadRow['upload_filename'];
     pg_free_result($result);
     /* Create Job */
     $user_pk = $SysConf['auth']['UserId'];
     $job_pk = JobAddJob($user_pk, $ShortName, $uploadpk);
     /* Validate the agent list and add agents as needed. */
     /** Don't worry about order or duplicates -- it will do the right thing. **/
     $Depth = 0;
     $agent_list = menu_find("Agents", $depth);
     for ($al = 0; !empty($agentlist[$al]); $al++) {
         /* check if the agent exists in the list of viable agents */
         $Found = -1;
         for ($ac = 0; $Found < 0 && !empty($agent_list[$ac]->URI); $ac++) {
             if (!strcmp($agent_list[$ac]->URI, $agentlist[$al])) {
                 $Found = $al;
                 break;
             }
         }
         if ($Found >= 0) {
             //print "Adding to " . $agentlist[$Found] . "<br>\n";
             $Dependencies = array();
             $P =& $Plugins[plugin_find_id($agentlist[$Found])];
             $rv = $P->AgentAdd($job_pk, $uploadpk, $ErrorMsg, $Dependencies);
             if ($rv == -1) {
                 $rc .= $ErrorMsg;
             }
         } else {
             $rc .= "Agent '" . htmlentities($agentlist[$al]) . "' not found.\n";
         }
     }
     return $rc;
 }
Beispiel #2
0
 /**
  * @param string $hook 'ParmAgents'|'Agents'|'UploadMulti'
  * @return array
  */
 public static function getAgentPluginNames($hook = 'Agents')
 {
     $maxDepth = 0;
     $agentList = menu_find($hook, $maxDepth) ?: array();
     $agentPluginNames = array();
     if (is_array($agentList)) {
         foreach ($agentList as $parmAgent) {
             $agent = plugin_find_id($parmAgent->URI);
             if (!empty($agent)) {
                 $agentPluginNames[] = $agent;
             }
         }
     }
     return $agentPluginNames;
 }
 /**
  * \brief Display the loaded menu and plugins.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     global $Plugins;
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             $UploadPk = GetParm("upload", PARM_INTEGER);
             if (empty($UploadPk)) {
                 return;
             }
             $Depth = 0;
             $agent_list = menu_find("Agents", $depth);
             $Skip = array("agent_unpack", "agent_adj2nest", "wget_agent");
             for ($ac = 0; !empty($agent_list[$ac]->URI); $ac++) {
                 if (array_search($agent_list[$ac]->URI, $Skip) !== false) {
                     continue;
                 }
                 $P =& $Plugins[plugin_find_id($agent_list[$ac]->URI)];
                 if ($P->AgentHasResults($UploadPk) != 1) {
                     $V .= "<option value='" . $agent_list[$ac]->URI . "'>";
                     $V .= htmlentities($agent_list[$ac]->Name);
                     $V .= "</option>\n";
                 }
             }
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }
Beispiel #4
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;
 }
 /**
  * \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;
 }
/**
 * \brief Given a top-level menu name, find
 * the list of sub-menus below it and max depth of menu.
 * NOTICE this this function returns the sub menus of $Name, NOT the menu specified
 * by $Name.
 *
 * \todo rename this function to menu_find_submenus.
 *
 * \param $Name      top-level menu name, may be a "::" separated list.
 * \param $MaxDepth  max depth of menu, returned value
 * \param $Menu      menu object array (default is global $MenuList)
 *
 * \return array of sub-menus.  $MaxDepth is also returned
 */
function menu_find($Name, &$MaxDepth, $Menu = NULL)
{
    global $MenuList;
    if (empty($Menu)) {
        $Menu = $MenuList;
    }
    if (empty($Name)) {
        return $Menu;
    }
    $PathParts = explode("::", $Name, 2);
    foreach ($Menu as $Key => $Val) {
        if ($Val->Name == $PathParts[0]) {
            if (empty($PathParts[1])) {
                $MaxDepth = $Val->MaxDepth;
                return $Val->SubMenu;
            } else {
                return menu_find($PathParts[1], $MaxDepth, $Val->SubMenu);
            }
        }
    }
    return NULL;
}
Beispiel #7
0
 /**
  * \brief Given a upload_pk, list every item in it.
  * If it is an individual file, then list the file contents.
  */
 function ShowItem($Upload, $Item, $Show, $Folder, $uploadtree_tablename)
 {
     global $container;
     /** @var DbManager */
     $dbManager = $container->get('db.manager');
     $RowStyle1 = "style='background-color:#ecfaff'";
     // pale blue
     $RowStyle2 = "style='background-color:#ffffe3'";
     // pale yellow
     $ColorSpanRows = 3;
     // Alternate background color every $ColorSpanRows
     $RowNum = 0;
     $V = "";
     /* Use plugin "view" and "download" if they exist. */
     $Uri = Traceback_uri() . "?mod=" . $this->Name . "&folder={$Folder}";
     /* there are three types of Browse-Pfile menus */
     /* menu as defined by their plugins */
     $MenuPfile = menu_find("Browse-Pfile", $MenuDepth);
     /* menu but without Compare */
     $MenuPfileNoCompare = menu_remove($MenuPfile, "Compare");
     /* menu with only Tag and Compare */
     $MenuTag = array();
     foreach ($MenuPfile as $value) {
         if ($value->Name == 'Tag' or $value->Name == 'Compare') {
             $MenuTag[] = $value;
         }
     }
     $Results = GetNonArtifactChildren($Item, $uploadtree_tablename);
     $ShowSomething = 0;
     $V .= "<table class='text' style='border-collapse: collapse' border=0 padding=0>\n";
     $stmtGetFirstChild = __METHOD__ . '.getFirstChild';
     $dbManager->prepare($stmtGetFirstChild, "SELECT uploadtree_pk FROM {$uploadtree_tablename} WHERE parent=\$1 limit 1");
     foreach ($Results as $Row) {
         if (empty($Row['uploadtree_pk'])) {
             continue;
         }
         $ShowSomething = 1;
         $Name = $Row['ufile_name'];
         /* Set alternating row background color - repeats every $ColorSpanRows rows */
         $RowStyle = $RowNum++ % (2 * $ColorSpanRows) < $ColorSpanRows ? $RowStyle1 : $RowStyle2;
         $V .= "<tr {$RowStyle}>";
         /* Check for children so we know if the file should by hyperlinked */
         $result = $dbManager->execute($stmtGetFirstChild, array($Row['uploadtree_pk']));
         $HasChildren = $dbManager->fetchArray($result);
         $dbManager->freeResult($result);
         $Parm = "upload={$Upload}&show={$Show}&item=" . $Row['uploadtree_pk'];
         $Link = $HasChildren ? "{$Uri}&show={$Show}&upload={$Upload}&item={$Row['uploadtree_pk']}" : NULL;
         if ($Show == 'detail') {
             $V .= "<td class='mono'>" . DirMode2String($Row['ufile_mode']) . "</td>";
             if (!Isdir($Row['ufile_mode'])) {
                 $V .= "<td align='right'>&nbsp;&nbsp;" . number_format($Row['pfile_size'], 0, "", ",") . "&nbsp;&nbsp;</td>";
             } else {
                 $V .= "<td>&nbsp;</td>";
             }
         }
         $displayItem = Isdir($Row['ufile_mode']) ? "{$Name}/" : $Name;
         if (!empty($Link)) {
             $displayItem = "<a href=\"{$Link}\">{$displayItem}</a>";
         }
         if (Iscontainer($Row['ufile_mode'])) {
             $displayItem = "<b>{$displayItem}</b>";
         }
         $V .= "<td>{$displayItem}</td>\n";
         if (!Iscontainer($Row['ufile_mode'])) {
             $V .= menu_to_1list($MenuPfileNoCompare, $Parm, "<td>", "</td>\n", 1, $Upload);
         } else {
             if (!Isdir($Row['ufile_mode'])) {
                 $V .= menu_to_1list($MenuPfile, $Parm, "<td>", "</td>\n", 1, $Upload);
             } else {
                 $V .= menu_to_1list($MenuTag, $Parm, "<td>", "</td>\n", 1, $Upload);
             }
         }
     }
     /* foreach($Results as $Row) */
     $V .= "</table>\n";
     if (!$ShowSomething) {
         $text = _("No files");
         $V .= "<b>{$text}</b>\n";
     } else {
         $V .= "<hr>\n";
         if (count($Results) == 1) {
             $text = _("1 item");
             $V .= "{$text}\n";
         } else {
             $text = _("items");
             $V .= count($Results) . " {$text}\n";
         }
     }
     return $V;
 }
Beispiel #8
0
 /**
  * @param Request $request
  * @return JsonResponse
  */
 protected function respondFolderGetTableData(Request $request)
 {
     /* Get list of uploads in this folder */
     list($result, $iTotalDisplayRecords, $iTotalRecords) = $this->getListOfUploadsOfFolder($request);
     $uri = Traceback_uri() . "?mod=license";
     /* Browse-Pfile menu */
     $menuPfile = menu_find("Browse-Pfile", $menuDepth);
     /* Browse-Pfile menu without the compare menu item */
     $menuPfileNoCompare = menu_remove($menuPfile, "Compare");
     $users = $this->userDao->getUserChoices();
     $statusTypesAvailable = $this->uploadDao->getStatusTypeMap();
     if (!$this->userPerm) {
         unset($statusTypesAvailable[4]);
     }
     $output = array();
     $rowCounter = 0;
     while ($row = $this->dbManager->fetchArray($result)) {
         if (empty($row['upload_pk']) || !$this->uploadDao->isAccessible($row['upload_pk'], Auth::getGroupId())) {
             continue;
         }
         $rowCounter++;
         $output[] = $this->showRow($row, $request, $uri, $menuPfile, $menuPfileNoCompare, $statusTypesAvailable, $users, $rowCounter);
     }
     $this->dbManager->freeResult($result);
     return new JsonResponse(array('sEcho' => intval($request->get('sEcho')), 'aaData' => $output, 'iTotalRecords' => $iTotalRecords, 'iTotalDisplayRecords' => $iTotalDisplayRecords));
 }
 /**
  * \brief Generate output.
  */
 function Output()
 {
     global $PG_CONN;
     global $Plugins;
     // make sure there is a db connection since I've pierced the core-db abstraction
     if (!$PG_CONN) {
         DBconnect();
         if (!$PG_CONN) {
             echo "NO DB connection";
         }
     }
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     $V = "";
     // tmp  $this->popmd5();
     switch ($this->OutputType) {
         case "XML":
             break;
         case "Text":
             break;
         case "HTML":
             // micro menus
             $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             //debugprint($_REQUEST, "_REQUEST");
             $errorstr = "License not added";
             // update the db
             if (@$_POST["updateit"]) {
                 $resultstr = $this->Updatedb($_POST);
                 $V .= $resultstr;
                 if (strstr($resultstr, $errorstr)) {
                     $V .= $this->Updatefm(0);
                 } else {
                     $V .= $this->Inputfm();
                 }
                 break;
             }
             if (@$_REQUEST['add'] == 'y') {
                 $V .= $this->Updatefm(0);
                 break;
             }
             // Add new rec to db
             if (@$_POST["addit"]) {
                 $resultstr = $this->Adddb($_POST);
                 $V .= $resultstr;
                 if (strstr($resultstr, $errorstr)) {
                     $V .= $this->Updatefm(0);
                 } else {
                     $V .= $this->Inputfm();
                 }
                 break;
             }
             // bring up the update form
             $rf_pk = @$_REQUEST['rf_pk'];
             if ($rf_pk) {
                 $V .= $this->Updatefm($rf_pk);
                 break;
             }
             $V .= $this->Inputfm();
             if (@$_POST["req_shortname"]) {
                 $V .= $this->LicenseList($_POST["req_shortname"], $_POST["req_marydone"]);
             }
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print $V;
     return;
 }
 /**
  * \brief test for menu_functions()
  */
 function test_menu_functions()
 {
     print "test function menu_insert()\n";
     global $MenuList;
     $Path = "TestMenu::Test1::Test2";
     $LastOrder = 0;
     $URI = "TestURI";
     $Title = "TestTitle";
     $Target = "TestTarget";
     $HTML = "TestHTML";
     $countMenuListBefore = count($MenuList);
     $result = menu_insert($Path, $LastOrder, $URI, $Title, $Target, $HTML);
     $this->assertEquals($Path, $MenuList[$countMenuListBefore]->FullName);
     print "test function menu_find)\n";
     $depth = 2;
     $result = menu_find("Test1", $depth);
     print "test function menu_to_1html)\n";
     $result = menu_to_1html($MenuList);
     $this->assertRegExp("/TestMenu/", $result);
     print "test function menu_to_1list)\n";
     $Parm = "";
     $result = menu_to_1list($MenuList, $Parm, "", "");
     $this->assertRegExp("/TestMenu/", $result);
     print "Ending unit test for common-menu.php\n";
 }
 /**
  * \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;
 }
Beispiel #12
0
/**
 * \brief search in available plugins and return all agents
 *
 * \return Plugin[] list of checked agent plugins, mapped by name
 */
function listAgents()
{
    $agents = array();
    $agentList = menu_find("Agents", $Depth);
    if (!empty($agentList)) {
        foreach ($agentList as $agentItem) {
            /*
            The URI below contains the agent name e.g agent_license, this is
            not be confused with the Name attribute in the class, for example,
            the Name attribute for agent_license is: Schedule License Analysis
            */
            $agentPlugin = plugin_find($agentItem->URI);
            if (empty($agentPlugin)) {
                continue;
            }
            $name = htmlentities($agentPlugin->Name);
            $agents[$name] = $agentPlugin;
        }
    }
    return $agents;
}
/**
 * \brief read the UI form and format the user selected agents into a
 * comma separated list
 *
 * \return string $agentsChecked list of checked agents
 */
function userAgents()
{
    global $Plugins;
    global $PG_CONN;
    $agentsChecked = "";
    $AgentList = menu_find("Agents", $Depth);
    if (!empty($AgentList)) {
        foreach ($AgentList as $AgentItem) {
            /*
            The URI below contains the agent name e.g agent_license, this is
            not be confused with the Name attribute in the class, for example,
            the Name attribute for agent_license is: Schedule License Analysis
            */
            $Agent =& $Plugins[plugin_find_id($AgentItem->URI)];
            if (empty($Agent)) {
                continue;
            }
            $Name = htmlentities($Agent->Name);
            $Parm = GetParm("Check_" . $Name, PARM_INTEGER);
            if ($Parm == 1) {
                // save the name
                $agentsChecked .= $Name . ',';
            }
        }
        // remove , from last name
        $agentsChecked = trim($agentsChecked, ',');
    }
    return $agentsChecked;
}
Beispiel #14
0
 /**
  * @brief Create the output.
  */
 function Output($title = NULL)
 {
     global $SysConf;
     $sysConfig = $SysConf['SYSCONFIG'];
     $vars = array();
     $vars['title'] = empty($title) ? _("Welcome to FOSSology") : $title;
     $vars['bannerMsg'] = @$sysConfig['BannerMsg'];
     $vars['logoLink'] = $sysConfig['LogoLink'] ?: 'http://fossology.org';
     $vars['logoImg'] = $sysConfig['LogoImage'] ?: 'images/fossology-logo.gif';
     if (array_key_exists('SupportEmailLabel', $sysConfig) && !empty($sysConfig['SupportEmailLabel']) && array_key_exists('SupportEmailAddr', $sysConfig) && !empty($sysConfig['SupportEmailAddr'])) {
         $menuItem = '<a href="mailto:' . $sysConfig['SupportEmailAddr'] . '?subject=' . @$sysConfig['SupportEmailSubject'] . '">' . $sysConfig['SupportEmailLabel'] . '</a>';
         menu_insert("Main::Help::" . $sysConfig['SupportEmailLabel'], 0, NULL, NULL, NULL, $menuItem);
     }
     $menu = menu_find("Main", $MenuDepth);
     $vars['mainMenu'] = $this->menu_html($menu, 0);
     $vars['uri'] = Traceback_uri();
     /* Handle login information */
     $vars['isLoggedOut'] = (empty($_SESSION[Auth::USER_NAME]) or $_SESSION[Auth::USER_NAME] == "Default User");
     $vars['isLoginPage'] = GetParm("mod", PARM_STRING) == 'auth';
     global $SysConf;
     if (array_key_exists('BUILD', $SysConf)) {
         $vars['versionInfo'] = array('version' => $SysConf['BUILD']['VERSION'], 'buildDate' => $SysConf['BUILD']['BUILD_DATE'], 'commitHash' => $SysConf['BUILD']['COMMIT_HASH'], 'commitDate' => $SysConf['BUILD']['COMMIT_DATE'], 'branchName' => $SysConf['BUILD']['BRANCH']);
     }
     if (!$vars['isLoggedOut']) {
         $this->mergeUserLoginVars($vars);
     }
     $out = $this->renderer->loadTemplate('components/menu.html.twig')->render($vars);
     return $out;
 }
Beispiel #15
0
 public function Output()
 {
     $page = "";
     $uploadPk = GetParm('upload', PARM_INTEGER);
     if (empty($uploadPk)) {
         $uploadPk = -1;
     } elseif ($uploadPk > 0) {
         if (!$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
             $this->vars['message'] = _("Permission Denied");
             return;
         }
     }
     $this->vars['uploadId'] = $uploadPk;
     /* Process any actions */
     $action = GetParm("action", PARM_STRING);
     $page = GetParm('page', PARM_INTEGER) ?: 0;
     if ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_WRITE && !empty($action)) {
         $jq_pk = GetParm("jobid", PARM_INTEGER);
         $uploadPk = GetParm("upload", PARM_INTEGER);
         if (!($uploadPk === -1 && ($_SESSION[Auth::USER_LEVEL] >= PLUGIN_DB_ADMIN || $this->jobDao->hasActionPermissionsOnJob($jq_pk, Auth::getUserId(), Auth::getGroupId()))) && !$this->uploadDao->isEditable($uploadPk, Auth::getGroupId())) {
             $this->vars['message'] = _("Permission Denied to perform action");
         } else {
             $thisURL = Traceback_uri() . "?mod=" . $this->Name . "&upload={$uploadPk}";
             switch ($action) {
                 case 'pause':
                     if (empty($jq_pk)) {
                         break;
                     }
                     $command = "pause {$jq_pk}";
                     $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
                     if ($rv == false) {
                         $this->vars['errorInfo'] = _("Unable to pause job.") . " " . $response_from_scheduler . $error_info;
                     }
                     echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>";
                     break;
                 case 'restart':
                     if (empty($jq_pk)) {
                         break;
                     }
                     $command = "restart {$jq_pk}";
                     $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
                     if ($rv == false) {
                         $this->vars['errorInfo'] = _("Unable to restart job.") . " " . $response_from_scheduler . $error_info;
                     }
                     echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>";
                     break;
                 case 'cancel':
                     if (empty($jq_pk)) {
                         break;
                     }
                     $Msg = "\"" . _("Killed by") . " " . $_SESSION[Auth::USER_NAME] . "\"";
                     $command = "kill {$jq_pk} {$Msg}";
                     $rv = fo_communicate_with_scheduler($command, $response_from_scheduler, $error_info);
                     if ($rv == false) {
                         $this->vars['errorInfo'] = _("Unable to cancel job.") . $response_from_scheduler . $error_info;
                     }
                     echo "<script type=\"text/javascript\"> window.location.replace(\"{$thisURL}\"); </script>";
                     break;
             }
         }
     }
     $job = GetParm('job', PARM_INTEGER);
     if (!empty($job)) {
         $this->vars['jobId'] = $job;
         $this->vars['uploadName'] = $this->getUploadNameForGeekyScan($job);
     } else {
         $allusersval = GetParm("allusers", PARM_INTEGER);
         if (!$allusersval) {
             $allusersval = 0;
         }
         $this->vars['allusersval'] = $allusersval;
         if (!$page) {
             $page = 0;
         }
         $this->vars['page'] = $page;
         $this->vars['clockTime'] = $this->getTimeToRefresh();
         $this->vars['allusersdiv'] = menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
         $this->vars['injectedFoot'] = GetParm("injectedFoot", PARM_TEXT);
         $this->vars['message'] = GetParm("injectedMessage", PARM_TEXT);
     }
 }
Beispiel #16
0
/**
 * \brief list agents
 *
 * lists the agents that are registered with the system.
 * Assumes that the agent plugins have been configured.
 *
 * @return array $agent_list
 */
function list_agents()
{
    $agent_list = menu_find("Agents", $depth);
    return $agent_list;
}
Beispiel #17
0
 /**
  * \brief Create the output.
  */
 function Output($Title = NULL)
 {
     global $SysConf;
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     if (empty($Title)) {
         $Title = _("Welcome to FOSSology");
     }
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /* Banner Message? */
             if (@$SysConf['SYSCONFIG']['BannerMsg']) {
                 $V .= "<h4 style='background-color:#ffbbbb'>" . $SysConf['SYSCONFIG']['BannerMsg'] . "</h4>";
             }
             if (!$this->_CSSdone) {
                 $V .= $this->OutputCSS();
             }
             $Menu = menu_find("Main", $MenuDepth);
             /** Same height at FOSSology logo **/
             $V .= "<table border=0 width='100%'>";
             $V .= "<tr>";
             /* custom or default logo? */
             if (@$SysConf['SYSCONFIG']['LogoImage'] and @$SysConf['SYSCONFIG']['LogoLink']) {
                 $LogoLink = $SysConf['SYSCONFIG']['LogoLink'];
                 $LogoImg = $SysConf['SYSCONFIG']['LogoImage'];
             } else {
                 $LogoLink = 'http://fossology.org';
                 //$LogoImg = Traceback_uri() ."images/fossology-logo.gif";
                 $LogoImg = "images/fossology-logo.gif";
             }
             $V .= "<td width='150' rowspan='2'><a href='{$LogoLink}' target='_top' style='background:white;'><img alt='FOSSology' title='FOSSology' src='" . "{$LogoImg}' border=0></a></td>";
             $V .= "<td colspan='2'>";
             $V .= $this->menu_html($Menu, 0);
             $V .= "</td>";
             $V .= "</tr><tr>";
             $V .= "<td>";
             $V .= "<font size='+2'><b>{$Title}</b></font>";
             $V .= "</td>";
             $V .= "<td align='right' valign='bottom'>";
             /* Handle login information */
             if (plugin_find_id("auth") >= 0 || plugin_find_id("smauth") >= 0) {
                 if (empty($_SESSION['User']) or $_SESSION['User'] == "Default User") {
                     $text = _("login");
                     $V .= "<small><a href='" . Traceback_uri() . "?mod=auth'><b>{$text}</b></a></small>";
                 } else {
                     $text = _("User");
                     $V .= "<small>{$text}:</small> " . @$_SESSION['User'] . "<br>";
                     if (plugin_find_id("auth") >= 0) {
                         $V .= "<small><a href='" . Traceback_uri() . "?mod=auth'><b>logout</b></a></small>";
                     } else {
                         $V .= "<small><a href='" . Traceback_uri() . "?mod=smauth'><b>logout</b></a></small>";
                     }
                 }
                 /* Use global system SupportEmail variables, if addr and label are set */
                 if (@$SysConf['SYSCONFIG']['SupportEmailLabel'] and @$SysConf['SYSCONFIG']['SupportEmailAddr']) {
                     $V .= " | ";
                     $V .= "<small><a href='mailto:" . $SysConf['SYSCONFIG']['SupportEmailAddr'] . "?subject=" . $SysConf['SYSCONFIG']['SupportEmailSubject'] . "'>" . $SysConf['SYSCONFIG']['SupportEmailLabel'] . "</a>";
                 }
             }
             $V .= "</td>";
             $V .= "</tr>";
             $V .= "</table>";
             $V .= "<hr />";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \brief Given a Folder_pk, list every upload in the folder.
  */
 function ShowFolder($Folder, $Show)
 {
     global $Plugins;
     global $PG_CONN;
     $V = "";
     /* Get list of uploads in this folder */
     $sql = "SELECT * FROM upload\n        INNER JOIN uploadtree ON upload_fk = upload_pk\n        AND upload.pfile_fk = uploadtree.pfile_fk\n        AND parent IS NULL\n        AND lft IS NOT NULL \n        WHERE upload_pk IN\n        (SELECT child_id FROM foldercontents WHERE foldercontents_mode & 2 != 0 AND parent_fk = {$Folder})\n        ORDER BY upload_filename,upload_desc,upload_pk,upload_origin;";
     $result = pg_query($PG_CONN, $sql);
     DBCheckResult($result, $sql, __FILE__, __LINE__);
     $Uri = Traceback_uri() . "?mod=" . $this->Name;
     $V .= "<table border=1 width='100%'>";
     $V .= "<tr><td valign='top' width='20%'>\n";
     $V .= FolderListScript();
     $text = _("Folder Navigation");
     $V .= "<center><H3>{$text}</H3></center>\n";
     $V .= "<center><small>";
     if ($Folder != GetUserRootFolder()) {
         $text = _("Top");
         $V .= "<a href='" . Traceback_uri() . "?mod=" . $this->Name . "'>{$text}</a> |";
     }
     $text = _("Expand");
     $V .= "<a href='javascript:Expand();'>{$text}</a> |";
     $text = _("Collapse");
     $V .= "<a href='javascript:Collapse();'>{$text}</a> |";
     $text = _("Refresh");
     $V .= "<a href='" . Traceback() . "'>{$text}</a>";
     $V .= "</small></center>";
     $V .= "<P>\n";
     $V .= "<form>\n";
     $V .= FolderListDiv($Folder, 0, $Folder, 1);
     $V .= "</form>\n";
     $V .= "</td><td valign='top'>\n";
     $text = _("Uploads");
     $V .= "<center><H3>{$text}</H3></center>\n";
     $V .= "<table class='text' id='browsetbl' border=0 width='100%' cellpadding=0>\n";
     $text = _("Upload Name and Description");
     $text1 = _("Upload Date");
     $V .= "<th>{$text}</th><th>{$text1}</th></tr>\n";
     /* Browse-Pfile menu */
     $MenuPfile = menu_find("Browse-Pfile", $MenuDepth);
     /* Browse-Pfile menu without the compare menu item */
     $MenuPfileNoCompare = menu_remove($MenuPfile, "Compare");
     while ($Row = pg_fetch_assoc($result)) {
         if (empty($Row['upload_pk'])) {
             continue;
         }
         $Desc = htmlentities($Row['upload_desc']);
         $UploadPk = $Row['upload_pk'];
         /* check permission on upload */
         $UploadPerm = GetUploadPerm($UploadPk);
         if ($UploadPerm < PERM_READ) {
             continue;
         }
         $Name = $Row['ufile_name'];
         if (empty($Name)) {
             $Name = $Row['upload_filename'];
         }
         /* If UploadtreePk is not an artifact, then use it as the root.
            Else get the first non artifact under it.
            */
         if (Isartifact($Row['ufile_mode'])) {
             $UploadtreePk = DirGetNonArtifact($Row['uploadtree_pk'], $uploadtree_tablename);
         } else {
             $UploadtreePk = $Row['uploadtree_pk'];
         }
         $V .= "<tr><td>";
         if (IsContainer($Row['ufile_mode'])) {
             $V .= "<a href='{$Uri}&upload={$UploadPk}&folder={$Folder}&item={$UploadtreePk}&show={$Show}'>";
             $V .= "<b>" . $Name . "</b>";
             $V .= "</a>";
         } else {
             $V .= "<b>" . $Name . "</b>";
         }
         $V .= "<br>";
         if (!empty($Desc)) {
             $V .= "<i>" . $Desc . "</i><br>";
         }
         $Upload = $Row['upload_pk'];
         $Parm = "upload={$Upload}&show={$Show}&item=" . $Row['uploadtree_pk'];
         if (Iscontainer($Row['ufile_mode'])) {
             $V .= menu_to_1list($MenuPfile, $Parm, " ", " ", 1, $UploadPk);
         } else {
             $V .= menu_to_1list($MenuPfileNoCompare, $Parm, " ", " ", 1, $UploadPk);
         }
         /* Job queue link */
         $text = _("History");
         if (plugin_find_id('showjobs') >= 0) {
             $V .= "<a href='" . Traceback_uri() . "?mod=showjobs&upload={$UploadPk}'>[{$text}]</a>";
             $V .= "</td>\n";
             $V .= "<td align='right'>" . substr($Row['upload_ts'], 0, 19) . "</td>";
         }
         $V .= "<tr><td colspan=2>&nbsp;</td></tr>\n";
     }
     pg_free_result($result);
     $V .= "</table>\n";
     $V .= "</td></tr>\n";
     $V .= "</table>\n";
     return $V;
 }
Beispiel #19
0
/**
 * \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;
}
 /**
  * \brief Generate the text for this plugin.
  */
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return;
     }
     global $PG_CONN;
     global $PERM_NAMES;
     $V = "";
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             /* If this is a POST, then process the request. */
             $User = GetParm('username', PARM_TEXT);
             if (!empty($User)) {
                 $rc = $this->Edit();
                 if (empty($rc)) {
                     /* Need to refresh the screen */
                     $text = _("User information updated.");
                     $V .= displayMessage($text);
                 } else {
                     $V .= displayMessage($rc);
                 }
             }
             // Get the user data
             $sql = "SELECT * FROM users WHERE user_pk='" . @$_SESSION['UserId'] . "';";
             $result = pg_query($PG_CONN, $sql);
             DBCheckResult($result, $sql, __FILE__, __LINE__);
             $R = pg_fetch_assoc($result);
             pg_free_result($result);
             /* Build HTML form */
             $V .= "<form name='formy' method='POST'>\n";
             // no url = this url
             /* if login by siteminder, didn't show this in page*/
             if (siteminder_check() == -1) {
                 $V .= _("You <font color='red'>must</font> provide your current password in order to make any changes.<br />\n");
                 $text = _("Enter your password");
                 $V .= "{$text}: <input type='password' name='pass0' size=20>\n";
                 $V .= "<hr>\n";
             }
             $V .= _("To change user information, edit the following fields. You do not need to edit every field. Only fields with edits will be changed.<P />\n");
             $Style = "<tr><td colspan=2 style='background:black;'></td></tr><tr>";
             $V .= "<table style='border:1px solid black; text-align:left; background:lightyellow;' width='100%'>";
             $Val = htmlentities($R['user_name'], ENT_QUOTES);
             $text = _("Username");
             $V .= "{$Style}<th width='25%'>{$text}</th>";
             $V .= "<td><input type='text' value='{$Val}' name='username' size=20></td>\n";
             $V .= "</tr>\n";
             $Val = htmlentities($R['user_desc'], ENT_QUOTES);
             $text = _("Description, full name, contact, etc. (optional) ");
             $V .= "{$Style}<th>{$text}</th>\n";
             $V .= "<td><input type='text' name='description' value='{$Val}' size=60></td>\n";
             $V .= "</tr>\n";
             $Val = htmlentities($R['user_email'], ENT_QUOTES);
             $text = _("Email address (optional)");
             $V .= "{$Style}<th>{$text}</th>\n";
             $V .= "<td><input type='text' name='email' value='{$Val}' size=60></td>\n";
             $V .= "</tr>\n";
             $text = _("Password");
             $text1 = _("Re-enter password");
             $V .= "{$Style}<th>{$text}<br>{$text1}</th><td>";
             $V .= "<input type='password' name='pass1' size=20><br />\n";
             $V .= "<input type='password' name='pass2' size=20></td>\n";
             $V .= "</tr>\n";
             if (empty($R['email_notify'])) {
                 $Checked = "";
             } else {
                 $Checked = "checked='checked'";
             }
             $text = _("E-mail Notification");
             $V .= "{$Style}<th>{$text}</th><td>\n";
             $V .= "<input name='emailnotify' type='checkbox' {$Checked}>";
             $V .= "</tr>\n";
             if (@$_SESSION['UserLevel'] > PLUGIN_DB_READ) {
                 $text = _("Default scans");
                 $V .= "{$Style}<th>{$text}\n</th><td>\n";
                 /*
                  * added this code so the form makes sense.  You can have an admin define default agents
                  * but if you don't have Analyze or better permissions, then those agents are not available to
                  * you!  With out this code the default agent text was there, but nothing else... this way
                  * the form at least makes sense.   Turns out agent unpack is always around so both
                  * conditions must be checked.
                  */
                 $AgentList = menu_find("Agents", $Depth);
                 if (!empty($AgentList)) {
                     foreach ($AgentList as $AgentItem) {
                         $uri = $AgentItem->URI;
                     }
                     if ($uri == "agent_unpack" && count($AgentList) == 1) {
                         $text = _("You do not have permission to change your default agents");
                         $V .= "<h3>{$text}</h3>\n";
                     } else {
                         $V .= AgentCheckBoxMake(-1, array("agent_unpack", "agent_adj2nest", "wget_agent"));
                     }
                 }
                 $V .= "</td></tr>\n";
                 $text = _("Default bucketpool");
                 $V .= "{$Style}<th>{$text}</th>";
                 $V .= "<td>";
                 $Val = htmlentities($R['default_bucketpool_fk'], ENT_QUOTES);
                 $V .= SelectBucketPool($Val);
                 $V .= "</td>";
                 $V .= "</tr>\n";
                 /*
                         /******  New Upload Group ****** /
                         / * Get master array of groups * /
                         $sql = "select group_pk, group_name from groups order by group_name";
                         $groupresult = pg_query($PG_CONN, $sql);
                         DBCheckResult($groupresult, $sql, __FILE__, __LINE__);
                         $GroupArray = array();
                         while ($GroupRow = pg_fetch_assoc($groupresult))
                           $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name'];
                         pg_free_result($groupresult);
                         $text = _("Group to give access permission for every new upload");
                         $V.= "$Style<th>$text</th>";
                         $V.= "<td>";
                         $V .= Array2SingleSelect($GroupArray, "new_upload_group_fk", $R['new_upload_group_fk'], true, false);
                         $V.= "</td>";
                         $V .= "</tr>\n";
                 
                         / ******  New Upload Permissions ****** /
                         $text = _("Access Permission to give the above group");
                         $V.= "$Style<th>$text</th>";
                         $V.= "<td>";
                         $Selected = (empty($R['new_upload_perm'])) ? -1 : $R['new_upload_perm'];
                         $V .= Array2SingleSelect($PERM_NAMES, "new_upload_perm", $Selected, true, false);
                         $V.= "</td>";
                         $V .= "</tr>\n";
                 */
             }
             $V .= "</table><P />";
             $text = _("Update Account");
             $V .= "<input type='submit' value='{$text}'>\n";
             $V .= "</form>\n";
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
Beispiel #21
0
 function Output()
 {
     if ($this->State != PLUGIN_STATE_READY) {
         return 0;
     }
     $V = "";
     $Page = "";
     $UploadPk = GetParm('upload', PARM_INTEGER);
     if (empty($UploadPk)) {
         $UploadPk = -1;
     } else {
         $UploadPerm = GetUploadPerm($UploadPk);
         if ($UploadPerm < PERM_WRITE) {
             $text = _("Permission Denied");
             echo "<h2>{$text}<h2>";
             return;
         }
     }
     switch ($this->OutputType) {
         case "XML":
             break;
         case "HTML":
             // micro menus
             $V .= menu_to_1html(menu_find($this->Name, $MenuDepth), 0);
             /* Process any actions */
             if (@$_SESSION['UserLevel'] >= PLUGIN_DB_WRITE) {
                 $jq_pk = GetParm("jobid", PARM_INTEGER);
                 $Action = GetParm("action", PARM_STRING);
                 $UploadPk = GetParm("upload", PARM_INTEGER);
                 if (!empty($UploadPk)) {
                     $UploadPerm = GetUploadPerm($UploadPk);
                     if ($UploadPerm < PERM_WRITE) {
                         $text = _("Permission Denied");
                         echo "<h2>{$text}<h2>";
                         return;
                     }
                 }
                 $Page = GetParm('page', PARM_INTEGER);
                 if (empty($Page)) {
                     $Page = 0;
                 }
                 $jqtype = GetParm("jqtype", PARM_STRING);
                 $ThisURL = Traceback_uri() . "?mod=" . $this->Name . "&upload={$UploadPk}";
                 $Job = GetParm('job', PARM_INTEGER);
                 switch ($Action) {
                     case 'pause':
                         if (empty($jq_pk)) {
                             break;
                         }
                         $Command = "pause {$jq_pk}";
                         $rv = fo_communicate_with_scheduler($Command, $response_from_scheduler, $error_info);
                         if ($rv == false) {
                             $V .= _("Unable to pause job.") . " " . $response_from_scheduler . $error_info;
                         }
                         echo "<script type=\"text/javascript\"> window.location.replace(\"{$ThisURL}\"); </script>";
                         break;
                     case 'restart':
                         if (empty($jq_pk)) {
                             break;
                         }
                         $Command = "restart {$jq_pk}";
                         $rv = fo_communicate_with_scheduler($Command, $response_from_scheduler, $error_info);
                         if ($rv == false) {
                             $V .= _("Unable to restart job.") . " " . $response_from_scheduler . $error_info;
                         }
                         echo "<script type=\"text/javascript\"> window.location.replace(\"{$ThisURL}\"); </script>";
                         break;
                     case 'cancel':
                         if (empty($jq_pk)) {
                             break;
                         }
                         $Msg = "\"" . _("Killed by") . " " . @$_SESSION['User'] . "\"";
                         $Command = "kill {$jq_pk} {$Msg}";
                         $rv = fo_communicate_with_scheduler($Command, $response_from_scheduler, $error_info);
                         if ($rv == false) {
                             $V .= _("Unable to cancel job.") . $response_from_scheduler . $error_info;
                         }
                         echo "<script type=\"text/javascript\"> window.location.replace(\"{$ThisURL}\"); </script>";
                         break;
                     default:
                         break;
                 }
             }
             if (!empty($Job)) {
                 $V .= $this->ShowJobDB($Job);
             } else {
                 if ($UploadPk) {
                     $upload_pks = array($UploadPk);
                     $Jobs = $this->Uploads2Jobs($upload_pks, $Page);
                 } else {
                     $Jobs = $this->MyJobs($this->nhours);
                 }
                 $JobsInfo = $this->GetJobInfo($Jobs, $Page);
                 /* Sort jobs by job_pk (so most recent comes out first) */
                 usort($JobsInfo, "CompareJobsInfo");
                 $V .= $this->Show($JobsInfo, $Page);
             }
             break;
         case "Text":
             break;
         default:
             break;
     }
     if (!$this->OutputToStdout) {
         return $V;
     }
     print "{$V}";
     return;
 }
 /**
  * \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;
 }