Track an email address click through using the click.php???

danjd

New Member
Anyone know if i can adapt the click.php to display the email address of the person who clicked the link?

I'm think that using tags and the click.php script i should be able to.

Stan... you seem to be the man..... what do you reckon? this is lifted from the click through page 'You could also track people e-mails for example.'

big thanks!
 

stanbusk

Administrator
Staff member
Yes, you can do that. You have to add code to get that data stored in a second file for example. It is more o less duplicating part of the existing code.
 

danjd

New Member
Great!

So my second question is...... :wink:

well how would i go about that then. I'm not really the programming whizz.......:oops: Do you have any examples of this you would be willing to share with us Stan?

PS Thanks so much for the quick response!
 

stanbusk

Administrator
Staff member
This is an example that logs 2 more parameters,
the country and the operating system:
Code:
<?php
/***************************************************************************
 *                               click.php
 *                            -------------------
 *   begin                : Monday, Jan 30, 2006
 *   copyright            : (C) 2006 MaxProgramming, LLC
 *   email                : [email protected]
 *
 ***************************************************************************/
 
import_request_variables('GPC'); // In case register_globals = OFF in php.ini

//--SETTINGS--------------------------------------------------------------------

$filename         = 'click.dat';   // Data file path
$filename_country = 'country.dat'; // Data file path
$filename_system  = 'system.dat';  // Data file path

$password = 'admin';     // Admin panel password

//--SCRIPT----------------------------------------------------------------------

if (file_exists($filename)) {
   $handle = fopen($filename, "r+"); //The file $filename exists
} else {
   $handle = fopen($filename, "a+"); //The file $filename doesn't exists
   rewind($handle);
}
$fcontents = file($filename);

if (file_exists($filename_country)) {
   $handle_country = fopen($filename_country, "r+"); //The file $filename_country exists
} else {
   $handle_country = fopen($filename_country, "a+"); //The file $filename_country doesn't exists
   rewind($handle_country);
}
$fcontents_country = file($filename_country);

if (file_exists($filename_system)) {
   $handle_system = fopen($filename_system, "r+"); //The file $filename_system exists
} else {
   $handle_system = fopen($filename_system, "a+"); //The file $filename_system doesn't exists
   rewind($handle_system);
}
$fcontents_system = file($filename_system);

if ($admin == $password) {
	$page .= "<html>\n";
	$page .= "<head><title>Admin Page</title></head>\n";
	$page .= "<body bgcolor=#ffaa04>\n";

	$page .= "<table border=1 cellpadding=5 cellspacing=0>\n";
	$page .= "<tr bgcolor=#0703A9>\n";
	$page .= "<td colspan=2><font size=3 face=arial color=white><b>Click Count Statistics</b></font></td>\n";
	$page .= "</tr>\n";
	$page .= "<tr bgcolor=#999999>\n";
	$page .= "<td><font size=2 face=arial><B>URL</td>\n";
	$page .= "<td align=center><font size=2 face=arial><B>Clicks</td>\n";
	$page .= "</tr>\n";
	while (list ($line_num, $line) = each ($fcontents)) { // while there are elements in the array
		list($url, $count) = split('\|', $line);
		$page .= "<tr bgcolor=#dddddd><td><font size=2 face=arial><a href=\"$url\" target=\"_blank\">$url</a></td><td align=center><font size=2 face=arial>$count</td><tr>\n";
	}
	$page .= "</table>\n";

	$page .= "<br>\n";

	// ------------------------------ Display Country Statistics
	$page .= "<table border=1 cellpadding=5 cellspacing=0>\n";
	$page .= "<tr bgcolor=#0703A9>\n";
	$page .= "<td colspan=2><font size=3 face=arial color=white><b>Country Statistics</b></font></td>\n";
	$page .= "</tr>\n";
	$page .= "<tr bgcolor=#999999>\n";
	$page .= "<td><font size=2 face=arial><B>Country</td>\n";
	$page .= "<td align=center><font size=2 face=arial><B>Clicks</td>\n";
	$page .= "</tr>\n";
	while (list ($line_num, $line) = each ($fcontents_country)) { // while there are elements in the array
		list($data, $count) = split('\|', $line);
		$page .= "<tr bgcolor=#dddddd><td><font size=2 face=arial>$data</td><td align=center><font size=2 face=arial>$count</td><tr>\n";
	}
	$page .= "</table>\n";

	$page .= "<br>\n";

	// ------------------------------ Display Operating System Statistics
	$page .= "<table border=1 cellpadding=5 cellspacing=0>\n";
	$page .= "<tr bgcolor=#0703A9>\n";
	$page .= "<td colspan=2><font size=3 face=arial color=white><b>Operating System Statistics</b></font></td>\n";
	$page .= "</tr>\n";
	$page .= "<tr bgcolor=#999999>\n";
	$page .= "<td><font size=2 face=arial><B>Operating System</td>\n";
	$page .= "<td align=center><font size=2 face=arial><B>Clicks</td>\n";
	$page .= "</tr>\n";
	while (list ($line_num, $line) = each ($fcontents_system)) { // while there are elements in the array
		list($data, $count) = split('\|', $line);
		$page .= "<tr bgcolor=#dddddd><td><font size=2 face=arial>$data</td><td align=center><font size=2 face=arial>$count</td><tr>\n";
	}
	$page .= "</table>\n";

	$page .= "</body>\n";
	$page .= "</html>\n";

	echo $page;

} else {

	// ------------------------------ We log the country
	if ($country <> "") {
		$exists = False;
		while (list ($line_num, $line) = each ($fcontents_country)) { // while there are elements in the array
			list($data, $count) = split('\|', $line);			
			$count = str_replace("\n", "", $count);		
			if (strcmp($data, $country) == 0) { 
				//$count = intval($count);
				$count++;
				$exists = True;
			} 
			
			if ($line_num > '0') { $newcontents_country .= "\n"; }
			$newcontents_country .= "$data|$count";
		}

		if (!$exists) {
			if ($newcontents_country <> "") { $newcontents_country .="\n"; }
			$count = 1;
			$newcontents_country .= "$country|$count";
		}

		if (flock($handle_country, LOCK_EX)) { 
			fputs($handle_country, $newcontents_country);
			flock($handle_country, LOCK_UN);
		}
		
		fclose($handle_country);

	}

	// ------------------------------ We log the operating system
	if ($system <> "") {
		$exists = False;
		while (list ($line_num, $line) = each ($fcontents_system)) { // while there are elements in the array
			list($data, $count) = split('\|', $line);			
			$count = str_replace("\n", "", $count);		
			if (strcmp($data, $system) == 0) { 
				//$count = intval($count);
				$count++;
				$exists = True;
			} 
			
			if ($line_num > '0') { $newcontents_system .= "\n"; }
			$newcontents_system .= "$data|$count";
		}

		if (!$exists) {
			if ($newcontents_system <> "") { $newcontents_system .="\n"; }
			$count = 1;
			$newcontents_system .= "$system|$count";
		}

		if (flock($handle_system, LOCK_EX)) { 
			fputs($handle_system, $newcontents_system);
			flock($handle_system, LOCK_UN);
		}
		
		fclose($handle_system);

	}

	// ------------------------------ We log the URL that was clicked
	if ($link <> "") {
		$exists = False;
		while (list ($line_num, $line) = each ($fcontents)) { // while there are elements in the array
			list($url, $count) = split('\|', $line);			
			$count = str_replace("\n", "", $count);		
			if (strcmp($url, $link) == 0) { 
				//$count = intval($count);
				$count++;
				$exists = True;
			} 
			
			if ($line_num > '0') { $newcontents .= "\n"; }
			$newcontents .= "$url|$count";
		}

		if (!$exists) {
			if ($newcontents <> "") { $newcontents .="\n"; }
			$count = 1;
			$newcontents .= "$link|$count";
		}

		if (flock($handle, LOCK_EX)) { 
			fputs($handle, $newcontents);
			flock($handle, LOCK_UN);
		}
		
		fclose($handle);
		
		if ( $forward == "no" ) {
			//Do nothing
		} else {
			header("Location: $link");
		}
	}
}

?>
 

mdelrossi

New Member
I had it working but for some reason it doesen't anymore.

Code:
php?email=[E-mail Address]
what am I doing wrong?

thanks
mdr
 
Top