CodeIgniter会话由bots垃圾邮件 [英] CodeIgniter Session spammed by bots

查看:292
本文介绍了CodeIgniter会话由bots垃圾邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站每天大约有2000名访问者,该网站被各种搜索引擎漫游器垃圾邮件。我试图减少会话到期时间到20分钟,仍然我得到了很多mysql_slow_queries。因此,我查看了 Google抓取工具,cron和代码签名会话,完全忽略来自会话表的机器人,但是它们的方式是忽略 IPs ,但是当我分析数据库时看到同一个bot使用不同的 IPs 。我注意到机器人每次使用相同的用户代理,所以可以安全地忽略用户代理?

I have a site with roughly 2000 visitors per day, and the site is spammed with the various search engine bots. I tried reducing the session expire time to 20 minutes, and still I get alot of mysql_slow_queries. So I was looking into the article, Google crawler, cron and codeigniter sessions, to fully ignore the bots from the sessions table, but the the way they do is, ignore the IPs, but as I was analyzing the database I see that the same bot uses different IPs. I noticed that the bots use the same user agent everytime though, so is it safe to ignore the user agents instead? What could be some of the necessary steps to avoid slow queries and ignore the bots?

一些SLOW查询

INSERT INTO `ci_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES ('619bfd8ef4171480645feb17a15323ee', '219.92.135.144', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15', 1384875135, '')

INSERT INTO `ci_sessions` (`session_id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES ('fa48b5168b8e84d90dc9b87ce65dfc89', '66.249.74.112', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', 1384875522, '')


推荐答案

编辑 / config 中的 user_agent.php ,并添加您在会话中看到的bot,

Edit your user_agent.php in /config, and add the bots you see in your session, adding them to the bot section should eliminate the sessions from logging.

// There are hundreds of bots but these are the most common.
$robots = array(
    'googlebot'     => 'Googlebot',
    'msnbot'        => 'MSNBot',
    'baiduspider'   => 'Baiduspider',
    'bingbot'       => 'Bing',
    'slurp'         => 'Inktomi Slurp',
    'yahoo'         => 'Yahoo',
    'askjeeves'     => 'AskJeeves',
    'fastcrawler'   => 'FastCrawler',
    'infoseek'      => 'InfoSeek Robot 1.0',
    'lycos'         => 'Lycos',
    'yandex'        => 'YandexBot'
);

你可以减少机器人的数量,但不会消除它们。此用户代理进程可用于创建 MY_session.php ,然后排除与bot匹配的代理的会话创建。

You can reduce the # of bots, but won't eliminate them. This user-agent process could be used to create a MY_session.php and then exclude session creation for agents matching bots.

EDIT:

我继续在github上创建并在此处记录:

http://blog.biernacki.ca/2014/ 01 / codeigniter-keeping-bots-out-of-your-sessions-table-or-how-i-cleans-up-my-sessions /

享受

这篇关于CodeIgniter会话由bots垃圾邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆