Current location: Hot Scripts Forums » Programming Languages » PHP » Stop refreshing the page and cheating!


Stop refreshing the page and cheating!

Reply
  #1 (permalink)  
Old 03-28-07, 04:35 PM
alej469's Avatar
alej469 alej469 is offline
Newbie Coder
 
Join Date: Apr 2005
Location: West Midlands, UK
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Stop refreshing the page and cheating!

I've got a simple query that adds 1 to the number of views whenever someone loads a page. The problem is, my site isn't too big and people can cheat and refresh the page 20 times in order to make their page the most viewed page.

I've tried using the Sleep function to slow them down, however this just seems to make the page load slower, which is really annoying for other users. Any ideas how I can stop these friggin cheaters?
__________________
Funny videos
Reply With Quote
  #2 (permalink)  
Old 03-28-07, 04:40 PM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
use a cookie to signify to your counter to not to count the reload if found.
__________________
"BTW, I can't program at all the only thing I figured out is how to upload templates to my server."
Reply With Quote
  #3 (permalink)  
Old 03-28-07, 05:10 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
PHP Code:

<?php


$length 
60 60 24 30// 1 month
if ( !isset( $_COOKIE['visited'] ) )
{
    
setcookie'visited'1time() + $length );
    
// increment hit counter
    
$counter++;
}

?>
__________________
The toxic ZCE
Reply With Quote
  #4 (permalink)  
Old 03-28-07, 07:52 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Cant there still cheat by removing all cookies then refresh again?
Reply With Quote
  #5 (permalink)  
Old 03-28-07, 08:05 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Of course, that is so obvious it probably doesn't even warrant it's own message.

It acts mainly as a deterrent. You will never be able to totally protect all forms of anonymous tracking features.

The most you could do, short of having visitors register an account, is set a cookie and track their IP... but they are both fairly limited in reliability. Do you have any other suggestions?
__________________
The toxic ZCE

Last edited by Keith; 03-28-07 at 08:08 PM.
Reply With Quote
  #6 (permalink)  
Old 03-28-07, 09:05 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
I agree.
Should put in the cookies function and also track there ip, if they view there own page like 300 times then it looks like there cheating
Give them a warning and if they dont complie then ban the cheaters
You can tell they must of viewed then removed the cookies lots of time how sad. There page must suck?
Reply With Quote
  #7 (permalink)  
Old 03-28-07, 09:46 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Warn or ban them? That's equally as difficult as tracking them without having them register.
__________________
The toxic ZCE
Reply With Quote
  #8 (permalink)  
Old 03-28-07, 10:04 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Oh ye off course. Maybe the warning can be an temporary ip ban? when this warned ip is detected on the site they can be redirected or shown a message?
Reply With Quote
  #9 (permalink)  
Old 03-28-07, 10:42 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
Good thinking, IP tracking was suggested above.
__________________
The toxic ZCE
Reply With Quote
  #10 (permalink)  
Old 03-29-07, 09:39 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You could add one more field to your dataBase table for time. Then you can query the table for them and compare that time with the current time to see if enough time has passed. If it has then credit them with a hit and update their time field. If not then don't.

If this is there first time viewing then they won't be in the dataBase yet. When you create their record for the first time, you set the time field with the current time and credit them a hit.
__________________
Jerry Broughton

Last edited by job0107; 03-29-07 at 09:41 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
LogiCodes.com is cheating on customer.... nattapon The Lounge 11 06-30-04 11:33 AM


All times are GMT -5. The time now is 05:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.