32 $this->Name =
"view_info";
33 $this->Title = _(
"View File Information");
34 $this->Dependency = array(
"browse");
37 parent::__construct();
38 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
39 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
40 $this->userDao = $GLOBALS[
'container']->get(
'dao.user');
48 $tooltipText = _(
"View file information");
49 menu_insert(
"Browse-Pfile::Info", 5, $this->Name, $tooltipText);
52 $URI = $this->Name . $Parm;
62 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
66 $tooltipText = _(
"View information about this file");
69 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
72 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
74 menu_insert(
"Browse::Info", -3, $URI, $tooltipText);
81 function ShowView($Upload, $Item, $ShowMenu = 0)
84 if (empty($Upload) || empty($Item)) {
92 $vars[
'repoLocPage'] = $Page;
100 $sql =
"SELECT * FROM uploadtree
101 INNER JOIN pfile ON uploadtree_pk = $1
102 AND pfile_fk = pfile_pk
107 __METHOD__ .
"GetFileDescribingRow"
109 $bytes = $row[
'pfile_size'];
111 $bytes = number_format($bytes, 0,
"",
",") .
' B';
112 if ($bytesH == $bytes) {
115 $bytesH =
'(' . $bytesH .
')';
117 $vars[
'sizeInBytes'] = $bytes;
118 $vars[
'sizeInMB'] = $bytesH;
119 $vars[
'fileSha1'] = $row[
'pfile_sha1'];
120 $vars[
'fileMd5'] = $row[
'pfile_md5'];
121 $vars[
'fileSha256'] = $row[
'pfile_sha256'];
122 $vars[
'fileSize'] = $row[
'pfile_size'];
123 $vars[
'filePfileId'] = $row[
'pfile_fk'];
134 if (empty($Upload) || empty($Item)) {
143 $offset = $page * $MAX;
147 $sql =
"SELECT * FROM pfile,uploadtree
148 WHERE pfile_pk=pfile_fk
150 (SELECT pfile_fk FROM uploadtree WHERE uploadtree_pk = $1)
152 $this->
dbManager->prepare(__METHOD__ .
"getListOfFiles", $sql);
153 $result = $this->
dbManager->execute(__METHOD__ .
"getListOfFiles", array($Item,$MAX,$offset));
154 $count = pg_num_rows($result);
155 if (($page > 0) || ($count >= $MAX)) {
156 $vMenu =
"<p>\n" .
MenuEndlessPage($page, ($count >= $MAX)) .
"</p>\n";
161 $v .= _(
"This exact file appears in the following locations:\n");
166 } elseif ($page > 0) {
167 $v .= _(
"End of listing.\n");
169 $v .= _(
"This file does not appear in any other known location.\n");
171 pg_free_result($result);
174 $vars[
'sightingsContent'] = $v;
185 $groupId = Auth::getGroupId();
187 if (empty($Item) || empty($Upload)) {
192 $sql =
"SELECT * FROM uploadtree where uploadtree_pk = $1";
193 $this->
dbManager->prepare(__METHOD__ .
"DisplayMimetype", $sql);
194 $result = $this->
dbManager->execute(__METHOD__ .
"DisplayMimetype", array($Item));
195 if (pg_num_rows($result)) {
196 $vars[
'fileInfo'] = 1;
197 $row = pg_fetch_assoc($result);
199 if (! empty($row[
'mimetype_pk'])) {
200 $vars[
'displayMimeTypeName'] = $row[
'mimetype_name'];
204 $vars[
'fileInfo'] = 0;
210 if (! empty($row[
'pfile_fk'])) {
211 $sql =
"select mimetype_name from pfile, mimetype where pfile_pk = $1 and pfile_mimetypefk=mimetype_pk";
212 $this->
dbManager->prepare(__METHOD__ .
"GetMimetype", $sql);
214 __METHOD__ .
"GetMimetype",
215 array($row[
'pfile_fk'])
217 if (pg_num_rows($result)) {
218 $pmRow = pg_fetch_assoc($result);
219 $vars[
'getMimeTypeName'] = $pmRow[
'mimetype_name'];
225 $sql =
"SELECT agent_enabled FROM agent WHERE agent_name ='scanoss' ORDER BY agent_ts LIMIT 1;";
226 $row = $this->
dbManager->getSingleRow($sql, [],
227 __METHOD__ .
"checkScanOss");
228 if (!empty($row) && $row[
"agent_enabled"] ==
't') {
229 $sql =
"SELECT s.purl, s.matchtype, s.lineranges, s.url, s.filepath " .
230 "FROM scanoss_fileinfo s, uploadtree u where u.uploadtree_pk = $1 and s.pfile_fk = u.pfile_fk;";
231 $pmRow = $this->
dbManager->getSingleRow($sql, [$Item],
232 __METHOD__ .
"GetFileMatchInfo");
234 if (!empty($pmRow)) {
235 $vars[
'purl'] = $pmRow[
'purl'];
236 $vars[
'matchType'] = $pmRow[
'matchtype'];
237 $vars[
'lineRange'] = $pmRow[
'lineranges'];
238 $vars[
'url'] = $pmRow[
'url'];
239 $vars[
'path'] = $pmRow[
'filepath'];
240 $vars[
'scanossInfo'] = 1;
242 $vars[
'scanossInfo'] = 0;
245 $sql =
"select * from upload where upload_pk=$1";
248 array($row[
'upload_fk']),
249 __METHOD__ .
"getUploadOrigin"
253 if ($row[
'upload_mode'] & 1 << 2) {
254 $text = _(
"Added by URL");
255 } elseif ($row[
'upload_mode'] & 1 << 3) {
256 $text = _(
"Added by file upload");
257 } elseif ($row[
'upload_mode'] & 1 << 4) {
258 $text = _(
"Added from filesystem");
260 $vars[
'fileUploadOriginInfo'] = $text;
261 $vars[
'fileUploadOrigin'] = $row[
'upload_origin'];
264 $ts = $row[
'upload_ts'];
265 $vars[
'fileUploadDate'] = substr($ts, 0, strrpos($ts,
'.'));
269 $sql =
"SELECT user_name from users, upload where user_pk = user_fk and upload_pk = $1";
270 $row = $this->
dbManager->getSingleRow($sql, array($Upload), __METHOD__ .
"getUploadOwner");
272 $vars[
'fileUploadUser'] = $row[
'user_name'];
273 $userId = $this->uploadDao->getAssignee($Upload, $groupId);
274 $vars[
'fileAssigneeUser'] = ($userId == 1) ?
'Unassigned' : $this->userDao->getUserName($userId);
275 $assignedDate = $this->uploadDao->getAssigneeDate($Upload);
276 $vars[
'fileAssigneeUserOn'] = empty($assignedDate) ?
'NA' : substr($assignedDate, 0, strrpos($assignedDate,
'.'));
277 $vars[
'fileClearingDuration'] = $this->uploadDao->getClearingDuration($Upload)[0];
293 $rpm_info = array(
"Package" =>
"pkg_name",
294 "Alias" =>
"pkg_alias",
295 "Architecture" =>
"pkg_arch",
296 "Version" =>
"version",
297 "License" =>
"license",
298 "Group" =>
"pkg_group",
299 "Packager" =>
"packager",
300 "Release" =>
"release",
301 "BuildDate" =>
"build_date",
302 "Vendor" =>
"vendor",
304 "Summary" =>
"summary",
305 "Description" =>
"description",
306 "Source" =>
"source_rpm");
308 $deb_binary_info = array(
"Package" =>
"pkg_name",
309 "Architecture" =>
"pkg_arch",
310 "Version" =>
"version",
311 "Section" =>
"section",
312 "Priority" =>
"priority",
313 "Installed Size" =>
"installed_size",
314 "Maintainer" =>
"maintainer",
315 "Homepage" =>
"homepage",
316 "Source" =>
"source",
317 "Summary" =>
"summary",
318 "Description" =>
"description");
320 $deb_source_info = array(
"Format" =>
"format",
321 "Source" =>
"source",
322 "Binary" =>
"pkg_name",
323 "Architecture" =>
"pkg_arch",
324 "Version" =>
"version",
325 "Maintainer" =>
"maintainer",
326 "Uploaders" =>
"uploaders",
327 "Standards-Version" =>
"standards_version");
329 if (empty($Item) || empty($Upload)) {
336 $sql =
"SELECT agent_enabled FROM agent WHERE agent_name ='pkgagent' order by agent_ts LIMIT 1;";
337 $row = $this->
dbManager->getSingleRow($sql, array(), __METHOD__ .
"checkPkgagentDisabled");
338 if (isset($row) && ($row[
'agent_enabled'] ==
'f')) {
343 $sql =
"SELECT typlen FROM pg_type where typname='pkgagent_ars' limit 1;";
344 $this->
dbManager->prepare(__METHOD__ .
"displayPackageInfo", $sql);
345 $result = $this->
dbManager->execute(__METHOD__ .
"displayPackageInfo", array());
346 $numrows = pg_num_rows($result);
349 $vars[
'packageAgentNA'] = 1;
354 $agent_status = AgentARSList(
'pkgagent_ars', $Upload);
355 if (empty($agent_status)) {
356 $vars[
'packageAgentStatus'] = 1;
358 "?mod=schedule_agent&upload=$Upload&agent=agent_pkgagent";
361 $sql =
"SELECT mimetype_name
363 INNER JOIN pfile ON uploadtree_pk = $1
364 AND pfile_fk = pfile_pk
365 INNER JOIN mimetype ON pfile_mimetypefk = mimetype_pk;";
366 $this->
dbManager->prepare(__METHOD__ .
"getMimetypeName", $sql);
367 $result = $this->
dbManager->execute(__METHOD__ .
"getMimetypeName", array($Item));
368 while ($row = pg_fetch_assoc($result)) {
369 if (! empty($row[
'mimetype_name'])) {
370 $MIMETYPE = $row[
'mimetype_name'];
378 if ($MIMETYPE ==
"application/x-rpm") {
381 INNER JOIN uploadtree ON uploadtree_pk = $1
382 AND uploadtree.pfile_fk = pkg_rpm.pfile_fk;";
383 $R = $this->
dbManager->getSingleRow($sql, array($Item), __METHOD__ .
"getRPMPackageInfo");
384 if ((! empty($R[
'source_rpm'])) and (
trim($R[
'source_rpm']) !=
"(none)")) {
385 $vars[
'packageType'] = _(
"RPM Binary Package");
387 $vars[
'packageType'] = _(
"RPM Source Package");
391 if (! empty($R[
'pkg_pk'])) {
392 $Require = $R[
'pkg_pk'];
393 foreach ($rpm_info as $key => $value) {
395 $entry[
'count'] = $Count;
396 $entry[
'type'] = _($key);
397 $entry[
'value'] = htmlentities($R[
"$value"]);
399 $vars[
'packageEntries'][] = $entry;
402 $sql =
"SELECT * FROM pkg_rpm_req WHERE pkg_fk = $1;";
403 $this->
dbManager->prepare(__METHOD__ .
"getPkg_rpm_req", $sql);
404 $result = $this->
dbManager->execute(__METHOD__ .
"getPkg_rpm_req", array($Require));
406 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
408 $entry[
'count'] = $Count;
409 $entry[
'type'] = _(
"Requires");
410 $entry[
'value'] = htmlentities($R[
'req_value']);
412 $vars[
'packageRequires'][] = $entry;
416 } elseif ($MIMETYPE ==
"application/x-debian-package") {
417 $vars[
'packageType'] = _(
"Debian Binary Package\n");
421 INNER JOIN uploadtree ON uploadtree_pk = $1
422 AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
423 $R = $this->
dbManager->getSingleRow($sql, array($Item), __METHOD__ .
"debianBinaryPackageInfo");
427 $Require = $R[
'pkg_pk'];
428 foreach ($deb_binary_info as $key => $value) {
430 $entry[
'count'] = $Count;
431 $entry[
'type'] = _($key);
432 $entry[
'value'] = htmlentities($R[
"$value"]);
434 $vars[
'packageEntries'][] = $entry;
436 pg_free_result($result);
438 $sql =
"SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
439 $this->
dbManager->prepare(__METHOD__ .
"getPkg_rpm_req", $sql);
440 $result = $this->
dbManager->execute(__METHOD__ .
"getPkg_rpm_req", array($Require));
442 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
444 $entry[
'count'] = $Count;
445 $entry[
'type'] = _(
"Depends");
446 $entry[
'value'] = htmlentities($R[
'req_value']);
448 $vars[
'packageRequires'][] = $entry;
453 } elseif ($MIMETYPE ==
"application/x-debian-source") {
454 $vars[
'packageType'] = _(
"Debian Source Package\n");
458 INNER JOIN uploadtree ON uploadtree_pk = $1
459 AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
460 $R = $this->
dbManager->getSingleRow($sql, array($Item), __METHOD__ .
"debianSourcePakcageInfo");
464 $Require = $R[
'pkg_pk'];
465 foreach ($deb_source_info as $key => $value) {
467 $entry[
'count'] = $Count;
468 $entry[
'type'] = _($key);
469 $entry[
'value'] = htmlentities($R[
"$value"]);
471 $vars[
'packageEntries'][] = $entry;
473 pg_free_result($result);
475 $sql =
"SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
476 $this->
dbManager->prepare(__METHOD__ .
"getPkg_rpm_req", $sql);
477 $result = $this->
dbManager->execute(__METHOD__ .
"getPkg_rpm_req", array($Require));
479 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
481 $entry[
'count'] = $Count;
482 $entry[
'type'] = _(
"Build-Depends");
483 $entry[
'value'] = htmlentities($R[
'req_value']);
485 $vars[
'packageRequires'][] = $entry;
491 $vars[
'packageType'] =
"";
503 $groupId = Auth::getGroupId();
504 $row = $this->uploadDao->getUploadEntry($Item);
506 $vars[
'tagInvalid'] = 1;
511 $upload_pk = $row[
"upload_fk"];
514 $vars[
'tagInvalid'] = 2;
517 $sql =
"SELECT * FROM uploadtree INNER JOIN (SELECT * FROM tag_file,tag WHERE tag_pk = tag_fk) T
518 ON uploadtree.pfile_fk = T.pfile_fk WHERE uploadtree.upload_fk = $1
519 AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 UNION SELECT * FROM uploadtree INNER JOIN
520 (SELECT * FROM tag_uploadtree,tag WHERE tag_pk = tag_fk) T ON uploadtree.uploadtree_pk = T.uploadtree_fk
521 WHERE uploadtree.upload_fk = $1 AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 ORDER BY ufile_name";
522 $this->
dbManager->prepare(__METHOD__, $sql);
523 $result = $this->
dbManager->execute(__METHOD__, array($upload_pk, $lft,$rgt));
524 if (pg_num_rows($result) > 0) {
525 while ($row = pg_fetch_assoc($result)) {
527 $entry[
'ufile_name'] = $row[
'ufile_name'];
528 $entry[
'tag'] = $row[
'tag'];
529 if ($this->uploadDao->isAccessible($upload_pk, $groupId)) {
531 "?mod=tag&action=edit&upload=$Upload&item=" . $row[
'uploadtree_pk'] .
532 "&tag_file_pk=" . $row[
'tag_file_pk'];
536 $vars[
'tagsEntries'][] = $entry;
552 $reusedInfo = $this->uploadDao->getReusedUpload(
556 foreach ($reusedInfo as $row) {
558 $reuseUploadFk = $row[
'reused_upload_fk'];
559 $reuseGroupFk = $row[
'reused_group_fk'];
560 $reusedUpload = $this->uploadDao->getUpload($reuseUploadFk);
561 $reuseMode = array();
562 if ($row[
'reuse_mode'] & UploadDao::REUSE_ENHANCED) {
563 $reuseMode[] =
"Enhanced";
565 $reuseMode[] =
"Normal";
567 if ($row[
'reuse_mode'] & UploadDao::REUSE_MAIN) {
568 $reuseMode[] =
"Main license";
570 if ($row[
'reuse_mode'] & UploadDao::REUSE_CONF) {
571 $reuseMode[] =
"Report configuration settings";
573 $entry[
'name'] = $reusedUpload->getFilename();
575 "?mod=license&upload=$reuseUploadFk&item=" .
576 $this->uploadDao->getUploadParent($reuseUploadFk);
577 $entry[
'group'] = $this->userDao->getGroupNameById($reuseGroupFk) .
579 $entry[
'sha1'] = $this->uploadDao->getUploadHashes($reuseUploadFk)[
'sha1'];
580 $entry[
'mode'] = implode(
", ", $reuseMode) .
" reuse";
582 $vars[
'reusedPackageList'][] = $entry;
590 if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
595 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId,
null, $showBox = 0,
"View-Meta");
597 $this->vars += $this->
ShowTagInfo($uploadId, $itemId);
598 $this->vars += $this->ShowPackageinfo($uploadId, $itemId, 1);
601 $this->vars += $this->
ShowView($uploadId, $itemId);
605 public function getTemplateName()
607 return "ui-view-info.html.twig";
611 $NewPlugin->Initialize();
This is the Plugin class. All plugins should:
Contains the constants and helpers for authentication of user.
ShowMetaView($Upload, $Item)
Display the meta data associated with the file.
ShowPackageInfo($Upload, $Item, $ShowMenu=0)
Display the package info associated with the rpm/debian package.
Output()
This function is called when user output is requested. This function is responsible for content....
ShowView($Upload, $Item, $ShowMenu=0)
Display the info data associated with the file.
ShowTagInfo($Upload, $Item)
Display the tag info data associated with the file.
showReuseInfo($uploadId)
Get the info regarding reused package.
ShowSightings($Upload, $Item)
Show Sightings, List the directory locations where this pfile is found.
RegisterMenus()
Customize submenus.
__construct()
base constructor. Most plugins will just use this
Dir2FileList(&$Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file....
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
HumanSize( $bytes)
Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB.
char * trim(char *ptext)
Trimming whitespace.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
fo_dbManager * dbManager
fo_dbManager object