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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2020-09-02 10:02:12 +0300
committerGitHub <noreply@github.com>2020-09-02 10:02:12 +0300
commit11f54ee6389bd8ac408385b0d1760936c496470c (patch)
tree92d398822189d5ccdc842fa6e1c996c7347ebf11 /core/Twig.php
parent67d3486533579cb57c30e38074611c3ae80e9161 (diff)
Provide more debug information in system check (#16350)
* Provide more debug information in system check * hide some info in screenshots * try overriding some columns * hide tr instead of only the content * trying to get tests to work * try different way * try fix tests * make sure cookie exists * add overridejs to install * more tweaks * fix test * more tweaks * move things to DI * minor tweaks * minor tweaks * fix test * also anonymise DB username * Update Twig.php * Improve query performance * Fix ClientTest keywords Co-authored-by: diosmosis <diosmosis@users.noreply.github.com>
Diffstat (limited to 'core/Twig.php')
-rw-r--r--core/Twig.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/Twig.php b/core/Twig.php
index 1ff38003ab..a4fe82be08 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -176,6 +176,7 @@ class Twig
$this->addFilter_prettyDate();
$this->addFilter_safeDecodeRaw();
$this->addFilter_number();
+ $this->addFilter_anonymiseSystemInfo();
$this->addFilter_nonce();
$this->addFilter_md5();
$this->addFilter_onlyDomain();
@@ -434,6 +435,39 @@ class Twig
$this->twig->addFilter($formatter);
}
+ protected function addFilter_anonymiseSystemInfo()
+ {
+ $formatter = new TwigFilter('anonymiseSystemInfo', function ($string) {
+ if ($string === null) {
+ return '';
+ }
+ if ($string === false || $string === true) {
+ return (int) $string;
+ }
+ $string = str_replace([PIWIK_DOCUMENT_ROOT, str_replace( '/', '\/', PIWIK_DOCUMENT_ROOT )], '$DOC_ROOT', $string);
+ $string = str_replace([PIWIK_USER_PATH, str_replace( '/', '\/', PIWIK_USER_PATH ) ], '$USER_PATH', $string);
+ $string = str_replace([PIWIK_INCLUDE_PATH, str_replace( '/', '\/', PIWIK_INCLUDE_PATH ) ], '$INCLUDE_PATH', $string);
+
+ // replace anything token like
+ $string = preg_replace('/[[:xdigit:]]{31,80}/', 'TOKEN_REPLACED', $string);
+
+ // just in case it was somehow show in a text
+ if (SettingsPiwik::isMatomoInstalled()) {
+ $string = str_replace(SettingsPiwik::getPiwikUrl(), '$MATOMO_URL', $string);
+ $string = str_replace(SettingsPiwik::getSalt(), '$MATOMO_SALT', $string);
+
+ $config = Config::getInstance();
+ $db = $config->database;
+ $string = str_replace($db['username'], '$DB_USERNAME', $string);
+ $string = str_replace($db['password'], '$DB_PASSWORD', $string);
+ $string = str_replace($db['host'], '$DB_HOST', $string);
+ $string = str_replace($db['dbname'], '$DB_NAME', $string);
+ }
+ return $string;
+ });
+ $this->twig->addFilter($formatter);
+ }
+
protected function addFilter_nonce()
{
$nonce = new TwigFilter('nonce', array('Piwik\\Nonce', 'getNonce'));