Wie kann ich denn dem vom BlackGoofy empfohlenen Mod, die vom Bot gespiderten Seiten abringen?
Edit: Wäre das ein gangbarer Weg?
Neue Tabelle
Code: Alles auswählen
CREATE TABLE `phpbb_bots_log` (
`BotID` SMALLINT( 2 ) NOT NULL ,
`BotURL` VARCHAR( 255 ) NOT NULL ,
`visitdate` VARCHAR( 255 ) NOT NULL
) TYPE = MYISAM ;
In Constants.php neue Konstante definieren
Funktion is_robot in function.php erweitern
Code: Alles auswählen
function is_robot()
{
global $db, $HTTP_SERVER_VARS, $table_prefix;
// define bots table - for the users who are to lazy to edit constants.php hehehe!
define('BOTS_TABLE', $table_prefix . "bots");
// get required user data
$user_ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$user_agent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
//NEU
$requested_url=$HTTP_SERVER_VARS['REQUEST_URI'];
// 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);
}
//NEU
$sql = "INSERT INTO " . BOT_LOG_TABLE . " (BotID, BotURL, visitdate)
VALUES (" . $row['bot_id'] .",'" . $requested_url . "'," . $today . ")";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert bot URL', '', __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);
}
//NEU
$sql = "INSERT INTO " . BOT_LOG_TABLE . " (BotID, BotURL, visitdate)
VALUES (" . $row['bot_id'] .",'" . $requested_url . "'," . $today . ")";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not insert bot URL', '', __LINE__, __FILE__, $sql);
//****
}
}
}
}
return 0;
}