links.php 包含以下代码:
$ipaddress = $_SERVER["REMOTE_ADDR"];
<p><a href="track.php?page=http://www.google.co.uk" target="_blank">google.co.uk</a></p>
<p><a href="track.php?page=http://www.bbc.co.uk" target="_blank">bbc.co.uk</a></p>
<p><a href="track.php?page=http://www.cnn.com" target="_blank">cnn.com</a></p>
<p><a href="track.php?page=http://www.yahoo.co.uk" target="_blank">yahoo.co.uk</a></p>
track.php 捕获点击的链接:
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mydb1") or die(mysql_error());
$redirect = mysql_real_escape_string($_GET['page']);
$ipaddress = $_SERVER["REMOTE_ADDR"];
$page_insert = mysql_query("INSERT INTO link_track (myurl, myip1, mydate) VALUES ('$redirect', '$ipaddress', now())") or die(mysql_error());
header("Location: $redirect");
有没有办法阻止某人直接访问track.php。
您的帮助将不胜感激,谢谢。
我对其他问题表示歉意:如果我想http://www.
从 url 中删除部分,我可以修改我的 track.php 代码如下:
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("mydb1") or die(mysql_error());
$redirect = mysql_real_escape_string($_GET['page']);
$redirect2 = parse_url($redirect, PHP_URL_HOST);
$redirect2 = preg_replace('/^(www\.)/i', '', $redirect2);
$ipaddress = $_SERVER["REMOTE_ADDR"];
$page_insert = mysql_query("INSERT INTO link_track (myurl, myip1, mydate) VALUES ('$redirect2', '$ipaddress', now())") or die(mysql_error());
header("Location: $redirect");