Prune remote files part 30
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- plugins/Tour/tests/UI/expected-screenshots/.gitkeepDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_ConsentManager_widget_initial.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_all_completed.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges_page_2.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges_page_3.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_completed.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_initial.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_none_completed.pngDeleted
- plugins/Tour/tests/UI/expected-screenshots/Tour_widget_skipped_goal.pngDeleted
- plugins/Tour/vue/dist/Tour.umd.jsDeleted-382
- plugins/Tour/vue/dist/Tour.umd.min.jsDeleted-8
- plugins/Tour/vue/dist/umd.metadata.jsonDeleted-5
- plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vueDeleted-303
- plugins/Tour/vue/src/index.tsDeleted-8
- plugins/TrackingSpamPrevention/.gitattributesDeleted-9
- plugins/TrackingSpamPrevention/.github/workflows/matomo-ai-checklist.ymlDeleted-32
- plugins/TrackingSpamPrevention/.github/workflows/matomo-tests.ymlDeleted-74
- plugins/TrackingSpamPrevention/.github/workflows/phpcs.ymlDeleted-43
- plugins/TrackingSpamPrevention/AllowListIpRange.phpDeleted-37
- plugins/TrackingSpamPrevention/BanIpNotificationEmail.phpDeleted-99
- plugins/TrackingSpamPrevention/BlockedGeoIp.phpDeleted-79
- plugins/TrackingSpamPrevention/BlockedIpRanges.phpDeleted-195
- plugins/TrackingSpamPrevention/BlockedIpRanges/Aws.phpDeleted-68
- plugins/TrackingSpamPrevention/BlockedIpRanges/Azure.phpDeleted-84
- plugins/TrackingSpamPrevention/BlockedIpRanges/DigitalOcean.phpDeleted-46
- plugins/TrackingSpamPrevention/BlockedIpRanges/ExceptionRange.phpDeleted-21
- plugins/TrackingSpamPrevention/BlockedIpRanges/Gcloud.phpDeleted-51
- plugins/TrackingSpamPrevention/BlockedIpRanges/IpRangeProviderInterface.phpDeleted-15
- plugins/TrackingSpamPrevention/BlockedIpRanges/Oracle.phpDeleted-51
- plugins/TrackingSpamPrevention/BlockedIpRanges/VariableRange.phpDeleted-31
- plugins/TrackingSpamPrevention/BrowserDetection.phpDeleted-51
- plugins/TrackingSpamPrevention/CHANGELOG.mdDeleted-69
- plugins/TrackingSpamPrevention/Commands/BlockGeoIpOrganisation.phpDeleted-51
- plugins/TrackingSpamPrevention/Configuration.phpDeleted-181
- plugins/TrackingSpamPrevention/LICENSEDeleted-674
- plugins/TrackingSpamPrevention/README.mdDeleted-56
- plugins/TrackingSpamPrevention/Settings/BlockCloudsSetting.phpDeleted-30
- plugins/TrackingSpamPrevention/SystemSettings.phpDeleted-243
- plugins/TrackingSpamPrevention/Tasks.phpDeleted-49
- plugins/TrackingSpamPrevention/Tracker/RequestProcessor.phpDeleted-59
- plugins/TrackingSpamPrevention/TrackingSpamPrevention.phpDeleted-172
- plugins/TrackingSpamPrevention/Updates/5.0.10.phpDeleted-34
- plugins/TrackingSpamPrevention/Updates/5.0.11.phpDeleted-36
- plugins/TrackingSpamPrevention/Updates/5.0.9.phpDeleted-49
- plugins/TrackingSpamPrevention/config/config.phpDeleted-39
- plugins/TrackingSpamPrevention/config/test.phpDeleted-19
- plugins/TrackingSpamPrevention/config/tracker.phpDeleted-4
- plugins/TrackingSpamPrevention/docs/faq.mdDeleted-50
- plugins/TrackingSpamPrevention/lang/am.jsonDeleted-1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("CoreHome"), require("vue")); else if(typeof define === 'function' && define.amd) define(["CoreHome", ], factory); else if(typeof exports === 'object') exports["Tour"] = factory(require("CoreHome"), require("vue")); else root["Tour"] = factory(root["CoreHome"], root["Vue"]);})((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__19dc__, __WEBPACK_EXTERNAL_MODULE__8bbf__) {return /******/ (function(modules) { // webpackBootstrap/******/ // The module cache/******/ var installedModules = {};/******//******/ // The require function/******/ function __webpack_require__(moduleId) {/******//******/ // Check if module is in cache/******/ if(installedModules[moduleId]) {/******/ return installedModules[moduleId].exports;/******/ }/******/ // Create a new module (and put it into the cache)/******/ var module = installedModules[moduleId] = {/******/ i: moduleId,/******/ l: false,/******/ exports: {}/******/ };/******//******/ // Execute the module function/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);/******//******/ // Flag the module as loaded/******/ module.l = true;/******//******/ // Return the exports of the module/******/ return module.exports;/******/ }/******//******//******/ // expose the modules object (__webpack_modules__)/******/ __webpack_require__.m = modules;/******//******/ // expose the module cache/******/ __webpack_require__.c = installedModules;/******//******/ // define getter function for harmony exports/******/ __webpack_require__.d = function(exports, name, getter) {/******/ if(!__webpack_require__.o(exports, name)) {/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });/******/ }/******/ };/******//******/ // define __esModule on exports/******/ __webpack_require__.r = function(exports) {/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });/******/ }/******/ Object.defineProperty(exports, '__esModule', { value: true });/******/ };/******//******/ // create a fake namespace object/******/ // mode & 1: value is a module id, require it/******/ // mode & 2: merge all properties of value into the ns/******/ // mode & 4: return value when already ns object/******/ // mode & 8|1: behave like require/******/ __webpack_require__.t = function(value, mode) {/******/ if(mode & 1) value = __webpack_require__(value);/******/ if(mode & 8) return value;/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;/******/ var ns = Object.create(null);/******/ __webpack_require__.r(ns);/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));/******/ return ns;/******/ };/******//******/ // getDefaultExport function for compatibility with non-harmony modules/******/ __webpack_require__.n = function(module) {/******/ var getter = module && module.__esModule ?/******/ function getDefault() { return module['default']; } :/******/ function getModuleExports() { return module; };/******/ __webpack_require__.d(getter, 'a', getter);/******/ return getter;/******/ };/******//******/ // Object.prototype.hasOwnProperty.call/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };/******//******/ // __webpack_public_path__/******/ __webpack_require__.p = "plugins/Tour/vue/dist/";/******//******//******/ // Load entry module and return exports/******/ return __webpack_require__(__webpack_require__.s = "fae3");/******/ })/************************************************************************//******/ ({
/***/ "19dc":/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__19dc__;
/***/ }),
/***/ "8bbf":/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__;
/***/ }),
/***/ "fae3":/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";// ESM COMPAT FLAG__webpack_require__.r(__webpack_exports__);
// EXPORTS__webpack_require__.d(__webpack_exports__, "BecomeMatomoExpert", function() { return /* reexport */ BecomeMatomoExpert; });
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js// This file is imported into lib/wc client bundles.
if (typeof window !== 'undefined') { var currentScript = window.document.currentScript if (false) { var getCurrentScript; }
var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) if (src) { __webpack_require__.p = src[1] // eslint-disable-line }}
// Indicate to webpack that this file can be concatenated/* harmony default export */ var setPublicPath = (null);
// EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"}var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf");
// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--1-1!./plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vue?vue&type=template&id=78131424
const _hoisted_1 = { class: "widgetBody tourEngagement"};const _hoisted_2 = { "aria-hidden": "true"};const _hoisted_3 = { key: 0};const _hoisted_4 = { class: "completed"};const _hoisted_5 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1);const _hoisted_6 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1);const _hoisted_7 = ["innerHTML"];const _hoisted_8 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1);const _hoisted_9 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("br", null, null, -1);const _hoisted_10 = ["innerHTML"];const _hoisted_11 = { key: 1};const _hoisted_12 = { key: 0};const _hoisted_13 = ["innerHTML"];const _hoisted_14 = ["title"];const _hoisted_15 = ["title"];const _hoisted_16 = ["title", "onClick"];const _hoisted_17 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { class: "icon-hide"}, null, -1);const _hoisted_18 = [_hoisted_17];const _hoisted_19 = ["href"];const _hoisted_20 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("hr", null, null, -1);const _hoisted_21 = { style: { "text-align": "center", "padding-bottom": "0" }};const _hoisted_22 = /*#__PURE__*/Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("hr", null, null, -1);const _hoisted_23 = ["innerHTML"];function render(_ctx, _cache, $props, $setup, $data, $options) { const _component_ActivityIndicator = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("ActivityIndicator"); return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_1, [_ctx.loading ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])(_component_ActivityIndicator, { key: 0, loading: true })) : _ctx.level ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], { key: 1 }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", _hoisted_2, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.level.numLevelsTotal, i => { return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], { key: i }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["icon-star", _ctx.level.currentLevel >= i ? 'successStar' : 'upgradeStar']) }, null, 2), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(' '))], 64); }), 128))]), _ctx.isCompleted ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_3, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("strong", _hoisted_4, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Tour_CompletionTitle')), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('Tour_CompletionMessage')) + " ", 1), _hoisted_5, _hoisted_6, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { innerHTML: _ctx.$sanitize(_ctx.youCanCallYourselfHtml) }, null, 8, _hoisted_7), _hoisted_8, _hoisted_9, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("span", { innerHTML: _ctx.$sanitize(_ctx.shareHtml) }, null, 8, _hoisted_10)])])) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", _hoisted_11, [_ctx.level.description ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("p", _hoisted_12, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.level.description), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", { innerHTML: _ctx.$sanitize(_ctx.statusLevelHtml) }, null, 8, _hoisted_13), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("ul", null, [(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderList"])(_ctx.pagedChallenges, challenge => { return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("li", { key: challenge.id, class: Object(external_commonjs_vue_commonjs2_vue_root_Vue_["normalizeClass"])(["tourChallenge", challenge.id]), title: challenge.description }, [challenge.isCompleted || challenge.isSkipped ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("span", { key: 0, class: "icon-ok", title: _ctx.translate('Tour_ChallengeCompleted') }, null, 8, _hoisted_15)) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", { key: 1, href: "javascript:void 0;", class: "skip-challenge", title: _ctx.translate('Tour_SkipThisChallenge'), onClick: $event => _ctx.skipChallenge(challenge.id) }, _hoisted_18, 8, _hoisted_16)), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(' ') + " "), _ctx.$sanitizeUrl(challenge.url) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", { key: 2, href: _ctx.$sanitizeUrl(challenge.url), target: "_blank", rel: "noreferrer noopener" }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(challenge.name), 9, _hoisted_19)) : (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], { key: 3 }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(challenge.name), 1)], 64))], 10, _hoisted_14); }), 128))]), _hoisted_20, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", _hoisted_21, [_ctx.hasPrevPage ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", { key: 0, class: "previousChallenges", onClick: _cache[0] || (_cache[0] = $event => _ctx.currentPage -= 1) }, " ‹ " + Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.hasNextPage ? _ctx.translate('General_Previous') : _ctx.translate('Tour_PreviousChallenges')), 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.hasPrevPage && _ctx.hasNextPage ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])(external_commonjs_vue_commonjs2_vue_root_Vue_["Fragment"], { key: 1 }, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createTextVNode"])(" | ")], 64)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), _ctx.hasNextPage ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("a", { key: 2, class: "nextChallenges", onClick: _cache[1] || (_cache[1] = $event => _ctx.currentPage += 1) }, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.hasPrevPage ? _ctx.translate('General_Next') : _ctx.translate('Tour_NextChallenges')) + " › ", 1)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]), _hoisted_22, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", { class: "tourSuperUserNote", innerHTML: _ctx.$sanitize(_ctx.superUserNoteHtml) }, null, 8, _hoisted_23)]))], 64)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true)]);}// CONCATENATED MODULE: ./plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vue?vue&type=template&id=78131424
// EXTERNAL MODULE: external "CoreHome"var external_CoreHome_ = __webpack_require__("19dc");
// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--15-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--1-1!./plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vue?vue&type=script&lang=ts
const PER_PAGE = 5;/* harmony default export */ var BecomeMatomoExpertvue_type_script_lang_ts = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ components: { ActivityIndicator: external_CoreHome_["ActivityIndicator"] }, data() { return { loading: true, challenges: [], level: null, currentPage: 0 }; }, computed: { isCompleted() { return this.challenges.every(c => c.isCompleted || c.isSkipped); }, pagedChallenges() { const start = this.currentPage * PER_PAGE; return this.challenges.slice(start, start + PER_PAGE); }, totalPages() { return Math.ceil(this.challenges.length / PER_PAGE); }, hasPrevPage() { return this.currentPage > 0; }, hasNextPage() { return this.currentPage < this.totalPages - 1; }, statusLevelHtml() { if (!this.level) { return ''; } return Object(external_CoreHome_["translate"])('Tour_StatusLevel', `<strong>${this.level.currentLevelName}</strong>`, String(this.level.challengesNeededForNextLevel), `<strong>${this.level.nextLevelName}</strong>`); }, youCanCallYourselfHtml() { return Object(external_CoreHome_["translate"])('Tour_YouCanCallYourselfExpert', '<strong class="successStar">', '</strong>'); }, shareHtml() { if (!this.level) { return ''; } const shareText = encodeURIComponent(Object(external_CoreHome_["translate"])('Tour_ShareAllChallengesCompleted', this.level.currentLevelName)); const url = encodeURIComponent('https://matomo.org'); const shareUrl = `http://twitter.com/share?text=${shareText}&url=${url}`; return Object(external_CoreHome_["translate"])('Tour_ShareYourAchievementOn', `<a target="_blank" rel="noreferrer noopener" href="${shareUrl}">Twitter</a>`); }, superUserNoteHtml() { const faqUrl = 'https://matomo.org/faq/' + 'general/faq_35/'; return Object(external_CoreHome_["translate"])('Tour_OnlyVisibleToSuperUser', Object(external_CoreHome_["externalLink"])(faqUrl), '</a>'); } }, mounted() { this.fetchData(); window.addEventListener('focus', this.onFocus); }, beforeUnmount() { window.removeEventListener('focus', this.onFocus); }, methods: { translate: external_CoreHome_["translate"], onFocus() { this.fetchData(); }, async fetchData() { try { const [challenges, level] = await Promise.all([external_CoreHome_["AjaxHelper"].fetch({ method: 'Tour.getChallenges' }), external_CoreHome_["AjaxHelper"].fetch({ method: 'Tour.getLevel' })]); this.challenges = challenges; this.level = level; if (!this.loading) { return; } // set initial page to first uncompleted const firstIncomplete = challenges.findIndex(c => !c.isCompleted && !c.isSkipped); const done = firstIncomplete === -1 ? challenges.length : firstIncomplete; this.currentPage = Math.floor(done / PER_PAGE); } catch (_unused) { // silently keep current state on error } finally { this.loading = false; } }, async skipChallenge(id) { const challenge = this.challenges.find(c => c.id === id); if (challenge) { challenge.isSkipped = true; } try { await external_CoreHome_["AjaxHelper"].post({ method: 'Tour.skipChallenge', id }); } catch (_unused2) { if (challenge) { challenge.isSkipped = false; } } } }}));// CONCATENATED MODULE: ./plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vue?vue&type=script&lang=ts // CONCATENATED MODULE: ./plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vue
BecomeMatomoExpertvue_type_script_lang_ts.render = render
/* harmony default export */ var BecomeMatomoExpert = (BecomeMatomoExpertvue_type_script_lang_ts);// CONCATENATED MODULE: ./plugins/Tour/vue/src/index.ts/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib-no-default.js
/***/ })
/******/ });});//# sourceMappingURL=Tour.umd.js.map12345678(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("CoreHome"),require("vue")):"function"===typeof define&&define.amd?define(["CoreHome"],t):"object"===typeof exports?exports["Tour"]=t(require("CoreHome"),require("vue")):e["Tour"]=t(e["CoreHome"],e["Vue"])})("undefined"!==typeof self?self:this,(function(e,t){return function(e){var t={};function n(l){if(t[l])return t[l].exports;var r=t[l]={i:l,l:!1,exports:{}};return e[l].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(l,r,function(t){return e[t]}.bind(null,r));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="plugins/Tour/vue/dist/",n(n.s="fae3")}({"19dc":function(t,n){t.exports=e},"8bbf":function(e,n){e.exports=t},fae3:function(e,t,n){"use strict";if(n.r(t),n.d(t,"BecomeMatomoExpert",(function(){return L})),"undefined"!==typeof window){var l=window.document.currentScript,r=l&&l.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);r&&(n.p=r[1])}var o=n("8bbf");const c={class:"widgetBody tourEngagement"},a={"aria-hidden":"true"},s={key:0},i={class:"completed"},u=Object(o["createElementVNode"])("br",null,null,-1),d=Object(o["createElementVNode"])("br",null,null,-1),p=["innerHTML"],m=Object(o["createElementVNode"])("br",null,null,-1),b=Object(o["createElementVNode"])("br",null,null,-1),j=["innerHTML"],g={key:1},O={key:0},h=["innerHTML"],f=["title"],k=["title"],v=["title","onClick"],y=Object(o["createElementVNode"])("span",{class:"icon-hide"},null,-1),C=[y],N=["href"],E=Object(o["createElementVNode"])("hr",null,null,-1),T={style:{"text-align":"center","padding-bottom":"0"}},B=Object(o["createElementVNode"])("hr",null,null,-1),x=["innerHTML"];function S(e,t,n,l,r,y){const S=Object(o["resolveComponent"])("ActivityIndicator");return Object(o["openBlock"])(),Object(o["createElementBlock"])("div",c,[e.loading?(Object(o["openBlock"])(),Object(o["createBlock"])(S,{key:0,loading:!0})):e.level?(Object(o["openBlock"])(),Object(o["createElementBlock"])(o["Fragment"],{key:1},[Object(o["createElementVNode"])("p",a,[(Object(o["openBlock"])(!0),Object(o["createElementBlock"])(o["Fragment"],null,Object(o["renderList"])(e.level.numLevelsTotal,t=>(Object(o["openBlock"])(),Object(o["createElementBlock"])(o["Fragment"],{key:t},[Object(o["createElementVNode"])("span",{class:Object(o["normalizeClass"])(["icon-star",e.level.currentLevel>=t?"successStar":"upgradeStar"])},null,2),Object(o["createTextVNode"])(Object(o["toDisplayString"])(" "))],64))),128))]),e.isCompleted?(Object(o["openBlock"])(),Object(o["createElementBlock"])("div",s,[Object(o["createElementVNode"])("p",null,[Object(o["createElementVNode"])("strong",i,Object(o["toDisplayString"])(e.translate("Tour_CompletionTitle")),1),Object(o["createTextVNode"])(" "+Object(o["toDisplayString"])(e.translate("Tour_CompletionMessage"))+" ",1),u,d,Object(o["createElementVNode"])("span",{innerHTML:e.$sanitize(e.youCanCallYourselfHtml)},null,8,p),m,b,Object(o["createElementVNode"])("span",{innerHTML:e.$sanitize(e.shareHtml)},null,8,j)])])):(Object(o["openBlock"])(),Object(o["createElementBlock"])("div",g,[e.level.description?(Object(o["openBlock"])(),Object(o["createElementBlock"])("p",O,Object(o["toDisplayString"])(e.level.description),1)):Object(o["createCommentVNode"])("",!0),Object(o["createElementVNode"])("p",{innerHTML:e.$sanitize(e.statusLevelHtml)},null,8,h),Object(o["createElementVNode"])("ul",null,[(Object(o["openBlock"])(!0),Object(o["createElementBlock"])(o["Fragment"],null,Object(o["renderList"])(e.pagedChallenges,t=>(Object(o["openBlock"])(),Object(o["createElementBlock"])("li",{key:t.id,class:Object(o["normalizeClass"])(["tourChallenge",t.id]),title:t.description},[t.isCompleted||t.isSkipped?(Object(o["openBlock"])(),Object(o["createElementBlock"])("span",{key:0,class:"icon-ok",title:e.translate("Tour_ChallengeCompleted")},null,8,k)):(Object(o["openBlock"])(),Object(o["createElementBlock"])("a",{key:1,href:"javascript:void 0;",class:"skip-challenge",title:e.translate("Tour_SkipThisChallenge"),onClick:n=>e.skipChallenge(t.id)},C,8,v)),Object(o["createTextVNode"])(Object(o["toDisplayString"])(" ")+" "),e.$sanitizeUrl(t.url)?(Object(o["openBlock"])(),Object(o["createElementBlock"])("a",{key:2,href:e.$sanitizeUrl(t.url),target:"_blank",rel:"noreferrer noopener"},Object(o["toDisplayString"])(t.name),9,N)):(Object(o["openBlock"])(),Object(o["createElementBlock"])(o["Fragment"],{key:3},[Object(o["createTextVNode"])(Object(o["toDisplayString"])(t.name),1)],64))],10,f))),128))]),E,Object(o["createElementVNode"])("p",T,[e.hasPrevPage?(Object(o["openBlock"])(),Object(o["createElementBlock"])("a",{key:0,class:"previousChallenges",onClick:t[0]||(t[0]=t=>e.currentPage-=1)}," ‹ "+Object(o["toDisplayString"])(e.hasNextPage?e.translate("General_Previous"):e.translate("Tour_PreviousChallenges")),1)):Object(o["createCommentVNode"])("",!0),e.hasPrevPage&&e.hasNextPage?(Object(o["openBlock"])(),Object(o["createElementBlock"])(o["Fragment"],{key:1},[Object(o["createTextVNode"])(" | ")],64)):Object(o["createCommentVNode"])("",!0),e.hasNextPage?(Object(o["openBlock"])(),Object(o["createElementBlock"])("a",{key:2,class:"nextChallenges",onClick:t[1]||(t[1]=t=>e.currentPage+=1)},Object(o["toDisplayString"])(e.hasPrevPage?e.translate("General_Next"):e.translate("Tour_NextChallenges"))+" › ",1)):Object(o["createCommentVNode"])("",!0)]),B,Object(o["createElementVNode"])("p",{class:"tourSuperUserNote",innerHTML:e.$sanitize(e.superUserNoteHtml)},null,8,x)]))],64)):Object(o["createCommentVNode"])("",!0)])}var P=n("19dc");const V=5;var H=Object(o["defineComponent"])({components:{ActivityIndicator:P["ActivityIndicator"]},data(){return{loading:!0,challenges:[],level:null,currentPage:0}},computed:{isCompleted(){return this.challenges.every(e=>e.isCompleted||e.isSkipped)},pagedChallenges(){const e=this.currentPage*V;return this.challenges.slice(e,e+V)},totalPages(){return Math.ceil(this.challenges.length/V)},hasPrevPage(){return this.currentPage>0},hasNextPage(){return this.currentPage<this.totalPages-1},statusLevelHtml(){return this.level?Object(P["translate"])("Tour_StatusLevel",`<strong>${this.level.currentLevelName}</strong>`,String(this.level.challengesNeededForNextLevel),`<strong>${this.level.nextLevelName}</strong>`):""},youCanCallYourselfHtml(){return Object(P["translate"])("Tour_YouCanCallYourselfExpert",'<strong class="successStar">',"</strong>")},shareHtml(){if(!this.level)return"";const e=encodeURIComponent(Object(P["translate"])("Tour_ShareAllChallengesCompleted",this.level.currentLevelName)),t=encodeURIComponent("https://matomo.org"),n=`http://twitter.com/share?text=${e}&url=${t}`;return Object(P["translate"])("Tour_ShareYourAchievementOn",`<a target="_blank" rel="noreferrer noopener" href="${n}">Twitter</a>`)},superUserNoteHtml(){const e="https://matomo.org/faq/general/faq_35/";return Object(P["translate"])("Tour_OnlyVisibleToSuperUser",Object(P["externalLink"])(e),"</a>")}},mounted(){this.fetchData(),window.addEventListener("focus",this.onFocus)},beforeUnmount(){window.removeEventListener("focus",this.onFocus)},methods:{translate:P["translate"],onFocus(){this.fetchData()},async fetchData(){try{const[e,t]=await Promise.all([P["AjaxHelper"].fetch({method:"Tour.getChallenges"}),P["AjaxHelper"].fetch({method:"Tour.getLevel"})]);if(this.challenges=e,this.level=t,!this.loading)return;const n=e.findIndex(e=>!e.isCompleted&&!e.isSkipped),l=-1===n?e.length:n;this.currentPage=Math.floor(l/V)}catch(e){}finally{this.loading=!1}},async skipChallenge(e){const t=this.challenges.find(t=>t.id===e);t&&(t.isSkipped=!0);try{await P["AjaxHelper"].post({method:"Tour.skipChallenge",id:e})}catch(n){t&&(t.isSkipped=!1)}}}});H.render=S;var L=H;/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */}})}));//# sourceMappingURL=Tour.umd.min.js.map12345{ "dependsOn": [ "CoreHome" ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303<!-- Matomo - free/libre analytics platform
@link https://matomo.org @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later-->
<template> <div class="widgetBody tourEngagement"> <ActivityIndicator v-if="loading" :loading="true" /> <template v-else-if="level"> <p aria-hidden="true"> <template v-for="i in level.numLevelsTotal" :key="i" > <span class="icon-star" :class="level.currentLevel >= i ? 'successStar' : 'upgradeStar'" /> <!-- keep the space the server-rendered template had between stars --> {{ ' ' }} </template> </p>
<div v-if="isCompleted"> <p> <strong class="completed"> {{ translate('Tour_CompletionTitle') }} </strong> {{ translate('Tour_CompletionMessage') }} <br><br> <span v-html="$sanitize(youCanCallYourselfHtml)" /> <br><br> <span v-html="$sanitize(shareHtml)" /> </p> </div>
<div v-else> <p v-if="level.description"> {{ level.description }} </p> <p v-html="$sanitize(statusLevelHtml)" />
<ul> <li v-for="challenge in pagedChallenges" :key="challenge.id" class="tourChallenge" :class="challenge.id" :title="challenge.description" > <span v-if="challenge.isCompleted || challenge.isSkipped" class="icon-ok" :title="translate('Tour_ChallengeCompleted')" /> <a v-else href="javascript:void 0;" class="skip-challenge" :title="translate('Tour_SkipThisChallenge')" @click="skipChallenge(challenge.id)" > <span class="icon-hide" /> </a> <!-- keep the space the server-rendered template had between the status icon and the challenge link --> {{ ' ' }} <a v-if="$sanitizeUrl(challenge.url)" :href="$sanitizeUrl(challenge.url)" target="_blank" rel="noreferrer noopener" > {{ challenge.name }} </a> <template v-else> {{ challenge.name }} </template> </li> </ul>
<hr> <p style="text-align:center;padding-bottom:0;"> <a v-if="hasPrevPage" class="previousChallenges" @click="currentPage -= 1" > ‹ {{ hasNextPage ? translate('General_Previous') : translate('Tour_PreviousChallenges') }} </a> <template v-if="hasPrevPage && hasNextPage"> | </template> <a v-if="hasNextPage" class="nextChallenges" @click="currentPage += 1" > {{ hasPrevPage ? translate('General_Next') : translate('Tour_NextChallenges') }} › </a> </p> <hr> <p class="tourSuperUserNote" v-html="$sanitize(superUserNoteHtml)" /> </div> </template> </div></template>
<script lang="ts">import { defineComponent } from 'vue';import { AjaxHelper, ActivityIndicator, translate, externalLink,} from 'CoreHome';
const PER_PAGE = 5;
interface Challenge { id: string; name: string; description: string; isCompleted: boolean; isSkipped: boolean; url: string;}
interface Level { description: string; currentLevel: number; currentLevelName: string; nextLevelName: string; numLevelsTotal: number; challengesNeededForNextLevel: number;}
export default defineComponent({ components: { ActivityIndicator, }, data() { return { loading: true, challenges: [] as Challenge[], level: null as Level | null, currentPage: 0, }; }, computed: { isCompleted(): boolean { return this.challenges.every( (c) => c.isCompleted || c.isSkipped, ); }, pagedChallenges(): Challenge[] { const start = this.currentPage * PER_PAGE; return this.challenges.slice(start, start + PER_PAGE); }, totalPages(): number { return Math.ceil( this.challenges.length / PER_PAGE, ); }, hasPrevPage(): boolean { return this.currentPage > 0; }, hasNextPage(): boolean { return this.currentPage < this.totalPages - 1; }, statusLevelHtml(): string { if (!this.level) { return ''; } return translate( 'Tour_StatusLevel', `<strong>${this.level.currentLevelName}</strong>`, String(this.level.challengesNeededForNextLevel), `<strong>${this.level.nextLevelName}</strong>`, ); }, youCanCallYourselfHtml(): string { return translate( 'Tour_YouCanCallYourselfExpert', '<strong class="successStar">', '</strong>', ); }, shareHtml(): string { if (!this.level) { return ''; } const shareText = encodeURIComponent( translate( 'Tour_ShareAllChallengesCompleted', this.level.currentLevelName, ), ); const url = encodeURIComponent('https://matomo.org'); const shareUrl = `http://twitter.com/share?text=${shareText}&url=${url}`; return translate( 'Tour_ShareYourAchievementOn', `<a target="_blank" rel="noreferrer noopener" href="${shareUrl}">Twitter</a>`, ); }, superUserNoteHtml(): string { const faqUrl = 'https://matomo.org/faq/' + 'general/faq_35/'; return translate( 'Tour_OnlyVisibleToSuperUser', externalLink(faqUrl), '</a>', ); }, }, mounted() { this.fetchData(); window.addEventListener('focus', this.onFocus); }, beforeUnmount() { window.removeEventListener('focus', this.onFocus); }, methods: { translate,
onFocus() { this.fetchData(); },
async fetchData() { try { const [challenges, level] = await Promise.all([ AjaxHelper.fetch<Challenge[]>({ method: 'Tour.getChallenges', }), AjaxHelper.fetch<Level>({ method: 'Tour.getLevel', }), ]);
this.challenges = challenges; this.level = level;
if (!this.loading) { return; }
// set initial page to first uncompleted const firstIncomplete = challenges.findIndex( (c) => !c.isCompleted && !c.isSkipped, ); const done = firstIncomplete === -1 ? challenges.length : firstIncomplete; this.currentPage = Math.floor(done / PER_PAGE); } catch { // silently keep current state on error } finally { this.loading = false; } },
async skipChallenge(id: string) { const challenge = this.challenges.find( (c) => c.id === id, ); if (challenge) { challenge.isSkipped = true; }
try { await AjaxHelper.post({ method: 'Tour.skipChallenge', id, }); } catch { if (challenge) { challenge.isSkipped = false; } } }, },});</script>12345678/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */
export { default as BecomeMatomoExpert } from './BecomeMatomoExpert/BecomeMatomoExpert.vue';123456789tests/UI/expected-screenshots/*.png filter=lfs diff=lfs merge=lfs
# Files excluded from git packagestests/ export-ignore.github/ export-ignore.gitignore export-ignore.gitattributes export-ignore.travis.yml export-ignore
1234567891011121314151617181920212223242526272829303132# Action for running tests
name: AI Checklist
on: pull_request: types: [opened, synchronize, reopened, edited]
permissions: actions: read checks: none contents: none deployments: none issues: none packages: none pull-requests: read repository-projects: none security-events: none statuses: none
concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true
jobs: AiChecklist: runs-on: ubuntu-24.04 strategy: fail-fast: false steps: - name: Run tests uses: matomo-org/github-action-checklist-gate@main1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374# Action for running tests# This file has been automatically created.# To recreate it you can run this command# ./console generate:test-action --plugin="TrackingSpamPrevention" --php-versions="matomo5_min_php,matomo5_max_php" --schedule-cron="40 2 * * 6"
name: Plugin TrackingSpamPrevention Tests
on: pull_request: types: [opened, synchronize] push: branches: - '**.x-dev' workflow_dispatch: schedule: - cron: "40 2 * * 6"
permissions: actions: read checks: none contents: read deployments: none issues: read packages: none pull-requests: read repository-projects: none security-events: none statuses: none
concurrency: group: php-${{ github.ref }} cancel-in-progress: true
jobs: PluginTests: runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: php: [ 'matomo5_min_php', 'matomo5_max_php' ] target: ['minimum_required_matomo', 'maximum_supported_matomo'] steps: - uses: actions/checkout@v3 with: lfs: true persist-credentials: false - name: Install package ripgrep run: sudo apt-get install ripgrep - name: Run tests uses: matomo-org/github-action-tests@main with: plugin-name: 'TrackingSpamPrevention' php-version: ${{ matrix.php }} test-type: 'PluginTests' matomo-test-branch: ${{ matrix.target }} artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} upload-artifacts: ${{ matrix.php == 'matomo5_min_php' && matrix.target == 'maximum_supported_matomo' }} UI: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 with: lfs: true persist-credentials: false - name: running tests uses: matomo-org/github-action-tests@main with: plugin-name: 'TrackingSpamPrevention' matomo-test-branch: 'maximum_supported_matomo' test-type: 'UI' php-version: 'matomo5_min_php' node-version: '16' artifacts-pass: ${{ secrets.ARTIFACTS_PASS }} upload-artifacts: true12345678910111213141516171819202122232425262728293031323334353637383940414243name: PHPCS check
on: pull_request
permissions: actions: read checks: read contents: read deployments: none issues: read packages: none pull-requests: read repository-projects: none security-events: none statuses: read
jobs: phpcs: name: PHPCS runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 with: lfs: false persist-credentials: false - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '7.4' tools: cs2pr - name: Install dependencies run: composer init --name=matomo/trackingspamprevention --quiet; composer --no-plugins config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -n; composer config repositories.matomo-coding-standards vcs https://github.com/matomo-org/matomo-coding-standards -n; composer require matomo-org/matomo-coding-standards:dev-master; composer install --dev --prefer-dist --no-progress --no-suggest - name: Check PHP code styles id: phpcs run: ./vendor/bin/phpcs --report-full --standard=phpcs.xml --report-checkstyle=./phpcs-report.xml - name: Show PHPCS results in PR if: ${{ always() && steps.phpcs.outcome == 'failure' }} run: cs2pr ./phpcs-report.xml --prepend-filename12345678910111213141516171819202122232425262728293031323334353637<?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\TrackingSpamPrevention;
use Matomo\Network\IP;
class AllowListIpRange{ /** * @var Configuration */ private $configuration;
public function __construct(Configuration $configuration) { $this->configuration = $configuration; }
public function isAllowed($ip) { $rangesAllowed = $this->configuration->getIpRangesAlwaysAllowed();
if (!empty($rangesAllowed)) { $ip = IP::fromStringIP($ip); return $ip->isInRanges($rangesAllowed); }
return false; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899<?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\TrackingSpamPrevention;
use Piwik\Common;use Piwik\Log;use Piwik\Mail;use Piwik\Piwik;use Piwik\SettingsPiwik;
class BanIpNotificationEmail{ public function send($ipRange, $ip, $email, $maxActionsAllowed, $locationData, $nowDateTime) { if (empty($email) || !Piwik::isValidEmailString($email)) { return; }
$mail = new Mail(); $mail->addTo($email); $mail->setSubject('An IP was banned as too many actions were tracked.'); $mail->setDefaultFromPiwik(); if ( empty($mail->getFromName()) || in_array($mail->getFromName(), [ 'CoreHome_WebAnalyticsReports', 'TagManager_MatomoTagName' ]) ) { $mail->setFrom($mail->getFrom(), 'Web Analytics Reports'); }
$mailBody = 'This is for your information. The following IP was banned because visit tried to track more than ' . Common::sanitizeInputValue($maxActionsAllowed) . ' actions:'; $mailBody .= PHP_EOL . PHP_EOL . '"' . Common::sanitizeInputValue($ipRange) . '"' . PHP_EOL; $instanceId = SettingsPiwik::getPiwikInstanceId(); $matomoUrl = SettingsPiwik::getPiwikUrl(); if (!empty($matomoUrl)) { $url = parse_url($matomoUrl); $matomoHost = $url['host']; }
if (!empty($_GET)) { $get = $_GET; if (isset($get['token_auth'])) { $get['token_auth'] = 'XYZANONYMIZED'; } } else { $get = []; }
if (!empty($_POST)) { $post = $_POST; if (isset($post['token_auth'])) { $post['token_auth'] = 'XYZANONYMIZED'; } } else { $post = []; }
if (!empty($instanceId)) { $mailBody .= PHP_EOL . 'Instance ID: ' . Common::sanitizeInputValue($instanceId); } if (!empty($matomoHost)) { $mailBody .= PHP_EOL . 'URL: ' . Common::sanitizeInputValue($matomoHost); } $mailBody .= PHP_EOL . 'Current date (UTC): ' . Common::sanitizeInputValue($nowDateTime) . 'IP as detected in header: ' . Common::sanitizeInputValue($ip) . 'GET request info: ' . json_encode($get) . 'POST request info: ' . json_encode($post) . PHP_EOL;
if (!empty($locationData)) { $mailBody .= 'Geo IP info: ' . json_encode($locationData) . PHP_EOL; }
if (!empty($_SERVER['HTTP_USER_AGENT'])) { $mailBody .= 'User Agent: ' . Common::sanitizeInputValue($_SERVER['HTTP_USER_AGENT']) . PHP_EOL; }
$mail->setBodyText($mailBody);
$testMode = (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE); if ($testMode) { Log::info($mail->getSubject() . ':' . $mail->getBodyText()); } else { $mail->send(); }
$a = $mail->getBodyText();
return $mail->getBodyText(); }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879<?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\TrackingSpamPrevention;
use Piwik\Plugins\UserCountry\LocationProvider;use Piwik\Plugins\UserCountry\VisitorGeolocator;
class BlockedGeoIp{ /** * @var array */ private $blockedProviders;
public function __construct($blockedProviders = []) { $this->blockedProviders = $blockedProviders; }
public function detectLocation($ip, $language) { // we need to use both IP and language so it will use the same cache key as in core! $visitorLocator = new VisitorGeolocator(); $info = array('lang' => $language, 'ip' => $ip); return $visitorLocator->getLocation($info, $useClassCache = true); }
public function isExcludedCountry($ip, $language, $excludedCountries, $includedCountries) { if (empty($excludedCountries) && empty($includedCountries)) { return false; }
$result = $this->detectLocation($ip, $language); if (empty($result[LocationProvider::COUNTRY_CODE_KEY])) { return false; }
$countryCode = strtolower($result[LocationProvider::COUNTRY_CODE_KEY]);
if (!empty($includedCountries) && in_array($countryCode, $includedCountries, true)) { return false; } elseif (!empty($includedCountries)) { return true; }
if (!empty($excludedCountries) && in_array($countryCode, $excludedCountries, true)) { return true; }
return false; }
public function isExcludedProvider($ip, $language) { if (empty($this->blockedProviders) || !(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('UserCountry'))) { return false; } $result = $this->detectLocation($ip, $language);
if (!empty($result[LocationProvider::ORG_KEY])) { $org = $result[LocationProvider::ORG_KEY]; foreach ($this->blockedProviders as $blockedProvider) { if (!empty($blockedProvider) && stripos($org, $blockedProvider) !== false) { return true; } } }
return false; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195<?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\TrackingSpamPrevention;
use Matomo\Network\IP;use Piwik\Cache as PiwikCache;use Piwik\Common;use Piwik\Option;use Piwik\Piwik;use Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\IpRangeProviderInterface;use Piwik\SettingsPiwik;use Piwik\Tracker\Cache;
class BlockedIpRanges{ public const OPTION_KEY = 'TrackingSpamBlockedIpRanges';
/** * @var IpRangeProviderInterface[] */ private $providers;
/** * @var Configuration */ private $configuration;
/** * @param IpRangeProviderInterface[] $providers * @param Configuration $configuration */ public function __construct($providers, Configuration $configuration) { $this->providers = $providers; $this->configuration = $configuration; }
/** * will return the array indexed by ip start * @return array */ public function getBlockedRanges() { $ranges = Option::get(self::OPTION_KEY); if (empty($ranges)) { return []; } $ranges = json_decode($ranges, true); if (empty($ranges)) { return []; } return $ranges; }
/** * An array of blocked ranges * @param array[] $ranges */ public function setBlockedRanges($ranges) { // we index them by first character for performance reasons see the excluded method Option::set(self::OPTION_KEY, json_encode($ranges)); }
private function getIndexForIpOrRange($ipOrRange) { if (empty($ipOrRange)) { return; } // when IP is 10.11.12.13 then we return "10." // when IP is f::0 then we return "f:" foreach (['.', ':'] as $searchChar) { $posSearchChar = strpos($ipOrRange, $searchChar); if ($posSearchChar !== false) { return Common::mb_substr($ipOrRange, 0, $posSearchChar) . $searchChar; } }
// fallback, should not happen return Common::mb_substr($ipOrRange, 0, 1); }
public function isExcluded($ip) { if (empty($ip)) { return false; }
if (!filter_var($ip, FILTER_VALIDATE_IP)) { return false; }
// for performance reasons we index ranges by first character of ip. assuming this works in most cases. // so we compare less ranges as it is slow to compare many ranges $indexed = $this->getIndexForIpOrRange($ip);
if (empty($indexed)) { return false; }
$trackerCache = Cache::getCacheGeneral(); if (empty($trackerCache[self::OPTION_KEY][$indexed])) { return; }
$ip = IP::fromStringIP($ip); $key = 'TrackingSpamPreventionIsIpInRange' . $ip->toString();
$cache = PiwikCache::getTransientCache(); if ($cache->contains($key)) { $isInRanges = $cache->fetch($key); } else { $isInRanges = $ip->isInRanges($trackerCache[self::OPTION_KEY][$indexed]);
$cache->save($key, $isInRanges); }
return $isInRanges; }
public function banIp($ip) { $ranges = $this->getBlockedRanges(); $index = $this->getIndexForIpOrRange($ip); if (empty($ranges[$index])) { $ranges[$index] = []; }
if (strpos($ip, '.') !== false) { $ipRange = $ip . '/32'; } else { $ipRange = $ip . '/128'; }
if (!in_array($ipRange, $ranges[$index], true)) { $ranges[$index][] = $ipRange; $this->setBlockedRanges($ranges);
/** * This event is posted when an IP is being banned from tracking. You can use it for example to notify someone * that this IP was banned. * * @param string $ipRange The IP range that will be blocked * @param string $ip The IP that caused this range to be blocked */ Piwik::postEvent('TrackingSpamPrevention.banIp', [$ipRange, $ip]); }
return $ranges; }
public function unsetAllIpRanges() { $this->setBlockedRanges([]); }
public function updateBlockedIpRanges() { if (!SettingsPiwik::isInternetEnabled()) { $this->unsetAllIpRanges(); return; }
$ranges = [];
foreach ($this->providers as $provider) { try { $ranges = array_merge($ranges, $provider->getRanges()); } catch (\Exception $e) { if ($this->configuration->shouldThrowExceptionOnIpRangeSync()) { throw $e; } } }
$indexedRange = []; if (!empty($ranges)) { foreach ($ranges as $range) { $indexed = $this->getIndexForIpOrRange($range); if (empty($indexedRange[$indexed])) { $indexedRange[$indexed] = []; } $indexedRange[$indexed][] = $range; } } $this->setBlockedRanges($indexedRange); }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768<?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\TrackingSpamPrevention\BlockedIpRanges;
use Piwik\Http;
class Aws implements IpRangeProviderInterface{ public function getRanges(): array { $ranges = [];
$aws = Http::sendHttpRequest( 'https://ip-ranges.amazonaws.com/ip-ranges.json', 120, null, null, 0, false, false, false, 'GET', null, null, false );
if (empty($aws)) { throw new \Exception('Failed to retrieve AWS IP ranges'); }
$aws = json_decode($aws, true);
if (empty($aws)) { throw new \Exception('Failed to retrieve AWS IP ranges: ' . json_last_error_msg()); } if (empty($aws['prefixes'])) { throw new \Exception('Failed to retrieve AWS IPv4 range prefixes'); } if (empty($aws['ipv6_prefixes'])) { throw new \Exception('Failed to retrieve AWS IPv6 range prefixes'); }
foreach ($aws['prefixes'] as $range) { if (isset($range['ip_prefix'])) { $ranges[] = $range['ip_prefix']; } } foreach ($aws['ipv6_prefixes'] as $range) { if (isset($range['ipv6_prefix'])) { $ranges[] = $range['ipv6_prefix']; } }
if (empty($ranges)) { throw new \Exception('Failed to retrieve any AWS IP range.'); }
return $ranges; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384<?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\TrackingSpamPrevention\BlockedIpRanges;
use Piwik\Common;use Piwik\Http;
class Azure implements IpRangeProviderInterface{ public function getRanges(): array { $ranges = [];
$downloadUrl = $this->getDownloadUrl();
$azure = Http::sendHttpRequest($downloadUrl, 120);
if (empty($azure)) { throw new \Exception('Failed to retrieve azure IP ranges'); } $azure = json_decode($azure, true); if (empty($azure)) { throw new \Exception('Failed to retrieve azure IP ranges: ' . json_last_error_msg()); } if (empty($azure['values'])) { throw new \Exception('Failed to retrieve azure IP range values'); }
$azureValues = $azure['values']; foreach ($azureValues as $azureValue) { if (!isset($azureValue['properties']['addressPrefixes'])) { throw new \Exception('Failed to get azure address prefixes'); } foreach ($azureValue['properties']['addressPrefixes'] as $ip) { $ranges[] = $ip; } }
return $ranges; }
public function getDownloadUrl() { // get info somehow for up to date from url https://www.microsoft.com/en-us/download/confirmation.aspx?id=56519
// see also https://docs.microsoft.com/en-us/azure/virtual-network/service-tags-overview . // The api itself we don't really want to use. We'd need a subscriptionId. Unless we fetch it on a matomo server and make it available through a JSON there but then not sure if we are allowed to do that // or can we get it differently? Like do they have a fixed URL or so? // seems we could maybe assume the URL always stays the same except for the date part but then we'd need to check which date works (I've seen older URLs with same strucutre only date different) // might be easiest to fetch "details" page and then extract the URL from there? // should look like 'https://download.microsoft.com/download/7/1/D/71D86715-5596-4529-9B13-DA13A5DE5B63/ServiceTags_Public_20201207.json'
$contentDownloadPage = Http::sendHttpRequest('https://www.microsoft.com/en-us/download/details.aspx?id=56519', 120); $prefixUrl = 'url":"'; $prefixStrLen = mb_strlen($prefixUrl, 'UTF-8'); $posStart = mb_strpos($contentDownloadPage, $prefixUrl . 'https://download.microsoft.com/download/', 0, 'UTF-8'); $posEnd = mb_strpos($contentDownloadPage, '.json"', $posStart + $prefixStrLen, 'UTF-8'); // we don't want to match the " in url":" $contentDownloadPage = mb_substr( $contentDownloadPage, $posStart + $prefixStrLen, $posEnd - $posStart - $prefixStrLen, 'UTF-8' ); $downloadUrl = trim($contentDownloadPage, '="' . "'") . '.json'; $downloadUrl = trim($downloadUrl);
if (strpos($downloadUrl, 'http') !== 0) { throw new \Exception('Expected download URL for Azure IP ranges to start with HTTP but it does not. It is: ' . $downloadUrl); }
if (!Common::stringEndsWith($downloadUrl, '.json')) { throw new \Exception('Expected download URL for Azure IP ranges to end with ".json" but it does not. It is: ' . $downloadUrl); }
return $downloadUrl; }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546<?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\TrackingSpamPrevention\BlockedIpRanges;
use Piwik\Http;
class DigitalOcean implements IpRangeProviderInterface{ public function getRanges(): array { $ranges = [];
$digitalOcean = Http::sendHttpRequest('https://www.digitalocean.com/geo/google.csv', 120, null, null, 0, false, false, true);
if (empty($digitalOcean) || empty($digitalOcean['status']) || $digitalOcean['status'] != 200) { throw new \Exception('Failed to retrieve digital ocean IP ranges'); }
if (empty($digitalOcean['data'])) { return []; }
$digitalOcean = str_getcsv($digitalOcean['data']);
if (empty($digitalOcean)) { throw new \Exception('Failed to parse digital ocean IP ranges'); }
foreach ($digitalOcean as $block) { $ranges[] = $block[0]; }
if (empty($ranges)) { throw new \Exception('Failed to retrieve any digital ocean IP range.'); }
return $ranges; }}123456789101112131415161718192021<?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\TrackingSpamPrevention\BlockedIpRanges;
/** * For tests only */class ExceptionRange implements IpRangeProviderInterface{ public function getRanges(): array { throw new \Exception('Failed to get any range'); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<?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\TrackingSpamPrevention\BlockedIpRanges;
use Piwik\Http;
class Gcloud implements IpRangeProviderInterface{ public function getRanges(): array { $ranges = [];
$gcloud = Http::sendHttpRequest('https://www.gstatic.com/ipranges/cloud.json', 120);
if (empty($gcloud)) { throw new \Exception('Failed to retrieve gcloud IP ranges'); }
$gcloud = json_decode($gcloud, true);
if (empty($gcloud)) { throw new \Exception('Failed to retrieve gcloud IP ranges: ' . json_last_error_msg()); }
if (empty($gcloud['prefixes'])) { throw new \Exception('Failed to retrieve gcloud IP range values'); }
foreach ($gcloud['prefixes'] as $prefix) { if (isset($prefix['ipv4Prefix'])) { $ranges[] = $prefix['ipv4Prefix']; } if (isset($prefix['ipv6Prefix'])) { $ranges[] = $prefix['ipv6Prefix']; } }
if (empty($ranges)) { throw new \Exception('Failed to retrieve any gcloud IP range.'); }
return $ranges; }}123456789101112131415<?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\TrackingSpamPrevention\BlockedIpRanges;
interface IpRangeProviderInterface{ public function getRanges(): array;}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<?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\TrackingSpamPrevention\BlockedIpRanges;
use Piwik\Http;
class Oracle implements IpRangeProviderInterface{ public function getRanges(): array { $ranges = [];
$oracle = Http::sendHttpRequest('https://docs.cloud.oracle.com/en-us/iaas/tools/public_ip_ranges.json', 120);
if (empty($oracle)) { throw new \Exception('Failed to retrieve oracle IP ranges'); }
$oracle = json_decode($oracle, true);
if (empty($oracle)) { throw new \Exception('Failed to retrieve oracle IP ranges: ' . json_last_error_msg()); }
if (empty($oracle['regions'])) { throw new \Exception('Failed to retrieve oracle IP range regions'); }
foreach ($oracle['regions'] as $region) { foreach ($region['cidrs'] as $cidr) { if (!isset($cidr['cidr'])) { throw new \Exception('Failed to get oracle address prefixes'); } $ranges[] = $cidr['cidr']; } }
if (empty($ranges)) { throw new \Exception('Failed to retrieve any oracle IP range.'); }
return $ranges; }}12345678910111213141516171819202122232425262728293031<?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\TrackingSpamPrevention\BlockedIpRanges;
/** * For tests only */class VariableRange implements IpRangeProviderInterface{ /** * @var string[] */ private $ranges;
public function __construct($ranges) { $this->ranges = $ranges; }
public function getRanges(): array { return $this->ranges; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<?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\TrackingSpamPrevention;
use Piwik\Container\StaticContainer;use Piwik\DeviceDetector\DeviceDetectorFactory;
class BrowserDetection{ public function isHeadlessBrowser($userAgent) { if (empty($userAgent)) { return false; }
$browsers = [ 'HeadlessChrome', 'PhantomJS', 'Electron', 'ApacheBench', // Load test 'Siege/', // Load test 'https://k6.io/', // Load test, Added full URL to handle case where UA can be fook6bar or fook6/ 'Radview', // Load test 'Locust', // Load test 'Cypress' //Testing Tool ]; foreach ($browsers as $browser) { if (stripos($userAgent, $browser) !== false) { return true; } } return false; }
public function isLibrary($userAgent) { if (empty($userAgent)) { return false; } $staticContainer = StaticContainer::get(DeviceDetectorFactory::class)->makeInstance($userAgent);
return $staticContainer->isLibrary(); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869## Changelog
# 5.0.11 - 2026-07-06- Enabled block headless browser by default
# 5.0.10 - 2026-06-22- Removed Verein zur Foerderung eines Deutschen Forschungsnetzes (DFN) from the default block list
# 5.0.9 - 2026-05-11- Added code to block more providers by default
# 5.0.8 - 2025-05-26- Fixed broken Azure link for looking up IP ranges
# 5.0.7 - 2025-01-06- Added Matomo URL to email report
# 5.0.6 - 2024-12-09- Fixed broken Azure link for looking up IP ranges
# 5.0.5 - 2024-10-24- Look for headless browser in clientHints to detect spam
# 5.0.4 - 2024-10-21- Compatability with PHP 8.4
# 5.0.3- Textual changes
# 5.0.2- Added plugin category for Marketplace
# 5.0.1- Fix issue where max action limit was blocking IP addresses from the allow list
# 5.0.0- Compatibility with Matomo 5.0
# 4.1.7- Fixed Azure IP ranges download URL parsing code better accounting for character encoding
# 4.1.6- Started including userAgent in the banned IP email
# 4.1.5- Azure IP ranges download code updated and added tests to alert if download fails
# 4.1.4- Add new command to block new organisations `./console trackingspamprevention:block-geo-ip-organisation --organisation-name="Example"`
# 4.1.3- Translation changes- Added code to not throw exception if digitalOcean file is empty
# 4.1.2- Fix location data in email to show IP instead of IP range- Started blocking digital ocean through providers.- Stopped checking GeoIp DB if UserCountry plugin is disabled- Azure IP ranges download code updated
# 4.1.1- Fixed IP ban notification email leading to internal sever error
# 4.1.0- Exclude user agents from load testing services- Exclude user agents from server side tracking SDK by enabling an option
# 4.0.0* Initial version123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051<?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\TrackingSpamPrevention\Commands;
use Piwik\Plugin\ConsoleCommand;use Piwik\Config;use Piwik\Plugins\TrackingSpamPrevention\Configuration;
class BlockGeoIpOrganisation extends ConsoleCommand{ protected function configure() { $this->setName('trackingspamprevention:block-geo-ip-organisation'); $this->setDescription('Blocks a new GeoIP organisation. It will save the organisation in the config file.'); $this->addRequiredValueOption('organisation-name', null, 'Name of the organisation to block:'); }
/** * @return int */ protected function doExecute(): int { $input = $this->getInput(); $output = $this->getOutput(); $this->checkAllRequiredOptionsAreNotEmpty();
$config = Config::getInstance(); $pluginConfig = $config->TrackingSpamPrevention;
if (empty($pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS])) { $pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS] = []; }
$name = $input->getOption('organisation-name'); $pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS][] = mb_strtolower(trim($name));
$pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS] = array_values(array_unique($pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS]));
$config->TrackingSpamPrevention = $pluginConfig; $config->forceSave();
return self::SUCCESS; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181<?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\TrackingSpamPrevention;
use Piwik\Config;
class Configuration{ public const DEFAULT_RANGE_THROW_EXCEPTION = 0; public const DEFAULT_RANGE_ALLOW_LIST = ['']; public const DEFAULT_GEOIP_MATCH_PROVIDERS = [ 'alicloud', 'alibaba cloud', 'kwaifong group limited', 'contabo', 'digitalocean', 'digital ocean', 'leaseweb', 'hostroyale technologies', 'ucloud information', 'secure internet llc', 'inios oy', 'fnk llc', 'dedipath-llc', 'mirholding b.v.', 'datacamp limited', 'voxility llp', 'lucidacloud', 'cloud computing corporation', 'gigabit hosting', 'hetzner online', 'm247 europe srl', 'incognet llc', 'ponynet', 'as40676', 'nforce entertainment b.v.', 'trabia srl', 'latitude-sh', 'dataforest gmbh', '31173 services ab', 'advin services llc', 'wholesale services provider', 'netminders', 'altushost b.v.', 'amazon-02', 'akamai connected cloud', 'uab cherry servers', 'datema bilisim ticaret anonim sirketi', 'alibaba us technology co., ltd.', 'netcup gmbh', 'jinx co., limited', 'fd-298-8796', 'cloudsingularity', 'weserve b.v.', 'amarutu technology ltd', 'limestonenetworks', 'versija sia', 'oy crea nova hosting solution ltd', 'owl limited', 'tzulo', 'serverastra kft', 'ionos se', 'as-globaltelehost', 'estnoc oy', 'as-colocrossing', 'greenhost bv', 'keminet shpk', 'worldstream b.v.', 'aeza international ltd', 'asline limited', 'packethub s.a.', 'gorillaservers', 'as-vultr', 'nl-811-40021', 'cheapy-host', 'jsc selectel', 'gb network solutions sdn. bhd.', 'latitude.sh', 'limestone networks, inc', 'scaleway', 'm247 europe', ];
public const KEY_RANGE_THROW_EXCEPTION = 'block_cloud_sync_throw_exception_on_error'; public const KEY_RANGE_ALLOW_LIST = 'iprange_allowlist'; public const KEY_GEOIP_MATCH_PROVIDERS = 'block_geoip_organisations';
public function install() { $config = $this->getConfig();
$default = $config->TrackingSpamPrevention; if (empty($default)) { $default = array(); }
if (empty($default[self::KEY_RANGE_THROW_EXCEPTION])) { $default[self::KEY_RANGE_THROW_EXCEPTION] = self::DEFAULT_RANGE_THROW_EXCEPTION; } if (empty($default[self::KEY_RANGE_ALLOW_LIST])) { $default[self::KEY_RANGE_ALLOW_LIST] = self::DEFAULT_RANGE_ALLOW_LIST; } if (empty($default[self::KEY_GEOIP_MATCH_PROVIDERS])) { $default[self::KEY_GEOIP_MATCH_PROVIDERS] = self::DEFAULT_GEOIP_MATCH_PROVIDERS; }
$config->TrackingSpamPrevention = $default;
$config->forceSave(); }
public function uninstall() { $config = $this->getConfig(); $config->TrackingSpamPrevention = array(); $config->forceSave(); }
/** * @return bool */ public function shouldThrowExceptionOnIpRangeSync() { $value = $this->getConfigValue(self::KEY_RANGE_THROW_EXCEPTION, self::DEFAULT_RANGE_THROW_EXCEPTION);
if ($value === false || $value === '' || $value === null) { $value = self::KEY_RANGE_THROW_EXCEPTION; }
return (bool) $value; }
/** * @return array */ public function getIpRangesAlwaysAllowed() { $value = $this->getConfigValue(self::KEY_RANGE_ALLOW_LIST, self::DEFAULT_RANGE_ALLOW_LIST);
if (empty($value) || !is_array($value)) { $value = self::DEFAULT_RANGE_ALLOW_LIST; }
$value = array_values(array_filter($value)); $value = array_map(function ($range) { if (strpos($range, '/') === false) { // we assume user did not enter a range so we make it one that matches that one ip if (strpos($range, '.') !== false) { $range .= '/32'; } elseif (strpos($range, ':') !== false) { $range .= '/128'; } } return $range; }, $value);
return $value; }
private function getConfig() { return Config::getInstance(); }
private function getConfigValue($name, $default) { $config = $this->getConfig(); $attribution = $config->TrackingSpamPrevention; if (isset($attribution[$name])) { return $attribution[$name]; } return $default; }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license forsoftware and other kinds of works.
The licenses for most software and other practical works are designedto take away your freedom to share and change the works. By contrast,the GNU General Public License is intended to guarantee your freedom toshare and change all versions of a program--to make sure it remains freesoftware for all its users. We, the Free Software Foundation, use theGNU General Public License for most of our software; it applies also toany other work released this way by its authors. You can apply it toyour programs, too.
When we speak of free software, we are referring to freedom, notprice. Our General Public Licenses are designed to make sure that youhave the freedom to distribute copies of free software (and charge forthem if you wish), that you receive source code or can get it if youwant it, that you can change the software or use pieces of it in newfree programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying youthese rights or asking you to surrender the rights. Therefore, you havecertain responsibilities if you distribute copies of the software, or ifyou modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whethergratis or for a fee, you must pass on to the recipients the samefreedoms that you received. You must make sure that they, too, receiveor can get the source code. And you must show them these terms so theyknow their rights.
Developers that use the GNU GPL protect your rights with two steps:(1) assert copyright on the software, and (2) offer you this Licensegiving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explainsthat there is no warranty for this free software. For both users' andauthors' sake, the GPL requires that modified versions be marked aschanged, so that their problems will not be attributed erroneously toauthors of previous versions.
Some devices are designed to deny users access to install or runmodified versions of the software inside them, although the manufacturercan do so. This is fundamentally incompatible with the aim ofprotecting users' freedom to change the software. The systematicpattern of such abuse occurs in the area of products for individuals touse, which is precisely where it is most unacceptable. Therefore, wehave designed this version of the GPL to prohibit the practice for thoseproducts. If such problems arise substantially in other domains, westand ready to extend this provision to those domains in future versionsof the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.States should not allow patents to restrict development and use ofsoftware on general-purpose computers, but in those that do, we wish toavoid the special danger that patents applied to a free program couldmake it effectively proprietary. To prevent this, the GPL assures thatpatents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution andmodification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds ofworks, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under thisLicense. Each licensee is addressed as "you". "Licensees" and"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the workin a fashion requiring copyright permission, other than the making of anexact copy. The resulting work is called a "modified version" of theearlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work basedon the Program.
To "propagate" a work means to do anything with it that, withoutpermission, would make you directly or secondarily liable forinfringement under applicable copyright law, except executing it on acomputer or modifying a private copy. Propagation includes copying,distribution (with or without modification), making available to thepublic, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables otherparties to make or receive copies. Mere interaction with a user througha computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"to the extent that it includes a convenient and prominently visiblefeature that (1) displays an appropriate copyright notice, and (2)tells the user that there is no warranty for the work (except to theextent that warranties are provided), that licensees may convey thework under this License, and how to view a copy of this License. Ifthe interface presents a list of user commands or options, such as amenu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the workfor making modifications to it. "Object code" means any non-sourceform of a work.
A "Standard Interface" means an interface that either is an officialstandard defined by a recognized standards body, or, in the case ofinterfaces specified for a particular programming language, one thatis widely used among developers working in that language.
The "System Libraries" of an executable work include anything, otherthan the work as a whole, that (a) is included in the normal form ofpackaging a Major Component, but which is not part of that MajorComponent, and (b) serves only to enable use of the work with thatMajor Component, or to implement a Standard Interface for which animplementation is available to the public in source code form. A"Major Component", in this context, means a major essential component(kernel, window system, and so on) of the specific operating system(if any) on which the executable work runs, or a compiler used toproduce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means allthe source code needed to generate, install, and (for an executablework) run the object code and to modify the work, including scripts tocontrol those activities. However, it does not include the work'sSystem Libraries, or general-purpose tools or generally available freeprograms which are used unmodified in performing those activities butwhich are not part of the work. For example, Corresponding Sourceincludes interface definition files associated with source files forthe work, and the source code for shared libraries and dynamicallylinked subprograms that the work is specifically designed to require,such as by intimate data communication or control flow between thosesubprograms and other parts of the work.
The Corresponding Source need not include anything that userscan regenerate automatically from other parts of the CorrespondingSource.
The Corresponding Source for a work in source code form is thatsame work.
2. Basic Permissions.
All rights granted under this License are granted for the term ofcopyright on the Program, and are irrevocable provided the statedconditions are met. This License explicitly affirms your unlimitedpermission to run the unmodified Program. The output from running acovered work is covered by this License only if the output, given itscontent, constitutes a covered work. This License acknowledges yourrights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do notconvey, without conditions so long as your license otherwise remainsin force. You may convey covered works to others for the sole purposeof having them make modifications exclusively for you, or provide youwith facilities for running those works, provided that you comply withthe terms of this License in conveying all material for which you donot control copyright. Those thus making or running the covered worksfor you must do so exclusively on your behalf, under your directionand control, on terms that prohibit them from making any copies ofyour copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely underthe conditions stated below. Sublicensing is not allowed; section 10makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technologicalmeasure under any applicable law fulfilling obligations under article11 of the WIPO copyright treaty adopted on 20 December 1996, orsimilar laws prohibiting or restricting circumvention of suchmeasures.
When you convey a covered work, you waive any legal power to forbidcircumvention of technological measures to the extent such circumventionis effected by exercising rights under this License with respect tothe covered work, and you disclaim any intention to limit operation ormodification of the work as a means of enforcing, against the work'susers, your or third parties' legal rights to forbid circumvention oftechnological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as youreceive it, in any medium, provided that you conspicuously andappropriately publish on each copy an appropriate copyright notice;keep intact all notices stating that this License and anynon-permissive terms added in accord with section 7 apply to the code;keep intact all notices of the absence of any warranty; and give allrecipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications toproduce it from the Program, in the form of source code under theterms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independentworks, which are not by their nature extensions of the covered work,and which are not combined with it such as to form a larger program,in or on a volume of a storage or distribution medium, is called an"aggregate" if the compilation and its resulting copyright are notused to limit the access or legal rights of the compilation's usersbeyond what the individual works permit. Inclusion of a covered workin an aggregate does not cause this License to apply to the otherparts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the termsof sections 4 and 5, provided that you also convey themachine-readable Corresponding Source under the terms of this License,in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excludedfrom the Corresponding Source as a System Library, need not beincluded in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means anytangible personal property which is normally used for personal, family,or household purposes, or (2) anything designed or sold for incorporationinto a dwelling. In determining whether a product is a consumer product,doubtful cases shall be resolved in favor of coverage. For a particularproduct received by a particular user, "normally used" refers to atypical or common use of that class of product, regardless of the statusof the particular user or of the way in which the particular useractually uses, or expects or is expected to use, the product. A productis a consumer product regardless of whether the product has substantialcommercial, industrial or non-consumer uses, unless such uses representthe only significant mode of use of the product.
"Installation Information" for a User Product means any methods,procedures, authorization keys, or other information required to installand execute modified versions of a covered work in that User Product froma modified version of its Corresponding Source. The information mustsuffice to ensure that the continued functioning of the modified objectcode is in no case prevented or interfered with solely becausemodification has been made.
If you convey an object code work under this section in, or with, orspecifically for use in, a User Product, and the conveying occurs aspart of a transaction in which the right of possession and use of theUser Product is transferred to the recipient in perpetuity or for afixed term (regardless of how the transaction is characterized), theCorresponding Source conveyed under this section must be accompaniedby the Installation Information. But this requirement does not applyif neither you nor any third party retains the ability to installmodified object code on the User Product (for example, the work hasbeen installed in ROM).
The requirement to provide Installation Information does not include arequirement to continue to provide support service, warranty, or updatesfor a work that has been modified or installed by the recipient, or forthe User Product in which it has been modified or installed. Access to anetwork may be denied when the modification itself materially andadversely affects the operation of the network or violates the rules andprotocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,in accord with this section must be in a format that is publiclydocumented (and with an implementation available to the public insource code form), and must require no special password or key forunpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of thisLicense by making exceptions from one or more of its conditions.Additional permissions that are applicable to the entire Program shallbe treated as though they were included in this License, to the extentthat they are valid under applicable law. If additional permissionsapply only to part of the Program, that part may be used separatelyunder those permissions, but the entire Program remains governed bythis License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your optionremove any additional permissions from that copy, or from any part ofit. (Additional permissions may be written to require their ownremoval in certain cases when you modify the work.) You may placeadditional permissions on material, added by you to a covered work,for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material youadd to a covered work, you may (if authorized by the copyright holders ofthat material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "furtherrestrictions" within the meaning of section 10. If the Program as youreceived it, or any part of it, contains a notice stating that it isgoverned by this License along with a term that is a furtherrestriction, you may remove that term. If a license document containsa further restriction but permits relicensing or conveying under thisLicense, you may add to a covered work material governed by the termsof that license document, provided that the further restriction doesnot survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, youmust place, in the relevant source files, a statement of theadditional terms that apply to those files, or a notice indicatingwhere to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in theform of a separately written license, or stated as exceptions;the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expresslyprovided under this License. Any attempt otherwise to propagate ormodify it is void, and will automatically terminate your rights underthis License (including any patent licenses granted under the thirdparagraph of section 11).
However, if you cease all violation of this License, then yourlicense from a particular copyright holder is reinstated (a)provisionally, unless and until the copyright holder explicitly andfinally terminates your license, and (b) permanently, if the copyrightholder fails to notify you of the violation by some reasonable meansprior to 60 days after the cessation.
Moreover, your license from a particular copyright holder isreinstated permanently if the copyright holder notifies you of theviolation by some reasonable means, this is the first time you havereceived notice of violation of this License (for any work) from thatcopyright holder, and you cure the violation prior to 30 days afteryour receipt of the notice.
Termination of your rights under this section does not terminate thelicenses of parties who have received copies or rights from you underthis License. If your rights have been terminated and not permanentlyreinstated, you do not qualify to receive new licenses for the samematerial under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive orrun a copy of the Program. Ancillary propagation of a covered workoccurring solely as a consequence of using peer-to-peer transmissionto receive a copy likewise does not require acceptance. However,nothing other than this License grants you permission to propagate ormodify any covered work. These actions infringe copyright if you donot accept this License. Therefore, by modifying or propagating acovered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automaticallyreceives a license from the original licensors, to run, modify andpropagate that work, subject to this License. You are not responsiblefor enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of anorganization, or substantially all assets of one, or subdividing anorganization, or merging organizations. If propagation of a coveredwork results from an entity transaction, each party to thattransaction who receives a copy of the work also receives whateverlicenses to the work the party's predecessor in interest had or couldgive under the previous paragraph, plus a right to possession of theCorresponding Source of the work from the predecessor in interest, ifthe predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of therights granted or affirmed under this License. For example, you maynot impose a license fee, royalty, or other charge for exercise ofrights granted under this License, and you may not initiate litigation(including a cross-claim or counterclaim in a lawsuit) alleging thatany patent claim is infringed by making, using, selling, offering forsale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under thisLicense of the Program or a work on which the Program is based. Thework thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claimsowned or controlled by the contributor, whether already acquired orhereafter acquired, that would be infringed by some manner, permittedby this License, of making, using, or selling its contributor version,but do not include claims that would be infringed only as aconsequence of further modification of the contributor version. Forpurposes of this definition, "control" includes the right to grantpatent sublicenses in a manner consistent with the requirements ofthis License.
Each contributor grants you a non-exclusive, worldwide, royalty-freepatent license under the contributor's essential patent claims, tomake, use, sell, offer for sale, import and otherwise run, modify andpropagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any expressagreement or commitment, however denominated, not to enforce a patent(such as an express permission to practice a patent or covenant not tosue for patent infringement). To "grant" such a patent license to aparty means to make such an agreement or commitment not to enforce apatent against the party.
If you convey a covered work, knowingly relying on a patent license,and the Corresponding Source of the work is not available for anyoneto copy, free of charge and under the terms of this License, through apublicly available network server or other readily accessible means,then you must either (1) cause the Corresponding Source to be soavailable, or (2) arrange to deprive yourself of the benefit of thepatent license for this particular work, or (3) arrange, in a mannerconsistent with the requirements of this License, to extend the patentlicense to downstream recipients. "Knowingly relying" means you haveactual knowledge that, but for the patent license, your conveying thecovered work in a country, or your recipient's use of the covered workin a country, would infringe one or more identifiable patents in thatcountry that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction orarrangement, you convey, or propagate by procuring conveyance of, acovered work, and grant a patent license to some of the partiesreceiving the covered work authorizing them to use, propagate, modifyor convey a specific copy of the covered work, then the patent licenseyou grant is automatically extended to all recipients of the coveredwork and works based on it.
A patent license is "discriminatory" if it does not include withinthe scope of its coverage, prohibits the exercise of, or isconditioned on the non-exercise of one or more of the rights that arespecifically granted under this License. You may not convey a coveredwork if you are a party to an arrangement with a third party that isin the business of distributing software, under which you make paymentto the third party based on the extent of your activity of conveyingthe work, and under which the third party grants, to any of theparties who would receive the covered work from you, a discriminatorypatent license (a) in connection with copies of the covered workconveyed by you (or copies made from those copies), or (b) primarilyfor and in connection with specific products or compilations thatcontain the covered work, unless you entered into that arrangement,or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limitingany implied license or other defenses to infringement that mayotherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement orotherwise) that contradict the conditions of this License, they do notexcuse you from the conditions of this License. If you cannot convey acovered work so as to satisfy simultaneously your obligations under thisLicense and any other pertinent obligations, then as a consequence you maynot convey it at all. For example, if you agree to terms that obligate youto collect a royalty for further conveying from those to whom you conveythe Program, the only way you could satisfy both those terms and thisLicense would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you havepermission to link or combine any covered work with a work licensedunder version 3 of the GNU Affero General Public License into a singlecombined work, and to convey the resulting work. The terms of thisLicense will continue to apply to the part which is the covered work,but the special requirements of the GNU Affero General Public License,section 13, concerning interaction through a network will apply to thecombination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions ofthe GNU General Public License from time to time. Such new versions willbe similar in spirit to the present version, but may differ in detail toaddress new problems or concerns.
Each version is given a distinguishing version number. If theProgram specifies that a certain numbered version of the GNU GeneralPublic License "or any later version" applies to it, you have theoption of following the terms and conditions either of that numberedversion or of any later version published by the Free SoftwareFoundation. If the Program does not specify a version number of theGNU General Public License, you may choose any version ever publishedby the Free Software Foundation.
If the Program specifies that a proxy can decide which futureversions of the GNU General Public License can be used, that proxy'spublic statement of acceptance of a version permanently authorizes youto choose that version for the Program.
Later license versions may give you additional or differentpermissions. However, no additional obligations are imposed on anyauthor or copyright holder as a result of your choosing to follow alater version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BYAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHTHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTYOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAMIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OFALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYSTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANYGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THEUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OFDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRDPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability providedabove cannot be given local legal effect according to their terms,reviewing courts shall apply local law that most closely approximatesan absolute waiver of all civil liability in connection with theProgram, unless a warranty or assumption of liability accompanies acopy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatestpossible use to the public, the best way to achieve this is to make itfree software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safestto attach them to the start of each source file to most effectivelystate the exclusion of warranty; and each file should have at leastthe "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a shortnotice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriateparts of the General Public License. Of course, your program's commandsmight be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,if any, to sign a "copyright disclaimer" for the program, if necessary.For more information on this, and how to apply and follow the GNU GPL, see<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your programinto proprietary programs. If your program is a subroutine library, youmay consider it more useful to permit linking proprietary applications withthe library. If this is what you want to do, use the GNU Lesser GeneralPublic License instead of this License. But first, please read<https://www.gnu.org/licenses/why-not-lgpl.html>.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# Matomo Tracking Spam Prevention Plugin
[](https://github.com/matomo-org/plugin-TrackingSpamPrevention/actions/workflows/matomo-tests.yml)
## Description
Ever noticed tracking requests that look unnatural or originated from locations you wouldn't expect to get visits from?
These tracking requests may be caused by spammers or bots and make your data less accurate. The only thing that is worse than having no data is inaccurate data.
This plugin offers various options to fight spam and bots, so you can rely on your data:
### 1. Block requests from cloud providers
When enabled, this plugin will automatically detect IP addresses used by popular cloud providers like AWS, Azure, Digital Ocean, Google Cloud and Oracle Cloud.
When a tracking request matches such an IP address, then the tracking request will be blocked. Additionally, some Cloud providers like Alibaba Cloud may be detected using the geolocation database (requires eg DB-IP City DB).
If you are only tracking using the JavaScript tracker then this should be a safe feature to enable as tracking requests from humans would not originate from these clouds.
If you are sending tracking requests from a cloud server, then you can also configure IP addresses that are always allowed, so you can still use this feature.
### 2. Block requests from headless browsers
When enabled, this plugin detects the most popular headless browsers and block tracking requests that originate from a headless browser.
Headless browsers are browsers without a user interface and are mostly used for automation. Regular visitors would not use such a browser. It can block additional bots and spam requests that otherwise would not be detected.
It cannot detect a headless browser when the user agent is customised. Often, we can detect them though.
### 3. Restrict number of actions per visit
When enabled, you can configure how many actions a visit should max have.
Most sites never have more than around 100 to 300 actions within one visit under normal circumstances. In many cases it might therefore be safe to assume that if someone has caused more actions than the configured amount of actions, it might be actually tracking spam or a bot or something else like non-human activity is causing these actions.
Matomo will in this case stop recording further actions for that visit to have less inaccurate data and to reduce server load. The IP address of this visit will then be blocked for up to 24 hours.
You can also be notified by email when an IP address is banned because a visit had too many actions.
### 4. Exclude countries
This feature lets you configure to only accept tracking requests for visitors from specific countries. For example, if you have a German website, then it might be unexpected to have any legit visitors from a country outside of Europe meaning a visitor is likely a spammer or a bot in this case. By only tracking visitors from certain countries you can easily avoid a lot of potential spam and bots plus you might also avoid needing to be compliant with certain privacy laws.
### 5. Referrer spam
This feature is not part of this plugin but part of Matomo core.Matomo maintains a [list of spam referrers](https://matomo.org/blog/2015/05/stopping-referrer-spam/) and Matomo will block tracking requests when such a referrer is detected.
### Recommended other features
You might also want to [configure to track only URLs that belong to your website](https://matomo.org/faq/how-to/faq_21077/). This way any URL that does not belong to your website will not be tracked. This feature is part of Matomo core.
### Privacy
The plugin does not send any information of your visitors to another server. If you enable the "block requests from cloud providers" feature, then your server will download up to date IP ranges from cloud providers directly and store the information in your database.123456789101112131415161718192021222324252627282930<?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\TrackingSpamPrevention\Settings;
use Piwik\Settings\Plugin\SystemSetting;
class BlockCloudsSetting extends SystemSetting{ private $oldValue;
public function getOldValue() { return $this->oldValue; }
public function setValue($value) { $this->oldValue = $this->getValue();
parent::setValue($value); }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243<?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\TrackingSpamPrevention;
use Piwik\Container\StaticContainer;use Piwik\Intl\Data\Provider\RegionDataProvider;use Piwik\Piwik;use Piwik\Plugins\TrackingSpamPrevention\Settings\BlockCloudsSetting;use Piwik\Settings\Setting;use Piwik\Settings\FieldConfig;use Piwik\SettingsPiwik;use Piwik\Tracker\Cache;use Piwik\Validators\Email;
class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings{ /** @var Setting */ public $max_actions;
/** @var Setting */ public $notification_email;
/** @var BlockCloudsSetting */ public $block_clouds;
/** @var Setting */ public $excludedCountries;
/** @var Setting */ public $includedCountries;
/** @var Setting */ public $blockHeadless;
/** @var Setting */ public $blockServerSideLibraries;
protected function init() { $this->block_clouds = $this->createBlockCloudsSetting(); $this->blockHeadless = $this->createBlockHeadlessSettings(); $this->blockServerSideLibraries = $this->createBlockServerSideLibrariesSetting(); $this->max_actions = $this->createMaxActionsSetting(); $this->notification_email = $this->createNotificationEmail();
$this->excludedCountries = $this->createExcludedCountriesSetting(); $this->includedCountries = $this->createIncludedCountriesSetting(); }
private function createBlockCloudsSetting() { $setting = new BlockCloudsSetting('block_clouds', false, FieldConfig::TYPE_BOOL, $this->pluginName); $setting->setConfigureCallback(function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingBlockCloudTitle'); $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; $field->description = Piwik::translate('TrackingSpamPrevention_SettingBlockCloudDescription'); if (!SettingsPiwik::isInternetEnabled()) { $field->description = Piwik::translate('TrackingSpamPrevention_BlockCloudNoteInternetDisabled') . $field->description; } }); $this->addSetting($setting); return $setting; }
private function createBlockHeadlessSettings() { return $this->makeSetting('block_headless', $default = true, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingBlockHeadlessTitle'); $field->description = Piwik::translate('TrackingSpamPrevention_SettingBlockHeadlessDescription'); $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; }); }
private function createMaxActionsSetting() { return $this->makeSetting('max_actions_allowed', $default = 0, FieldConfig::TYPE_INT, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingMaxActionsTitle'); $field->description = Piwik::translate('TrackingSpamPrevention_SettingMaxActionsDescription'); $field->uiControl = FieldConfig::UI_CONTROL_TEXT; }); }
private function createNotificationEmail() { return $this->makeSetting('notification_email', $default = '', FieldConfig::TYPE_STRING, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingNotificationEmailTitle'); $field->description = Piwik::translate('TrackingSpamPrevention_SettingNotificationEmailDescription'); $field->uiControl = FieldConfig::UI_CONTROL_TEXT; $field->condition = 'max_actions_allowed>0'; $field->validators[] = new Email(); }); }
public function save() { parent::save();
$ranges = StaticContainer::get(BlockedIpRanges::class);
if ((bool) $this->block_clouds->getValue() !== (bool) $this->block_clouds->getOldValue()) { if ($this->block_clouds->getValue()) { // is now enabled, lets sync ip ranges $ranges->updateBlockedIpRanges(); } else { // we also unset any IP that was banned recently $ranges->unsetAllIpRanges(); } Cache::clearCacheGeneral(); } }
private function createExcludedCountriesSetting() { return $this->makeSetting('excluded_countries', [], FieldConfig::TYPE_ARRAY, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingExcludedCountriesTitle'); $field->description = Piwik::translate('TrackingSpamPrevention_SettingExcludedCountriesDescription'); $field->uiControl = FieldConfig::UI_CONTROL_MULTI_TUPLE; $field1 = new FieldConfig\MultiPair("Country", 'country', FieldConfig::UI_CONTROL_SINGLE_SELECT); $field1->availableValues = $this->listCountries(); $field->uiControlAttributes['field1'] = $field1->toArray();
$self = $this; $field->transform = function ($value) use ($self) { return $self->transformCountryList($value); };
$field->validate = function ($value) use ($field1) { foreach ($value as $country) { if (empty($country['country'])) { continue; } if ($country['country'] === 'xx') { continue; // valid, country not detected } if (!isset($field1->availableValues[$country['country']])) { throw new \Exception('Invalid country code'); } } }; }); }
public function transformCountryList($value) { if (!empty($value) && is_array($value)) { $newVal = []; foreach ($value as $index => $val) { if (empty($val['country'])) { continue; } $newVal[] = ['country' => $val['country']]; } return $newVal; } return $value; }
private function createIncludedCountriesSetting() { return $this->makeSetting('included_countries', [], FieldConfig::TYPE_ARRAY, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingIncludedCountriesTitle'); $field->description = Piwik::translate('TrackingSpamPrevention_SettingIncludedCountriesDescription'); $field->uiControl = FieldConfig::UI_CONTROL_MULTI_TUPLE; $field1 = new FieldConfig\MultiPair("Country", 'country', FieldConfig::UI_CONTROL_SINGLE_SELECT); $field1->availableValues = $this->listCountries(); $field->uiControlAttributes['field1'] = $field1->toArray();
$self = $this; $field->transform = function ($value) use ($self) { return $self->transformCountryList($value); }; $field->validate = function ($value) use ($field1) { foreach ($value as $country) { if (empty($country['country'])) { continue; } if ($country['country'] === 'xx') { continue; // valid, country not detected } if (!isset($field1->availableValues[$country['country']])) { throw new \Exception('Invalid country code'); } } }; }); }
private function createBlockServerSideLibrariesSetting() { return $this->makeSetting('blockServerSideLibraries', false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { $field->title = Piwik::translate('TrackingSpamPrevention_SettingBlockServerSideLibrariesTitle'); $field->inlineHelp = Piwik::translate('TrackingSpamPrevention_SettingBlockServerSideLibrariesDescription', array('<strong>','</strong>','<br>')); $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; }); }
private function listCountries() { $regionDataProvider = StaticContainer::get(RegionDataProvider::class); $countryList = $regionDataProvider->getCountryList(); array_walk($countryList, function (&$item, $key) { $item = Piwik::translate('Intl_Country_' . strtoupper($key)); }); asort($countryList); //order by localized name return $countryList; }
public function getExcludedCountryCodes() { return $this->settingToCountryCodes($this->excludedCountries); }
public function getIncludedCountryCodes() { return $this->settingToCountryCodes($this->includedCountries); }
private function settingToCountryCodes(Setting $setting) { $val = $setting->getValue();
if (empty($val) || !is_array($val)) { return []; }
$codes = []; foreach ($val as $value) { if (!empty($value['country'])) { $codes[] = $value['country']; } } return $codes; }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849<?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\TrackingSpamPrevention;
class Tasks extends \Piwik\Plugin\Tasks{ /** * @var SystemSettings */ private $systemSettings;
/** * @var BlockedIpRanges */ private $blockedIpRanges;
public function __construct(SystemSettings $systemSettings, BlockedIpRanges $blockedIpRanges) { $this->systemSettings = $systemSettings; $this->blockedIpRanges = $blockedIpRanges; }
public function schedule() { $this->daily('updateBlockedIpRanges'); }
/** * To test execute the following command: * `./console core:run-scheduled-tasks --force "Piwik\Plugins\TrackingSpamPrevention\Tasks.updateBlockedIpRanges"` * */ public function updateBlockedIpRanges() { if ($this->systemSettings->block_clouds->getValue()) { $this->blockedIpRanges->updateBlockedIpRanges(); } else { // we also unset any banned IP every 24 hours $this->blockedIpRanges->unsetAllIpRanges(); } }}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859<?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\TrackingSpamPrevention\Tracker;
use Piwik\Common;use Piwik\Container\StaticContainer;use Piwik\Plugins\TrackingSpamPrevention\AllowListIpRange;use Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges;use Piwik\Plugins\TrackingSpamPrevention\SystemSettings;use Piwik\Tracker\Request;use Piwik\Tracker;use Piwik\Tracker\Visit\VisitProperties;
class RequestProcessor extends Tracker\RequestProcessor{ /** * @var SystemSettings */ private $systemSettings; /** * @var BlockedIpRanges */ private $blockedIpRanges;
public function __construct(SystemSettings $systemSettings, BlockedIpRanges $blockedIpRanges) { $this->systemSettings = $systemSettings; $this->blockedIpRanges = $blockedIpRanges; }
public function afterRequestProcessed(VisitProperties $visitProperties, Request $request) { $actions = $visitProperties->getProperty('visit_total_actions'); $maxActions = $this->systemSettings->max_actions->getValue();
if (empty($maxActions) || !is_numeric($maxActions) || $maxActions <= 0) { return; // unlimited } if ((int)$actions >= $maxActions) { $ipString = $request->getIpString(); if (StaticContainer::get(AllowListIpRange::class)->isAllowed($ipString)) { Common::printDebug("Ignoring max visits as the visit matches an IP range that is always allowed"); return; }
$this->blockedIpRanges->banIp($ipString);
Common::printDebug("Stop tracking as max number of actions reached"); return true; // abort } }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172<?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\TrackingSpamPrevention;
use Matomo\Network\IP;use Piwik\Common;use Piwik\Container\StaticContainer;use Piwik\Date;use Piwik\Tracker\Request;use Piwik\Tracker\VisitExcluded;
class TrackingSpamPrevention extends \Piwik\Plugin{ private $isInstalledInThisRequest = false;
public function registerEvents() { return [ 'Tracker.isExcludedVisit' => 'isExcludedVisit', 'Tracker.setTrackerCacheGeneral' => 'setTrackerCacheGeneral', 'TrackingSpamPrevention.banIp' => 'onBanIp', ]; }
public function install() { $this->isInstalledInThisRequest = true; $config = new Configuration(); $config->install(); }
public function activate() { $this->isInstalledInThisRequest = true; }
public function uninstall() { $config = new Configuration(); $config->uninstall(); }
public function onBanIp($ipRange, $ip) { $settings = $this->getSystemSettings(); $email = $settings->notification_email->getValue(); $maxActions = $settings->max_actions->getValue(); $locationData = $this->getBlockGeoIp()->detectLocation($ip, Common::getBrowserLanguage()); $now = Date::now()->getDatetime();
$banIpMail = new BanIpNotificationEmail(); $banIpMail->send($ipRange, $ip, $email, $maxActions, $locationData, $now); }
public function setTrackerCacheGeneral(&$cache) { $isTestMode = defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE; if ($this->isInstalledInThisRequest && !$isTestMode) { // dont do anything when plugin gets loaded as DI config would not be loaded yet and it would // cause an issue with activity log since it does a geolocation which uses the tracker cache return; } $ranges = $this->getBlockedIpRanges(); $cache[BlockedIpRanges::OPTION_KEY] = $ranges->getBlockedRanges(); }
public function isExcludedVisit(&$excluded, Request $request) { if ($excluded) { return; // already excluded, not needed to check }
$visitExcluded = new VisitExcluded($request); $ipString = $request->getIpString();
$ip = IP::fromStringIP($ipString); if (is_callable(array($visitExcluded, 'isChromeDataSaverUsed')) && $visitExcluded->isChromeDataSaverUsed($ip)) { Common::printDebug("Not excluding visit as chrome data saver is used"); return; }
if (StaticContainer::get(AllowListIpRange::class)->isAllowed($ipString)) { Common::printDebug("Not excluding visit as it matches an IP range that is always allowed"); return; }
$settings = $this->getSystemSettings(); $blockGeoIp = $this->getBlockGeoIp(); $browserLang = $request->getBrowserLanguage();
$browserDetection = new BrowserDetection(); $clientHints = json_encode($request->getClientHints()); if ( $settings->blockHeadless->getValue() && ( $browserDetection->isHeadlessBrowser($request->getUserAgent()) || $browserDetection->isHeadlessBrowser($clientHints) ) ) { // note above user agent could have been overwritten with UA parameter but that's fine since it's easy to change useragent anyway Common::printDebug("Excluding visit as headless browser detected"); $excluded = 'excluded: headless browser'; return; }
if ( $settings->block_clouds->getValue() && $blockGeoIp->isExcludedProvider($ipString, $browserLang) ) { // only needs to be done when cloud providers are blocked specifically Common::printDebug("Excluding visit as geoip detects a cloud provider"); $excluded = 'excluded: geoip cloud provider'; return; }
if ($this->getBlockedIpRanges()->isExcluded($ipString)) { // we also execute this when block clouds disabled because it might contain banned ips Common::printDebug("Excluding visit as IP originates from a cloud provider"); $excluded = 'excluded: ip cloud provider'; return; }
if ( $blockGeoIp->isExcludedCountry( $ipString, $browserLang, $settings->getExcludedCountryCodes(), $settings->getIncludedCountryCodes() ) ) { Common::printDebug("Excluding visit as geoip detects an excluded (or not included) country"); $excluded = 'excluded: country'; return; }
if ( $settings->blockServerSideLibraries->getValue() && $browserDetection->isLibrary($request->getUserAgent()) ) { Common::printDebug("Excluding visit as Server Side Library detected"); $excluded = 'excluded: ServerSideLibraries-'; return; } }
private function getSystemSettings() { return StaticContainer::get(SystemSettings::class); }
private function getBlockedIpRanges() { return StaticContainer::get(BlockedIpRanges::class); }
private function getBlockGeoIp() { return StaticContainer::get(BlockedGeoIp::class); }
public function isTrackerPlugin() { return true; }}12345678910111213141516171819202122232425262728293031323334<?php
/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */
namespace Piwik\Plugins\TrackingSpamPrevention;
use Piwik\Config;use Piwik\Updater;use Piwik\Updates as PiwikUpdates;
class Updates_5_0_10 extends PiwikUpdates{ public function doUpdate(Updater $updater) { // 5.0.9 force-added this to existing block lists; it should not be blocked by default. $config = Config::getInstance(); $pluginConfig = $config->TrackingSpamPrevention; $providers = $pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS] ?? [];
$key = array_search('verein zur foerderung eines deutschen forschungsnetzes', $providers, true);
if ($key !== false) { unset($providers[$key]); $pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS] = array_values($providers); $config->TrackingSpamPrevention = $pluginConfig; $config->forceSave(); } }}123456789101112131415161718192021222324252627282930313233343536<?php
/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */
namespace Piwik\Plugins\TrackingSpamPrevention;
use Piwik\Config;use Piwik\Settings\Storage\Factory;use Piwik\Updater;use Piwik\Updates as PiwikUpdates;
class Updates_5_0_11 extends PiwikUpdates{ public function doUpdate(Updater $updater) { $pluginConfig = Config::getInstance()->TrackingSpamPrevention;
if (is_array($pluginConfig) && array_key_exists('block_headless', $pluginConfig)) { return; }
$backend = (new Factory())->getPluginStorage('TrackingSpamPrevention', '')->getBackend(); $currentValue = $backend->loadValue('block_headless', null);
if ($currentValue !== null) { return; }
$backend->saveValue('block_headless', false); }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849<?php
/** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */
namespace Piwik\Plugins\TrackingSpamPrevention;
use Piwik\Config;use Piwik\Updater;use Piwik\Updates as PiwikUpdates;
class Updates_5_0_9 extends PiwikUpdates{ public function doUpdate(Updater $updater) { $config = Config::getInstance(); $pluginConfig = $config->TrackingSpamPrevention; $existingProviders = [];
if (!empty($pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS]) && is_array($pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS])) { $existingProviders = $pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS]; }
$normalizedProviders = []; foreach ($existingProviders as $provider) { $provider = mb_strtolower(trim((string) $provider)); if ($provider !== '') { $normalizedProviders[] = $provider; } }
$mergedProviders = array_values(array_unique(array_merge( $normalizedProviders, Configuration::DEFAULT_GEOIP_MATCH_PROVIDERS )));
if ($existingProviders === $mergedProviders) { return; }
$pluginConfig[Configuration::KEY_GEOIP_MATCH_PROVIDERS] = $mergedProviders; $config->TrackingSpamPrevention = $pluginConfig; $config->forceSave(); }}123456789101112131415161718192021222324252627282930313233343536373839<?php
return array(
'trackingspam.iprangeproviders' => Piwik\DI::add(array( Piwik\DI::get('Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\Aws'), Piwik\DI::get('Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\Azure'), Piwik\DI::get('Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\DigitalOcean'), Piwik\DI::get('Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\Gcloud'), Piwik\DI::get('Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\Oracle'), )),
'Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges' => Piwik\DI::autowire() ->constructorParameter('providers', Piwik\DI::get('trackingspam.iprangeproviders')),
'Piwik\Plugins\TrackingSpamPrevention\BlockedGeoIp' => Piwik\DI::autowire() ->constructor(Piwik\DI::get('trackingspam.block_geoip_organisations')),
'trackingspam.block_geoip_organisations' => function (\Piwik\Container\Container $c) { if ($c->has('ini.TrackingSpamPrevention.block_geoip_organisations')) { return $c->get('ini.TrackingSpamPrevention.block_geoip_organisations'); } return []; },
\Piwik\Config::class => Piwik\DI::decorate(function ($previous) { $tsp = $previous->TrackingSpamPrevention; if (empty($tsp)) { $tsp = array(); } if (empty($tsp['block_geoip_organisations'])) { // prevent possible tracking error if this config is removed otherwise $tsp['block_geoip_organisations'] = []; } $previous->TrackingSpamPrevention = $tsp;
return $previous; }),);12345678910111213141516171819<?php
return array(
'trackingspam.iprangeproviders' => array( new \Piwik\Plugins\TrackingSpamPrevention\BlockedIpRanges\VariableRange(['10.10.0.0/21', '200.200.0.0/21']) ),
\Piwik\Config::class => Piwik\DI::decorate(function ($previous) { $tsp = $previous->TrackingSpamPrevention; if (empty($tsp['block_geoip_organisations'])) { // prevent possible tracking error if this config is removed otherwise $tsp['block_geoip_organisations'] = []; } $previous->TrackingSpamPrevention = $tsp;
return $previous; }));1234<?php
return array();1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950## FAQ
__How do I allow specific IPs to not be blocked?__
Say you are using AWS to replay your traffic using log analytics. When you have the block clouds feature enabled, all the requests from your AWS would be blocked. However, you can specifically allow your own IPs to be allowed and not blocked by editing your `config/config.ini.php` file and configuring a list of allowed IP ranges like this:
```[TrackingSpamPrevention]iprange_allowlist[] = "127.0.0.1/32"iprange_allowlist[] = "192.168.0.0/21"```
Make sure to enter a valid IP range.
__What happens when it fails to synchronise public IPs from cloud providers?__
Any error is currently ignored and if it does not synchronise successfully, then the IP for the provider that failed are not synced.
To be aware when such an error happens you can enable the following setting:
```[TrackingSpamPrevention]block_cloud_sync_throw_exception_on_error = 1```
It is disabled by default as it could stop other scheduled tasks from being executed.
__How can I block specific organisations from being tracked?__
This can be useful if you are receiving spam requests from a provider that isn't automatically detected yet by this plugin.
For this to work the "Block cloud provider" setting must be enabled and a geolocation provider must be enabled.
You can block any organisation (if the geolocation database you are using includes this information) like this:
```[TrackingSpamPrevention]block_geoip_organisations[] = "ExampleOrg"block_geoip_organisations[] = "another example"```
Alternatively, you can execute a command to block a new organisation like this:
```bash./console trackingspamprevention:block-geo-ip-organisation --organisation-name="Example"```
Each organisation will be compared lower case and the organisation only needs to contain the configured value, it does not need to match it exactly.
You can find out the organisation name for an IP address by visiting the website of your geolocation database and using their demo tool.1{}plugins/Tour/tests/UI/expected-screenshots/.gitkeepDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_ConsentManager_widget_initial.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_all_completed.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges_page_2.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_complete_some_challenges_page_3.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_completed.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_initial.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_none_completed.pngDeleted
plugins/Tour/tests/UI/expected-screenshots/Tour_widget_skipped_goal.pngDeleted
plugins/Tour/vue/dist/Tour.umd.jsDeleted-382
plugins/Tour/vue/dist/Tour.umd.min.jsDeleted-8
plugins/Tour/vue/dist/umd.metadata.jsonDeleted-5
plugins/Tour/vue/src/BecomeMatomoExpert/BecomeMatomoExpert.vueDeleted-303
plugins/Tour/vue/src/index.tsDeleted-8
plugins/TrackingSpamPrevention/.gitattributesDeleted-9
plugins/TrackingSpamPrevention/.github/workflows/matomo-ai-checklist.ymlDeleted-32
plugins/TrackingSpamPrevention/.github/workflows/matomo-tests.ymlDeleted-74
plugins/TrackingSpamPrevention/.github/workflows/phpcs.ymlDeleted-43
plugins/TrackingSpamPrevention/AllowListIpRange.phpDeleted-37
plugins/TrackingSpamPrevention/BanIpNotificationEmail.phpDeleted-99
plugins/TrackingSpamPrevention/BlockedGeoIp.phpDeleted-79
plugins/TrackingSpamPrevention/BlockedIpRanges.phpDeleted-195
plugins/TrackingSpamPrevention/BlockedIpRanges/Aws.phpDeleted-68
plugins/TrackingSpamPrevention/BlockedIpRanges/Azure.phpDeleted-84
plugins/TrackingSpamPrevention/BlockedIpRanges/DigitalOcean.phpDeleted-46
plugins/TrackingSpamPrevention/BlockedIpRanges/ExceptionRange.phpDeleted-21
plugins/TrackingSpamPrevention/BlockedIpRanges/Gcloud.phpDeleted-51
plugins/TrackingSpamPrevention/BlockedIpRanges/IpRangeProviderInterface.phpDeleted-15
plugins/TrackingSpamPrevention/BlockedIpRanges/Oracle.phpDeleted-51
plugins/TrackingSpamPrevention/BlockedIpRanges/VariableRange.phpDeleted-31
plugins/TrackingSpamPrevention/BrowserDetection.phpDeleted-51
plugins/TrackingSpamPrevention/CHANGELOG.mdDeleted-69
plugins/TrackingSpamPrevention/Commands/BlockGeoIpOrganisation.phpDeleted-51
plugins/TrackingSpamPrevention/Configuration.phpDeleted-181
plugins/TrackingSpamPrevention/LICENSEDeleted-674
plugins/TrackingSpamPrevention/README.mdDeleted-56
plugins/TrackingSpamPrevention/Settings/BlockCloudsSetting.phpDeleted-30
plugins/TrackingSpamPrevention/SystemSettings.phpDeleted-243
plugins/TrackingSpamPrevention/Tasks.phpDeleted-49
plugins/TrackingSpamPrevention/Tracker/RequestProcessor.phpDeleted-59
plugins/TrackingSpamPrevention/TrackingSpamPrevention.phpDeleted-172
plugins/TrackingSpamPrevention/Updates/5.0.10.phpDeleted-34
plugins/TrackingSpamPrevention/Updates/5.0.11.phpDeleted-36
plugins/TrackingSpamPrevention/Updates/5.0.9.phpDeleted-49
plugins/TrackingSpamPrevention/config/config.phpDeleted-39
plugins/TrackingSpamPrevention/config/test.phpDeleted-19
plugins/TrackingSpamPrevention/config/tracker.phpDeleted-4
plugins/TrackingSpamPrevention/docs/faq.mdDeleted-50
plugins/TrackingSpamPrevention/lang/am.jsonDeleted-1