-
Notifications
You must be signed in to change notification settings - Fork 13
/
click.php
124 lines (90 loc) · 3.31 KB
/
click.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?PHP
## http://www.jmbsoft.com/license.php
// These settings must match the database settings used for TGPX
$USERNAME = 'username'; // The username to access your MySQL database
$PASSWORD = 'password'; // The password to access your MySQL database
$DATABASE = 'database'; // The name of your MySQL database
$HOSTNAME = 'localhost'; // The hostname of your MySQL database server
// Would you like to use the IP log to track unique clicks?
// Change this to TRUE if you want to use the IP log
$USE_IPLOG = FALSE;
// Would you like to use cookies to track unique clicks?
// Change this to FALSE if you do not want to use cookies
$USE_COOKIES = TRUE;
// The length of time (in seconds) before this script's cookie expires
// Cookies are used to track unique clicks
$EXPIRE = 86400;
// The template for your traffic trading script URL
// If you are not using a traffic trading script, do not change this value
$TEMPLATE = '{$gallery_url}';
// If your traffic trading script supports encoded URLs set this value to TRUE.
// This will allow you to send traffic to URLs that contain query strings without a problem.
// If you are not using a traffic trading script, do not change this value
$ENCODE = FALSE;
###########################################################################################################
## DONE EDITING THIS FILE. YOU DO NOT NEED TO EDIT THIS FILE ANY FURTHER ##
###########################################################################################################
if( $ENCODE )
{
$_GET['u'] = urlencode($_GET['u']);
}
$TEMPLATE = str_replace('{$skim}', $_GET['s'], $TEMPLATE);
$TEMPLATE = str_replace('{$gallery_url}', $_GET['u'], $TEMPLATE);
foreach( $_GET as $key => $value )
{
$TEMPLATE = str_replace("{\$$key}", $value, $TEMPLATE);
}
if( $_GET['id'] )
{
$value = null;
$cookie_set = FALSE;
$ip_logged = FALSE;
if( $USE_COOKIES && isset($_COOKIE['tgpx_click']) )
{
$ids = explode(',', $_COOKIE['tgpx_click']);
if( in_array($_GET['id'], $ids) )
{
$cookie_set = TRUE;
}
else
{
$ids[] = $_GET['id'];
$value = join(',', $ids);
}
}
else
{
$value = $_GET['id'];
}
if( !$cookie_set )
{
mysql_connect($HOSTNAME, $USERNAME, $PASSWORD);
mysql_select_db($DATABASE);
$safe_id = mysql_real_escape_string($_GET['id']);
$safe_ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
if( $USE_IPLOG )
{
$result = mysql_query("SELECT COUNT(*) FROM `tx_addresses` WHERE `gallery_id`='$safe_id' AND `ip_address`='$safe_ip'");
$row = mysql_fetch_row($result);
if( $row[0] > 0 )
{
$ip_logged = TRUE;
}
}
if( !$ip_logged )
{
mysql_query("UPDATE `tx_galleries` SET `clicks`=`clicks`+1 WHERE `gallery_id`='$safe_id'");
if( $USE_IPLOG )
{
mysql_query("INSERT INTO `tx_addresses` VALUES ('$safe_id', '$safe_ip', " . time() . ")");
}
}
if( $USE_COOKIES )
{
setcookie('tgpx_click', $value, time()+$EXPIRE, '/');
}
mysql_close();
}
}
header("Location: $TEMPLATE");
?>