1
0
Fork 0
mirror of https://github.com/Findus23/matomo-DiagnosticsExtended.git synced 2024-09-19 16:03:46 +02:00
matomo-DiagnosticsExtended/Diagnostic/PhpUserCheck.php

53 lines
1.2 KiB
PHP

<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\DiagnosticsExtended\Diagnostic;
use Piwik\Piwik;
use Piwik\Plugins\Diagnostics\Diagnostic\Diagnostic;
use Piwik\Plugins\Diagnostics\Diagnostic\DiagnosticResult;
use Piwik\SettingsServer;
use Psr\Log\LoggerInterface;
class PhpUserCheck implements Diagnostic
{
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var string
*/
private $label;
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
$this->label = "🧪 " . Piwik::translate("DiagnosticsExtended_PhpUserCheckLabel");
}
/**
* @return DiagnosticResult[]
*/
public function execute()
{
if (SettingsServer::isWindows()|| !function_exists("posix_getuid")) {
return [];
}
if (posix_getuid() === 0) {
return [DiagnosticResult::singleResult(
$this->label,
DiagnosticResult::STATUS_WARNING,
Piwik::translate("DiagnosticsExtended_PhpUserCheckWarning")
)];
}
return [];
}
}