Captcha updates
This commit is contained in:
@@ -263,7 +263,12 @@ class action_plugin_botmon extends DokuWiki_Action_Plugin {
|
|||||||
echo DOKU_TAB . DOKU_TAB . '"dlgLoading": ' . json_encode($this->getLang('bm_dlgLoading')) . ',' . NL;
|
echo DOKU_TAB . DOKU_TAB . '"dlgLoading": ' . json_encode($this->getLang('bm_dlgLoading')) . ',' . NL;
|
||||||
echo DOKU_TAB . DOKU_TAB . '"dlgError": ' . json_encode($this->getLang('bm_dlgError')) . ',' . NL;
|
echo DOKU_TAB . DOKU_TAB . '"dlgError": ' . json_encode($this->getLang('bm_dlgError')) . ',' . NL;
|
||||||
echo DOKU_TAB . '};' . NL;
|
echo DOKU_TAB . '};' . NL;
|
||||||
|
|
||||||
|
// captcha configuration options
|
||||||
|
echo DOKU_TAB . '$BMConfig = {' . NL;
|
||||||
|
echo DOKU_TAB . DOKU_TAB . '"captchaBypass": ' . json_encode($this->getConf('captchaBypass')) . NL;
|
||||||
|
echo DOKU_TAB . '};' . NL;
|
||||||
|
|
||||||
echo '</script>' . NL;
|
echo '</script>' . NL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
admin.js
20
admin.js
@@ -1712,6 +1712,16 @@ BotMon.live = {
|
|||||||
return visitor.hasOwnProperty('_ipRange');
|
return visitor.hasOwnProperty('_ipRange');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// is the IP address from a specifin known ISP network
|
||||||
|
fromISPRange: function(visitor, ...isps) {
|
||||||
|
if (visitor.hasOwnProperty('_ipRange')) {
|
||||||
|
if (isps.indexOf(visitor._ipRange.g) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
// is the page language mentioned in the client's accepted languages?
|
// is the page language mentioned in the client's accepted languages?
|
||||||
// the parameter holds an array of exceptions, i.e. page languages that should be ignored.
|
// the parameter holds an array of exceptions, i.e. page languages that should be ignored.
|
||||||
matchLang: function(visitor, ...exceptions) {
|
matchLang: function(visitor, ...exceptions) {
|
||||||
@@ -2026,7 +2036,7 @@ BotMon.live = {
|
|||||||
if (botsVsHumans) {
|
if (botsVsHumans) {
|
||||||
botsVsHumans.appendChild(makeElement('dt', {}, "Bot statistics"));
|
botsVsHumans.appendChild(makeElement('dt', {}, "Bot statistics"));
|
||||||
|
|
||||||
for (let i = 0; i <= 6; i++) {
|
for (let i = 0; i <= 5; i++) {
|
||||||
const dd = makeElement('dd');
|
const dd = makeElement('dd');
|
||||||
let title = '';
|
let title = '';
|
||||||
let value = '';
|
let value = '';
|
||||||
@@ -2043,15 +2053,15 @@ BotMon.live = {
|
|||||||
title = "Bots-humans ratio visits:";
|
title = "Bots-humans ratio visits:";
|
||||||
value = BotMon.t._getRatio(data.visits.suspected + data.visits.bots, data.visits.users + data.visits.humans, 100);
|
value = BotMon.t._getRatio(data.visits.suspected + data.visits.bots, data.visits.users + data.visits.humans, 100);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 3:
|
||||||
title = "Known bots views:";
|
title = "Known bots views:";
|
||||||
value = data.views.bots || kNoData;
|
value = data.views.bots || kNoData;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 4:
|
||||||
title = "Suspected bots views:";
|
title = "Suspected bots views:";
|
||||||
value = data.views.suspected || kNoData;
|
value = data.views.suspected || kNoData;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 5:
|
||||||
title = "Bots-humans ratio views:";
|
title = "Bots-humans ratio views:";
|
||||||
value = BotMon.t._getRatio(data.views.suspected + data.views.bots, data.views.users + data.views.humans, 100);
|
value = BotMon.t._getRatio(data.views.suspected + data.views.bots, data.views.users + data.views.humans, 100);
|
||||||
break;
|
break;
|
||||||
@@ -2771,7 +2781,7 @@ BotMon.live = {
|
|||||||
/* bot evaluation rating */
|
/* bot evaluation rating */
|
||||||
if (data._type !== BM_USERTYPE.KNOWN_BOT && data._type !== BM_USERTYPE.KNOWN_USER) {
|
if (data._type !== BM_USERTYPE.KNOWN_BOT && data._type !== BM_USERTYPE.KNOWN_USER) {
|
||||||
dl.appendChild(make('dt', undefined, "Bot rating:"));
|
dl.appendChild(make('dt', undefined, "Bot rating:"));
|
||||||
dl.appendChild(make('dd', {'class': 'bot-rating'}, ( data._botVal ? data._botVal : '–' ) + ' (of ' + BotMon.live.data.rules._threshold + ')'));
|
dl.appendChild(make('dd', {'class': 'bot-rating'}, ( data._botVal ? data._botVal : '0' ) + ' (of ' + BotMon.live.data.rules._threshold + ')'));
|
||||||
|
|
||||||
/* add bot evaluation details: */
|
/* add bot evaluation details: */
|
||||||
if (data._eval) {
|
if (data._eval) {
|
||||||
|
|||||||
14
admin.php
14
admin.php
@@ -53,6 +53,13 @@ class admin_plugin_botmon extends AdminPlugin {
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<article role="tabpanel" id="botmon__latest">
|
<article role="tabpanel" id="botmon__latest">
|
||||||
|
<script>
|
||||||
|
const BMSettings = {
|
||||||
|
showday: ' . json_encode($this->getConf('showday')) . ',
|
||||||
|
combineNets: ' . json_encode($this->getConf('combineNets')) . ',
|
||||||
|
useCaptcha: ' . json_encode($this->getConf('useCaptcha') !== 'disabled') . '
|
||||||
|
};
|
||||||
|
</script>
|
||||||
<h2 class="a11y">Latest data</h2>
|
<h2 class="a11y">Latest data</h2>
|
||||||
<header id="botmon__today__title">Loading …</header>
|
<header id="botmon__today__title">Loading …</header>
|
||||||
<div id="botmon__today__content">
|
<div id="botmon__today__content">
|
||||||
@@ -116,13 +123,6 @@ class admin_plugin_botmon extends AdminPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo DOKU_TAB . DOKU_TAB . '</ul>' . NL . DOKU_TAB . '</article>' . NL;
|
echo DOKU_TAB . DOKU_TAB . '</ul>' . NL . DOKU_TAB . '</article>' . NL;
|
||||||
echo DOKU_TAB . '<script>
|
|
||||||
const BMSettings = {
|
|
||||||
showday: ' . json_encode($this->getConf('showday')) . ',
|
|
||||||
combineNets: ' . json_encode($this->getConf('combineNets')) . ',
|
|
||||||
useCaptcha: ' . json_encode($this->getConf('useCaptcha') !== 'disabled') . '
|
|
||||||
};
|
|
||||||
</script>' . NL;
|
|
||||||
echo '</div><!-- End of BotMon Admin Tool -->';
|
echo '</div><!-- End of BotMon Admin Tool -->';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
captcha.js
11
captcha.js
@@ -218,16 +218,15 @@ const $BMCaptcha = {
|
|||||||
|
|
||||||
_autoCheck: function(e) {
|
_autoCheck: function(e) {
|
||||||
|
|
||||||
let bPass = 0;
|
const bypass = ($BMConfig['captchaBypass'] || '').split(',');
|
||||||
const threshold = 1;
|
var action = false;
|
||||||
|
|
||||||
const pLang = document.documentElement.lang || 'en';
|
if (bypass.indexOf('langmatch') >= 0) { // Languages matching
|
||||||
if (pLang !== 'en') {
|
|
||||||
const cntLangs = navigator.languages.map(lang => lang.split('-')[0]);
|
const cntLangs = navigator.languages.map(lang => lang.split('-')[0]);
|
||||||
if (cntLangs.indexOf(pLang) >= 0) bPass += 1;
|
if (cntLangs.indexOf(document.documentElement.lang || 'en') >= 0) action = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bPass >= threshold) e.click();
|
if (action) e.click(); // action!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// initialise the captcha module:
|
// initialise the captcha module:
|
||||||
|
|||||||
@@ -10,3 +10,4 @@ $conf['combineNets'] = true;
|
|||||||
$conf['geoiplib'] = 'disabled';
|
$conf['geoiplib'] = 'disabled';
|
||||||
$conf['useCaptcha'] = 'disabled';
|
$conf['useCaptcha'] = 'disabled';
|
||||||
$conf['captchaSeed'] = 'c53bc5f94929451987efa6c768d8856b';
|
$conf['captchaSeed'] = 'c53bc5f94929451987efa6c768d8856b';
|
||||||
|
$conf['captchaBypass'] = '';
|
||||||
|
|||||||
@@ -5,14 +5,21 @@
|
|||||||
* @author Sascha Leib <sascha@leib.be>
|
* @author Sascha Leib <sascha@leib.be>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// How to show data in the admin interface:
|
||||||
$meta['showday'] = array('multichoice',
|
$meta['showday'] = array('multichoice',
|
||||||
'_choices' => array ('yesterday', 'today'));
|
'_choices' => array ('yesterday', 'today'));
|
||||||
|
|
||||||
$meta['combineNets'] = array('onoff');
|
$meta['combineNets'] = array('onoff');
|
||||||
|
|
||||||
|
// Geolocation settings:
|
||||||
$meta['geoiplib'] = array('multichoice',
|
$meta['geoiplib'] = array('multichoice',
|
||||||
'_choices' => array ('disabled', 'phpgeoip'));
|
'_choices' => array ('disabled', 'phpgeoip'));
|
||||||
|
|
||||||
|
// Captcha settings:
|
||||||
$meta['useCaptcha'] = array('multichoice',
|
$meta['useCaptcha'] = array('multichoice',
|
||||||
'_choices' => array ('disabled', 'loremipsum', 'dada'));
|
'_choices' => array ('disabled', 'loremipsum', 'dada'));
|
||||||
|
|
||||||
$meta['captchaSeed'] = array('string');
|
$meta['captchaSeed'] = array('string');
|
||||||
|
|
||||||
|
$meta['captchaBypass'] = array('multicheckbox',
|
||||||
|
'_choices' => array ('langmatch'), '_other' => 'exists');
|
||||||
|
|||||||
@@ -21,3 +21,6 @@ $lang['useCaptcha'] = 'Enable Captcha<br><small>(Experimental, read the manual
|
|||||||
$lang['useCaptcha_o_dada'] = 'Captcha with Dada placeholder text';
|
$lang['useCaptcha_o_dada'] = 'Captcha with Dada placeholder text';
|
||||||
|
|
||||||
$lang['captchaSeed'] = 'Captcha Seed<br><small>(Enter a random string, e.g. <a href="https://www.browserling.com/tools/random-hex" target="_blank">from here</a>)</small>';
|
$lang['captchaSeed'] = 'Captcha Seed<br><small>(Enter a random string, e.g. <a href="https://www.browserling.com/tools/random-hex" target="_blank">from here</a>)</small>';
|
||||||
|
|
||||||
|
$lang['captchaBypass'] = 'Automatically solve the Captcha, if …<br><small>(Note: this probably does not make much sense for English wikis!)</small>';
|
||||||
|
$lang['captchaBypass_langmatch'] = 'Client and page languages match ';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
base botmon
|
base botmon
|
||||||
author Sascha Leib
|
author Sascha Leib
|
||||||
email ad@hominem.com
|
email ad@hominem.com
|
||||||
date 2025-10-31
|
date 2025-11-02
|
||||||
name Bot Monitoring
|
name Bot Monitoring
|
||||||
desc A tool for monitoring and analysing bot traffic to your wiki (under development)
|
desc A tool for monitoring and analysing bot traffic to your wiki (under development)
|
||||||
url https://www.dokuwiki.org/plugin:botmon
|
url https://www.dokuwiki.org/plugin:botmon
|
||||||
|
|||||||
Reference in New Issue
Block a user