query("SELECT * FROM forwarder WHERE shorturl = '".mysql_real_escape_string(trim($_GET['id']))."' AND lid = '' AND status = '1'"); if (mysql_affected_rows()>0) { while($row = mysql_fetch_array($rSQL)) { $id = $row["id"]; $counter = $row["counter"]; $longurl = $row["longurl"]; } ++$counter; if (getenv('HTTP_CLIENT_IP')) { $ipaddress = getenv('HTTP_CLIENT_IP'); } else if(getenv('HTTP_X_FORWARDED_FOR')) { $ipaddress = getenv('HTTP_X_FORWARDED_FOR'); } else if(getenv('HTTP_X_FORWARDED')) { $ipaddress = getenv('HTTP_X_FORWARDED'); } else if(getenv('HTTP_FORWARDED_FOR')) { $ipaddress = getenv('HTTP_FORWARDED_FOR'); } else if(getenv('HTTP_FORWARDED')) { $ipaddress = getenv('HTTP_FORWARDED'); } else if(getenv('REMOTE_ADDR')) { $ipaddress = getenv('REMOTE_ADDR'); } else { $ipaddress = 'UNKNOWN'; } $__sql->query("UPDATE forwarder SET lastclick = '".time()."', lastip = '".$ipaddress."', counter = '".$counter."' WHERE id = '".$id."'"); $__sql->query("INSERT INTO forwarder_stats (fid, ip, date, user_agent ) VALUES ( '".$id."', '".$ipaddress."', '".time()."', '".$_SERVER[HTTP_USER_AGENT]."')"); header("Location: ".$longurl); } else { header("Location: https://www.permapack.ch"); } ?>