Tracking & Redirect Script
Hey Folks
OK so here is all the code you guys need for a click tracking & redirect script
First of all if you want to capture the visitors country code you need to create a FREE account at IP Stack
https://ipstack.com/signup/free
Once done you then can login and you will see your API key ( KEEP THIS PRIVATE ! )
Create a file called play.php and paste the code below and then edit
Code:
<?php
// Display Message In Case Script Takes A While To Finish
echo 'Redirecting .... Please Wait';
//
// Database Info
$dbn = 'DATABASE-NAME';
$dbu = 'USERNAME';
$dbp = 'PASSWORD';
$dbh = 'localhost';
$dbc = mysqli_connect($dbh,$dbu,$dbp,$dbn);
//
// Info To Be Added
$site = 'PlayMegaMoolah.co.uk'; // Site Name To Be Tracked
$brand = $_GET['brand']; // Desired Destination
$dd = date('d');
$mm = date('m');
$yy = date('Y');
$ip = $_SERVER['REMOTE_ADDR'];
//
// Initialize CURL:
$access_key = 'YOUR API KEY';
$ch = curl_init('http://api.ipstack.com/'.$ip.'?access_key='.$access_key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
curl_close($ch);
$api_result = json_decode($json, true);
$ccode = $api_result['country_code'];
$cname = $api_result['country_name'];
//
// Add Visit Info Into DB
$addstat = mysqli_query($dbc,"INSERT INTO `tracking` (day,month,year,ip,cc,cname,site,destination) VALUES ('$dd','$mm','$yy','$ip','$ccode','$cname','$site','$brand')");
//
// I HAVE LEFT MY BRAND NAMES AND LINKS IN BELOW SO YOU CAN SEE HOW THIS FLOWS FROM THE HTACCESS
// FILE TO HERE - REMEMBER TO CHANGE BRANDS THERE AND IN HERE !
if($addstat)
{
if($brand == '') // If brand is empty it will redirect to this
{
$header = 'https://ads.affiliatecruise.com/redirect.aspx?pid=xxxxx&bid=xxxx';
} elseif($brand == 'genesis-slots')
{
$header = 'https://ads.affiliatecruise.com/redirect.aspx?pid=xxx&bid=xxx';
} elseif($brand == 'slots-baby') {
$header = 'https://affiliates.slotsbaby.com/Redirect.aspx?mid=xxx';
} elseif($brand == 'wizard-slots') {
$header = 'https://affiliates.wizardslots.com/Redirect.aspx?mid=xxx';
} elseif($brand == 'thor-slots') {
$header = 'https://affiliates.thorslots.com/Redirect.aspx?mid=xxx';
} elseif($brand == 'easy-slots') {
$header = 'https://affiliates.easyslots.com/Redirect.aspx?mid=xxx';
} elseif($brand == 'cozino') {
$header = 'http://affiliates.cozino.com/Redirect.aspx?mid=xxx';
} elseif($brand == 'yukon-gold') {
$header = 'https://iredirect.net/referral/?site=yg&aff_id=xxxx';
}
header("Location:$header");
}
//
?>
Now for the Database Table - Launch PHPMYADMIN
Create a New Database Then click SQL and paste this code to create the table ( remember to add the details to the code above )
Code:
- phpMyAdmin SQL Dump
-- version 4.8.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Mar 20, 2019 at 10:23 AM
-- Server version: 10.0.38-MariaDB-cll-lve
-- PHP Version: 7.2.7
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `winspins_tracking`
--
-- --------------------------------------------------------
--
-- Table structure for table `tracking`
--
CREATE TABLE `tracking` (
`vid` bigint(8) NOT NULL,
`day` text NOT NULL,
`month` text NOT NULL,
`year` text NOT NULL,
`ip` text NOT NULL,
`cc` text NOT NULL,
`cname` text NOT NULL,
`site` text NOT NULL,
`destination` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tracking`
--
ALTER TABLE `tracking`
ADD PRIMARY KEY (`vid`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `tracking`
--
ALTER TABLE `tracking`
MODIFY `vid` bigint(8) NOT NULL AUTO_INCREMENT;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Here is the .htaccess File
Code:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^egccc\.pgvrgeskmgsuurgn\.co.uk$ [NC]
RewriteRule ^(.*)$ https://www.playmegamoolah.co.uk/$1 [L,R=301]
RewriteRule ^play$ play.php?brand=
RewriteRule ^sloty$ play.php?brand=sloty
RewriteRule ^play/slots-baby$ play.php?brand=slots-baby
RewriteRule ^play/wizard-slots$ play.php?brand=wizard-slots
RewriteRule ^play/thor-slots$ play.php?brand=thor-slots
RewriteRule ^play/easy-slots$ play.php?brand=easy-slots
RewriteRule ^play/cozino$ play.php?brand=cozino
RewriteRule ^play/yukon-gold$ play.php?brand=yukon-gold
RewriteRule ^play/genesis-slots$ play.php?brand=genesis-slots
Then in your pages simply link like play/BrandName :)
Enjoy !