public function Output() { $V = ""; /* If this is a POST, then process the request. */ $groupname = GetParm('groupname', PARM_TEXT); if (!empty($groupname)) { try { /* @var $userDao UserDao */ $userDao = $GLOBALS['container']->get('dao.user'); $groupId = $userDao->addGroup($groupname); $userDao->addGroupMembership($groupId, Auth::getUserId()); $text = _("Group"); $text1 = _("added"); $this->vars['message'] = "{$text} {$groupname} {$text1}."; } catch (Exception $e) { $this->vars['message'] = $e->getMessage(); } } /* Build HTML form */ $text = _("Add a Group"); $V .= "<h4>{$text}</h4>\n"; $V .= "<form name='formy' method='POST' action=" . Traceback_uri() . "?mod=group_add>\n"; $Val = htmlentities(GetParm('groupname', PARM_TEXT), ENT_QUOTES); $text = _("Enter the groupname:"); $V .= "{$text}\n"; $V .= "<input type='text' value='{$Val}' name='groupname' size=20>\n"; $text = _("Add"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; return $V; }
/** * \brief Generate the text for this plugin. */ public function Output() { /* If this is a POST, then process the request. */ $FolderSelectId = GetParm('selectfolderid', PARM_INTEGER); if (empty($FolderSelectId)) { $FolderSelectId = FolderGetTop(); } $FolderId = GetParm('oldfolderid', PARM_INTEGER); $NewName = GetParm('newname', PARM_TEXT); $NewDesc = GetParm('newdesc', PARM_TEXT); if (!empty($FolderId)) { $FolderSelectId = $FolderId; $rc = $this->Edit($FolderId, $NewName, $NewDesc); if ($rc == 1) { /* Need to refresh the screen */ $text = _("Folder Properties changed"); $this->vars["message"] = $text; } } /* Get the folder info */ $sql = 'SELECT * FROM folder WHERE folder_pk = $1;'; $Folder = $this->dbManager->getSingleRow($sql, array($FolderSelectId), __METHOD__ . "getFolderRow"); /* Display the form */ $formVars["onchangeURI"] = Traceback_uri() . "?mod=" . $this->Name . "&selectfolderid="; $formVars["folderListOption"] = FolderListOption(-1, 0, 1, $FolderSelectId); $formVars["folder_name"] = $Folder['folder_name']; $formVars["folder_desc"] = $Folder['folder_desc']; return $this->renderString("admin-folder-edit-form.html.twig", $formVars); }
/** * \brief Generate the text for this plugin. */ public function Output() { /* If this is a POST, then process the request. */ $ParentId = GetParm('parentid', PARM_INTEGER); $NewFolder = GetParm('newname', PARM_TEXT); $Desc = GetParm('description', PARM_TEXT); if (!empty($ParentId) && !empty($NewFolder)) { $rc = $this->create($ParentId, $NewFolder, $Desc); if ($rc == 1) { /* Need to refresh the screen */ $text = _("Folder"); $text1 = _("Created"); $this->vars['message'] = "{$text} " . htmlentities($NewFolder) . " {$text1}"; } else { if ($rc == 4) { $text = _("Folder"); $text1 = _("Exists"); $this->vars['message'] = "{$text} " . htmlentities($NewFolder) . " {$text1}"; } } } $root_folder_pk = GetUserRootFolder(); $formVars["folderOptions"] = FolderListOption($root_folder_pk, 0); return $this->renderString("admin-folder-create-form.html.twig", $formVars); }
function Output() { if ($this->State != PLUGIN_STATE_READY) { return 0; } $licenseShortname = GetParm("lic", PARM_TEXT); $licenseId = GetParm("rf", PARM_NUMBER); $groupId = $_SESSION[Auth::GROUP_ID]; if (empty($licenseShortname) && empty($licenseId)) { return; } if ($licenseId) { $license = $this->licenseDao->getLicenseById($licenseId, $groupId); } else { $license = $this->licenseDao->getLicenseByShortName($licenseShortname, $groupId); } if ($license === null) { return; } $this->vars['shortName'] = $license->getShortName(); $this->vars['fullName'] = $license->getFullName(); $parent = $this->licenseDao->getLicenseParentById($license->getId()); if ($parent !== null) { $this->vars['parentId'] = $parent->getId(); $this->vars['parentShortName'] = $parent->getShortName(); } $licenseUrl = $license->getUrl(); if (strtolower($licenseUrl) == 'none') { $licenseUrl = NULL; } $this->vars['url'] = $licenseUrl; $this->vars['text'] = $license->getText(); $this->vars['risk'] = $license->getRisk(); return $this->render('popup_license.html.twig'); }
/** * \brief Display the loaded menu and plugins. */ function Output() { global $PG_CONN; if ($this->State != PLUGIN_STATE_READY) { return; } if (!$PG_CONN) { return "NO DB connection"; } $bucket_pk = GetParm("bucket_pk", PARM_RAW); $uploadtree_pk = GetParm("item", PARM_INTEGER); /* Get the uploadtree table name */ $uploadtree_rec = GetSingleRec("uploadtree", "where uploadtree_pk='{$uploadtree_pk}'"); $uploadtree_tablename = GetUploadtreeTableName($uploadtree_rec['upload_fk']); /* Get all the non-artifact children */ $children = GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename); /* Loop through children and create a list of those that contain $bucket_pk */ $outstr = $bucket_pk; foreach ($children as $child) { if (BucketInTree($bucket_pk, $child['uploadtree_pk'])) { $outstr .= ",{$child['uploadtree_pk']}"; } } return $outstr; }
function __construct() { $possibleOutputFormat = trim(GetParm("outputFormat", PARM_STRING)); if (strcmp($possibleOutputFormat, "") !== 0 && strcmp($possibleOutputFormat, self::DEFAULT_OUTPUT_FORMAT) !== 0 && ctype_alnum($possibleOutputFormat)) { $this->outputFormat = $possibleOutputFormat; } parent::__construct(self::NAME, array(self::TITLE => _(strtoupper($this->outputFormat) . " generation"), self::PERMISSION => Auth::PERM_WRITE, self::REQUIRES_LOGIN => true)); }
/** * \brief Generate the text for this plugin. */ function Output() { global $PG_CONN; global $SysConf; if ($this->State != PLUGIN_STATE_READY) { return; } $user_pk = $SysConf['auth']['UserId']; /* Get array of groups that this user is an admin of */ $GroupArray = GetGroupArray($user_pk); $V = ""; /* If this is a POST, then process the request. */ $Group = GetParm('grouppk', PARM_TEXT); if (!empty($Group)) { $rc = DeleteGroup($Group); if (empty($rc)) { /* Need to refresh the screen */ $text = _("Group"); $text1 = _("Deleted"); $V .= displayMessage("{$text} {$GroupArray[$Group]} {$text1}."); } else { $V .= displayMessage($rc); } } /* Build HTML form */ $text = _("Delete a Group"); $V .= "<h4>{$text}</h4>\n"; $V .= "<form name='formy' method='POST' action=" . Traceback_uri() . "?mod=group_delete>\n"; /* Get array of users */ $UserArray = Table2Array('user_pk', 'user_name', 'users'); /* Remove from $GroupArray any active users. A user must always have a group by the same name */ foreach ($GroupArray as $group_fk => $group_name) { if (array_search($group_name, $UserArray)) { unset($GroupArray[$group_fk]); } } if (empty($GroupArray)) { $text = _("You have no groups you can delete."); echo "<p>{$text}<p>"; return; } reset($GroupArray); if (empty($group_pk)) { $group_pk = key($GroupArray); } $text = _("Select the group to delete: \n"); $V .= "{$text}"; /*** Display group select list, on change request new page with group= in url ***/ $V .= Array2SingleSelect($GroupArray, "grouppk", $group_pk, false, false); $text = _("Delete"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * @brief Display the loaded menu and plugins. */ function Output() { $nomosagent_pk = GetParm("napk", PARM_INTEGER); $rf_shortname = GetParm("lic", PARM_RAW); $uploadtree_pk = GetParm("item", PARM_INTEGER); $uploadtree_tablename = GetParm("ut", PARM_RAW); $files = Level1WithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, false, $uploadtree_tablename); $csv = count($files) != 0 ? rawurlencode($rf_shortname) . implode(',', array_keys($files)) : ''; return $csv; }
/** * \brief Generate the text for this plugin. */ public function Output() { /* If this is a POST, then process the request. */ $folder = GetParm('folder', PARM_INTEGER); if (!empty($folder)) { $userId = Auth::getUserId(); $sql = "SELECT folder_name FROM folder join users on (users.user_pk = folder.user_fk or users.user_perm = 10) where folder_pk = \$1 and users.user_pk = \$2;"; $Folder = $this->dbManager->getSingleRow($sql, array($folder, $userId), __METHOD__ . "GetRowWithFolderName"); if (!empty($Folder['folder_name'])) { $rc = $this->Delete($folder, $userId); if (empty($rc)) { /* Need to refresh the screen */ $text = _("Deletion of folder "); $text1 = _(" added to job queue"); $this->vars['message'] = $text . $Folder['folder_name'] . $text1; } else { $text = _("Deletion of "); $text1 = _(" failed: "); $this->vars['message'] = $text . $Folder['folder_name'] . $text1 . $rc; } } else { $text = _("Cannot delete this folder :: Permission denied"); $this->vars['message'] = $text; } } $V = "<form method='post'>\n"; // no url = this url $text = _("Select the folder to"); $text1 = _("delete"); $V .= "{$text} <em>{$text1}</em>.\n"; $V .= "<ul>\n"; $text = _("This will"); $text1 = _("delete"); $text2 = _("the folder, all subfolders, and all uploaded files stored within the folder!"); $V .= "<li>{$text} <em>{$text1}</em> {$text2}\n"; $text = _("Be very careful with your selection since you can delete a lot of work!"); $V .= "<li>{$text}\n"; $text = _("All analysis only associated with the deleted uploads will also be deleted."); $V .= "<li>{$text}\n"; $text = _("THERE IS NO UNDELETE. When you select something to delete, it will be removed from the database and file repository."); $V .= "<li>{$text}\n"; $V .= "</ul>\n"; $text = _("Select the folder to delete: "); $V .= "<P>{$text}\n"; $V .= "<select name='folder'>\n"; $text = _("select folder"); $V .= "<option value=''>[{$text}]</option>\n"; $V .= FolderListOption(-1, 0); $V .= "</select><P />\n"; $text = _("Delete"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; return $V; }
/** * \brief This function is called when user output is * requested. This function is responsible for content. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $Plugins; $P =& $Plugins[plugin_find_id("Default")]; $GoMod = GetParm("remod", PARM_STRING); $GoOpt = GetParm("reopt", PARM_STRING); $GoOpt = preg_replace("/--/", "&", $GoOpt); return $P->Output($GoMod, $GoOpt); }
/** * \brief Generate the text for this plugin. */ public function Output() { global $PG_CONN; $V = ""; /* If this is a POST, then process the request. */ $folder = GetParm('folder', PARM_INTEGER); if (!empty($folder)) { $rc = $this->Delete($folder); $sql = "SELECT * FROM folder where folder_pk = '{$folder}';"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $Folder = pg_fetch_assoc($result); pg_free_result($result); if (empty($rc)) { /* Need to refresh the screen */ $text = _("Deletion of folder "); $text1 = _(" added to job queue"); $this->vars['message'] = $text . $Folder['folder_name'] . $text1; } else { $text = _("Deletion of "); $text1 = _(" failed: "); $this->vars['message'] = $text . $Folder['folder_name'] . $text1 . $rc; } } $V .= "<form method='post'>\n"; // no url = this url $text = _("Select the folder to"); $text1 = _("delete"); $V .= "{$text} <em>{$text1}</em>.\n"; $V .= "<ul>\n"; $text = _("This will"); $text1 = _("delete"); $text2 = _("the folder, all subfolders, and all uploaded files stored within the folder!"); $V .= "<li>{$text} <em>{$text1}</em> {$text2}\n"; $text = _("Be very careful with your selection since you can delete a lot of work!"); $V .= "<li>{$text}\n"; $text = _("All analysis only associated with the deleted uploads will also be deleted."); $V .= "<li>{$text}\n"; $text = _("THERE IS NO UNDELETE. When you select something to delete, it will be removed from the database and file repository."); $V .= "<li>{$text}\n"; $V .= "</ul>\n"; $text = _("Select the folder to delete: "); $V .= "<P>{$text}\n"; $V .= "<select name='folder'>\n"; $text = _("select folder"); $V .= "<option value=''>[{$text}]</option>\n"; $V .= FolderListOption(-1, 0); $V .= "</select><P />\n"; $text = _("Delete"); $V .= "<input type='submit' value='{$text}!'>\n"; $V .= "</form>\n"; return $V; }
/** * @param $itemId * @return string */ public function getFormatParameter($itemId = NULL) { $selectedFormat = GetParm("format", PARM_STRING); if (in_array($selectedFormat, $this->formatOptions)) { return $selectedFormat; } if (empty($itemId)) { return self::FORMAT_FLOW; } else { $mimeType = GetMimeType($itemId); list($type, $dummy) = explode("/", $mimeType, 2); return $type == 'text' ? self::FORMAT_TEXT : self::FORMAT_FLOW; } }
/** * \brief This function is called when user output is * requested. This function is responsible for content. \n * The $ToStdout flag is "1" if output should go to stdout, and * 0 if it should be returned as a string. (Strings may be parsed * and used by other plugins.) */ function Output() { global $PG_CONN; if ($this->State != PLUGIN_STATE_READY) { return; } $V = ""; global $Plugins; $View =& $Plugins[plugin_find_id("view")]; $Item = GetParm("item", PARM_INTEGER); $Upload = GetParm("upload", PARM_INTEGER); $ModBack = GetParm("modback", PARM_STRING); if (empty($ModBack)) { $ModBack = 'copyrighthist'; } $pfile = 0; $sql = "SELECT * FROM uploadtree WHERE uploadtree_pk = " . $Item . ";"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $row = pg_fetch_assoc($result); pg_free_result($result); if (!empty($row['pfile_fk'])) { $pfile = $row['pfile_fk']; } else { $text = _("Could not locate the corresponding pfile."); print $text; } $sql = "SELECT * FROM copyright WHERE copy_startbyte IS NOT NULL\n and pfile_fk=" . $pfile . ";"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); if (pg_num_rows($result) < 1) { $text = _("No copyright data is available for this file."); print $text; return; } $row = pg_fetch_assoc($result, 0); $colors = array(); $colors['statement'] = 0; $colors['email'] = 1; $colors['url'] = 2; if (!empty($row['copy_startbyte'])) { while ($row = pg_fetch_assoc($result)) { $View->AddHighlight($row['copy_startbyte'], $row['copy_endbyte'], $colors[$row['type']], '', $row['content'], -1, Traceback_uri() . "?mod=copyrightlist&agent=" . $row['agent_fk'] . "&item={$Item}&hash=" . $row['hash'] . "&type=" . $row['type']); } $View->SortHighlightMenu(); } pg_free_result($result); $View->ShowView(NULL, $ModBack, 1, 1, NULL, True); return; }
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); } } }
/** * \brief Display the loaded menu and plugins. */ function Output() { global $Plugins; if ($this->State != PLUGIN_STATE_READY) { return; } //$uTime = microtime(true); // make sure there is a db connection switch ($this->OutputType) { case "XML": break; case "HTML": $nomosagent_pk = GetParm("napk", PARM_INTEGER); $rf_shortname = GetParm("lic", PARM_RAW); $uploadtree_pk = GetParm("item", PARM_INTEGER); $uploadtree_tablename = GetParm("ut", PARM_RAW); $debug = array_key_exists("debug", $_GET) ? true : false; $Files = Level1WithLicense($nomosagent_pk, $rf_shortname, $uploadtree_pk, false, $uploadtree_tablename); $V = ""; if (count($Files) == 0) { $V .= ""; } else { $V .= rawurlencode($rf_shortname); foreach ($Files as $uppk => $fname) { $V .= ",{$uppk}"; } } break; case "Text": break; default: } /* if ($debug) { $Time = microtime(true) - $uTime; // convert usecs to secs $text = _("Elapsed time: %.2f seconds"); printf( "<small>$text</small>", $Time); } */ if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \brief Display the loaded menu and plugins. */ function Output() { $V = ""; $item = GetParm("uploadtree_pk", PARM_INTEGER); /* get uploadtree_tablename from $Item */ $uploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk='{$item}'"); $uploadRec = GetSingleRec("upload", "where upload_pk='{$uploadtreeRec['upload_fk']}'"); if (empty($uploadRec['uploadtree_tablename'])) { $uploadtree_tablename = "uploadtree"; } else { $uploadtree_tablename = $uploadRec['uploadtree_tablename']; } $List = GetAllTags($item, true, $uploadtree_tablename); foreach ($List as $L) { $V .= $L['tag_name'] . ","; } return new Response($V, Response::HTTP_OK, array('content-type' => 'text/plain')); }
/** * \brief Generate the text for this plugin. */ public function Output() { $V = ""; /* If this is a POST, then process the request. */ $ParentId = GetParm('parentid', PARM_INTEGER); $NewFolder = GetParm('newname', PARM_TEXT); $Desc = GetParm('description', PARM_TEXT); if (!empty($ParentId) && !empty($NewFolder)) { $rc = $this->create($ParentId, $NewFolder, $Desc); if ($rc == 1) { /* Need to refresh the screen */ $text = _("Folder"); $text1 = _("Created"); $this->vars['message'] = "{$text} {$NewFolder} {$text1}"; } else { if ($rc == 4) { $text = _("Folder"); $text1 = _("Exists"); $this->vars['message'] = "{$text} {$NewFolder} {$text1}"; } } } /* Display the form */ $V .= "<form method='POST'>\n"; // no url = this url $V .= "<ol>\n"; $text = _("Select the parent folder: \n"); $V .= "<li>{$text}"; $V .= "<select name='parentid'>\n"; $root_folder_pk = GetUserRootFolder(); $V .= FolderListOption($root_folder_pk, 0); $V .= "</select><P />\n"; $text = _("Enter the new folder name: \n"); $V .= "<li>{$text}"; $V .= "<INPUT type='text' name='newname' size=40 />\n<br>"; $text = _("Enter a meaningful description: \n"); $V .= "<br><li>{$text}"; $V .= "<INPUT type='text' name='description' size=80 />\n"; $V .= "</ol>\n"; $text = _("Create"); $V .= "<input type='submit' value='{$text}!'>\n"; $V .= "</form>\n"; return $V; }
/** * \brief Display the loaded menu and plugins. */ function Output() { $upload_id = GetParm("upload", PARM_INTEGER); if (empty($upload_id)) { return new Response('', Response::HTTP_OK, array('content-type' => 'text/plain')); } /** check if this upload has been disabled */ $sql = "select count(*) from tag_manage where upload_fk = \$1 and is_disabled = true"; $numTags = $GLOBALS['container']->get('db.manager')->getSingleRow($sql, array($upload_id)); $count = $numTags['count']; if (empty($count)) { $text = _("Disable"); $V = "<input type='submit' name='manage' value='{$text}'>\n"; } else { $text = _("Enable"); $V = "<input type='submit' name='manage' value='{$text}'>\n"; } return new Response($V, Response::HTTP_OK, array('content-type' => 'text/plain')); }
/** * \brief Display the loaded menu and plugins. */ public function Output() { global $Plugins; global $PG_CONN; $UploadPk = GetParm("upload", PARM_INTEGER); $Agent = GetParm("agent", PARM_STRING); if (empty($UploadPk) || empty($Agent)) { return new Response('missing parameter', Response::HTTP_BAD_REQUEST, array('Content-type' => 'text/plain')); } $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 new Response($errMsg, Response::HTTP_BAD_REQUEST, array('Content-type' => 'text/plain')); } $UploadRow = pg_fetch_assoc($result); $ShortName = $UploadRow['upload_filename']; pg_free_result($result); $user_pk = Auth::getUserId(); $group_pk = Auth::getGroupId(); $job_pk = JobAddJob($user_pk, $group_pk, $ShortName, $UploadPk); $Dependencies = array(); $P =& $Plugins[plugin_find_id($Agent)]; $rv = $P->AgentAdd($job_pk, $UploadPk, $ErrorMsg, $Dependencies); if ($rv <= 0) { $text = _("Scheduling of Agent(s) failed: "); return new Response($text . $rv . $ErrorMsg, Response::HTTP_BAD_REQUEST, array('Content-type' => 'text/plain')); } /** check if the scheudler is running */ $status = GetRunnableJobList(); $scheduler_msg = ""; if (empty($status)) { $scheduler_msg .= _("Is the scheduler running? "); } $URL = Traceback_uri() . "?mod=showjobs&upload={$UploadPk}"; /* Need to refresh the screen */ $text = _("Your jobs have been added to job queue."); $LinkText = _("View Jobs"); $msg = "{$scheduler_msg}" . "{$text} <a href={$URL}>{$LinkText}</a>"; $this->vars['message'] = $msg; return new Response($msg, Response::HTTP_OK, array('Content-type' => 'text/plain')); }
/** * \brief Generate the text for this plugin. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $Plugins; $V = ""; switch ($this->OutputType) { case "XML": break; case "HTML": /* If this is a POST, then process the request. */ $uploadpk = GetParm('uploadunpack', PARM_INTEGER); if (!empty($uploadpk)) { $P =& $Plugins[plugin_find_id("agent_unpack")]; $rc = $P->AgentAdd($uploadpk); if (empty($rc)) { /* Need to refresh the screen */ $text = _("Unpack added to job queue"); $V .= displayMessage($text); } else { $text = _("Unpack of Upload failed"); $V .= displayMessage("{$text}: {$rc}"); } } /* Set default values */ if (empty($GetURL)) { $GetURL = 'http://'; } //$V .= $this->ShowReunpackView($uploadtree_pk); break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \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; } }
/** * \brief test for GetParm($Name, $Type) */ function test_GetParm() { print "Starting unit test for common-parm.php\n"; print "test function GetParm()\n"; //Test Case 1: $_GET[$Name] = "Name", $Type = PARM_INTEGER $Name = "Name"; $_GET[$Name] = 20; $Type = PARM_INTEGER; $result = GetParm($Name, $Type); $this->assertEquals("20", $result); //Test Case 2: $_GET[$Name] = "Name", $Type = PARM_NUMBER $_GET[$Name] = 20.2; $Type = PARM_NUMBER; $result = GetParm($Name, $Type); $this->assertEquals("20.2", $result); //Test Case 3: $_GET[$Name] = "Name", $Type = PARM_STRING $_GET[$Name] = "/test/"; $Type = PARM_STRING; $result = GetParm($Name, $Type); $this->assertEquals("/test/", $result); //Test Case 4: $_GET[$Name] = "Name", $Type = PARM_TEXT $_GET[$Name] = "\\test\\"; $Type = PARM_TEXT; $result = GetParm($Name, $Type); $this->assertEquals("test", $result); //Test Case 5: $_GET[$Name] = "Name", $Type = PARM_RAW $_GET[$Name] = "\\test\\"; $Type = PARM_RAW; $result = GetParm($Name, $Type); $this->assertEquals("\\test\\", $result); //Test Case 5: $_GET[$Name] = NULL, $_POST[$NAME] = "NAME", $Type = PARM_TEXT $_POST[$Name] = $_GET[$Name]; $_GET[$Name] = NULL; $Type = PARM_TEXT; $result = GetParm($Name, $Type); $this->assertEquals("test", $result); //Test Case 6: $Type = NULL $Type = NULL; $result = GetParm($Name, $Type); $this->assertEquals("", $result); }
/** * \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": $upload_id = GetParm("upload", PARM_INTEGER); if (empty($upload_id)) { break; } global $PG_CONN; /** check if this upload has been disabled */ $sql = "select * from tag_manage where upload_fk = {$upload_id} and is_disabled = true;"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $count = pg_num_rows($result); pg_free_result($result); if (empty($count)) { $text = _("Disable"); $V = "<input type='submit' name='manage' value='{$text}'>\n"; } else { $text = _("Enable"); $V = "<input type='submit' name='manage' value='{$text}'>\n"; } break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \brief Display the loaded menu and plugins. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } $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; }
/** * \brief Display the loaded menu and plugins. */ function Output() { $FolderId = GetParm("folder", PARM_INTEGER); if (empty($FolderId)) { $FolderId = FolderGetTop(); } $V = ''; $uploadList = FolderListUploads_perm($FolderId, Auth::PERM_WRITE); foreach ($uploadList as $upload) { $V .= "<option value='" . $upload['upload_pk'] . "'>"; $V .= htmlentities($upload['name']); if (!empty($upload['upload_desc'])) { $V .= " (" . htmlentities($upload['upload_desc']) . ")"; } if (!empty($upload['upload_ts'])) { $V .= " :: " . htmlentities($upload['upload_ts']); } $V .= "</option>\n"; } return new Response($V, Response::HTTP_OK, array('Content-type' => 'text/plain')); }
/** * \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": $FolderId = GetParm("folder", PARM_INTEGER); if (empty($FolderId)) { $FolderId = FolderGetTop(); } $List = FolderListUploads_perm($FolderId, PERM_WRITE); foreach ($List as $L) { $V .= "<option value='" . $L['upload_pk'] . "'>"; $V .= htmlentities($L['name']); if (!empty($L['upload_desc'])) { $V .= " (" . htmlentities($L['upload_desc']) . ")"; } if (!empty($L['upload_ts'])) { $V .= " :: " . htmlentities($L['upload_ts']); } $V .= "</option>\n"; } break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \brief Display the loaded menu and plugins. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } $V = ""; global $Plugins; switch ($this->OutputType) { case "XML": break; case "HTML": $Item = GetParm("uploadtree_pk", PARM_INTEGER); /* get uploadtree_tablename from $Item */ $uploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk='{$Item}'"); $uploadRec = GetSingleRec("upload", "where upload_pk='{$uploadtreeRec['upload_fk']}'"); if (empty($uploadRec['uploadtree_tablename'])) { $uploadtree_tablename = "uploadtree"; } else { $uploadtree_tablename = $uploadRec['uploadtree_tablename']; } $List = GetAllTags($Item, true, $uploadtree_tablename); foreach ($List as $L) { $V .= $L['tag_name'] . ","; } break; case "Text": break; default: break; } if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \brief Display the loaded menu and plugins. */ function Output() { if ($this->State != PLUGIN_STATE_READY) { return; } global $Plugins; $CriteriaCount = 0; $V = ""; $GETvars = ""; $Item = GetParm("item", PARM_INTEGER); if ($this->OutputType != 'HTML') { return; } /* Show path if searching an item tree (don't show on global searches) */ if ($Item) { $V .= Dir2Browse($this->Name, $Item, NULL, 1, NULL) . "<P />\n"; $GETvars .= "&item={$Item}"; } $searchtype = GetParm("searchtype", PARM_STRING); $GETvars .= "&searchtype=" . urlencode($searchtype); $Filename = GetParm("filename", PARM_RAW); if (!empty($Filename)) { $CriteriaCount++; $GETvars .= "&filename=" . urlencode($Filename); } $tag = GetParm("tag", PARM_RAW); if (!empty($tag)) { $CriteriaCount++; $GETvars .= "&tag=" . urlencode($tag); } $SizeMin = GetParm("sizemin", PARM_TEXT); if (!empty($SizeMin) && $SizeMin >= 0) { $SizeMin = intval($SizeMin); $CriteriaCount++; $GETvars .= "&sizemin={$SizeMin}"; } $SizeMax = GetParm("sizemax", PARM_TEXT); if (!empty($SizeMax) && $SizeMax >= 0) { $SizeMax = intval($SizeMax); $CriteriaCount++; $GETvars .= "&sizemax={$SizeMax}"; } $License = GetParm("license", PARM_RAW); if (!empty($License)) { $CriteriaCount++; $GETvars .= "&license=" . urlencode($License); } $Copyright = GetParm("copyright", PARM_RAW); if (!empty($Copyright)) { $CriteriaCount++; $GETvars .= "©right=" . urlencode($Copyright); } $Page = GetParm("page", PARM_INTEGER); /******* Input form *******/ $V .= "<form action='" . Traceback_uri() . "?mod=" . $this->Name . "' method='POST'>\n"; /* searchtype: 'allfiles' or 'containers' */ $ContainersChecked = ""; $DirectoryChecked = ""; $AllFilesChecked = ""; if ($searchtype == 'containers') { $ContainersChecked = "checked=\"checked\""; } else { if ($searchtype == 'directory') { $DirectoryChecked = "checked=\"checked\""; } else { $AllFilesChecked = "checked=\"checked\""; } } $text = _("Limit search to (Note: can not limit license and copyright search on containers)"); $text1 = _("Containers only (rpms, tars, isos, etc), including directories."); $V .= "<u><i><b>{$text}:</b></i></u><br> <input type='radio' name='searchtype' value='containers' {$ContainersChecked}><b>{$text1}</b>\n"; $text2 = _("Containers only (rpms, tars, isos, etc), excluding directories."); $V .= "<br> <input type='radio' name='searchtype' value='directory' {$DirectoryChecked}><b>{$text2}</b>\n"; $text3 = _("All Files"); $V .= "<br> <input type='radio' name='searchtype' value='allfiles' {$AllFilesChecked}><b>{$text3}</b>\n"; $V .= "<p><u><i><b>" . _("You must choose one or more search criteria (not case sensitive).") . "</b></i></u>"; $V .= "<ul>\n"; /* filename */ $text = _("Enter the filename to find: "); $V .= "<li><b>{$text}</b>"; $V .= "<INPUT type='text' name='filename' size='40' value='" . htmlentities($Filename) . "'>\n"; $V .= "<br>" . _("You can use '%' as a wild-card. "); $V .= _("For example, '%v3.war', or 'mypkg%.tar'."); /* tag */ $text = _("Tag to find"); $V .= "<li><b>{$text}:</b> <input name='tag' size='30' value='" . htmlentities($tag) . "'>\n"; /* file size >= */ $text = _("File size is"); $text1 = _(" bytes\n"); $V .= "<li><b>{$text} ≥ </b><input name='sizemin' size=10 value='{$SizeMin}'>{$text1}"; /* file size <= */ $text = _("File size is"); $text1 = _(" bytes\n"); $V .= "<li><b>{$text} ≤ </b><input name='sizemax' size=10 value='{$SizeMax}'>{$text1}"; $V .= "</ul>\n"; $V .= "<ul>\n"; $V .= "<p><u><i><b>" . _("You may also choose one or more optional search filters (not case sensitive).") . "</b></i></u>"; /* license */ $text = _("License"); $V .= "<li><b>{$text}: </b><input name='license' value='{$License}'>"; $V .= "<br>" . _("For example, 'AGPL%'."); $text = _("Copyright"); $V .= "<li><b>{$text}: </b><input name='copyright' value='{$Copyright}'>"; $V .= "<br>" . _("For example, 'fsf'."); $V .= "</ul>\n"; $V .= "<input type='hidden' name='item' value='{$Item}'>\n"; $text = _("Search"); $V .= "<input type='submit' value='{$text}'>\n"; $V .= "</form>\n"; /******* END Input form *******/ if ($CriteriaCount) { if (empty($Page)) { $Page = 0; } $V .= "<hr>\n"; $text = _("Files matching"); $V .= "<H2>{$text} " . htmlentities($Filename) . "</H2>\n"; $UploadtreeRecs = $this->GetResults($Item, $Filename, $tag, $Page, $SizeMin, $SizeMax, $searchtype, $License, $Copyright); $V .= $this->HTMLResults($UploadtreeRecs, $Page, $GETvars, $License, $Copyright); } $this->vars['content'] = $V; }
function Output() { global $PG_CONN; global $PERM_NAMES; /* GET parameters */ $folder_pk = GetParm('folder', PARM_INTEGER); $upload_pk = GetParm('upload', PARM_INTEGER); $users_group_pk = GetParm('group_pk', PARM_INTEGER); $group_pk = GetParm('group', PARM_INTEGER); $perm_upload_pk = GetParm('permupk', PARM_INTEGER); $perm = GetParm('perm', PARM_INTEGER); $newgroup = GetParm('newgroup', PARM_INTEGER); $newperm = GetParm('newperm', PARM_INTEGER); $public_perm = GetParm('public', PARM_INTEGER); // start building the output buffer $V = ""; /* If perm_upload_pk is passed in, update either the perm or group_pk */ $sql = ""; if (!empty($perm_upload_pk)) { if ($perm === 0) { $sql = "delete from perm_upload where perm_upload_pk='{$perm_upload_pk}'"; } else { if (!empty($perm)) { $sql = "update perm_upload set perm='{$perm}' where perm_upload_pk='{$perm_upload_pk}'"; } else { if (!empty($group_pk)) { $sql = "update perm_upload set group_fk='{$group_pk}' where perm_upload_pk='{$perm_upload_pk}'"; } } } if (!empty($sql)) { $result = @pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } } else { if (!empty($newgroup) and !empty($newperm)) { // before inserting this new record, delete any record for the same upload and group since // that would be a duplicate $sql = "delete from perm_upload where upload_fk={$upload_pk} and group_fk={$newgroup}"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); // Don't insert a PERM_NONE. NONE is the default if ($newperm != PERM_NONE) { $sql = "insert into perm_upload (perm, upload_fk, group_fk) values ({$newperm}, {$upload_pk}, {$newgroup})"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } $newperm = $newgroup = 0; } else { if (!empty($public_perm)) { $sql = "update upload set public_perm='{$public_perm}' where upload_pk='{$upload_pk}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); pg_free_result($result); } } } $root_folder_pk = GetUserRootFolder(); if (empty($folder_pk)) { $folder_pk = $root_folder_pk; } // Get folder array folder_pk => folder_name $FolderArray = array(); GetFolderArray($root_folder_pk, $FolderArray); /* define js_url */ $V .= js_url(); $text = _("Select the folder that contains the upload: \n"); $V .= "{$text}"; /*** Display folder select list, on change request new page with folder= in url ***/ $url = Traceback_uri() . "?mod=upload_permissions&folder="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($FolderArray, "folderselect", $folder_pk, false, false, $onchange); /*** Display upload select list, on change, request new page with new upload= in url ***/ $text = _("Select the upload you wish to edit: \n"); $V .= "<br>{$text}"; // Get list of all upload records in this folder that the user has PERM_ADMIN $UploadList = FolderListUploads_perm($folder_pk, PERM_ADMIN); /* if (empty($UploadList)) { echo "You have no uploads in this folder for which you are an admin. Hit the back button"; return; } */ // Make data array for upload select list. Key is upload_pk, value is a composite // of the upload_filename and upload_ts. // Note that $UploadList may be empty so $UploadArray will be empty $UploadArray = array(); foreach ($UploadList as $UploadRec) { $SelectText = htmlentities($UploadRec['name']); if (!empty($UploadRec['upload_ts'])) { $SelectText .= ", " . substr($UploadRec['upload_ts'], 0, 19); } $UploadArray[$UploadRec['upload_pk']] = $SelectText; } /* Get selected upload info to display*/ if (empty($upload_pk)) { // no upload selected, so use the top one in the select list reset($UploadArray); $upload_pk = key($UploadArray); } /* Upload select list */ $url = Traceback_uri() . "?mod=upload_permissions&folder={$folder_pk}&upload="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($UploadArray, "uploadselect", $upload_pk, false, false, $onchange); /* Get permissions for this upload */ if (!empty($UploadArray)) { // Get upload.public_perm $sql = "select public_perm from upload where upload_pk='{$upload_pk}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $Row = pg_fetch_all($result); $public_perm = $Row[0]['public_perm']; pg_free_result($result); $text1 = _("Public Permission"); $V .= "<p>{$text1} "; $url = Traceback_uri() . "?mod=upload_permissions&folder={$folder_pk}&upload={$upload_pk}&public="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($PERM_NAMES, "publicpermselect", $public_perm, false, false, $onchange); $sql = "select perm_upload_pk, perm, group_pk, group_name from groups, perm_upload where group_fk=group_pk and upload_fk='{$upload_pk}'"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $PermArray = pg_fetch_all($result); pg_free_result($result); /* Get master array of groups */ $sql = "select group_pk, group_name from groups order by group_name"; $result = pg_query($PG_CONN, $sql); DBCheckResult($result, $sql, __FILE__, __LINE__); $GroupArray = array(); while ($GroupRow = pg_fetch_assoc($result)) { $GroupArray[$GroupRow['group_pk']] = $GroupRow['group_name']; } pg_free_result($result); /* Permissions Table */ $V .= "<p><table border=1>"; $GroupText = _("Group"); $PermText = _("Permission"); $V .= "<tr><th>{$GroupText}</th><th>{$PermText}</th></tr>"; foreach ($PermArray as $PermRow) { $V .= "<tr>"; $V .= "<td>"; // group $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&permupk={$PermRow['perm_upload_pk']}&group="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($GroupArray, "groupselect", $PermRow['group_pk'], false, false, $onchange); $V .= "</td>"; $V .= "<td>"; // permission $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&permupk={$PermRow['perm_upload_pk']}&perm="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $V .= Array2SingleSelect($PERM_NAMES, "permselect", $PermRow['perm'], false, false, $onchange); $V .= "</td>"; $V .= "</tr>"; } /* Print one extra row for adding perms */ $V .= "<tr>"; $V .= "<td>"; // group $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&newperm={$newperm}&newgroup="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $Selected = empty($newgroup) ? "" : $newgroup; $V .= Array2SingleSelect($GroupArray, "groupselectnew", $Selected, true, false, $onchange); $V .= "</td>"; $V .= "<td>"; // permission $url = Traceback_uri() . "?mod=upload_permissions&group_pk={$users_group_pk}&upload={$upload_pk}&folder={$folder_pk}&newgroup={$newgroup}&newperm="; $onchange = "onchange=\"js_url(this.value, '{$url}')\""; $Selected = empty($newperm) ? "" : $newperm; $V .= Array2SingleSelect($PERM_NAMES, "permselectnew", $Selected, false, false, $onchange); $V .= "</td>"; $V .= "</tr>"; $V .= "</table>"; $text = _("All upload permissions take place immediately when a value is changed. There is no submit button."); $V .= "<p>" . $text; $text = _("Add new groups on the last line."); $V .= "<br>" . $text; } else { $text = _("You have no permission to change permissions on any upload in this folder."); $V .= "<p>{$text}<p>"; } $V .= "<hr>"; $V .= $this->DisplayGroupMembership(); if (!$this->OutputToStdout) { return $V; } print "{$V}"; return; }
/** * \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; }