1 |
<?php |
2 |
$ref = $HTTP_SERVER_VARS["HTTP_REFERER"]; |
3 |
$idx = strpos($ref, "?"); |
4 |
if (!($idx === false)) $ref = substr($ref, 0, $idx); |
5 |
$tgt = $HTTP_SERVER_VARS["SERVER_NAME"]."/".$HTTP_SERVER_VARS["REQUEST_URI"]; |
6 |
$idx = strpos($tgt, "?"); |
7 |
if (!($idx === false)) $tgt = substr($tgt, 0, $idx); |
8 |
include("inc/conn.php"); |
9 |
$sth = $dbh->prepare("SELECT count FROM tracker WHERE (referer = '$ref') AND (target = '$tgt')"); |
10 |
$row = ""; |
11 |
if ($sth) { |
12 |
if ($sth->execute()) $row = $sth->fetchrow_array(); |
13 |
$sth->finish(); |
14 |
} |
15 |
if ($row) $sql = "UPDATE tracker SET count = count + 1 WHERE (referer = '$ref') AND (target = '$tgt')"; |
16 |
else $sql = "INSERT INTO tracker (referer, target, count) VALUES ('$ref', '$tgt', 1)"; |
17 |
$dbh->dbh_do($sql); |
18 |
$dbh->disconnect(); |
19 |
?> |