通过服务器发送页面请求?

时间:2009-06-05 19:49:42

标签: php javascript html proxy

如果用户点击显示外部网站的iframe内的链接,是否可以通过托管iframe的服务器路由网页请求?

实施例: somesite.com上的iframe显示google.com 用户单击someothersite.com的结果链接 该请求通过somesite.com的服务器发送并记录,以便他们现在可以记录他们点击的链接。

可能?不?

感谢。

1 个答案:

答案 0 :(得分:1)

不,浏览器的安全模型应该可以防止您篡改其他域上的网站(您必须这样做才能拦截点击次数)。

您可以通过自己的服务器代理iframe并重新编写它......

<iframe src="proxy.php?src=www.google.com"></iframe>

proxy.php的基本思想看起来像(这不应该完成甚至工作 - 只是为了让你知道它应该如何工作):

<?php

// Get the contents
$html = file_get_contents($_GET['src']);

// Rewrite the links
$html = preg_replace('/href=["\']?/i', 'href=clicky.php?src=', $html);

// Output the HTML
print($html);

?>