其中一个帖子视图在我的网站中迅速增加 - 有些人正在玩我的网站[关闭]

I have a simple function in my php web page to count the views of page using the following query.

UPDATE tbl_threads SET  views = (views+1);

It is working fine in my website from last 4 months. but today, a few minutes ago, suddenly the views of one of my post starts increasing as 100 / minute. I think some one (Some hacker) is peneterating my site. How can i control that? How can I resolve this issue. Then after some time, one more post views started increasing in the same rate. When I checked my traffic stats in google analytics, the traffic is normal. Please Help Me.

Set a flag in the session that marks them as having been counted as a visitor:

$_SESSION['didVisit'] = 1;

And then before updating the database, make sure it's not set:

if( !isset( $_SESSION['didVisit'] )
    // DO DATABASE UPDATE

You could also set a regular cookie that indicates you count the user as a view. Then when they come in, check first if that cookie exists before updating your database. In that way, they would have to delete their cookies everytime in order to count as a new view.

In the event that you believe a bot is hitting your site and hence won't work correctly with cookies, you could take multiple buts of $_SERVER information and (as stated in comments above) attempt to create a unique hash and store it in the database to identify the visitor.

Most bots these days (the friendly ones anyway) have defined user agents which you can check for and ignore those hits: http://www.monperrus.net/martin/list+of+robot+user+agents and http://www.robotstxt.org/db.html

Try only counting page views from unique IP addresses only, that way the page views won't increase every time a user reloads your page.