FOSSology  4.4.0
Open Source License Compliance by Open Source Software
OverviewController.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2023 Samuel Dushimimana <dushsam100@gmail.com>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 namespace Fossology\UI\Api\Controllers;
14 
17 use Psr\Http\Message\ServerRequestInterface;
18 
24 {
28  public function getDatabaseContents($request, $response, $args)
29  {
30  $this->throwNotAdminException();
32  $dashboardPlugin = $this->restHelper->getPlugin('dashboard');
33  $res = [
34  /**** Users ****/
35  $dashboardPlugin->DatabaseContentsRow("users", _("Users"), true),
36  /**** Uploads ****/
37  $dashboardPlugin->DatabaseContentsRow("upload", _("Uploads"), true),
38  /**** Unique pfiles ****/
39  $dashboardPlugin->DatabaseContentsRow("pfile", _("Unique files referenced in repository"), true),
40  /**** uploadtree recs ****/
41  $dashboardPlugin->DatabaseContentsRow("uploadtree_%", _("Individual Files"), true),
42  /**** License recs ****/
43  $dashboardPlugin->DatabaseContentsRow("license_file", _("Discovered Licenses"), true),
44  /**** Copyright recs ****/
45  $dashboardPlugin->DatabaseContentsRow("copyright", _("Copyrights/URLs/Emails"), true)
46  ];
47  return $response->withJson($res, 200);
48  }
49 
59  public function getDiskSpaceUsage($request, $response, $args)
60  {
61  $this->throwNotAdminException();
63  $dashboardPlugin = $this->restHelper->getPlugin('dashboard');
64  $res = $dashboardPlugin->DiskFree(true);
65  return $response->withJson($res, 200);
66  }
67 
77  public function getPhpInfo($request, $response, $args)
78  {
79  $this->throwNotAdminException();
81  $dashboardPlugin = $this->restHelper->getPlugin('dashboard');
82  $res = $dashboardPlugin->GetPHPInfoTable(true);
83  return $response->withJson($res, 200);
84  }
85 
95  public function getDatabaseMetrics($request, $response, $args)
96  {
97  $this->throwNotAdminException();
99  $dashboardPlugin = $this->restHelper->getPlugin('dashboard');
100  $res = $dashboardPlugin->DatabaseMetrics(true);
101  return $response->withJson($res, 200);
102  }
103 
113  public function getActiveQueries($request, $response, $args)
114  {
115  $this->throwNotAdminException();
117  $dashboardPlugin = $this->restHelper->getPlugin('dashboard');
118  global $PG_CONN;
119  $dashboardPlugin->pgVersion = pg_version($PG_CONN);
120  $res = $dashboardPlugin->DatabaseQueries(true);
121 
122  foreach ($res as &$value) {
123  $value['pid'] = intval($value['pid']);
124  }
125  return $response->withJson($res, 200);
126  }
127 }
Controller for OverviewController model.
Base controller for REST calls.
Override Slim response for withJson function.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN