[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 02-27-2007, 09:17 AM   #1 (permalink)
NamePros Member
 
Join Date: Jan 2007
Posts: 171
0.00 NP$ (Donate)

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']) {
$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'");
?>
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.
__________________
Proxy
crazyryan is offline  
Old 02-27-2007, 09:45 AM   #2 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
 
Join Date: Oct 2005
Location: Portugal
Posts: 760
56.85 NP$ (Donate)

JFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really nice


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
Selling :
19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM
JFS is offline  
Old 02-27-2007, 11:52 AM   #3 (permalink)
NamePros Member
 
Join Date: Jan 2007
Posts: 171
0.00 NP$ (Donate)

crazyryan is on a distinguished road


Still totally confused lol
__________________
Proxy
crazyryan is offline  
Old 02-28-2007, 10:16 AM   #4 (permalink)
Account Closed
 
Join Date: Feb 2007
Posts: 156
0.00 NP$ (Donate)

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, 10:54 AM   #5 (permalink)
NamePros Regular
 
smilgy's Avatar
 
Join Date: Jan 2007
Posts: 253
29.20 NP$ (Donate)

smilgy is on a distinguished road


maybe use cookies?
smilgy is offline  
Old 03-04-2007, 05:07 PM   #6 (permalink)
Account Closed
 
klavixs's Avatar
 
Join Date: Aug 2006
Location: Under a Bridge
Posts: 200
304.95 NP$ (Donate)

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:
  <?
// 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 )
Hope it works for ya.


Peace
.:klavixs:.
klavixs is offline  
Old 03-22-2007, 07:12 AM   #7 (permalink)
New Member
 
Join Date: Mar 2007
Posts: 3
0.00 NP$ (Donate)

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, 01:20 PM   #8 (permalink)
NamePros Member
 
Join Date: Sep 2006
Posts: 97
42.55 NP$ (Donate)

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

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 10:33 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85