本文整理汇总了PHP中GetSingleRec函数的典型用法代码示例。如果您正苦于以下问题:PHP GetSingleRec函数的具体用法?PHP GetSingleRec怎么用?PHP GetSingleRec使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSingleRec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Output
/**
* \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;
}
示例2: AgentHasResults
/**
* \brief Check if the upload has results from this agent.
*
* \param $upload_pk
*
* \returns:
* - 0 = no
* - 1 = yes, from latest agent version
* - 2 = yes, from older agent version (does not apply to adj2nest)
**/
function AgentHasResults($upload_pk)
{
/* see if the latest nomos and bucket agents have scaned this upload for this bucketpool */
$uploadtreeRec = GetSingleRec("uploadtree", "where upload_fk='{$upload_pk}' and lft is not null");
if (empty($uploadtreeRec)) {
return 0;
}
return 1;
}
示例3: WhoAmI
/**
* \brief Find out who I am from my user record.
* \returns user name
*/
function WhoAmI()
{
$user_pk = $_SESSION['UserId'];
if (empty($user_pk)) {
/* Note that this message is localized. This is a good practice for as
* much of your UI text as possible.
*/
return _("You are not logged in");
}
/* The user's name is stored in $_SESSION[User] after they login.
* But to demonstrate a database call, I'll get the name from the
* user's primary key (in $_SESSION[UserId]).
*/
$UserRow = GetSingleRec('users', "where user_pk='{$_SESSION['UserId']}'");
return $UserRow['user_name'];
}
示例4: Output
/**
* \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'));
}
示例5: Output
/**
* \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;
}
示例6: GetTreeInfo
/**
* @brief Get uploadtree info for a given uploadtree_pk.
* @param $Uploadtree_pk
* @return array with uploadtree record and:\n
* agent_pk\n
* bucketagent_pk\n
* nomosagent_pk\n
* bucketpool_pk\n
*/
function GetTreeInfo($Uploadtree_pk)
{
global $PG_CONN;
$TreeInfo = GetSingleRec("uploadtree", "WHERE uploadtree_pk = {$Uploadtree_pk}");
$TreeInfo['agent_pk'] = LatestAgentpk($TreeInfo['upload_fk'], "nomos_ars");
/* Get the ars_pk of the scan to display, also the select list */
$ars_pk = GetArrayVal("ars", $_GET);
$BucketSelect = SelectBucketDataset($TreeInfo['upload_fk'], $ars_pk, "selectbdata", "onchange=\"addArsGo('newds','selectbdata');\"");
$TreeInfo['ars_pk'] = $ars_pk;
if ($ars_pk == 0) {
/* No bucket data for this upload */
return $BucketSelect;
// $BucketSelect is error message
}
/* Get scan keys */
$where = "where ars_pk={$ars_pk}";
$row = GetSingleRec("bucket_ars", $where);
if (empty($row)) {
Fatal("No bucket data {$where}", __FILE__, __LINE__);
}
$TreeInfo['bucketagent_pk'] = $row["agent_fk"];
$TreeInfo['nomosagent_pk'] = $row["nomosagent_fk"];
$TreeInfo['bucketpool_pk'] = $row["bucketpool_fk"];
unset($row);
return $TreeInfo;
}
示例7: QueueUploadsOnAgents
/**
* \brief Schedule agent tasks on upload ids
*
* \param $upload_pk_list - upload ids, The string can be a comma-separated list of upload ids.
* Or, use 'ALL' to specify all upload ids.
* \param $agent_list - array of agent plugin objects to schedule.
* \param $Verbose - verbose output, not empty: output, empty: does not output
*/
function QueueUploadsOnAgents($upload_pk_list, $agent_list, $Verbose)
{
global $Plugins;
global $PG_CONN;
/* Get the users.default_bucketpool_fk */
$user_pk = Auth::getUserId();
$group_pk = Auth::getGroupId();
if (empty($upload_pk_list)) {
return;
}
// Schedule them
$agent_count = count($agent_list);
foreach (explode(",", $upload_pk_list) as $upload_pk) {
if (empty($upload_pk)) {
continue;
}
// Create a job for the upload
$where = "where upload_pk ='{$upload_pk}'";
$UploadRec = GetSingleRec("upload", $where);
if (empty($UploadRec)) {
echo "ERROR: unknown upload_pk: {$upload_pk}\n";
continue;
}
$ShortName = $UploadRec['upload_filename'];
/* Create Job */
$job_pk = JobAddJob($user_pk, $group_pk, $ShortName, $upload_pk);
// don't exit on AgentAdd failure, or all the agents requested will
// not get scheduled.
for ($ac = 0; $ac < $agent_count; $ac++) {
$agentname = $agent_list[$ac]->URI;
if (!empty($agentname)) {
$Agent =& $Plugins[plugin_find_id($agentname)];
$Dependencies = "";
$ErrorMsg = "already queued!";
$agent_jq_pk = $Agent->AgentAdd($job_pk, $upload_pk, $ErrorMsg, $Dependencies);
if ($agent_jq_pk <= 0) {
echo "WARNING: Scheduling failed for Agent {$agentname}, upload_pk is: {$upload_pk}, job_pk is:{$job_pk}\n";
echo "WARNING message: {$ErrorMsg}\n";
} else {
if ($Verbose) {
$SQL = "SELECT upload_filename FROM upload where upload_pk = {$upload_pk}";
$result = pg_query($PG_CONN, $SQL);
DBCheckResult($result, $SQL, __FILE__, __LINE__);
$row = pg_fetch_assoc($result);
pg_free_result($result);
print "{$agentname} is queued to run on {$upload_pk}:{$row['upload_filename']}.\n";
}
}
}
}
/* for $ac */
}
/* for each $upload_pk */
}
示例8: GetUploadPerm
/**
* @brief Get the upload permission for a user
* @param $upload_pk
* @param $user_pk (optional, default is current user_pk)
* @return hightest permission level a user has for an upload
**/
function GetUploadPerm($upload_pk, $user_pk = 0)
{
global $PG_CONN;
if ($user_pk == 0) {
$user_pk = Auth::getUserId();
}
if ($_SESSION[Auth::USER_LEVEL] == PLUGIN_DB_ADMIN) {
return Auth::PERM_ADMIN;
}
//for the command line didn't have session info
$UserRow = GetSingleRec("Users", "where user_pk='{$user_pk}'");
if ($UserRow['user_perm'] == PLUGIN_DB_ADMIN) {
return Auth::PERM_ADMIN;
}
$sql = "select max(perm) as perm from perm_upload, group_user_member where perm_upload.upload_fk={$upload_pk} and user_fk={$user_pk} and group_user_member.group_fk=perm_upload.group_fk";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
if (pg_num_rows($result) < 1) {
$perm = Auth::PERM_NONE;
} else {
$row = pg_fetch_assoc($result);
$perm = $row['perm'];
}
pg_free_result($result);
/* check the upload public permission */
$sql = "select public_perm from upload where upload_pk={$upload_pk}";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
if (pg_num_rows($result) < 1) {
$perm2 = Auth::PERM_NONE;
} else {
$row = pg_fetch_assoc($result);
$perm2 = $row['public_perm'];
}
pg_free_result($result);
return max($perm, $perm2);
}
示例9: Output
/**
* \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
//.........这里部分代码省略.........
示例10: GetLicenseList
/**
* \brief get nomos license list of one specified uploadtree_id
*
* \param $uploadtree_pk - uploadtree id
* \param $upload_pk - upload id
* \param $container - include container or not, 1: yes, 0: no (default)
*/
function GetLicenseList($uploadtree_pk, $upload_pk, $container = 0)
{
global $PG_CONN;
if (empty($uploadtree_pk)) {
/* Find the uploadtree_pk for this upload so that it can be used in the browse link */
$uploadtreeRec = GetSingleRec("uploadtree", "where parent is NULL and upload_fk='{$upload_pk}'");
$uploadtree_pk = $uploadtreeRec['uploadtree_pk'];
}
// print "Upload ID:$upload_pk; Uploadtree ID:$uploadtree_pk\n";
/* get last nomos agent_pk that has data for this upload */
$Agent_name = "nomos";
$AgentRec = AgentARSList("nomos_ars", $upload_pk, 1);
$agent_pk = $AgentRec[0]["agent_fk"];
if ($AgentRec === false) {
echo _("No data available");
return;
}
/* get the top of tree */
$sql = "SELECT upload_fk, lft, rgt from uploadtree where uploadtree_pk='{$uploadtree_pk}';";
$result = pg_query($PG_CONN, $sql);
DBCheckResult($result, $sql, __FILE__, __LINE__);
$toprow = pg_fetch_assoc($result);
pg_free_result($result);
$uploadtree_tablename = GetUploadtreeTableName($toprow['upload_fk']);
/* loop through all the records in this tree */
$sql = "select uploadtree_pk, ufile_name, lft, rgt from {$uploadtree_tablename} \n where upload_fk='{$toprow['upload_fk']}' \n and lft>'{$toprow['lft']}' and rgt<'{$toprow['rgt']}'\n and ((ufile_mode & (1<<28)) = 0)";
$container_sql = " and ((ufile_mode & (1<<29)) = 0)";
/* include container or not */
if (empty($container)) {
$sql .= $container_sql;
// do not include container
}
$sql .= "order by uploadtree_pk";
$outerresult = pg_query($PG_CONN, $sql);
DBCheckResult($outerresult, $sql, __FILE__, __LINE__);
/* Select each uploadtree row in this tree, write out text:
* filepath : license list
* e.g. Pound-2.4.tgz/Pound-2.4/svc.c: GPL_v3+, Indemnity
*/
while ($row = pg_fetch_assoc($outerresult)) {
$filepatharray = Dir2Path($row['uploadtree_pk'], $uploadtree_tablename);
$filepath = "";
foreach ($filepatharray as $uploadtreeRow) {
if (!empty($filepath)) {
$filepath .= "/";
}
$filepath .= $uploadtreeRow['ufile_name'];
}
$V = $filepath . ": " . GetFileLicenses_string($agent_pk, 0, $row['uploadtree_pk'], $uploadtree_tablename);
#$V = $filepath;
print "{$V}";
print "\n";
}
pg_free_result($outerresult);
}
示例11: OutputOpen
/**
* \brief This function is called when user output is
* requested. This function is responsible for assigning headers. \n
* If $Type is "HTML" then generate an HTTP header. \n
* If $Type is "XML" then begin an XML header. \n
* If $Type is "Text" then generate a text header as needed. \n
* The $ToStdout flag is "1" if output should go to stdout
*
* \return 0 if it should be returned as a string. (Strings may be parsed
* and used by other plugins.)
*/
function OutputOpen($Type, $ToStdout)
{
global $Plugins;
if ($this->State != PLUGIN_STATE_READY) {
return 0;
}
if (GetParm("output", PARM_STRING) == 'dltext') {
$Type = 'dltext';
}
$this->OutputType = $Type;
$this->OutputToStdout = $ToStdout;
$Item = GetParm("item", PARM_INTEGER);
if (empty($Item)) {
return;
}
// Get the upload for this uploadtree_pk
$uploadtreeRec = GetSingleRec("uploadtree", "where uploadtree_pk='{$Item}'");
$uploadtree_tablename = GetUploadtreeTableName($uploadtreeRec['upload_fk']);
switch ($this->OutputType) {
case "dltext":
$this->NoHeader = 1;
$Path = Dir2Path($Item, $uploadtree_tablename);
$Name = $Path[count($Path) - 1]['ufile_name'] . ".txt";
header("Content-Type: text");
header('Content-Disposition: attachment; filename="' . $Name . '"');
$V = "";
break;
case "XML":
$V = "<xml>\n";
break;
case "HTML":
header('Content-type: text/html');
if ($this->NoHTML) {
return;
}
$V = "";
if ($this->NoMenu == 0 && $this->Name != "menus") {
$Menu =& $Plugins[plugin_find_id("menus")];
$Menu->OutputSet($Type, $ToStdout);
} else {
$Menu = NULL;
}
/* DOCTYPE is required for IE to use styles! (else: css menu breaks) */
$V .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "xhtml1-frameset.dtd">' . "\n";
// $V .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
// $V .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Loose//EN" "http://www.w3.org/TR/html4/loose.dtd">' . "\n";
// $V .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd">' . "\n";
$V .= "<html>\n";
$V .= "<head>\n";
if ($this->NoHeader == 0) {
/** Known bug: DOCTYPE "should" be in the HEADER
and the HEAD tags should come first.
Also, IE will ignore <style>...</style> tags that are NOT
in a <head>...</head> block.
*
*/
if (!empty($this->Title)) {
$V .= "<title>" . htmlentities($this->Title) . "</title>\n";
}
$V .= "<link rel='stylesheet' href='fossology.css'>\n";
print $V;
$V = "";
if (!empty($Menu)) {
print $Menu->OutputCSS();
}
$V .= "</head>\n";
$V .= "<body class='text'>\n";
print $V;
$V = "";
if (!empty($Menu)) {
$Menu->Output($this->Title);
}
}
break;
case "Text":
break;
default:
break;
}
if (!$this->OutputToStdout) {
return $V;
}
print $V;
return;
}
示例12: Output
/**
* \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> ";
//.........这里部分代码省略.........
示例13: Output
/**
* \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;
//.........这里部分代码省略.........
示例14: UploadOne
/**
* \brief Given one object (file or URL), upload it.
*
* \param $FolderPath - folder path
* \param $UploadArchive - upload file(absolute path) or url
* \param $UploadName - uploaded file/dir name
* \param $UploadDescription - upload description
*
* \return 1: error, 0: success
*/
function UploadOne($FolderPath, $UploadArchive, $UploadName, $UploadDescription, $TarSource = NULL)
{
global $Verbose;
global $Test;
global $QueueList;
global $fossjobs_command;
global $public_flag;
global $SysConf;
global $PG_CONN;
global $VCS;
global $vcsuser;
global $vcspass;
global $TarExcludeList;
$jobqueuepk = 0;
if (empty($UploadName)) {
$text = "UploadName is empty\n";
echo $text;
return 1;
}
$user_pk = $SysConf['auth']['UserId'];
$group_pk = $SysConf['auth']['GroupId'];
/* Get the user record and check the PLUGIN_DB_ level to make sure they have at least write access */
$UsersRow = GetSingleRec("users", "where user_pk={$user_pk}");
if ($UsersRow["user_perm"] < PLUGIN_DB_WRITE) {
print "You have no permission to upload files into FOSSology\n";
return 1;
}
/* Get the folder's primary key */
$root_folder_fk = $UsersRow["root_folder_fk"];
global $OptionA;
/* Should it use bucket names? */
if ($OptionA) {
global $bucket_size;
$FolderPath .= "/" . GetBucketFolder($UploadName, $bucket_size);
}
$FolderPk = GetFolder($FolderPath, $root_folder_fk);
if ($FolderPk == 1) {
print " Uploading to folder: 'Software Repository'\n";
} else {
print " Uploading to folder: '{$FolderPath}'\n";
}
print " Uploading as '{$UploadName}'\n";
if (!empty($UploadDescription)) {
print " Upload description: '{$UploadDescription}'\n";
}
$Mode = 1 << 3;
// code for "it came from web upload"
/* Create the upload for the file */
if ($Verbose) {
print "JobAddUpload({$user_pk}, {$group_pk}, {$UploadName},{$UploadArchive},{$UploadDescription},{$Mode},{$FolderPk}, {$public_flag});\n";
}
if (!$Test) {
$Src = $UploadArchive;
if (!empty($TarSource)) {
$Src = $TarSource;
}
$UploadPk = JobAddUpload($user_pk, $group_pk, $UploadName, $Src, $UploadDescription, $Mode, $FolderPk, $public_flag);
print " UploadPk is: '{$UploadPk}'\n";
}
/* Prepare the job: job "wget" */
if ($Verbose) {
print "JobAddJob({$user_pk}, {$group_pk}, wget, {$UploadPk});\n";
}
if (!$Test) {
$jobpk = JobAddJob($user_pk, $group_pk, "wget", $UploadPk);
if (empty($jobpk) || $jobpk < 0) {
$text = _("Failed to insert job record");
echo $text;
return 1;
}
}
$jq_args = "{$UploadPk} - {$Src}";
if ($TarExcludeList) {
$jq_args .= " " . $TarExcludeList;
}
if ($VCS) {
$jq_args .= " " . $VCS;
}
// add flags when upload from version control system
if ($vcsuser && $vcspass) {
$jq_args .= " --username {$vcsuser} --password {$vcspass} ";
}
if ($Verbose) {
print "JobQueueAdd({$jobpk}, wget_agent, {$jq_args}, no, NULL);\n";
}
if (!$Test) {
$jobqueuepk = JobQueueAdd($jobpk, "wget_agent", $jq_args, "no", NULL);
if (empty($jobqueuepk)) {
$text = _("Failed to insert task 'wget' into job queue");
echo $text;
//.........这里部分代码省略.........
示例15: Output
/**
* \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;
//.........这里部分代码省略.........