带有持久URL的简单PHP代理


Simple PHP proxy with persistent URL

我有简单的PHP脚本:

<?php
$url = $_REQUEST['url'];
if (preg_match('/'b(https?|ftp):'/'/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>

我正在尝试回显页面:

http://forum.bodybuilding.com/showthread.php?t=162984431&page=10

但是回显显示:

http://forum.bodybuilding.com/showthread.php?t=162984431

的例子:

http://www.kylesbox.com/forumbuddy/fetch/fetch.php?url=http://forum.bodybuilding.com/showthread.php ? t = 162984431, = 10页

我不是PHP专家,但我认为这与持久url有关?我该如何解决这个问题,以便echo显示&也是符号吗?如果有帮助的话,我在服务器上安装了cURL。谢谢!

这里的"&"符号是查询字符串元素的一部分。因此,它将避免从第一个"&"获取值。我们可以在你的脚本上再加两行来完成工作。

<?php
$query=$_SERVER['QUERY_STRING'];  //get the full query string in url
$query_arr=explode("url=",$query);  //split the string by first get key
$url = $query_arr[1];  //take second parameter as url to be loaded
if (preg_match('/'b(https?|ftp):'/'/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>

这个脚本可以在下面的url中找到。

http://sugunan.net/demo/fetch.php?url=http://forum.bodybuilding.com/showthread.php ? t = 162984431, = 10页