Matomo Analytics – Ethical Stats. Powerful Insights. - Version 1.0.6

Version Description

Download this release

Release Info

Developer matomoteam
Plugin Icon 128x128 Matomo Analytics – Ethical Stats. Powerful Insights.
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

app/core/CronArchive.php CHANGED
@@ -1233,9 +1233,14 @@ class CronArchive
1233
 
1234
  public function logError($m)
1235
  {
1236
- if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) {
1237
- $m = substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY);
1238
- $m = str_replace(array("\n", "\t"), " ", $m);
 
 
 
 
 
1239
  }
1240
  $this->errors[] = $m;
1241
  $this->logger->error($m);
1233
 
1234
  public function logError($m)
1235
  {
1236
+ if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) {
1237
+ $m = str_replace(array("\n", "\t"), " ", $m);
1238
+ if (Common::mb_strlen($m) > self::TRUNCATE_ERROR_MESSAGE_SUMMARY) {
1239
+ $numCharactersKeepFromEnd = 100;
1240
+ $m = Common::mb_substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY - $numCharactersKeepFromEnd)
1241
+ . ' ... ' .
1242
+ Common::mb_substr($m, -1 * $numCharactersKeepFromEnd);
1243
+ }
1244
  }
1245
  $this->errors[] = $m;
1246
  $this->logger->error($m);
app/core/Db/Schema/Mysql.php CHANGED
@@ -38,11 +38,12 @@ class Mysql implements SchemaInterface
38
  {
39
  $engine = $this->getTableEngine();
40
  $prefixTables = $this->getTablePrefix();
 
41
 
42
  $tables = array(
43
  'user' => "CREATE TABLE {$prefixTables}user (
44
  login VARCHAR(100) NOT NULL,
45
- password VARCHAR(255) NOT NULL,
46
  alias VARCHAR(45) NOT NULL,
47
  email VARCHAR(100) NOT NULL,
48
  twofactor_secret VARCHAR(40) NOT NULL DEFAULT '',
@@ -52,7 +53,7 @@ class Mysql implements SchemaInterface
52
  ts_password_modified TIMESTAMP NULL,
53
  PRIMARY KEY(login),
54
  UNIQUE KEY uniq_keytoken(token_auth)
55
- ) ENGINE=$engine DEFAULT CHARSET=utf8
56
  ",
57
 
58
  'twofactor_recovery_code' => "CREATE TABLE {$prefixTables}twofactor_recovery_code (
@@ -60,7 +61,7 @@ class Mysql implements SchemaInterface
60
  login VARCHAR(100) NOT NULL,
61
  recovery_code VARCHAR(40) NOT NULL,
62
  PRIMARY KEY(idrecoverycode)
63
- ) ENGINE=$engine DEFAULT CHARSET=utf8
64
  ",
65
 
66
  'access' => "CREATE TABLE {$prefixTables}access (
@@ -70,7 +71,7 @@ class Mysql implements SchemaInterface
70
  access VARCHAR(50) NULL,
71
  PRIMARY KEY(idaccess),
72
  INDEX index_loginidsite (login, idsite)
73
- ) ENGINE=$engine DEFAULT CHARSET=utf8
74
  ",
75
 
76
  'site' => "CREATE TABLE {$prefixTables}site (
@@ -93,7 +94,7 @@ class Mysql implements SchemaInterface
93
  keep_url_fragment TINYINT NOT NULL DEFAULT 0,
94
  creator_login VARCHAR(100) NULL,
95
  PRIMARY KEY(idsite)
96
- ) ENGINE=$engine DEFAULT CHARSET=utf8
97
  ",
98
 
99
  'plugin_setting' => "CREATE TABLE {$prefixTables}plugin_setting (
@@ -105,7 +106,7 @@ class Mysql implements SchemaInterface
105
  `idplugin_setting` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
106
  PRIMARY KEY (idplugin_setting),
107
  INDEX(plugin_name, user_login)
108
- ) ENGINE=$engine DEFAULT CHARSET=utf8
109
  ",
110
 
111
  'site_setting' => "CREATE TABLE {$prefixTables}site_setting (
@@ -117,14 +118,14 @@ class Mysql implements SchemaInterface
117
  `idsite_setting` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
118
  PRIMARY KEY (idsite_setting),
119
  INDEX(idsite, plugin_name)
120
- ) ENGINE=$engine DEFAULT CHARSET=utf8
121
  ",
122
 
123
  'site_url' => "CREATE TABLE {$prefixTables}site_url (
124
  idsite INTEGER(10) UNSIGNED NOT NULL,
125
- url VARCHAR(255) NOT NULL,
126
  PRIMARY KEY(idsite, url)
127
- ) ENGINE=$engine DEFAULT CHARSET=utf8
128
  ",
129
 
130
  'goal' => "CREATE TABLE `{$prefixTables}goal` (
@@ -141,7 +142,7 @@ class Mysql implements SchemaInterface
141
  `deleted` tinyint(4) NOT NULL default '0',
142
  `event_value_as_revenue` tinyint(4) NOT NULL default '0',
143
  PRIMARY KEY (`idsite`,`idgoal`)
144
- ) ENGINE=$engine DEFAULT CHARSET=utf8
145
  ",
146
 
147
  'logger_message' => "CREATE TABLE {$prefixTables}logger_message (
@@ -151,7 +152,7 @@ class Mysql implements SchemaInterface
151
  level VARCHAR(16) NULL,
152
  message TEXT NULL,
153
  PRIMARY KEY(idlogger_message)
154
- ) ENGINE=$engine DEFAULT CHARSET=utf8
155
  ",
156
 
157
  'log_action' => "CREATE TABLE {$prefixTables}log_action (
@@ -162,7 +163,7 @@ class Mysql implements SchemaInterface
162
  url_prefix TINYINT(2) NULL,
163
  PRIMARY KEY(idaction),
164
  INDEX index_type_hash (type, hash)
165
- ) ENGINE=$engine DEFAULT CHARSET=utf8
166
  ",
167
 
168
  'log_visit' => "CREATE TABLE {$prefixTables}log_visit (
@@ -176,7 +177,7 @@ class Mysql implements SchemaInterface
176
  INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
177
  INDEX index_idsite_datetime (idsite, visit_last_action_time),
178
  INDEX index_idsite_idvisitor (idsite, idvisitor)
179
- ) ENGINE=$engine DEFAULT CHARSET=utf8
180
  ",
181
 
182
  'log_conversion_item' => "CREATE TABLE `{$prefixTables}log_conversion_item` (
@@ -197,7 +198,7 @@ class Mysql implements SchemaInterface
197
  deleted TINYINT(1) UNSIGNED NOT NULL,
198
  PRIMARY KEY(idvisit, idorder, idaction_sku),
199
  INDEX index_idsite_servertime ( idsite, server_time )
200
- ) ENGINE=$engine DEFAULT CHARSET=utf8
201
  ",
202
 
203
  'log_conversion' => "CREATE TABLE `{$prefixTables}log_conversion` (
@@ -215,7 +216,7 @@ class Mysql implements SchemaInterface
215
  PRIMARY KEY (idvisit, idgoal, buster),
216
  UNIQUE KEY unique_idsite_idorder (idsite, idorder),
217
  INDEX index_idsite_datetime ( idsite, server_time )
218
- ) ENGINE=$engine DEFAULT CHARSET=utf8
219
  ",
220
 
221
  'log_link_visit_action' => "CREATE TABLE {$prefixTables}log_link_visit_action (
@@ -228,7 +229,7 @@ class Mysql implements SchemaInterface
228
  custom_float DOUBLE NULL DEFAULT NULL,
229
  PRIMARY KEY(idlink_va),
230
  INDEX index_idvisit(idvisit)
231
- ) ENGINE=$engine DEFAULT CHARSET=utf8
232
  ",
233
 
234
  'log_profiling' => "CREATE TABLE {$prefixTables}log_profiling (
@@ -238,30 +239,30 @@ class Mysql implements SchemaInterface
238
  idprofiling BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
239
  PRIMARY KEY (idprofiling),
240
  UNIQUE KEY query(query(100))
241
- ) ENGINE=$engine DEFAULT CHARSET=utf8
242
  ",
243
 
244
  'option' => "CREATE TABLE `{$prefixTables}option` (
245
- option_name VARCHAR( 255 ) NOT NULL,
246
  option_value LONGTEXT NOT NULL,
247
  autoload TINYINT NOT NULL DEFAULT '1',
248
  PRIMARY KEY ( option_name ),
249
  INDEX autoload( autoload )
250
- ) ENGINE=$engine DEFAULT CHARSET=utf8
251
  ",
252
 
253
  'session' => "CREATE TABLE {$prefixTables}session (
254
- id VARCHAR( 255 ) NOT NULL,
255
  modified INTEGER,
256
  lifetime INTEGER,
257
  data TEXT,
258
  PRIMARY KEY ( id )
259
- ) ENGINE=$engine DEFAULT CHARSET=utf8
260
  ",
261
 
262
  'archive_numeric' => "CREATE TABLE {$prefixTables}archive_numeric (
263
  idarchive INTEGER UNSIGNED NOT NULL,
264
- name VARCHAR(255) NOT NULL,
265
  idsite INTEGER UNSIGNED NULL,
266
  date1 DATE NULL,
267
  date2 DATE NULL,
@@ -271,12 +272,12 @@ class Mysql implements SchemaInterface
271
  PRIMARY KEY(idarchive, name),
272
  INDEX index_idsite_dates_period(idsite, date1, date2, period, ts_archived),
273
  INDEX index_period_archived(period, ts_archived)
274
- ) ENGINE=$engine DEFAULT CHARSET=utf8
275
  ",
276
 
277
  'archive_blob' => "CREATE TABLE {$prefixTables}archive_blob (
278
  idarchive INTEGER UNSIGNED NOT NULL,
279
- name VARCHAR(255) NOT NULL,
280
  idsite INTEGER UNSIGNED NULL,
281
  date1 DATE NULL,
282
  date2 DATE NULL,
@@ -285,14 +286,14 @@ class Mysql implements SchemaInterface
285
  value MEDIUMBLOB NULL,
286
  PRIMARY KEY(idarchive, name),
287
  INDEX index_period_archived(period, ts_archived)
288
- ) ENGINE=$engine DEFAULT CHARSET=utf8
289
  ",
290
 
291
  'sequence' => "CREATE TABLE {$prefixTables}sequence (
292
  `name` VARCHAR(120) NOT NULL,
293
  `value` BIGINT(20) UNSIGNED NOT NULL ,
294
  PRIMARY KEY(`name`)
295
- ) ENGINE=$engine DEFAULT CHARSET=utf8
296
  ",
297
 
298
  'brute_force_log' => "CREATE TABLE {$prefixTables}brute_force_log (
@@ -301,7 +302,7 @@ class Mysql implements SchemaInterface
301
  `attempted_at` datetime NOT NULL,
302
  INDEX index_ip_address(ip_address),
303
  PRIMARY KEY(`id_brute_force_log`)
304
- ) ENGINE=$engine DEFAULT CHARSET=utf8
305
  ",
306
 
307
  'tracking_failure' => "CREATE TABLE {$prefixTables}tracking_failure (
@@ -310,14 +311,14 @@ class Mysql implements SchemaInterface
310
  `date_first_occurred` DATETIME NOT NULL ,
311
  `request_url` MEDIUMTEXT NOT NULL ,
312
  PRIMARY KEY(`idsite`, `idfailure`)
313
- ) ENGINE=$engine DEFAULT CHARSET=utf8
314
  ",
315
  'locks' => "CREATE TABLE `{$prefixTables}locks` (
316
  `key` VARCHAR(".Lock::MAX_KEY_LEN.") NOT NULL,
317
  `value` VARCHAR(255) NULL DEFAULT NULL,
318
  `expiry_time` BIGINT UNSIGNED DEFAULT 9999999999,
319
  PRIMARY KEY (`key`)
320
- ) ENGINE=$engine DEFAULT CHARSET=utf8
321
  ",
322
  );
323
 
@@ -384,7 +385,7 @@ class Mysql implements SchemaInterface
384
 
385
  /**
386
  * Get list of tables installed
387
- *
388
  * @param bool $forceReload Invalidate cache
389
  * @return array installed Tables
390
  */
@@ -452,7 +453,8 @@ class Mysql implements SchemaInterface
452
  */
453
  public function createTable($nameWithoutPrefix, $createDefinition)
454
  {
455
- $statement = sprintf("CREATE TABLE IF NOT EXISTS `%s` ( %s ) ENGINE=%s DEFAULT CHARSET=utf8 ;",
 
456
  Common::prefixTable($nameWithoutPrefix),
457
  $createDefinition,
458
  $this->getTableEngine());
@@ -551,6 +553,11 @@ class Mysql implements SchemaInterface
551
  return $this->getDbSettings()->getTablePrefix();
552
  }
553
 
 
 
 
 
 
554
  private function getTableEngine()
555
  {
556
  return $this->getDbSettings()->getEngine();
38
  {
39
  $engine = $this->getTableEngine();
40
  $prefixTables = $this->getTablePrefix();
41
+ $charset = $this->getCharset();
42
 
43
  $tables = array(
44
  'user' => "CREATE TABLE {$prefixTables}user (
45
  login VARCHAR(100) NOT NULL,
46
+ password VARCHAR(191) NOT NULL,
47
  alias VARCHAR(45) NOT NULL,
48
  email VARCHAR(100) NOT NULL,
49
  twofactor_secret VARCHAR(40) NOT NULL DEFAULT '',
53
  ts_password_modified TIMESTAMP NULL,
54
  PRIMARY KEY(login),
55
  UNIQUE KEY uniq_keytoken(token_auth)
56
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
57
  ",
58
 
59
  'twofactor_recovery_code' => "CREATE TABLE {$prefixTables}twofactor_recovery_code (
61
  login VARCHAR(100) NOT NULL,
62
  recovery_code VARCHAR(40) NOT NULL,
63
  PRIMARY KEY(idrecoverycode)
64
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
65
  ",
66
 
67
  'access' => "CREATE TABLE {$prefixTables}access (
71
  access VARCHAR(50) NULL,
72
  PRIMARY KEY(idaccess),
73
  INDEX index_loginidsite (login, idsite)
74
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
75
  ",
76
 
77
  'site' => "CREATE TABLE {$prefixTables}site (
94
  keep_url_fragment TINYINT NOT NULL DEFAULT 0,
95
  creator_login VARCHAR(100) NULL,
96
  PRIMARY KEY(idsite)
97
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
98
  ",
99
 
100
  'plugin_setting' => "CREATE TABLE {$prefixTables}plugin_setting (
106
  `idplugin_setting` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
107
  PRIMARY KEY (idplugin_setting),
108
  INDEX(plugin_name, user_login)
109
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
110
  ",
111
 
112
  'site_setting' => "CREATE TABLE {$prefixTables}site_setting (
118
  `idsite_setting` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
119
  PRIMARY KEY (idsite_setting),
120
  INDEX(idsite, plugin_name)
121
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
122
  ",
123
 
124
  'site_url' => "CREATE TABLE {$prefixTables}site_url (
125
  idsite INTEGER(10) UNSIGNED NOT NULL,
126
+ url VARCHAR(190) NOT NULL,
127
  PRIMARY KEY(idsite, url)
128
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
129
  ",
130
 
131
  'goal' => "CREATE TABLE `{$prefixTables}goal` (
142
  `deleted` tinyint(4) NOT NULL default '0',
143
  `event_value_as_revenue` tinyint(4) NOT NULL default '0',
144
  PRIMARY KEY (`idsite`,`idgoal`)
145
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
146
  ",
147
 
148
  'logger_message' => "CREATE TABLE {$prefixTables}logger_message (
152
  level VARCHAR(16) NULL,
153
  message TEXT NULL,
154
  PRIMARY KEY(idlogger_message)
155
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
156
  ",
157
 
158
  'log_action' => "CREATE TABLE {$prefixTables}log_action (
163
  url_prefix TINYINT(2) NULL,
164
  PRIMARY KEY(idaction),
165
  INDEX index_type_hash (type, hash)
166
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
167
  ",
168
 
169
  'log_visit' => "CREATE TABLE {$prefixTables}log_visit (
177
  INDEX index_idsite_config_datetime (idsite, config_id, visit_last_action_time),
178
  INDEX index_idsite_datetime (idsite, visit_last_action_time),
179
  INDEX index_idsite_idvisitor (idsite, idvisitor)
180
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
181
  ",
182
 
183
  'log_conversion_item' => "CREATE TABLE `{$prefixTables}log_conversion_item` (
198
  deleted TINYINT(1) UNSIGNED NOT NULL,
199
  PRIMARY KEY(idvisit, idorder, idaction_sku),
200
  INDEX index_idsite_servertime ( idsite, server_time )
201
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
202
  ",
203
 
204
  'log_conversion' => "CREATE TABLE `{$prefixTables}log_conversion` (
216
  PRIMARY KEY (idvisit, idgoal, buster),
217
  UNIQUE KEY unique_idsite_idorder (idsite, idorder),
218
  INDEX index_idsite_datetime ( idsite, server_time )
219
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
220
  ",
221
 
222
  'log_link_visit_action' => "CREATE TABLE {$prefixTables}log_link_visit_action (
229
  custom_float DOUBLE NULL DEFAULT NULL,
230
  PRIMARY KEY(idlink_va),
231
  INDEX index_idvisit(idvisit)
232
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
233
  ",
234
 
235
  'log_profiling' => "CREATE TABLE {$prefixTables}log_profiling (
239
  idprofiling BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
240
  PRIMARY KEY (idprofiling),
241
  UNIQUE KEY query(query(100))
242
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
243
  ",
244
 
245
  'option' => "CREATE TABLE `{$prefixTables}option` (
246
+ option_name VARCHAR( 191 ) NOT NULL,
247
  option_value LONGTEXT NOT NULL,
248
  autoload TINYINT NOT NULL DEFAULT '1',
249
  PRIMARY KEY ( option_name ),
250
  INDEX autoload( autoload )
251
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
252
  ",
253
 
254
  'session' => "CREATE TABLE {$prefixTables}session (
255
+ id VARCHAR( 191 ) NOT NULL,
256
  modified INTEGER,
257
  lifetime INTEGER,
258
  data TEXT,
259
  PRIMARY KEY ( id )
260
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
261
  ",
262
 
263
  'archive_numeric' => "CREATE TABLE {$prefixTables}archive_numeric (
264
  idarchive INTEGER UNSIGNED NOT NULL,
265
+ name VARCHAR(190) NOT NULL,
266
  idsite INTEGER UNSIGNED NULL,
267
  date1 DATE NULL,
268
  date2 DATE NULL,
272
  PRIMARY KEY(idarchive, name),
273
  INDEX index_idsite_dates_period(idsite, date1, date2, period, ts_archived),
274
  INDEX index_period_archived(period, ts_archived)
275
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
276
  ",
277
 
278
  'archive_blob' => "CREATE TABLE {$prefixTables}archive_blob (
279
  idarchive INTEGER UNSIGNED NOT NULL,
280
+ name VARCHAR(190) NOT NULL,
281
  idsite INTEGER UNSIGNED NULL,
282
  date1 DATE NULL,
283
  date2 DATE NULL,
286
  value MEDIUMBLOB NULL,
287
  PRIMARY KEY(idarchive, name),
288
  INDEX index_period_archived(period, ts_archived)
289
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
290
  ",
291
 
292
  'sequence' => "CREATE TABLE {$prefixTables}sequence (
293
  `name` VARCHAR(120) NOT NULL,
294
  `value` BIGINT(20) UNSIGNED NOT NULL ,
295
  PRIMARY KEY(`name`)
296
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
297
  ",
298
 
299
  'brute_force_log' => "CREATE TABLE {$prefixTables}brute_force_log (
302
  `attempted_at` datetime NOT NULL,
303
  INDEX index_ip_address(ip_address),
304
  PRIMARY KEY(`id_brute_force_log`)
305
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
306
  ",
307
 
308
  'tracking_failure' => "CREATE TABLE {$prefixTables}tracking_failure (
311
  `date_first_occurred` DATETIME NOT NULL ,
312
  `request_url` MEDIUMTEXT NOT NULL ,
313
  PRIMARY KEY(`idsite`, `idfailure`)
314
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
315
  ",
316
  'locks' => "CREATE TABLE `{$prefixTables}locks` (
317
  `key` VARCHAR(".Lock::MAX_KEY_LEN.") NOT NULL,
318
  `value` VARCHAR(255) NULL DEFAULT NULL,
319
  `expiry_time` BIGINT UNSIGNED DEFAULT 9999999999,
320
  PRIMARY KEY (`key`)
321
+ ) ENGINE=$engine DEFAULT CHARSET=$charset
322
  ",
323
  );
324
 
385
 
386
  /**
387
  * Get list of tables installed
388
+ *`
389
  * @param bool $forceReload Invalidate cache
390
  * @return array installed Tables
391
  */
453
  */
454
  public function createTable($nameWithoutPrefix, $createDefinition)
455
  {
456
+ $charset = $this->getCharset();
457
+ $statement = sprintf("CREATE TABLE IF NOT EXISTS `%s` ( %s ) ENGINE=%s DEFAULT CHARSET=$charset ;",
458
  Common::prefixTable($nameWithoutPrefix),
459
  $createDefinition,
460
  $this->getTableEngine());
553
  return $this->getDbSettings()->getTablePrefix();
554
  }
555
 
556
+ private function getCharset()
557
+ {
558
+ return $this->getDbSettings()->getCharset();
559
+ }
560
+
561
  private function getTableEngine()
562
  {
563
  return $this->getDbSettings()->getEngine();
app/core/Db/Settings.php CHANGED
@@ -29,6 +29,15 @@ class Settings
29
  return $this->getDbSetting('tables_prefix');
30
  }
31
 
 
 
 
 
 
 
 
 
 
32
  public function getDbName()
33
  {
34
  return $this->getDbSetting('dbname');
29
  return $this->getDbSetting('tables_prefix');
30
  }
31
 
32
+ public function getCharset()
33
+ {
34
+ $charset = $this->getDbSetting('charset');
35
+ if (empty($charset)) {
36
+ $charset = 'utf8';
37
+ }
38
+ return $charset;
39
+ }
40
+
41
  public function getDbName()
42
  {
43
  return $this->getDbSetting('dbname');
app/core/DbHelper.php CHANGED
@@ -61,6 +61,15 @@ class DbHelper
61
  Schema::getInstance()->createTable($nameWithoutPrefix, $createDefinition);
62
  }
63
 
 
 
 
 
 
 
 
 
 
64
  /**
65
  * Returns true if Piwik is installed
66
  *
61
  Schema::getInstance()->createTable($nameWithoutPrefix, $createDefinition);
62
  }
63
 
64
+ public static function getUsedCharset()
65
+ {
66
+ if (Config::getInstance()->database['charset']) {
67
+ return strtolower(Config::getInstance()->database['charset']);
68
+ }
69
+
70
+ return 'utf8';
71
+ }
72
+
73
  /**
74
  * Returns true if Piwik is installed
75
  *
app/core/SettingsServer.php CHANGED
@@ -142,6 +142,11 @@ class SettingsServer
142
  */
143
  public static function raiseMemoryLimitIfNecessary()
144
  {
 
 
 
 
 
145
  $memoryLimit = self::getMemoryLimitValue();
146
  if ($memoryLimit === false) {
147
  return false;
@@ -150,7 +155,6 @@ class SettingsServer
150
 
151
  if (self::isArchivePhpTriggered()) {
152
  // core:archive command: no time limit, high memory limit
153
- self::setMaxExecutionTime(0);
154
  $minimumMemoryLimitWhenArchiving = Config::getInstance()->General['minimum_memory_limit_when_archiving'];
155
  if ($memoryLimit < $minimumMemoryLimitWhenArchiving) {
156
  return self::setMemoryLimit($minimumMemoryLimitWhenArchiving);
142
  */
143
  public static function raiseMemoryLimitIfNecessary()
144
  {
145
+ if (self::isArchivePhpTriggered()) {
146
+ // core:archive command: no time limit, high memory limit
147
+ self::setMaxExecutionTime( 0 );
148
+ }
149
+
150
  $memoryLimit = self::getMemoryLimitValue();
151
  if ($memoryLimit === false) {
152
  return false;
155
 
156
  if (self::isArchivePhpTriggered()) {
157
  // core:archive command: no time limit, high memory limit
 
158
  $minimumMemoryLimitWhenArchiving = Config::getInstance()->General['minimum_memory_limit_when_archiving'];
159
  if ($memoryLimit < $minimumMemoryLimitWhenArchiving) {
160
  return self::setMemoryLimit($minimumMemoryLimitWhenArchiving);
app/core/Tracker/Request.php CHANGED
@@ -13,6 +13,7 @@ use Piwik\Common;
13
  use Piwik\Config;
14
  use Piwik\Container\StaticContainer;
15
  use Piwik\Cookie;
 
16
  use Piwik\Exception\InvalidRequestParameterException;
17
  use Piwik\Exception\UnexpectedWebsiteFoundException;
18
  use Piwik\IP;
13
  use Piwik\Config;
14
  use Piwik\Container\StaticContainer;
15
  use Piwik\Cookie;
16
+ use Piwik\DbHelper;
17
  use Piwik\Exception\InvalidRequestParameterException;
18
  use Piwik\Exception\UnexpectedWebsiteFoundException;
19
  use Piwik\IP;
app/plugins/Morpheus/templates/_jsGlobalVariables.twig CHANGED
@@ -16,7 +16,7 @@
16
  symbolDecimal: "{{ 'Intl_NumberSymbolDecimal'|translate }}"
17
  };
18
 
19
- piwik.relativePluginWebDirs = {{ relativePluginWebDirs|json_encode|raw }}
20
 
21
  {% if userLogin %}piwik.userLogin = "{{ userLogin|e('js')}}";{% endif %}
22
 
16
  symbolDecimal: "{{ 'Intl_NumberSymbolDecimal'|translate }}"
17
  };
18
 
19
+ piwik.relativePluginWebDirs = {{ relativePluginWebDirs|json_encode|raw }};
20
 
21
  {% if userLogin %}piwik.userLogin = "{{ userLogin|e('js')}}";{% endif %}
22
 
classes/WpMatomo/Admin/SystemReport.php CHANGED
@@ -43,7 +43,8 @@ class SystemReport {
43
  const TROUBLESHOOT_CLEAR_LOGS = 'matomo_troubleshooting_action_clear_logs';
44
 
45
  private $not_compatible_plugins = array(
46
- 'background-manager/background-manager.php', // Uses an old version of Twig and plugin is no longer maintained.
 
47
  );
48
 
49
  private $valid_tabs = array( 'troubleshooting' );
@@ -76,6 +77,10 @@ class SystemReport {
76
  Bootstrap::do_bootstrap();
77
  $scheduled_tasks = new ScheduledTasks( $this->settings );
78
 
 
 
 
 
79
  try {
80
  $errors = $scheduled_tasks->archive( $force = true, $throw_exception = false );
81
  } catch (\Exception $e) {
@@ -655,23 +660,15 @@ class SystemReport {
655
  'name' => 'Network Enabled',
656
  'value' => $is_network_enabled,
657
  );
658
- $rows[] = array(
659
- 'name' => 'Debug Mode Enabled',
660
- 'value' => defined( 'WP_DEBUG' ) && WP_DEBUG,
661
- );
662
- $rows[] = array(
663
- 'name' => 'Cron Enabled',
664
- 'value' => defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON,
665
- );
666
- $rows[] = array(
667
- 'name' => 'Force SSL Admin',
668
- 'value' => defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN,
669
- );
670
-
671
- $rows[] = array(
672
- 'name' => 'Language',
673
- 'value' => defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US',
674
- );
675
 
676
  $rows[] = array(
677
  'name' => 'Permalink Structure',
@@ -683,11 +680,6 @@ class SystemReport {
683
  'value' => strpos( __DIR__, ABSPATH ) === false && strpos( __DIR__, WP_CONTENT_DIR ) === false,
684
  );
685
 
686
- $rows[] = array(
687
- 'name' => 'WP Cache enabled',
688
- 'value' => defined( 'WP_CACHE' ) && WP_CACHE,
689
- );
690
-
691
  if (is_plugin_active('wp-piwik/wp-piwik.php')) {
692
  $rows[] = array(
693
  'name' => 'WP-Matomo (WP-Piwik) activated',
@@ -757,14 +749,38 @@ class SystemReport {
757
  'value' => @basename(PHP_BINARY),
758
  );
759
  }
 
 
 
 
 
 
 
 
 
 
 
 
760
  $rows[] = array(
761
  'name' => 'Timezone',
762
  'value' => date_default_timezone_get(),
763
  );
 
 
 
 
 
 
764
  $rows[] = array(
765
  'name' => 'Locale',
766
  'value' => get_locale(),
767
  );
 
 
 
 
 
 
768
 
769
  $rows[] = array(
770
  'name' => 'Memory Limit',
@@ -828,6 +844,13 @@ class SystemReport {
828
  );
829
  }
830
 
 
 
 
 
 
 
 
831
  return $rows;
832
  }
833
 
@@ -878,6 +901,16 @@ class SystemReport {
878
  'value' => $wpdb->prefix,
879
  );
880
 
 
 
 
 
 
 
 
 
 
 
881
  if ( method_exists( $wpdb, 'parse_db_host' ) ) {
882
  $host_data = $wpdb->parse_db_host( DB_HOST );
883
  if ( $host_data ) {
@@ -1043,8 +1076,8 @@ class SystemReport {
1043
  $rows[] = array(
1044
  'name' => __( 'Not compatible plugins', 'matomo' ),
1045
  'value' => count( $used_not_compatible ),
1046
- 'comment' => implode( ', ', $used_not_compatible ),
1047
- 'is_error' => true,
1048
  );
1049
  }
1050
  }
43
  const TROUBLESHOOT_CLEAR_LOGS = 'matomo_troubleshooting_action_clear_logs';
44
 
45
  private $not_compatible_plugins = array(
46
+ 'background-manager', // Uses an old version of Twig and plugin is no longer maintained.
47
+ 'data-tables-generator-by-supsystic', // uses an old version of twig causing some styles to go funny in the reporting and admin
48
  );
49
 
50
  private $valid_tabs = array( 'troubleshooting' );
77
  Bootstrap::do_bootstrap();
78
  $scheduled_tasks = new ScheduledTasks( $this->settings );
79
 
80
+ if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) {
81
+ define('PIWIK_ARCHIVE_NO_TRUNCATE', 1); // when triggering it manually, we prefer the full error message
82
+ }
83
+
84
  try {
85
  $errors = $scheduled_tasks->archive( $force = true, $throw_exception = false );
86
  } catch (\Exception $e) {
660
  'name' => 'Network Enabled',
661
  'value' => $is_network_enabled,
662
  );
663
+ $consts = array('WP_DEBUG', 'WP_DEBUG_DISPLAY', 'WP_DEBUG_LOG', 'DISABLE_WP_CRON', 'FORCE_SSL_ADMIN', 'WP_CACHE',
664
+ 'CONCATENATE_SCRIPTS', 'COMPRESS_SCRIPTS', 'COMPRESS_CSS', 'ENFORCE_GZIP', 'WP_LOCAL_DEV',
665
+ 'DIEONDBERROR', 'WPLANG');
666
+ foreach ($consts as $const) {
667
+ $rows[] = array(
668
+ 'name' => $const,
669
+ 'value' => defined( $const ) ? constant( $const) : '-',
670
+ );
671
+ }
 
 
 
 
 
 
 
 
672
 
673
  $rows[] = array(
674
  'name' => 'Permalink Structure',
680
  'value' => strpos( __DIR__, ABSPATH ) === false && strpos( __DIR__, WP_CONTENT_DIR ) === false,
681
  );
682
 
 
 
 
 
 
683
  if (is_plugin_active('wp-piwik/wp-piwik.php')) {
684
  $rows[] = array(
685
  'name' => 'WP-Matomo (WP-Piwik) activated',
749
  'value' => @basename(PHP_BINARY),
750
  );
751
  }
752
+ if (!\WpMatomo::is_safe_mode()) {
753
+ Bootstrap::do_bootstrap();
754
+ $cliPhp = new CliMulti\CliPhp();
755
+ $binary = $cliPhp->findPhpBinary();
756
+ if (!empty($binary)) {
757
+ $binary = basename($binary);
758
+ $rows[] = array(
759
+ 'name' => 'PHP Found Binary',
760
+ 'value' => $binary,
761
+ );
762
+ }
763
+ }
764
  $rows[] = array(
765
  'name' => 'Timezone',
766
  'value' => date_default_timezone_get(),
767
  );
768
+ if (function_exists('wp_timezone_string')) {
769
+ $rows[] = array(
770
+ 'name' => 'WP timezone',
771
+ 'value' => wp_timezone_string(),
772
+ );
773
+ }
774
  $rows[] = array(
775
  'name' => 'Locale',
776
  'value' => get_locale(),
777
  );
778
+ if (function_exists('get_user_locale')) {
779
+ $rows[] = array(
780
+ 'name' => 'User Locale',
781
+ 'value' => get_user_locale(),
782
+ );
783
+ }
784
 
785
  $rows[] = array(
786
  'name' => 'Memory Limit',
844
  );
845
  }
846
 
847
+ $suhosin_installed = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
848
+ $rows[] = array(
849
+ 'name' => 'Suhosin installed',
850
+ 'value' => !empty($suhosin_installed),
851
+ 'comment' => ''
852
+ );
853
+
854
  return $rows;
855
  }
856
 
901
  'value' => $wpdb->prefix,
902
  );
903
 
904
+ $rows[] = array(
905
+ 'name' => 'DB CHARSET',
906
+ 'value' => defined('DB_CHARSET') ? DB_CHARSET : '',
907
+ );
908
+
909
+ $rows[] = array(
910
+ 'name' => 'DB COLLATE',
911
+ 'value' => defined('DB_COLLATE') ? DB_COLLATE : '',
912
+ );
913
+
914
  if ( method_exists( $wpdb, 'parse_db_host' ) ) {
915
  $host_data = $wpdb->parse_db_host( DB_HOST );
916
  if ( $host_data ) {
1076
  $rows[] = array(
1077
  'name' => __( 'Not compatible plugins', 'matomo' ),
1078
  'value' => count( $used_not_compatible ),
1079
+ 'comment' => implode( ', ', $used_not_compatible ) . '<br><br> Matomo may work fine when using these plugins but there may be some issues. For more information see<br>https://matomo.org/faq/wordpress/which-plugins-is-matomo-for-wordpress-known-to-be-not-compatible-with/',
1080
+ 'is_warning' => true,
1081
  );
1082
  }
1083
  }
classes/WpMatomo/Admin/views/marketplace.php CHANGED
@@ -30,8 +30,8 @@ $matomo_extra_url_params = '&' . http_build_query(
30
  <?php } ?>
31
  <?php if ( $matomo_show_offer ) { ?>
32
  <div class="notice notice-info">
33
- <p>Limited time only: 300€ Off Matomo Premium Bundle. Now only 199€/year.
34
- <a href="https://matomo.org/wp-premium-bundle/" target="_blank" rel="noreferrer noopener" class="button">Learn more</a></p>
35
  <div style="clear:both;"></div>
36
  </div>
37
  <?php } ?>
30
  <?php } ?>
31
  <?php if ( $matomo_show_offer ) { ?>
32
  <div class="notice notice-info">
33
+ <h3>Limited time only</h3><p>300€ Off Matomo Premium Bundle. Now only 199€/year.</p>
34
+ <p><a href="https://matomo.org/wp-premium-bundle/" target="_blank" rel="noreferrer noopener" class="button-primary">Learn more</a></p>
35
  <div style="clear:both;"></div>
36
  </div>
37
  <?php } ?>
classes/WpMatomo/Db/WordPress.php CHANGED
@@ -60,7 +60,7 @@ class WordPress extends Mysqli {
60
  public function isConnectionUTF8() {
61
  $value = $this->fetchOne( 'SELECT @@character_set_client;' );
62
 
63
- return ! empty( $value ) && strtolower( $value ) === 'utf8';
64
  }
65
 
66
  public function checkClientVersion() {
@@ -70,7 +70,7 @@ class WordPress extends Mysqli {
70
  public function getClientVersion() {
71
  $value = $this->fetchOne( 'SELECT @@version;' );
72
 
73
- return ! empty( $value ) && strtolower( $value ) === 'utf8';
74
  }
75
 
76
  public function closeConnection() {
60
  public function isConnectionUTF8() {
61
  $value = $this->fetchOne( 'SELECT @@character_set_client;' );
62
 
63
+ return ! empty( $value ) && strpos(strtolower( $value ), 'utf8') === 0;
64
  }
65
 
66
  public function checkClientVersion() {
70
  public function getClientVersion() {
71
  $value = $this->fetchOne( 'SELECT @@version;' );
72
 
73
+ return $value;
74
  }
75
 
76
  public function closeConnection() {
classes/WpMatomo/Installer.php CHANGED
@@ -286,12 +286,15 @@ class Installer {
286
  }
287
  }
288
 
 
 
289
  $database = array(
290
  'host' => $host,
291
  'port' => $port,
292
  'username' => DB_USER,
293
  'password' => DB_PASSWORD,
294
  'dbname' => DB_NAME,
 
295
  'tables_prefix' => $wpdb->prefix . MATOMO_DATABASE_PREFIX,
296
  'adapter' => 'WordPress',
297
  );
286
  }
287
  }
288
 
289
+ $charset = $wpdb->charset ? $wpdb->charset : 'utf8';
290
+
291
  $database = array(
292
  'host' => $host,
293
  'port' => $port,
294
  'username' => DB_USER,
295
  'password' => DB_PASSWORD,
296
  'dbname' => DB_NAME,
297
+ 'charset' => $charset,
298
  'tables_prefix' => $wpdb->prefix . MATOMO_DATABASE_PREFIX,
299
  'adapter' => 'WordPress',
300
  );
classes/WpMatomo/User/Sync.php CHANGED
@@ -183,6 +183,8 @@ class Sync {
183
  if ( $matomo_user_login ) {
184
  $user_in_matomo = $user_model->getUser( $matomo_user_login );
185
  } else {
 
 
186
  $login = substr( $login, 0, self::MAX_USER_NAME_LENGTH );
187
 
188
  if ( ! $user_model->getUser( $login ) ) {
183
  if ( $matomo_user_login ) {
184
  $user_in_matomo = $user_model->getUser( $matomo_user_login );
185
  } else {
186
+ // wp usernames may include whitespace etc
187
+ $login = preg_replace('/[^A-Za-zÄäÖöÜüß0-9_.@+-]+/D', '_', $login);
188
  $login = substr( $login, 0, self::MAX_USER_NAME_LENGTH );
189
 
190
  if ( ! $user_model->getUser( $login ) ) {
config/config.php CHANGED
@@ -58,10 +58,10 @@ return array(
58
  }
59
 
60
  $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
61
- $matomo_salt = get_option($matomo_salt_key); // needs to per site!
62
  if (!$matomo_salt) {
63
  $matomo_salt = \Piwik\Common::getRandomString(32);
64
- update_option($matomo_salt_key, $matomo_salt);
65
  }
66
 
67
  $general['salt'] = $matomo_salt;
@@ -150,6 +150,7 @@ return array(
150
  unset($values['database']['password']);
151
  unset($values['database']['dbname']);
152
  unset($values['database']['tables_prefix']);
 
153
  unset($values['Plugins']);
154
  unset($values['General']['enable_users_admin']);
155
  unset($values['General']['enable_sites_admin']);
58
  }
59
 
60
  $matomo_salt_key = Settings::OPTION_PREFIX . 'matomo_salt';
61
+ $matomo_salt = get_option($matomo_salt_key); // needs to be per site!
62
  if (!$matomo_salt) {
63
  $matomo_salt = \Piwik\Common::getRandomString(32);
64
+ update_option($matomo_salt_key, $matomo_salt, true);
65
  }
66
 
67
  $general['salt'] = $matomo_salt;
150
  unset($values['database']['password']);
151
  unset($values['database']['dbname']);
152
  unset($values['database']['tables_prefix']);
153
+ unset($values['database']['charset']);
154
  unset($values['Plugins']);
155
  unset($values['General']['enable_users_admin']);
156
  unset($values['General']['enable_sites_admin']);
matomo.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: The #1 Google Analytics alternative that gives you full control over your data and protects the privacy for your users. Free, secure and open.
5
  * Author: Matomo
6
  * Author URI: https://matomo.org
7
- * Version: 1.0.5
8
  * Domain Path: /languages
9
  * WC requires at least: 2.4.0
10
  * WC tested up to: 4.0.0
4
  * Description: The #1 Google Analytics alternative that gives you full control over your data and protects the privacy for your users. Free, secure and open.
5
  * Author: Matomo
6
  * Author URI: https://matomo.org
7
+ * Version: 1.0.6
8
  * Domain Path: /languages
9
  * WC requires at least: 2.4.0
10
  * WC tested up to: 4.0.0
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: matomo,piwik,analytics,statistics,stats,tracking,ecommerce
5
  Requires at least: 4.8
6
  Tested up to: 5.4
7
- Stable tag: 1.0.5
8
  Requires PHP: 7.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
4
  Tags: matomo,piwik,analytics,statistics,stats,tracking,ecommerce
5
  Requires at least: 4.8
6
  Tested up to: 5.4
7
+ Stable tag: 1.0.6
8
  Requires PHP: 7.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html