diff --git a/action.php b/action.php index c4cd017..62a3c3d 100644 --- a/action.php +++ b/action.php @@ -16,7 +16,7 @@ class action_plugin_botmon extends DokuWiki_Action_Plugin { public function __construct() { // determine if a captcha should be loaded: - $this->showCaptcha = 'Z'; + $this->showCaptcha = 'Z'; // Captcha unknown $useCaptcha = $this->getConf('useCaptcha'); // should we show a captcha? @@ -153,7 +153,8 @@ class action_plugin_botmon extends DokuWiki_Action_Plugin { substr($conf['lang'],0,2), /* page language */ implode(',', array_unique(array_map( function($it) { return substr(trim($it),0,2); }, explode(',',trim($_SERVER['HTTP_ACCEPT_LANGUAGE'], " \t;,*"))))), /* accepted client languages */ $this->getCountryCode(), /* GeoIP country code */ - $this->showCaptcha /* show captcha? */ + $this->showCaptcha, /* show captcha? */ + $_SERVER['REQUEST_METHOD'] ?? '' /* request method */ ); //* create the log line */ diff --git a/admin.css b/admin.css index 68a1cd1..a0c9806 100644 --- a/admin.css +++ b/admin.css @@ -476,8 +476,6 @@ max-width: 100%; overflow: hidden; } - dd { - } dd a { white-space: nowrap; overflow: hidden; diff --git a/admin.js b/admin.js index 05a87a1..a2a4d9a 100644 --- a/admin.js +++ b/admin.js @@ -1845,7 +1845,7 @@ BotMon.live = { switch (type) { case "srv": typeName = "Server"; - columns = ['ts','ip','pg','id','typ','usr','agent','ref','lang','accept','geo','captcha']; + columns = ['ts','ip','pg','id','typ','usr','agent','ref','lang','accept','geo','captcha','method']; break; case "log": typeName = "Page load"; diff --git a/captcha.js b/captcha.js index 9f32475..61958d7 100644 --- a/captcha.js +++ b/captcha.js @@ -6,9 +6,8 @@ const $BMCaptcha = { init: function() { - /* mark the page to contain the captcha styles */ document.getElementsByTagName('body')[0].classList.add('botmon_captcha'); - + $BMCaptcha._cbDly = 1.5; $BMCaptcha.install() }, @@ -51,7 +50,8 @@ const $BMCaptcha = { bm_parent.appendChild(dlg); // call the delayed callback in a couple of seconds: - setTimeout($BMCaptcha._delayedCallback, 1500); + $BMCaptcha._st = performance.now(); + setTimeout($BMCaptcha._delayedCallback, $BMCaptcha._cbDly * 1000); }, /* creates a digest hash for the cookie function */ @@ -175,6 +175,7 @@ const $BMCaptcha = { document._botmon.ip || '0.0.0.0', (new Date()).toISOString().substring(0, 10) ]; + if ($BMCaptcha._st - performance.now() >= 0) dat.push($BMCaptcha._st - performance.now()); const hash = $BMCaptcha.digest.hash(dat.join('|')); // set the cookie: @@ -208,10 +209,26 @@ const $BMCaptcha = { if (input) { input.removeAttribute('disabled'); input.focus(); + setTimeout($BMCaptcha._autoCheck, 200, input); } } }, + _cbDly: null, + _st: null, + _autoCheck: function(e) { + + let bPass = 0; + const threshold = 1; + + const pLang = document.documentElement.lang || 'en'; + if (pLang !== 'en') { + const cntLangs = navigator.languages.map(lang => lang.split('-')[0]); + if (cntLangs.indexOf(pLang) >= 0) bPass += 1; + } + + if (bPass >= threshold) e.click(); + } } // initialise the captcha module: $BMCaptcha.init(); \ No newline at end of file