-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathad.php
74 lines (57 loc) · 2.09 KB
/
ad.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
<?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
###########################################################################################################
## DONE EDITING THIS FILE. YOU DO NOT NEED TO EDIT THIS FILE ANY FURTHER ##
###########################################################################################################
if( $_GET['id'] )
{
$ids = array();
$raw_click = FALSE;
if( isset($_COOKIE['tgpx_ad_click']) )
{
$ids = unserialize($_COOKIE['tgpx_ad_click']);
if( isset($ids[$_GET['id']]) )
{
$raw_click = TRUE;
}
}
$ids[$_GET['id']] = 1;
mysql_connect($HOSTNAME, $USERNAME, $PASSWORD);
mysql_select_db($DATABASE);
$safe_id = mysql_real_escape_string($_GET['id']);
$safe_ip = mysql_real_escape_string(sprintf('%u', ip2long($_SERVER['REMOTE_ADDR'])));
$now = time();
mysql_query("UPDATE `tx_iplog_ads` SET `raw_clicks`=`raw_clicks`+1,`last_click`=$now WHERE `ad_id`='$safe_id' AND `ip_address`='$safe_ip'");
if( mysql_affected_rows() == 0 )
{
mysql_query("INSERT INTO `tx_iplog_ads` VALUES ('$safe_id', '$safe_ip', 0, $now)");
}
else
{
$raw_click = TRUE;
}
if( $raw_click )
{
mysql_query("UPDATE `tx_ads` SET `raw_clicks`=`raw_clicks`+1 WHERE `ad_id`='$safe_id'");
}
else
{
mysql_query("UPDATE `tx_ads` SET `unique_clicks`=`unique_clicks`+1,`raw_clicks`=`raw_clicks`+1 WHERE `ad_id`='$safe_id'");
}
setcookie('tgpx_ad_click', serialize($ids), time()+86400, '/');
mysql_close();
}
if( $_GET['u'] )
{
header("Location: {$_GET['u']}");
}
else
{
echo "ERROR: The u= value was not passed to the script";
}
?>