2021-03-24 21:32:23 +01:00
|
|
|
<?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;
|
|
|
|
|
2021-04-12 16:12:03 +02:00
|
|
|
use Piwik\Piwik;
|
2021-03-24 21:32:23 +01:00
|
|
|
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;
|
2021-04-12 16:12:03 +02:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $label;
|
2021-03-24 21:32:23 +01:00
|
|
|
|
|
|
|
public function __construct(LoggerInterface $logger)
|
|
|
|
{
|
|
|
|
$this->logger = $logger;
|
2021-04-12 16:12:03 +02:00
|
|
|
$this->label = "🧪 " . Piwik::translate("DiagnosticsExtended_PhpUserCheckLabel");
|
2021-03-24 21:32:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return DiagnosticResult[]
|
|
|
|
*/
|
|
|
|
public function execute()
|
|
|
|
{
|
2021-05-17 17:00:16 +02:00
|
|
|
if (SettingsServer::isWindows()|| !function_exists("posix_getuid")) {
|
2021-03-24 21:32:23 +01:00
|
|
|
return [];
|
|
|
|
}
|
|
|
|
if (posix_getuid() === 0) {
|
|
|
|
return [DiagnosticResult::singleResult(
|
2021-04-12 16:12:03 +02:00
|
|
|
$this->label,
|
2021-03-24 21:32:23 +01:00
|
|
|
DiagnosticResult::STATUS_WARNING,
|
2021-04-12 16:12:03 +02:00
|
|
|
Piwik::translate("DiagnosticsExtended_PhpUserCheckWarning")
|
2021-03-24 21:32:23 +01:00
|
|
|
)];
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|