NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Earn $5 - Limiting users clicking to once every 24 hrs.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-27-2007, 10:17 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Jan 2007
Posts: 207
crazyryan is on a distinguished road
 



Earn $5 - Limiting users clicking to once every 24 hrs.


Basically, if a user goes to proxy.php?id=73 on my site, it'll update the visits out counter for that link id by adding 1, so it adds 1 each time it is clicked.

However, that can obviously be cheated by someone clicking it 10 times in like 10 seconds and easily making the links out go to 10.

I want to like, let users click proxy.php?id=whatever as many times as they want, but only unique clicks are counted, so if i clicked a link 10 times, the links out for that id would go up 1, and not 10 like it does currently.

PHP Code:
<?
// We need the database stuff
require 'config.php';
if (
$_GET['id']) {
????: NamePros.com http://www.namepros.com/programming/299260-earn-5-limiting-users-clicking-once.html
$id mysql_real_escape_string(addslashes($_GET['id']));
// Check ID exists
$q "SELECT * from links where link_id = '$id'";
????: NamePros.com http://www.namepros.com/showthread.php?t=299260
$res mysql_query($q) or die("Error in query " mysql_error());
$nr mysql_num_rows($res);
if (
$nr 0) {
$data mysql_fetch_assoc($res);
mysql_query("UPDATE links set link_visitors = (link_visitors + 1) where link_id = '$id'");
?>
Is my code, I'm guessing I need some kind of if statement before the UPDATE query.

$5 to anyone who does it for me.
crazyryan is offline  
Old 02-27-2007, 10:45 AM   #2 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
Join Date: Oct 2005
Location: Portugal
Posts: 800
JFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to all
 



check this :
http://www.phpfreaks.com/quickcode/U...Counter/52.php

it's very basic but it will get the job done, if you want something working with db check:
http://inobscuro.com/tutorials/read/30/


hope it helps
__________________
Joćo Fernandes Silva
JFS is offline  
Old 02-27-2007, 12:52 PM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Jan 2007
Posts: 207
crazyryan is on a distinguished road
 



Still totally confused lol
crazyryan is offline  
Old 02-28-2007, 11:16 AM   #4 (permalink)
Account Closed
Join Date: Feb 2007
Posts: 156
zzzw is an unknown quantity at this point
 



yeah its easy i suppose you just check and remember ip and check if you had the same ip in the last 10 minutes ? nothing special.

basically you get the user's ip and put it in the stack. next time you check you remove old entries and check the users ip against what's left in the stack
zzzw is offline  
Old 03-04-2007, 11:54 AM   #5 (permalink)
NamePros Regular
 
smilgy's Avatar
Join Date: Jan 2007
Posts: 255
smilgy is on a distinguished road
 



maybe use cookies?
smilgy is offline  
Old 03-04-2007, 06:07 PM   #6 (permalink)
Account Closed
 
klavixs's Avatar
Join Date: Aug 2006
Location: Under a Bridge
Posts: 200
klavixs will become famous soon enoughklavixs will become famous soon enough
 



Cool ok here you go


ok here you go


OLD:
PHP Code:
  <?
// We need the database stuff
require 'config.php';
if (
$_GET['id']) {
$id mysql_real_escape_string(addslashes($_GET['id']));
// Check ID exists
$q "SELECT * from links where link_id = '$id'";
$res mysql_query($q) or die("Error in query " mysql_error());
$nr mysql_num_rows($res);
if (
$nr 0) {
$data mysql_fetch_assoc($res);
mysql_query("UPDATE links set link_visitors = (link_visitors + 1) where link_id = '$id'");
?>
New:
PHP Code:
  <?
????: NamePros.com http://www.namepros.com/showthread.php?t=299260
// We need the database stuff
require 'config.php';
if (
$_GET['id']) {
$id mysql_real_escape_string(addslashes($_GET['id']));
// Check ID exists
$q "SELECT * from links where link_id = '$id'";
$res mysql_query($q) or die("Error in query " mysql_error());
$nr mysql_num_rows($res);
if (
$nr 0) {
$data mysql_fetch_assoc($res);
//if they dont have they cookie saying the used this already today.
if(!isset($_COOKIE[$id]))
{
mysql_query("UPDATE links set link_visitors = (link_visitors + 1) where link_id = '$id'");
//they used link set cookie
setcookie($id,"clicked");
}
//else nothing
?>
If this worked then please pm me for payment details(i can use the money )
????: NamePros.com http://www.namepros.com/showthread.php?t=299260
Hope it works for ya.


Peace
.:klavixs:.
klavixs is offline  
Old 03-22-2007, 08:12 AM   #7 (permalink)
New Member
Join Date: Mar 2007
Posts: 3
Houdas is an unknown quantity at this point
 



The solution by klavixs is cool, but what if the user has forbidden cookies? Or not forbidden, but he can delete the cookie and click again?

I would suggest logging user clicks to a database (based on user's IP address) instead.
Houdas is offline  
Old 03-22-2007, 02:20 PM   #8 (permalink)
NamePros Member
Join Date: Sep 2006
Posts: 97
The Critic is an unknown quantity at this point
 



IP addresses can easily be changed as well. All you have to do is have a few proxies up in multiple windows and just click away. Proxies can also block cookies, making tracking by cookie less than perfect as well.

A good compromise would be to plant a cookie with a unique id (md5(rand()) or something) when the person visits the page with the link and not allow the click if it doesn't exist. You can match the identifier with an IP range rather than an address so that people with dynamic IPs can't cheat the system. This weeds out the people who have cookies disabled. People can still clear out their cookies afterward and use a proxy to get a fresh cookie, but honestly there really isn't much you can do about that. Even banning proxy users by domain or IP wouldn't be perfect since new ones pop up everyday.
__________________
Paid Surveys
The Critic is offline  
Closed Thread


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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:31 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger