Welcome to mirror list, hosted at ThFree Co, Russian Federation.

DbOverSSLCheck.php « Diagnostic « Diagnostics « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 98576e6810cfe5f9f8e07d625fa305b799e05475 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

namespace Piwik\Plugins\Diagnostics\Diagnostic;

use Piwik\Config;
use Piwik\Db;
use Piwik\Translation\Translator;

/**
 * Check if Piwik is connected with database through ssl.
 */
class DbOverSSLCheck implements Diagnostic
{
    /**
     * @var Translator
     */
    private $translator;

    public function __construct(Translator $translator)
    {
        $this->translator = $translator;
    }

    public function execute()
    {
        $enable_ssl = Config::getInstance()->database['enable_ssl'];
        if (!$enable_ssl) {
            return array();
        }

        $label = $this->translator->translate('Installation_SystemCheckDatabaseSSL');

        $cipher = Db::fetchRow("show status like 'Ssl_cipher'");
        if(!empty($cipher['Value'])) {
             return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_OK, $this->translator->translate('Installation_SystemCheckDatabaseSSLCipher') . ': ' . $cipher['Value']));
        }

        //no cipher, not working
        $comment = sprintf($this->translator->translate('Installation_SystemCheckDatabaseSSLNotWorking'), "enable_ssl") . "<br />";

        // test ssl support
        $ssl_support = Db::fetchRow("SHOW VARIABLES LIKE 'have_ssl'");
        if(!empty($ssl_support['Value'])) {
            switch ($ssl_support['Value']) {
                case 'YES':
                    $comment .= $this->translator->translate('Installation_SystemCheckDatabaseSSLOn');
                    break;
                case 'DISABLED':
                    $comment .= $this->translator->translate('Installation_SystemCheckDatabaseSSLDisabled');
                    break;
                case 'NO':
                    $comment .= $this->translator->translate('Installation_SystemCheckDatabaseSSLNo');
                    break;
            }
        }

        $comment .= '<br />' . '<a target="_blank" rel="noreferrer noopener" href="https://matomo.org/faq/"> FAQ on matomo.org</a>';

        return array(DiagnosticResult::singleResult($label, DiagnosticResult::STATUS_WARNING, $comment));
    }
}