Googlebot phpbb
MOD Google.com, Alexa, Yahoo . .
:
1. admin/admin_bots.php
2. language/lang_english/lang_bot_admin.php
3. templates/ /admin/bots_add_body.tpl
4. templates/ /admin/bots_added.tpl
5. templates/ /admin/bots_body.tpl
6. bot_install.php

Googlebot

, bot_install.php :

#
#-----[ ]------------------------------------------
#

templates/ /admin/index_body.tpl

#
#-----[ ]------------------------------------------
#

<!-- BEGIN guest_user_row -->

#
#-----[ ]------------------------------------------
#

<!-- BEGIN spider_user_row -->
<tr>
<td width="20%" class="{spider_user_row.ROW_CLASS}"> <span class="gen">{spider_user_row.USERNAME}</span> </td>
<td width="20%" align="center" class="{spider_user_row.ROW_CLASS}"> <span class="gen">{spider_user_row.STARTED}</span> </td>
<td width="20%" align="center" nowrap="nowrap" class="{spider_user_row.ROW_CLASS}"> <span class="gen">{spider_user_row.LASTUPDATE}</span> </td>
<td width="20%" class="{spider_user_row.ROW_CLASS}"> <span class="gen"><a href="{spider_user_row.U_FORUM_LOCATION}" class="gen">{spider_user_row.FORUM_LOCATION}</a></span> </td>
<td width="20%" class="{spider_user_row.ROW_CLASS}"> <span class="gen"><a href="{spider_user_row.U_WHOIS_IP}" target="_phpbbwhois">{spider_user_row.IP_ADDRESS}</a></span> </td>
</tr>
<!-- END spider_user_row -->
<tr>
<td colspan="5" height="1" class="row3"><img src="../../../../phpBB2/templates/subSilver/templates/subSilver/images/spacer.gif" width="1" height="1" alt="."></td>
</tr>

#
#-----[ ]------------------------------------------
#

includes/sessions.php

#
#-----[ ]------------------------------------------
#

//
// Create or update the session
//

#
#-----[ ]------------------------------------------
#
$robot = ( ( defined('IS_ROBOT') ) ? IS_ROBOT : 0 );

#
#-----[ ]------------------------------------------
#

$sql = "UPDATE " . SESSIONS_TABLE . "
SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login, session_admin = $admin
WHERE session_id = '" . $session_id . "'
AND session_ip = '$user_ip'";

#
#-----[ ]------------------------------------------
#

session_page = $page_id, session_logged_in = $login

#
#-----[ ]------------------------------------------
#

, is_robot = '$robot'

#
#-----[ ]------------------------------------------
#

$sql = "INSERT INTO " . SESSIONS_TABLE . "
(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in, session_admin)

#
#-----[ ]------------------------------------------
#

session_page, session_logged_in

#
#-----[ ]------------------------------------------
#

, is_robot

#
#-----[ ]------------------------------------------
#


VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login, $admin)";


#
#-----[ ]------------------------------------------
#

'$user_ip', $page_id, $login

#
#-----[ ]------------------------------------------
#

, '$robot'

#
#-----[ ]------------------------------------------
#

global $SID;

if ( !empty($SID) && !preg_match('#sid=#', $url) )

#
#-----[ ]------------------------------------------
#

global $SID;

if ( !empty($SID) && !preg_match('#sid=#', $url) && !IS_ROBOT )

#
#-----[ ]------------------------------------------
#

viewonline.php

#
#-----[ ]------------------------------------------
#

$sql = "SELECT u.user_id, u.username, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_time, s.session_page, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
ORDER BY u.username ASC, s.session_ip ASC";

#
#-----[ ]------------------------------------------
#

s.session_page, s.session_ip

#
#-----[ ]------------------------------------------
#

, s.is_robot

#
#-----[ ]------------------------------------------
#
$username = $lang['Guest'];
#
#-----[ ]------------------------------------------
#
if($row['is_robot'])
{
$username = $row['is_robot'] . ' ( Bots )';
} else {
$username = $lang['Guest'];
}
#
#-----[ ]------------------------------------------
#

includes/page_header.php

#
#-----[ ]------------------------------------------
#

$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_level, s.session_logged_in, s.session_ip
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." s
WHERE u.user_id = s.session_user_id
AND s.session_time >= ".( time() - 300 ) . "
$user_forum_sql
ORDER BY u.username ASC, s.session_ip ASC";


#
#-----[ ]------------------------------------------
#

s.session_logged_in, s.session_ip

#
#-----[ ]------------------------------------------
#

, s.is_robot

#
#-----[ ]------------------------------------------
#


$userlist_ary = array();
$userlist_visible = array();

$prev_user_id = 0;
$prev_user_ip = $prev_session_ip = '';

#
#-----[ ]------------------------------------------
#

$prev_is_robot = '';

#
#-----[ ]------------------------------------------
#
$guests_online++;
}
}

$prev_session_ip = $row['session_ip'];

#
#-----[ ]------------------------------------------
#

$guests_online++;

if (($row['is_robot'] != '0') && ($row['is_robot'] != $prev_is_robot))
{



$row['is_robot'] = '<span style="color:#' . $theme['body_link'] . '"><b>' . $row['is_robot'] . '</b></span>';
$online_userlist = $row['is_robot'] . (($online_userlist!='') ? ', ' : '') . $online_userlist;

}

}

}
$prev_is_robot = $row['is_robot'];
$prev_session_ip = $row['session_ip'];


#
#-----[ ]------------------------------------------
#

common.php

#
#-----[ ]------------------------------------------
#

?>

#
#-----[ ]------------------------------------------
#

define('IS_ROBOT', is_robot() );


#
#-----[ ]------------------------------------------
#

admin/index.php

#
#-----[ ]------------------------------------------
#

$sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start
FROM " . SESSIONS_TABLE . "
WHERE session_logged_in = 0

#
#-----[ ]------------------------------------------
#

AND is_robot = '0'


#
#-----[ ]------------------------------------------
#

$onlinerow_guest = $db->sql_fetchrowset($result);

#
#-----[ ]------------------------------------------
#


$sql = "SELECT session_page, session_logged_in, session_time, session_ip, session_start, is_robot
FROM " . SESSIONS_TABLE . "
WHERE session_logged_in = 0
AND is_robot !='0'
AND session_time >= " . ( time() - 300 ) . "
ORDER BY session_time DESC";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Couldn't obtain spiders online information.", "", __LINE__, __FILE__, $sql);
}
$onlinerow_spider = $db->sql_fetchrowset($result);


#
#-----[ ]------------------------------------------
#


else
{
$template->assign_vars(array(
"L_NO_GUESTS_BROWSING" => $lang['No_users_browsing'])
);
}


#
#-----[ ]------------------------------------------
#


//
// search engine spiders
//

if ( count($onlinerow_spider) )
{

$spider_users = 0;

for($i = 0; $i < count($onlinerow_spider); $i++)
{
$spider_userip_ary[] = $onlinerow_spider[$i]['session_ip'];
$spider_users++;

if( $onlinerow_spider[$i]['session_page'] < 1 )
{
switch( $onlinerow_spider[$i]['session_page'] )
{
case PAGE_INDEX:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_POSTING:
$location = $lang['Posting_message'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_LOGIN:
$location = $lang['Logging_on'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_SEARCH:
$location = $lang['Searching_forums'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_PROFILE:
$location = $lang['Viewing_profile'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_VIEWONLINE:
$location = $lang['Viewing_online'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_VIEWMEMBERS:
$location = $lang['Viewing_member_list'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_PRIVMSGS:
$location = $lang['Viewing_priv_msgs'];
$location_url = "index.$phpEx?pane=right";
break;
case PAGE_FAQ:
$location = $lang['Viewing_FAQ'];
$location_url = "index.$phpEx?pane=right";
break;
default:
$location = $lang['Forum_index'];
$location_url = "index.$phpEx?pane=right";
}
}
else
{
$location_url = append_sid("admin_forums.$phpEx?mode=editforum&" . POST_FORUM_URL . "=" . $onlinerow_spider[$i]['session_page']);
$location = $forum_data[$onlinerow_spider[$i]['session_page'>;
}

$row_color = ( $spider_users % 2 ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( $spider_users % 2 ) ? $theme['td_class1'] : $theme['td_class2'];

$spider_ip = decode_ip($onlinerow_spider[$i]['session_ip']);

$template->assign_block_vars("spider_user_row", array(
"ROW_COLOR" => "#" . $row_color,
"ROW_CLASS" => $row_class,
"USERNAME" => $onlinerow_spider[$i]['is_robot'],
"STARTED" => create_date($board_config['default_dateformat'], $onlinerow_spider[$i]['session_start'], $board_config['board_timezone']),
"LASTUPDATE" => create_date($board_config['default_dateformat'], $onlinerow_spider[$i]['session_time'], $board_config['board_timezone']),
"FORUM_LOCATION" => $location,
"IP_ADDRESS" => $spider_ip,

"U_WHOIS_IP" => "http://network-tools.com/default.asp?host=$spider_ip",
"U_FORUM_LOCATION" => append_sid($location_url))
);
}

}
else
{
$template->assign_vars(array(
"L_NO_Spiders_BROWSING" => $lang['No_users_browsing'])
);
}

#
#-----[ ]------------------------------------------
#

includes/constants.php

#
#-----[ ]------------------------------------------
#

?>

#
#-----[ ]------------------------------------------
#

define('BOTS_TABLE', $table_prefix . "bots");

#
#-----[ ]------------------------------------------
#


includes/functions.php

#
#-----[ ]------------------------------------------
#

global $board_config, $theme, $images;

#
#-----[ ]------------------------------------------
#
global $board_config, $theme, $images, $db, $table_prefix;

#
#-----[ ]------------------------------------------
#
$theme = setup_style($board_config['default_style']);

#
#-----[ ]------------------------------------------
#
if (IS_ROBOT)
{
$sql = "SELECT bot_style FROM " . $table_prefix . "bots WHERE bot_name='" . IS_ROBOT . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$theme = setup_style($row['bot_style']);
} else {
$theme = setup_style($board_config['default_style']);
}

#
#-----[ ]------------------------------------------
#

?>

#
#-----[ ]------------------------------------------
#

//
// Part of bot MOD: This function checks whether the user agent or ip is
// listed as a bot and returns true otherwise false.
//

function is_robot()
{
global $db, $HTTP_SERVER_VARS, $table_prefix;


// get required user data
$user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$user_agent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];

// get bot table data
$sql = "SELECT bot_agent, bot_ip, bot_id, bot_visits, last_visit, bot_pages, bot_name
FROM " . BOTS_TABLE;

if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain bot data.', '', __LINE__, __FILE__, $sql);
}

// loop through bots table
while ($row = $db->sql_fetchrow($result))
{
// clear vars
$agent_match = 0;
$ip_match = 0;

// check for user agent match
foreach (explode('|', $row['bot_agent']) as $bot_agent)
{
if ($row['bot_agent'] && $bot_agent != '' && preg_match('#' . preg_quote($bot_agent, '#') . '#i', $user_agent)) $agent_match = 1;
}

// check for ip match
foreach (explode('|', $row['bot_ip']) as $bot_ip)
{
if ($row['bot_ip'] && $bot_ip != '' && strpos($user_ip, $bot_ip) === 0)
{
$ip_match = 1;
break;
}
}

// if both ip and agent matched update table and return true
if ($agent_match == 1 && $ip_match == 1)
{
// get time - seconds from epoch
$today = time();

$last_visits = explode('|', $row['last_visit']);

// if half an hour has passed since last visit
if (($today - (($last_visits[0] == '') ? 0 : $last_visits[0])) > 2700)
{
for ($i = ((4 > sizeof($last_visits)) ? sizeof($last_visits) : 4); $i >= 0; $i--)
{
if ($last_visits[$i-1] != '') $last_visits[$i] = $last_visits[$i-1];
}

// increment the new visit counter
$row['bot_visits']++;

// clear prior indexed pages
$row['bot_pages'] = 1;
} else {
// add to indexed pages
$row['bot_pages']++;
}

$last_visits[0] = $today;

// compress it all together
$last_visit = implode("|", $last_visits);

// update table
$sql = "UPDATE " . BOTS_TABLE . "
SET last_visit='$last_visit', bot_visits='" . $row['bot_visits'] . "', bot_pages='" . $row['bot_pages'] . "'
WHERE bot_id = " . $row['bot_id'];

if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t update data in bots table.', '', __LINE__, __FILE__, $sql);
}

return $row['bot_name'];

}
else
{
if ($agent_match == 1 || $ip_match == 1)

{

// get data from table
$sql = "SELECT pending_" . ((!$agent_match) ? 'agent' : 'ip') . "
FROM " . BOTS_TABLE . "
WHERE bot_id = " . $row['bot_id'];

if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain bot data.', '', __LINE__, __FILE__, $sql);
}

$row2 = $db->sql_fetchrow($result2);

// add ip/agent to the list
$pending_array = (( $row2['pending_' . ((!$agent_match) ? 'agent' : 'ip')] ) ? explode('|', $row2['pending_' . ((!$agent_match) ? 'agent' : 'ip')]) : array());

$found = 0;

if ( sizeof($pending_array) )
{
for ($loop = 0; $loop < count($pending_array); $loop+=2)
{
if ($pending_array[$loop] == ((!$agent_match) ? $user_agent : $user_ip)) $found = 1;
}
}

if ($found == 0)
{
$pending_array[] = ((!$agent_match) ? str_replace("|", "|", $user_agent) : $user_ip);
$pending_array[] = ((!$agent_match) ? $user_ip : str_replace("|", "|", $user_agent));
}
$pending = implode("|", $pending_array);

// update table
$sql = "UPDATE " . BOTS_TABLE . "
SET pending_" . ((!$agent_match) ? 'agent' : 'ip') . "='$pending'
WHERE bot_id = " . $row['bot_id'];

if ( !($result2 = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Couldn\'t update data in bots table.', '', __LINE__, __FILE__, $sql);
}
}
}

}

return 0;
}

#
#-----[ ]------------------------------------------








/ /
: webdeveloper
5:38 06-07-2010
?
1