-
Notifications
You must be signed in to change notification settings - Fork 16
/
aff.php
52 lines (44 loc) · 1.64 KB
/
aff.php
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
<?php
/**
* @title Affiliate Cookie Tracking + Redirection Handler + Affliate Coupons
*
* @package WHMCS 5.2.1+
* @author Myles McNamara ([email protected])
* @author WHMCS WHMCS Limited ([email protected])
* @copyright Copyright (c) Myles McNamara 2013-2014
* @license GNU GPL v3+
* @version 2.1.1
* @link https://gh.smyl.es/whmcs-affcoupons
*
*/
define("CLIENTAREA",true);
require("init.php");
// if affiliate id is present, update visitor count & set cookie
if ($aff = $whmcs->get_req_var('aff')) {
update_query("tblaffiliates",array("visitors"=>"+1"),array("id"=>$aff));
WHMCS_Cookie::set('AffiliateID',$aff,'3m');
}
// if product id passed in, redirect to order form
if ($pid = $whmcs->get_req_var('pid')) redir("a=add&pid=".(int)$pid,"cart.php");
// if product group id passed in, redirect to product group
if ($gid = $whmcs->get_req_var('gid')) redir("gid=".(int)$gid,"cart.php");
// if register = true, redirect to registration form
if ($whmcs->get_req_var('register')) redir("","register.php");
// if gocart = true, redirect to cart with request params
if ($whmcs->get_req_var('gocart')) {
$reqvars = '';
foreach ($_GET AS $k=>$v) $reqvars .= $k.'='.urlencode($v).'&';
redir($reqvars,"cart.php");
}
// get landing to redirect to from affiliate number
$r = select_query("tblaffcouponslanding", "landing", array("aff_id"=>$aff));
$data = mysql_fetch_array($r);
$landing = $data['landing'];
header("HTTP/1.1 301 Moved Permanently");
if ($landing) {
header("Location: $landing");
exit;
} else {
header("Location: ".$whmcs->get_config('Domain'),true,301);
exit;
}