3周前 (03-14) laical  PHP
文章评分 0 次,平均分 0.0
<span class="cp">&lt;?php</span>
        <span class="c1">// 要访问的目标页面</span>
        <span class="nv">$url</span> <span class="o">=</span> <span class="s2">"http://httpbin.org/ip"</span><span class="p">;</span>
        <span class="nv">$urls</span> <span class="o">=</span> <span class="s2">"https://httpbin.org/ip"</span><span class="p">;</span>

        <span class="c1">// 代理服务器(产品官网 www.16yun.cn)</span>
        <span class="nb">define</span><span class="p">(</span><span class="s2">"PROXY_SERVER"</span><span class="p">,</span> <span class="s2">"tcp://t.16yun.cn:31111"</span><span class="p">);</span>

        <span class="c1">// 隧道身份信息</span>
        <span class="nb">define</span><span class="p">(</span><span class="s2">"PROXY_USER"</span><span class="p">,</span> <span class="s2">"16YUN123"</span><span class="p">);</span>
        <span class="nb">define</span><span class="p">(</span><span class="s2">"PROXY_PASS"</span><span class="p">,</span> <span class="s2">"123456"</span><span class="p">);</span>

        <span class="nv">$proxyAuth</span> <span class="o">=</span> <span class="nb">base64_encode</span><span class="p">(</span><span class="nx">PROXY_USER</span> <span class="o">.</span> <span class="s2">":"</span> <span class="o">.</span> <span class="nx">PROXY_PASS</span><span class="p">);</span>

        <span class="c1">// 设置 Proxy tunnel</span>
        <span class="nv">$tunnel</span> <span class="o">=</span> <span class="nb">rand</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">10000</span><span class="p">);</span>

        <span class="nv">$headers</span> <span class="o">=</span> <span class="nb">implode</span><span class="p">(</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="p">,</span> <span class="p">[</span>
            <span class="s2">"Proxy-Authorization: Basic </span><span class="si">{</span><span class="nv">$proxyAuth</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span>
            <span class="s2">"Proxy-Tunnel: </span><span class="si">${</span><span class="nv">tunnel</span><span class="si">}</span><span class="s2">"</span><span class="p">,</span>
        <span class="p">]);</span>
        <span class="nv">$sniServer</span> <span class="o">=</span> <span class="nb">parse_url</span><span class="p">(</span><span class="nv">$urls</span><span class="p">,</span> <span class="nx">PHP_URL_HOST</span><span class="p">);</span>
        <span class="nv">$options</span> <span class="o">=</span> <span class="p">[</span>
            <span class="s2">"http"</span> <span class="o">=&gt;</span> <span class="p">[</span>
                <span class="s2">"proxy"</span>  <span class="o">=&gt;</span> <span class="nx">PROXY_SERVER</span><span class="p">,</span>
                <span class="s2">"header"</span> <span class="o">=&gt;</span> <span class="nv">$headers</span><span class="p">,</span>
                <span class="s2">"method"</span> <span class="o">=&gt;</span> <span class="s2">"GET"</span><span class="p">,</span>
                <span class="s1">'request_fulluri'</span> <span class="o">=&gt;</span> <span class="k">true</span><span class="p">,</span>
            <span class="p">],</span>
            <span class="s1">'ssl'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
                    <span class="s1">'SNI_enabled'</span> <span class="o">=&gt;</span> <span class="k">true</span><span class="p">,</span> <span class="c1">// Disable SNI for https over http proxies</span>
                    <span class="s1">'SNI_server_name'</span> <span class="o">=&gt;</span> <span class="nv">$sniServer</span>
            <span class="p">)</span>
        <span class="p">];</span>
        <span class="k">print</span><span class="p">(</span><span class="nv">$url</span><span class="p">);</span>
        <span class="nv">$context</span> <span class="o">=</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="nv">$options</span><span class="p">);</span>
        <span class="nv">$result</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="nv">$url</span><span class="p">,</span> <span class="k">false</span><span class="p">,</span> <span class="nv">$context</span><span class="p">);</span>
        <span class="nb">var_dump</span><span class="p">(</span><span class="nv">$result</span><span class="p">);</span>

        <span class="c1">// 访问 HTTPS 页面</span>
        <span class="k">print</span><span class="p">(</span><span class="nv">$urls</span><span class="p">);</span>
        <span class="nv">$context</span> <span class="o">=</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="nv">$options</span><span class="p">);</span>
        <span class="nv">$result</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="nv">$urls</span><span class="p">,</span> <span class="k">false</span><span class="p">,</span> <span class="nv">$context</span><span class="p">);</span>
        <span class="nb">var_dump</span><span class="p">(</span><span class="nv">$result</span><span class="p">);</span>




//下面这个css和插件后台设置的主题有关系,如果需要换样式,则需要修改以下CSS名称

  
 

除特别注明外,本站所有文章均为铁匠运维网原创,转载请注明出处来自http://www.tiejiang.org/26383.html

关于

发表评论

暂无评论

切换注册

登录

忘记密码 ?

您也可以使用第三方帐号快捷登录

切换登录

注册

扫一扫二维码分享