GeoIP touchups
This commit is contained in:
11
admin.php
11
admin.php
@@ -32,6 +32,9 @@ class admin_plugin_botmon extends AdminPlugin {
|
||||
|
||||
global $conf;
|
||||
|
||||
// display GeoIP data?
|
||||
$geoIPconf = $this->getConf('geoiplib');
|
||||
|
||||
// spinner animation as SVG image:
|
||||
$svg = '<svg width="12" height="12" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg" id="botmon__today__busy"><defs><linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="#666"></stop><stop offset="100%" stop-color="#666"></stop></linearGradient></defs><circle cx="25" cy="25" r="20" fill="none" stroke="url(#gradient)" stroke-width="8" stroke-dasharray="31.4 31.4"><animateTransform attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="1s" repeatCount="indefinite"></animateTransform></circle></svg>';
|
||||
|
||||
@@ -56,18 +59,20 @@ class admin_plugin_botmon extends AdminPlugin {
|
||||
<div id="botmon__today__content">
|
||||
<details id="botmon__today__overview" open>
|
||||
<summary>Bots overview</summary>
|
||||
<div class="botmon_bots_grid">
|
||||
<div class="botmon_bots_grid" data-geoip="' . $geoIPconf . '">
|
||||
<dl id="botmon__today__botsvshumans"></dl>
|
||||
<dl id="botmon__botslist"></dl>
|
||||
<dl id="botmon__today__countries"></dl>
|
||||
<dl id="botmon__botips"><dt>Suspected bots’ top <abbr>IP</abbr> ranges</dt><dd><mark>TODO</mark></dd></dl>
|
||||
<dl id="botmon__botcountries"></dl>
|
||||
</div>
|
||||
</details>
|
||||
<details id="botmon__today__webmetrics">
|
||||
<summary>Humans overview</summary>
|
||||
<div class="botmon_webmetrics_grid">
|
||||
<div class="botmon_webmetrics_grid" data-geoip="' . $geoIPconf . '">
|
||||
<dl id="botmon__today__wm_overview"></dl>
|
||||
<dl id="botmon__today__wm_clients"></dl>
|
||||
<dl id="botmon__today__wm_platforms"></dl>
|
||||
<dl id="botmon__today__wm_countries"></dl>
|
||||
</div>
|
||||
</details>
|
||||
<details id="botmon__today__traffic">
|
||||
|
||||
49
script.js
49
script.js
@@ -614,8 +614,6 @@ BotMon.live = {
|
||||
me.addToIPRanges(pv.ip);
|
||||
});*/
|
||||
|
||||
// add to the country lists:
|
||||
me.addToCountries(v.geo, v._country, v._type);
|
||||
|
||||
} else { /* humans only */
|
||||
|
||||
@@ -628,6 +626,9 @@ BotMon.live = {
|
||||
me.addToPagesList(pv.pg);
|
||||
});
|
||||
}
|
||||
|
||||
// add to the country lists:
|
||||
me.addToCountries(v.geo, v._country, v._type);
|
||||
|
||||
});
|
||||
|
||||
@@ -859,11 +860,8 @@ BotMon.live = {
|
||||
|
||||
/* countries of visits */
|
||||
_countries: {
|
||||
'user': [],
|
||||
'human': [],
|
||||
'likelyBot': [],
|
||||
'known_bot': []
|
||||
|
||||
'bot': []
|
||||
},
|
||||
/**
|
||||
* Adds a country code to the statistics.
|
||||
@@ -879,16 +877,12 @@ BotMon.live = {
|
||||
switch (type) {
|
||||
|
||||
case BM_USERTYPE.KNOWN_USER:
|
||||
arr = me._countries.user;
|
||||
break;
|
||||
case BM_USERTYPE.PROBABLY_HUMAN:
|
||||
arr = me._countries.human;
|
||||
break;
|
||||
case BM_USERTYPE.LIKELY_BOT:
|
||||
arr = me._countries.likelyBot;
|
||||
break;
|
||||
case BM_USERTYPE.KNOWN_BOT:
|
||||
arr = me._countries.known_bot;
|
||||
arr = me._countries.bot;
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unknown user type ${type} in function addToCountries.`);
|
||||
@@ -912,7 +906,7 @@ BotMon.live = {
|
||||
/**
|
||||
* Returns a list of countries with visit counts, sorted by visit count in descending order.
|
||||
*
|
||||
* @param {BM_USERTYPE} type The type of visitors to return.
|
||||
* @param {BM_USERTYPE} type array of types type of visitors to return.
|
||||
* @param {number} max The maximum number of entries to return.
|
||||
* @return {Array} A list of objects with properties 'iso' (ISO 3166-1 alpha-2 country code) and 'count' (visit count).
|
||||
*/
|
||||
@@ -924,17 +918,11 @@ BotMon.live = {
|
||||
let arr = null;
|
||||
switch (type) {
|
||||
|
||||
case BM_USERTYPE.KNOWN_USER:
|
||||
arr = me._countries.user;
|
||||
break;
|
||||
case BM_USERTYPE.PROBABLY_HUMAN:
|
||||
case 'human':
|
||||
arr = me._countries.human;
|
||||
break;
|
||||
case BM_USERTYPE.LIKELY_BOT:
|
||||
arr = me._countries.likelyBot;
|
||||
break;
|
||||
case BM_USERTYPE.KNOWN_BOT:
|
||||
arr = me._countries.known_bot;
|
||||
case 'bot':
|
||||
arr = me._countries.bot;
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unknown user type ${type} in function getCountryList.`);
|
||||
@@ -1778,7 +1766,7 @@ BotMon.live = {
|
||||
}
|
||||
|
||||
// update the suspected bot IP ranges list:
|
||||
/*const botIps = document.getElementById('botmon__today__botips');
|
||||
/*const botIps = document.getElementById('botmon__botips');
|
||||
if (botIps) {
|
||||
botIps.appendChild(makeElement('dt', {}, "Bot IP ranges (top 5)"));
|
||||
|
||||
@@ -1792,10 +1780,10 @@ BotMon.live = {
|
||||
}*/
|
||||
|
||||
// update the top bot countries list:
|
||||
const botCountries = document.getElementById('botmon__today__countries');
|
||||
const botCountries = document.getElementById('botmon__botcountries');
|
||||
if (botCountries) {
|
||||
botCountries.appendChild(makeElement('dt', {}, `Top bot Countries:`));
|
||||
const countryList = BotMon.live.data.analytics.getCountryList('likely_bot', 5);
|
||||
const countryList = BotMon.live.data.analytics.getCountryList('bot', 5);
|
||||
countryList.forEach( (cInfo) => {
|
||||
const cLi = makeElement('dd');
|
||||
cLi.appendChild(makeElement('span', {'class': 'has_icon country ctry_' + cInfo.id.toLowerCase() }, cInfo.name));
|
||||
@@ -1886,6 +1874,19 @@ BotMon.live = {
|
||||
}
|
||||
}
|
||||
|
||||
// update the top bot countries list:
|
||||
const usrCountries = document.getElementById('botmon__today__wm_countries');
|
||||
if (usrCountries) {
|
||||
usrCountries.appendChild(makeElement('dt', {}, `Top visitor Countries:`));
|
||||
const usrCtryList = BotMon.live.data.analytics.getCountryList('human', 5);
|
||||
usrCtryList.forEach( (cInfo) => {
|
||||
const cLi = makeElement('dd');
|
||||
cLi.appendChild(makeElement('span', {'class': 'has_icon country ctry_' + cInfo.id.toLowerCase() }, cInfo.name));
|
||||
cLi.appendChild(makeElement('span', {'class': 'count' }, cInfo.count));
|
||||
usrCountries.appendChild(cLi);
|
||||
});
|
||||
}
|
||||
|
||||
// update the top pages;
|
||||
const wmpages = document.getElementById('botmon__today__wm_pages');
|
||||
if (wmpages) {
|
||||
|
||||
39
style.less
39
style.less
@@ -405,10 +405,30 @@
|
||||
}
|
||||
}
|
||||
.botmon_bots_grid {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
&[data-geoip="disabled"] {
|
||||
& {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
#botmon__botcountries {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&:not([data-geoip="disabled"]) {
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
}
|
||||
}
|
||||
.botmon_webmetrics_grid {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
&[data-geoip="disabled"] {
|
||||
& {
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
#botmon__today__wm_countries {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&:not([data-geoip="disabled"]) {
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
}
|
||||
}
|
||||
.botmon_traffic_grid {
|
||||
grid-template-columns: 2fr 1fr;
|
||||
@@ -824,9 +844,18 @@
|
||||
}
|
||||
/* layout overrides for narrow screens: */
|
||||
@media (max-width: 670px) {
|
||||
#botmon__admin {
|
||||
.botmon_bots_grid, .botmon_webmetrics_grid {
|
||||
grid-template-columns: 100%;
|
||||
#botmon__admin #botmon__today {
|
||||
.botmon_bots_grid, .botmon_webmetrics_grid, .botmon_traffic_grid {
|
||||
& {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
dt {
|
||||
margin: .5em 0;
|
||||
}
|
||||
dl {
|
||||
border-left: transparent none 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user