【问题标题】:Simple PHP proxy with persistent URL具有持久 URL 的简单 PHP 代理
【发布时间】:2014-10-17 13:15:18
【问题描述】:

我有简单的 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&page=10

我不是 PHP 专家,但我认为这与持久 URL 有关吗?我将如何解决这个问题,以便回显在 & 符号之后显示所有内容?如果有帮助,我确实在我的服务器上安装了 cURL。谢谢!

【问题讨论】:

    标签: php curl proxy request echo


    【解决方案1】:

    这里的“&”符号是查询字符串元素的一部分。所以它会避免从第一个“&”中获取价值。我们可以在您的脚本上再添加两行来完成工作。

    <?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 中提供的 she 脚本作为工作脚本。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-03
      • 2012-10-15
      • 1970-01-01
      • 2011-09-27
      • 2020-05-01
      • 1970-01-01
      • 2014-12-01
      相关资源
      最近更新 更多