Bots Online

I came across this simple mod that has been requested dozens of times. Works well with a little modification.
- Code: Select all
################################################################ MOD Title]http://www.phpbb-seo.com/#[/url]# MOD De.scription: Adds the bots browsing the forum in the index viewonline, one entry per bot.#### MOD Version: 0.0.2#### Installation Level: (EASY)## Installation Time: 5 Minutes## Files To Edit: (5)## includes/page_header.php## includes/functions.php ## language/lang_english/lang_main.php## templates/Integra2/index_body.tpl#### Included Files: (1)################################################################## Author Notes:## _____________## ## This mod will add the bots name currently browsing the forum pages in the who is online block on forum index.## Each bots uses a special color.#### Example :## In total there is 25 user online :: 8 Registered, 2 Hidden, 11 Guests and 4 Bots## ^^^^^^^^^## Bots : Google , Yahoo! (2), MSN## ## As you can see, if a bot is crawling your forum with several IPs, it won't be listed several times.## The number of occurrences will be added after the bot's name, if applicable.## ## Bot detection is performed using IP ranges for a lot faster and handier use. ## For example Google can be detected with this range : 66.249.xx.xx## Ip range test means a lot less tests and a lot less IP updates.## Some will argue there could be false positive, as even if the whole ip Range is owned by Google,## not all IPs are used to crawl.## Our answer is this is a cosmetic mod, not a bot tracking mod, would you prefer to perform hundreds of IP ## tests within this range and Check UAs to make sure you're being crawled on each page load ?## Would this be worth it for the few times you could get false positives ?#### Of course it could occur that a search engine starts using new IP ranges. And thus an IP range list update ## on this mod, but, this is rather a rare occurrence.## ## The default Ip range list will allow for Google, Yahoo! and MSN bot recognition.#### License: [url=http://opensource.org/licenses/gpl-license.php]http://opensource.org/licenses/gpl-license.php[/url] GNU General Public License v2 ################################################################ MOD History:#### 2007-01-19 - 0.0.2## - First Release#### 2006-12-23 - 0.0.1## - Internal beta version.################################################################## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD############################################################## ##-----[ DIY INSTRUCTIONS ]------------------------------------------# Upload : contrib/xs_simple_show_bots.cfg to: root/admin and root/admin/modules ##-----[ OPEN ]----------------------------------------------# includes/page_header.php ##-----[ FIND ]----------------------------------------------# define('HEADER_INC', TRUE); ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN - BOTS$bots_online = array();$online_botlist = '';$bot_count = 0;$bot_style = array( 'Google' => 'style="color:#2159D6;font-weight:bold"', 'MSN' => 'style="color:#52BA18;font-weight:bold"', 'Yahoo!' => 'style="color:#FF0031;font-weight:bold"' );$bot_to_style = array( 'Google', 'Yahoo!', 'Yahoo!' , 'Yahoo!', 'MSN', 'MSN', 'MSN', 'MSN');$bot_ips = array( '66.249', '74.6', '66.196', '66.142', '64.4', '65.5', '131.107', '207.46' );// [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END - BOTS ##-----[ FIND ]----------------------------------------------# // Skip multiple sessions for one user if ( $row['session_ip'] != $prev_session_ip ) { $row['style'] = ''; $connected[] = $row; ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN $bot_id = is_bot(decode_ip($row['session_ip'])); if ( $bot_id >=0 ) { $guests_online--; $bot_count++; if ( !array_key_exists($bot_to_style[$bot_id], $bots_online) ) { $bots_online[$bot_to_style[$bot_id]] = 1; } else { $bots_online[$bot_to_style[$bot_id]] ++; } } // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END##-----[ FIND ]----------------------------------------------# if ( empty($online_userlist) ) { $online_userlist = $lang['None']; } ##-----[ BEFORE, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN if ( !empty($bots_online) ) { foreach ( $bots_online as $bot => $bot_num) { $bot_cnt = ( $bot_num > 1) ? "($bot_num)" : ''; $online_botlist .= (($online_botlist!='') ? ', ' : '') . "<span>$bot $bot_cnt</span>"; } } // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ FIND ]----------------------------------------------# $total_online_users = $logged_visible_online + $logged_hidden_online + $guests_online; ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN $total_online_users += $bot_count; // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ FIND ]----------------------------------------------# else { $l_g_user_s = $lang['Guest_users_total']; } ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN if ( $bot_count == 0 ) { $l_bot = $lang['Bot_nul']; } else if ( $bot_count == 1 ) { $l_bot = $lang['Bot_one']; } else { $l_bot = $lang['Bot_total']; } // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ FIND ]----------------------------------------------# $l_online_users .= sprintf($l_g_user_s, $guests_online); ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN $l_online_users .= sprintf($l_bot, $bot_count); // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ FIND ]----------------------------------------------# 'LOGGED_IN_USER_LIST' => $online_userlist, ##-----[ AFTER, ADD ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN 'BOT_LIST' => $lang['Bot_online'] . ( ($online_botlist != '') ? $online_botlist : $lang['None']), // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ OPEN ]----------------------------------------------#includes/functions.php ##-----[ FIND ]----------------------------------------------# ?> ##-----[ BEFORE, ADD ]----------------------------------------------#// [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN/*** tell if user is a bot on ip match*/function is_bot($user_ip) { global $bot_ips; if ( !empty($bot_ips) ) { foreach ( $bot_ips as $bot_id => $bot_ip) { if ( strpos(trim($user_ip), $bot_ip) === 0) { return $bot_id; } } } return -1;}// [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ OPEN ]----------------------------------------------# language/lang_english/lang_main.php ##-----[ FIND ]----------------------------------------------# $lang['Hidden_users_zero_total'] = '0 Hidden and ';$lang['Hidden_user_total'] = '%d Hidden and ';$lang['Hidden_users_total'] = '%d Hidden and ';$lang['Guest_users_zero_total'] = '0 Guests';$lang['Guest_users_total'] = '%d Guests';$lang['Guest_user_total'] = '%d Guest'; ##-----[ REPLACE WITH ]----------------------------------------------# // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN$lang['Hidden_users_zero_total'] = '0 Hidden, ';$lang['Hidden_user_total'] = '%d Hidden, ';$lang['Hidden_users_total'] = '%d Hidden, ';$lang['Guest_users_zero_total'] = '0 Guests and ';$lang['Guest_users_total'] = '%d Guests and ';$lang['Guest_user_total'] = '%d Guest and ';$lang['Bot_online'] = 'Online Bots : ';$lang['Bot_nul'] = '0 Bots';$lang['Bot_total'] = '%d Bots';$lang['Bot_one'] = '%d Bot';// [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END ##-----[ OPEN ]----------------------------------------------# templates/subSilver/index_body.tpl ##-----[ FIND ]----------------------------------------------# {LOGGED_IN_USER_LIST} ##-----[ IN-LINE FIND ]----------------------------------------------# {LOGGED_IN_USER_LIST} ##-----[ IN-LINE AFTER, ADD ]----------------------------------------------# <br>{BOT_LIST} ##-----[ SAVE/CLOSE ALL FILES ]------------------------------------------## EoM FRENCH INSTALL : The French lang code changes are the following : OPEN :______ language/lang_french/lang_main.php FIND :______ $lang['Hidden_users_zero_total'] = '0 Invisible et ';$lang['Hidden_user_total'] = '%d Invisible et ';$lang['Hidden_users_total'] = '%d Invisibles et ';$lang['Guest_users_zero_total'] = '0 InvitÃÂÂ ©';$lang['Guest_users_total'] = '%d InvitÃÂÂ ©s';$lang['Guest_user_total'] = '%d InvitÃÂÂ ©'; REPLACE WITH :______________ // [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT BEGIN$lang['Hidden_users_zero_total'] = '0 Invisible, ';$lang['Hidden_user_total'] = '%d Invisible, ';$lang['Hidden_users_total'] = '%d Invisibles, ';$lang['Guest_users_zero_total'] = '0 InvitÃÂÂ © et ';$lang['Guest_users_total'] = '%d InvitÃÂÂ ©s et ';$lang['Guest_user_total'] = '%d InvitÃÂÂ © et ';$lang['Bot_online'] = 'Bots : ';$lang['Bot_nul'] = '0 Bots';$lang['Bot_total'] = '%d Bots';$lang['Bot_one'] = '%d Bot';// [url=http://www.phpBB-SEO.com]http://www.phpBB-SEO.com[/url] SEO TOOLKIT END