Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple Click Tracking With PHP
Old 04-17-2009, 11:20 PM Simple Click Tracking With PHP
Skilled Talker

Posts: 71
Trades: 0
I am looking for a very simple way of tracking clicks on an ad that does not involve JavaScript or anything client-side. I am thinking of linking the ad to a PHP page that sends an email to a free webmail account (GMail or something) including the IP and date. The page would then redirect to the ad's target location. Is this a reasonable way to implement a simple click tracking system or is there something wrong with it? I realize that if someone had access to the code they could mess with the system (by sending fake emails to the account), but no one would have anything to gain from this. (Plus, once they have access to the code, they can probably do a lot more serious harm.
zephyrcat is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-18-2009, 03:22 AM Re: Simple Click Tracking With PHP
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
what's the use?

Anyone can change IP

you should put the cookie too.

and check for user agent too.
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Old 04-18-2009, 05:14 AM Re: Simple Click Tracking With PHP
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Quote:
Originally Posted by dark_lord View Post
what's the use?

Anyone can change IP

you should put the cookie too.

and check for user agent too.
IP can't normally be cloaked or changed. otherwise if there is an experienced hacker.

you can track IP with php and send it to your email address with this simple code

PHP Code:
$message="IP: " $_SERVER["REMOTE_ADDR"] . "\n" 
"Date:" date("F j, Y, g:i a");
mail(your email,a subject,$message); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");

Last edited by nayes84; 04-18-2009 at 05:15 AM..
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 12:01 PM Re: Simple Click Tracking With PHP
Novice Talker

Posts: 6
Name: Kevin Guske
Trades: 0
There are many ways / services to spoof IP addresses or hide them altogether. It's very easy to do this, and most web attacks are generated using this approach.
kguske is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 12:10 PM Re: Simple Click Tracking With PHP
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Quote:
Originally Posted by kguske View Post
There are many ways / services to spoof IP addresses or hide them altogether. It's very easy to do this, and most web attacks are generated using this approach.
well blocking proxies can protect well from this.
most of proxies online are easily identifiable because they provide tags indicate they are proxies. even some of them provide tags showing the real ip address for the user.
only very few or those who got hacked and their machine are run by some hacker as a hidden proxy. i believe those hackers are not that much to worry about, unless you are running an online money processing or banking service
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");

Last edited by nayes84; 04-18-2009 at 12:11 PM..
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 01:12 PM Re: Simple Click Tracking With PHP
Skilled Talker

Posts: 71
Trades: 0
Thanks for all your responses. This is to keep track of the number of clicks on an ad. I am not super concerned about IP-spoofing or anything, I just wanted to put that information in so that if someone clicks the ad over and over I can figure out what happened.
zephyrcat is offline
Reply With Quote
View Public Profile
 
Old 04-18-2009, 01:16 PM Re: Simple Click Tracking With PHP
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
* Edit Found some better code *

PHP Code:
<?php # File created on 11th February 2009 by Mike Rogers (http://www.fullondesign.co.uk/). 
 
## Start defining constants ## 
 
define(RUN_ERRORSTRUE); // Do you want the script to display errors? TRUE = yes you do.
 
define(redirect_or_echo'redirect'); // Do you want to redirect the user to another website, or just echo the other other webpages' content. 'rediect' will redirect, 'echo' will return the web pages constents. I recommend redirect.
 
## End defining constants ##
 
/* Start the link codes. The code is the ?code=123 part of the URL. The array should be fotmatted like:
 
$link['code'] = 'http://URL';
 
You may find it easier to do this with MySQL or including this as a seperate file. Too many links could lower performance, but for a small website just trying to cloak a few links this is good :)
 
*/
 
$link['1'] = 'http://www.site.com/';
 
// Start the system.
 
function external_url($url){
 
    if(
$return = @file_get_contents($url)){
 
        return 
$return;
 
    }elseif(
function_exists("curl_init")){
 
        
$ch curl_init();
 
        
curl_setopt($chCURLOPT_URL$url);
 
        
curl_setopt($chCURLOPT_HEADER0);
 
        
curl_setopt($chCURLOPT_TIMEOUT10);
 
        
curl_setopt($chCURLOPT_RETURNTRANSFER1); 
 
        
$return curl_exec($ch);
 
        
curl_close($ch);
 
        return 
$return;
 
    }elseif(
$return = @implode("", @file($url))){
 
        return 
$return;
 
    } else {
 
        return 
NULL;
 
    }
 
}
 
// Checks if the code is a number
 
if(is_numeric($_GET['code']) && is_array($link)){
 
    if(isset(
$link[$_GET['code']])){
 
        if(
redirect_or_echo === 'redirect'){
 
            
header('location: '.$link[$_GET['code']]);
 
        } elseif(
redirect_or_echo === 'echo'){
 
            echo 
external_url($link[$_GET['code']]);
 
        }else{
 
            if(
RUN_ERRORS === TRUE){
 
                echo 
'Sorry, an internal error has occoured.';    
 
            }
 
        }
 
    } else {
 
        if(
RUN_ERRORS === TRUE){
 
            echo 
'Sorry, the code you have provided is incorrect.';    
 
        }
 
    }
 
}else{
 
    if(
RUN_ERRORS === TRUE){
 
        echo 
'Sorry, the code you have provided is incorrect.';    
 
    }
 
}
 
/*
 
You are free to share, modify and use this code for commerical uses. Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you.
 
You use this at your own risk.
 
*/
 
?>
Taken from: http://www.fullondesign.co.uk/coding...ring-links.htm

Essentially, exactly what you need.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 04-18-2009 at 01:25 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 04-19-2009, 01:18 AM Re: Simple Click Tracking With PHP
Skilled Talker

Posts: 71
Trades: 0
Well after spending days messing with OpenX and Google Ad Manager I got fed up and spent half an hour (I haven't done PHP in forever) putting together a page that sends an email to a special email account with the IP, referring URL, and user agent and then redirects the user to the correct page. This way I have created an (almost) transparent way of tracking the number of clicks an ad gets. Plus, I actually get more control this way, since I can tell where the clicks come from. At some later point, I might even be able to set up a rotation system, if I wanted. One thing to remember, though, is that you have to ban robots with your robots.txt file unless you want a bunch of spiders clicking on the ad. I guess the lesson is that when you want something simple, just do it yourself.
zephyrcat is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple Click Tracking With PHP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.29086 seconds with 12 queries