include "config.inc"; //session_register("userid"); // Open database... $db = mysql_connect("freebiek.ipowermysql.com", "$databaseuser", "$databasepasswd"); mysql_select_db("$databasename",$db); //Retrieve from CT_CLICKS the count for the clickid given in the link, //in order to increment the count by 1, and the long url so that it can be redirected $clickid = $l; $sql = "select url, count from ct_clicks where clickid = '$clickid'"; //echo "$sql"; $result = mysql_query("$sql",$db); $url = @mysql_result($result, 0, "url"); $count = @mysql_result($result, 0, "count"); $count++; //Update CT_CLICKS with the new value of count $sql = "update ct_clicks set count = '$count' where clickid = '$clickid'"; $result = mysql_query("$sql",$db); //echo "URL = $url"; //Redirect the browser to the long url //Get all headers $date = date("Y-m-d"); $time = date("G:i:s"); $referer = $HTTP_REFERER; $useragent = $HTTP_USER_AGENT; $ip = GetHostByName($REMOTE_ADDR); if(!$referer) $referer = "Email link"; //echo "Ref = $referer"; //echo "Date: $date
"; //echo "COUNT: $count
"; $sql = "insert into ct_click_referer (clickid, referer, date, useragent, ip, time) values ('$clickid', '$referer', '$date', '$useragent', '$ip', '$time')"; mysql_query($sql); //echo "SQL: $sql
"; header("Location:".$url); ?>