Dynadot โ€” .com Transfer

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

SpaceshipSpaceship
Watch

crazyryan

Established Member
Impact
2
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:
<?
// 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.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
0
•••
Still totally confused lol :(
 
0
•••
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
 
0
•••
maybe use cookies?
 
0
•••
ok here you go

ok here you go


OLD:
PHP:
  <?
// 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:
  <?
// 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:.
 
0
•••
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.
 
0
•••
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.
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Spaceship
Domain Recover
CatchDoms
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back