";
#print "User $userid, Mess $messageid, Link $linkid";
if (!isset($linkdata['firstclick'])) {
Sql_query(sprintf('update %s set firstclick = now() where linkid = %d and userid = %d and messageid = %d',
$GLOBALS['tables']['linktrack'],$linkid,$userid,$messageid));
}
Sql_query(sprintf('update %s set clicked = clicked + 1 where linkid = %d and userid = %d and messageid = %d',
$GLOBALS['tables']['linktrack'],$linkid,$userid,$messageid));
$viewed = Sql_Fetch_Row_query(sprintf('SELECT viewed FROM %s WHERE messageid = %d AND userid = %d',
$GLOBALS['tables']['usermessage'], $messageid, $userid));
if (!$viewed[0]) {
Sql_Query(sprintf('update %s set viewed = now() where messageid = %d and userid = %d',
$GLOBALS['tables']['usermessage'], $messageid, $userid));
Sql_Query(sprintf('update %s set viewed = (viewed + 1) where id = %d',
$GLOBALS['tables']['message'], $messageid));
}
switch ($msgtype) {
case 'H':
Sql_Query(sprintf('insert into %s (linkid,userid,messageid,name,data,date)
values(%d,%d,%d,"Message Type","HTML",now())',
$GLOBALS['tables']['linktrack_userclick'],$linkid,$userid,$messageid));
break;
case 'T':
Sql_Query(sprintf('insert into %s (linkid,userid,messageid,name,data,date)
values(%d,%d,%d,"Message Type","Text",now())',
$GLOBALS['tables']['linktrack_userclick'],$linkid,$userid,$messageid));
break;
default:
Sql_Query(sprintf('insert into %s (linkid,userid,messageid,name,data,date)
values(%d,%d,%d,"Message Type","Unknown",now())',
$GLOBALS['tables']['linktrack_userclick'],$linkid,$userid,$messageid));
break;
}
$sysarrays = array_merge($_ENV,$_SERVER);
if (is_array($GLOBALS["userhistory_systeminfo"])) {
foreach ($GLOBALS["userhistory_systeminfo"] as $key) {
if (!empty($sysarrays[$key])) {
Sql_Query(sprintf('insert into %s (linkid,userid,messageid,name,data,date)
values(%d,%d,%d,"%s","%s",now())',
$GLOBALS['tables']['linktrack_userclick'],$linkid,$userid,$messageid,$key,addslashes($sysarrays[$key])));
}
}
}
header("Location: " . $linkdata['forward']);
exit;
?>