【问题标题】:Use PHP change link address in html source code在html源码中使用PHP更改链接地址
【发布时间】:2021-08-21 19:09:58
【问题描述】:

嘿,谢谢你检查我

---Php Code---

现在正在尝试学习如何在 php 中编码,以修复一个简单的 Url 代理,只需将 url 放在 www.Proxy.info/?u= 之后即可工作,并且一切正常,除了它不会更改嵌入的文件路径

所以在我试图代理的网站的源代码中,我有一个像这样的地址 /images/image.jpghttps://Somesite.com/js/file.js 并导致问题,因为现在代理的网站认为我的服务器上有文件

我需要添加到我的代理服务器地址 (www.Proxy.info/?u=),以便它使用现在代理的站点文件并使其工作,例如 http://www.Proxy.info/?u=/images/image.jpghttp://www.Proxy.info/?u=https://Somesite.com/js/file.js

有一个代理,做this,但是它使用的是nginx,我不太喜欢nginx,这里是第二个例子,有点简单

我有它

https://www.proxy.info/lib/fonts/source-code-pro-v14-latin-regular.woff2

但我需要它

https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2

或者

https://www.Proxy.info/?u=Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2

如果你可以编辑我的代码来修复那将是最好的,因为我添加代码非常糟糕

【问题讨论】:

    标签: php proxy


    【解决方案1】:

    如果您使用html form,则设置表单方法GET 和输入字段name="u" 并使用php $_GET['u'] 捕获查询url。这是我的评论,但现在无法评论。此外,您没有共享 php 代码,因为不完全确定必须在哪里添加/进行更改。请更新您的帖子/代码。

    更新答案:
    我看到你使用这个 github 开源:php-ultra-small-proxy

    index.php中使用此完整代码:

    <?php
    set_time_limit(0);
    include __DIR__.'/UltraSmallProxy.php';
    
    if(isset($_GET['u']))
    {
        $url = $_GET['u'];
        $proxy = new UltraSmallProxy();
        $output = $proxy->load($url); // <-- specify start page here
    
        echo $output;
    }
    ?>
    
    <form method="GET">
        <input type="url" name="u" placeholder="Enter proxy visit url" required>
        <input type="submit" value="go">
    </form>
    

    我使用isset() Function 来检查变量是否为空/设置/声明。另一件事是$_GET,它是一个php超级全局变量和参数是u。添加这个超级全局变量和参数你会得到这样的(https://www.proxy.info/?u=https://www.Somesite.com/lib/fonts/source-code-pro-v14-latin-regular.woff2)get request url。

    【讨论】:

    • @Hacker 我更新了答案,如果它解决了您的问题,请通过单击刻度按钮将我的答案标记为已解决。谢谢
    • 啊,我在添加代码时遇到了问题,您可以发送带有代码的文件
    • 下载:https://file.io/ng7K3wwCWbSi 然后解压
    • 您请求的文件已被删除
    • 该死,我在我的网络托管服务商中收到此错误 |警告:出于安全原因,set_time_limit() 在第 2 行的 /storage/ssd3/725/17428725/public_html/index.php 中被禁用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-10
    • 2019-04-14
    • 2015-06-01
    • 2019-07-31
    • 2011-06-09
    • 2015-02-02
    • 2015-09-28
    相关资源
    最近更新 更多