35 function __construct()
37 $this->Name =
"view_info";
38 $this->Title = _(
"View File Information");
39 $this->Dependency = array(
"browse");
42 parent::__construct();
43 $this->uploadDao = $GLOBALS[
'container']->get(
'dao.upload');
44 $this->
dbManager = $GLOBALS[
'container']->get(
'db.manager');
45 $this->userDao = $GLOBALS[
'container']->get(
'dao.user');
53 $tooltipText = _(
"View file information");
54 menu_insert(
"Browse-Pfile::Info",5,$this->Name,$tooltipText);
57 $URI = $this->Name . $Parm;
67 menu_insert(
"View-Meta::{$menuText}", $menuPosition);
71 $tooltipText = _(
"View information about this file");
74 menu_insert(
"View::{$menuText}", $menuPosition, $URI, $tooltipText);
77 menu_insert(
"View-Meta::{$menuText}", $menuPosition, $URI, $tooltipText);
79 menu_insert(
"Browse::Info", -3, $URI, $tooltipText);
89 if (empty($Upload) || empty($Item)) {
97 $vars[
'repoLocPage'] = $Page;
105 $sql =
"SELECT * FROM uploadtree 106 INNER JOIN pfile ON uploadtree_pk = $1 107 AND pfile_fk = pfile_pk 109 $row = $this->
dbManager->getSingleRow($sql, array($Item),
110 __METHOD__ .
"GetFileDescribingRow");
111 $bytes = $row[
'pfile_size'];
113 $bytes = number_format($bytes, 0,
"",
",") .
' B';
114 if ($bytesH == $bytes) {
117 $bytesH =
'(' . $bytesH .
')';
119 $vars[
'sizeInBytes'] = $bytes;
120 $vars[
'sizeInMB'] = $bytesH;
121 $vars[
'fileSha1'] = $row[
'pfile_sha1'];
122 $vars[
'fileMd5'] = $row[
'pfile_md5'];
123 $vars[
'fileSha256'] = $row[
'pfile_sha256'];
124 $vars[
'fileSize'] = $row[
'pfile_size'];
125 $vars[
'filePfileId'] = $row[
'pfile_fk'];
136 if (empty($Upload) || empty($Item)) {
145 $offset = $page * $MAX;
149 $sql =
"SELECT * FROM pfile,uploadtree 150 WHERE pfile_pk=pfile_fk 152 (SELECT pfile_fk FROM uploadtree WHERE uploadtree_pk = $1) 154 $this->
dbManager->prepare(__METHOD__.
"getListOfFiles",$sql);
155 $result = $this->
dbManager->execute(__METHOD__.
"getListOfFiles",array($Item,$MAX,$offset));
156 $count = pg_num_rows($result);
157 if (($page > 0) || ($count >= $MAX)) {
158 $vMenu =
"<p>\n" .
MenuEndlessPage($page, ($count >= $MAX)) .
"</p>\n";
163 $v .= _(
"This exact file appears in the following locations:\n");
168 }
else if ($page > 0) {
169 $v .= _(
"End of listing.\n");
171 $v .= _(
"This file does not appear in any other known location.\n");
173 pg_free_result($result);
176 $vars[
'sightingsContent'] = $v;
186 if (empty($Item) || empty($Upload)) {
191 $sql =
"SELECT * FROM uploadtree where uploadtree_pk = $1";
192 $this->
dbManager->prepare(__METHOD__.
"DisplayMimetype",$sql);
193 $result = $this->
dbManager->execute(__METHOD__.
"DisplayMimetype",array($Item));
194 if (pg_num_rows($result)) {
195 $vars[
'fileInfo'] = 1;
196 $row = pg_fetch_assoc($result);
198 if (! empty($row[
'mimetype_pk'])) {
199 $vars[
'displayMimeTypeName'] = $row[
'mimetype_name'];
203 $vars[
'fileInfo'] = 0;
209 if (! empty($row[
'pfile_fk'])) {
210 $sql =
"select mimetype_name from pfile, mimetype where pfile_pk = $1 and pfile_mimetypefk=mimetype_pk";
211 $this->
dbManager->prepare(__METHOD__ .
"GetMimetype", $sql);
212 $result = $this->
dbManager->execute(__METHOD__ .
"GetMimetype",
213 array($row[
'pfile_fk']));
214 if (pg_num_rows($result)) {
215 $pmRow = pg_fetch_assoc($result);
216 $vars[
'getMimeTypeName'] = $pmRow[
'mimetype_name'];
222 $sql =
"select * from upload where upload_pk=$1";
223 $row = $this->
dbManager->getSingleRow($sql, array($row[
'upload_fk']),
224 __METHOD__ .
"getUploadOrigin");
228 if ($row[
'upload_mode'] & 1 << 2) {
229 $text = _(
"Added by URL");
230 }
else if ($row[
'upload_mode'] & 1 << 3) {
231 $text = _(
"Added by file upload");
232 }
else if ($row[
'upload_mode'] & 1 << 4) {
233 $text = _(
"Added from filesystem");
235 $vars[
'fileUploadOriginInfo'] = $text;
236 $vars[
'fileUploadOrigin'] = $row[
'upload_origin'];
239 $ts = $row[
'upload_ts'];
240 $vars[
'fileUploadDate'] = substr($ts, 0, strrpos($ts,
'.'));
245 $sql =
"SELECT user_name from users, upload where user_pk = user_fk and upload_pk = $1";
246 $row = $this->
dbManager->getSingleRow($sql,array($Upload),__METHOD__.
"getUploadOwner");
248 $vars[
'fileUploadUser'] = $row[
'user_name'];
264 $rpm_info = array(
"Package"=>
"pkg_name",
265 "Alias"=>
"pkg_alias",
266 "Architecture"=>
"pkg_arch",
267 "Version"=>
"version",
268 "License"=>
"license",
269 "Group"=>
"pkg_group",
270 "Packager"=>
"packager",
271 "Release"=>
"release",
272 "BuildDate"=>
"build_date",
275 "Summary"=>
"summary",
276 "Description"=>
"description",
277 "Source"=>
"source_rpm");
279 $deb_binary_info = array(
"Package"=>
"pkg_name",
280 "Architecture"=>
"pkg_arch",
281 "Version"=>
"version",
282 "Section"=>
"section",
283 "Priority"=>
"priority",
284 "Installed Size"=>
"installed_size",
285 "Maintainer"=>
"maintainer",
286 "Homepage"=>
"homepage",
288 "Summary"=>
"summary",
289 "Description"=>
"description");
291 $deb_source_info = array(
"Format"=>
"format",
293 "Binary"=>
"pkg_name",
294 "Architecture"=>
"pkg_arch",
295 "Version"=>
"version",
296 "Maintainer"=>
"maintainer",
297 "Uploaders"=>
"uploaders",
298 "Standards-Version"=>
"standards_version");
300 if (empty($Item) || empty($Upload)) {
307 $sql =
"SELECT agent_enabled FROM agent WHERE agent_name ='pkgagent' order by agent_ts LIMIT 1;";
308 $row = $this->
dbManager->getSingleRow($sql,array(),__METHOD__.
"checkPkgagentDisabled");
309 if (isset($row) && ($row[
'agent_enabled'] ==
'f')) {
314 $sql =
"SELECT typlen FROM pg_type where typname='pkgagent_ars' limit 1;";
315 $this->
dbManager->prepare(__METHOD__.
"displayPackageInfo",$sql);
316 $result = $this->
dbManager->execute(__METHOD__.
"displayPackageInfo",array());
317 $numrows = pg_num_rows($result);
320 $vars[
'packageAgentNA'] = 1;
325 $agent_status = AgentARSList(
'pkgagent_ars', $Upload);
326 if (empty($agent_status)) {
327 $vars[
'packageAgentStatus'] = 1;
329 "?mod=schedule_agent&upload=$Upload&agent=agent_pkgagent";
332 $sql =
"SELECT mimetype_name 334 INNER JOIN pfile ON uploadtree_pk = $1 335 AND pfile_fk = pfile_pk 336 INNER JOIN mimetype ON pfile_mimetypefk = mimetype_pk;";
337 $this->
dbManager->prepare(__METHOD__.
"getMimetypeName",$sql);
338 $result = $this->
dbManager->execute(__METHOD__.
"getMimetypeName",array($Item));
339 while ($row = pg_fetch_assoc($result)) {
340 if (! empty($row[
'mimetype_name'])) {
341 $MIMETYPE = $row[
'mimetype_name'];
347 if ($MIMETYPE ==
"application/x-rpm") {
350 INNER JOIN uploadtree ON uploadtree_pk = $1 351 AND uploadtree.pfile_fk = pkg_rpm.pfile_fk;";
352 $R = $this->
dbManager->getSingleRow($sql,array($Item),__METHOD__.
"getRPMPackageInfo");
353 if ((! empty($R[
'source_rpm'])) and (
trim($R[
'source_rpm']) !=
"(none)")) {
354 $vars[
'packageType'] = _(
"RPM Binary Package");
356 $vars[
'packageType'] = _(
"RPM Source Package");
360 if (! empty($R[
'pkg_pk'])) {
361 $Require = $R[
'pkg_pk'];
362 foreach ($rpm_info as $key => $value) {
364 $entry[
'count'] = $Count;
365 $entry[
'type'] = _($key);
366 $entry[
'value'] = htmlentities($R[
"$value"]);
368 $vars[
'packageEntries'][] = $entry;
371 $sql =
"SELECT * FROM pkg_rpm_req WHERE pkg_fk = $1;";
372 $this->
dbManager->prepare(__METHOD__.
"getPkg_rpm_req",$sql);
373 $result = $this->
dbManager->execute(__METHOD__.
"getPkg_rpm_req",array($Require));
375 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
377 $entry[
'count'] = $Count;
378 $entry[
'type'] = _(
"Requires");
379 $entry[
'value'] = htmlentities($R[
'req_value']);
381 $vars[
'packageRequires'][] = $entry;
385 }
else if ($MIMETYPE ==
"application/x-debian-package") {
386 $vars[
'packageType'] = _(
"Debian Binary Package\n");
390 INNER JOIN uploadtree ON uploadtree_pk = $1 391 AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
392 $R = $this->
dbManager->getSingleRow($sql,array($Item),__METHOD__.
"debianBinaryPackageInfo");
396 $Require = $R[
'pkg_pk'];
397 foreach ($deb_binary_info as $key => $value) {
399 $entry[
'count'] = $Count;
400 $entry[
'type'] = _($key);
401 $entry[
'value'] = htmlentities($R[
"$value"]);
403 $vars[
'packageEntries'][] = $entry;
405 pg_free_result($result);
407 $sql =
"SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
408 $this->
dbManager->prepare(__METHOD__.
"getPkg_rpm_req",$sql);
409 $result = $this->
dbManager->execute(__METHOD__.
"getPkg_rpm_req",array($Require));
411 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
413 $entry[
'count'] = $Count;
414 $entry[
'type'] = _(
"Depends");
415 $entry[
'value'] = htmlentities($R[
'req_value']);
417 $vars[
'packageRequires'][] = $entry;
422 }
else if ($MIMETYPE ==
"application/x-debian-source") {
423 $vars[
'packageType'] = _(
"Debian Source Package\n");
427 INNER JOIN uploadtree ON uploadtree_pk = $1 428 AND uploadtree.pfile_fk = pkg_deb.pfile_fk;";
429 $R = $this->
dbManager->getSingleRow($sql,array($Item),__METHOD__.
"debianSourcePakcageInfo");
433 $Require = $R[
'pkg_pk'];
434 foreach ($deb_source_info as $key => $value) {
436 $entry[
'count'] = $Count;
437 $entry[
'type'] = _($key);
438 $entry[
'value'] = htmlentities($R[
"$value"]);
440 $vars[
'packageEntries'][] = $entry;
442 pg_free_result($result);
444 $sql =
"SELECT * FROM pkg_deb_req WHERE pkg_fk = $1;";
445 $this->
dbManager->prepare(__METHOD__.
"getPkg_rpm_req",$sql);
446 $result = $this->
dbManager->execute(__METHOD__.
"getPkg_rpm_req",array($Require));
448 while ($R = pg_fetch_assoc($result) and ! empty($R[
'req_pk'])) {
450 $entry[
'count'] = $Count;
451 $entry[
'type'] = _(
"Build-Depends");
452 $entry[
'value'] = htmlentities($R[
'req_value']);
454 $vars[
'packageRequires'][] = $entry;
460 $vars[
'packageType'] =
"";
472 $groupId = Auth::getGroupId();
473 $row = $this->uploadDao->getUploadEntry($Item);
475 $vars[
'tagInvalid'] = 1;
480 $upload_pk = $row[
"upload_fk"];
483 $vars[
'tagInvalid'] = 2;
486 $sql =
"SELECT * FROM uploadtree INNER JOIN (SELECT * FROM tag_file,tag WHERE tag_pk = tag_fk) T 487 ON uploadtree.pfile_fk = T.pfile_fk WHERE uploadtree.upload_fk = $1 488 AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 UNION SELECT * FROM uploadtree INNER JOIN 489 (SELECT * FROM tag_uploadtree,tag WHERE tag_pk = tag_fk) T ON uploadtree.uploadtree_pk = T.uploadtree_fk 490 WHERE uploadtree.upload_fk = $1 AND uploadtree.lft >= $2 AND uploadtree.rgt <= $3 ORDER BY ufile_name";
491 $this->
dbManager->prepare(__METHOD__,$sql);
492 $result = $this->
dbManager->execute(__METHOD__,array($upload_pk, $lft,$rgt));
493 if (pg_num_rows($result) > 0) {
494 while ($row = pg_fetch_assoc($result)) {
496 $entry[
'ufile_name'] = $row[
'ufile_name'];
497 $entry[
'tag'] = $row[
'tag'];
498 if ($this->uploadDao->isAccessible($upload_pk, $groupId)) {
500 "?mod=tag&action=edit&upload=$Upload&item=" . $row[
'uploadtree_pk'] .
501 "&tag_file_pk=" . $row[
'tag_file_pk'];
505 $vars[
'tagsEntries'][] = $entry;
521 $reusedInfo = $this->uploadDao->getReusedUpload($uploadId,
523 foreach ($reusedInfo as $row) {
525 $reuseUploadFk = $row[
'reused_upload_fk'];
526 $reuseGroupFk = $row[
'reused_group_fk'];
527 $reusedUpload = $this->uploadDao->getUpload($reuseUploadFk);
528 $reuseMode = array();
529 if ($row[
'reuse_mode'] & UploadDao::REUSE_ENHANCED) {
530 $reuseMode[] =
"Enhanced";
532 $reuseMode[] =
"Normal";
534 if ($row[
'reuse_mode'] & UploadDao::REUSE_MAIN) {
535 $reuseMode[] =
"Main license";
537 if ($row[
'reuse_mode'] & UploadDao::REUSE_CONF) {
538 $reuseMode[] =
"Report configuration settings";
540 $entry[
'name'] = $reusedUpload->getFilename();
542 "?mod=license&upload=$reuseUploadFk&item=" .
543 $this->uploadDao->getUploadParent($reuseUploadFk);
544 $entry[
'group'] = $this->userDao->getGroupNameById($reuseGroupFk) .
546 $entry[
'sha1'] = $this->uploadDao->getUploadHashes($reuseUploadFk)[
'sha1'];
547 $entry[
'mode'] = implode(
", ", $reuseMode).
" reuse";
549 $vars[
'reusedPackageList'][] = $entry;
554 public function Output()
557 if (!$this->uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
562 $this->vars[
'micromenu'] =
Dir2Browse(
"browse", $itemId, NULL, $showBox=0,
"View-Meta");
564 $this->vars += $this->
ShowTagInfo($uploadId, $itemId);
565 $this->vars += $this->ShowPackageinfo($uploadId, $itemId, 1);
568 $this->vars += $this->
ShowView($uploadId, $itemId);
572 public function getTemplateName()
574 return "ui-view-info.html.twig";
579 $NewPlugin->Initialize();
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.
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...
RegisterMenus()
Customize submenus.
showReuseInfo($uploadId)
Get the info regarding reused package.
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
ShowSightings($Upload, $Item)
Show Sightings, List the directory locations where this pfile is found.
fo_dbManager * dbManager
fo_dbManager object
This is the Plugin class. All plugins should:
HumanSize($bytes)
Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
ShowView($Upload, $Item, $ShowMenu=0)
Display the info data associated with the file.
ShowMetaView($Upload, $Item)
Display the meta data associated with the file.
ShowTagInfo($Upload, $Item)
Display the tag info data associated with the file.
ShowPackageInfo($Upload, $Item, $ShowMenu=0)
Display the package info associated with the rpm/debian package.
char * trim(char *ptext)
Trimming whitespace.