Exemplo n.º 1
0
 /**
  * @param Request $request
  * @return Response
  */
 protected function handle(Request $request)
 {
     $vars = array('licenseCount' => $this->licenseDao->getLicenseCount(), 'project' => _("FOSSology"), 'copyright' => _("Copyright (C) 2007-2014 Hewlett-Packard Development Company, L.P.<br>\nCopyright (C) 2014-2016 Siemens AG."));
     if (Auth::isAdmin()) {
         $repositoryApi = new RepositoryApi();
         $latestRelease = $repositoryApi->getLatestRelease();
         $commits = $repositoryApi->getCommitsOfLastDays(30);
         $commit = empty($commits) ? '' : substr($commits[0]['sha'], 0, 6);
         $vars = array_merge($vars, array('latestVersion' => $latestRelease, 'lastestCommit' => $commit));
     }
     return $this->render('about.html.twig', $this->mergeWithDefault($vars));
 }
Exemplo n.º 2
0
 /**
  * \brief This function is called when user output is
  * requested.  This function is responsible for content.
  */
 protected function getPathAndName()
 {
     if ($this->State != \PLUGIN_STATE_READY) {
         throw new Exception('Download plugin is not ready');
     }
     global $container;
     /** @var DbManager $dbManager */
     $dbManager = $container->get('db.manager');
     if (!$dbManager->getDriver()) {
         throw new Exception("Missing database connection.");
     }
     $reportId = GetParm("report", PARM_INTEGER);
     $item = GetParm("item", PARM_INTEGER);
     $logJq = GetParm('log', PARM_INTEGER);
     if (!empty($reportId)) {
         $row = $dbManager->getSingleRow("SELECT * FROM reportgen WHERE job_fk = \$1", array($reportId), "reportFileName");
         if ($row === false) {
             throw new Exception("Missing report");
         }
         $path = $row['filepath'];
         $filename = basename($path);
         $uploadId = $row['upload_fk'];
     } elseif (!empty($logJq)) {
         $sql = "SELECT jq_log, job_upload_fk FROM jobqueue LEFT JOIN job ON job.job_pk = jobqueue.jq_job_fk WHERE jobqueue.jq_pk =\$1";
         $row = $dbManager->getSingleRow($sql, array($logJq), "jqLogFileName");
         if ($row === false) {
             throw new Exception("Missing report");
         }
         $path = $row['jq_log'];
         $filename = basename($path);
         $uploadId = $row['job_upload_fk'];
     } elseif (empty($item)) {
         throw new Exception("Invalid item parameter");
     } else {
         $path = RepPathItem($item);
         if (empty($path)) {
             throw new Exception("Invalid item parameter");
         }
         $fileHandle = @fopen(RepPathItem($item), "rb");
         /* note that CheckRestore() does not return. */
         if (empty($fileHandle)) {
             $this->CheckRestore($item, $path);
         }
         $row = $dbManager->getSingleRow("SELECT ufile_name, upload_fk FROM uploadtree WHERE uploadtree_pk = \$1", array($item));
         if ($row === false) {
             throw new Exception("Missing item");
         }
         $filename = $row['ufile_name'];
         $uploadId = $row['upload_fk'];
     }
     /* @var $uploadDao UploadDao */
     $uploadDao = $GLOBALS['container']->get('dao.upload');
     if (!Auth::isAdmin() && !$uploadDao->isAccessible($uploadId, Auth::getGroupId())) {
         throw new Exception("No Permission: {$uploadId}");
     }
     if (!file_exists($path)) {
         throw new Exception("File does not exist");
     }
     if (!is_file($path)) {
         throw new Exception("Not a regular file");
     }
     return array($path, $filename);
 }