PHP Curl错误重定向

时间:2014-10-02 23:46:49

标签: javascript php redirect curl cloudflare

我曾经在网站上获取一些信息,使用curl登录并显示信息,但现在网站正在使用cloudflare。问题是我无法遵循重定向,因为网站使用的是javascript。

我认为解决起来非常简单,因为我在本地主机上使用php curl,并在5秒后发出消息" 在访问示例之前检查浏览器。&#34 ;将我重定向到: www.localhost / LINKOFTHEREDIRECT ,而不是转到 www.example.com/LINKOFTHEREDIRECT 并向我显示正确的网页。

这是我的代码:

<?php

$url0 = "http://example.com/login.php";
$url = "http://example.com/pageIwant.php";

    $user_agent='Mozilla/5.0 (Windows NT 6.3; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0';

    $options = array(
        CURLOPT_USERAGENT      => $user_agent, //set user agent
        CURLOPT_COOKIESESSION  => true,     // enable cookies
        CURLOPT_COOKIEFILE     =>"C:/Program Files/XAMPP/htdocs/cp/cookies.txt", //set cookie file
        CURLOPT_COOKIEJAR      =>"C:/Program Files/XAMPP/htdocs/cp/cookies.txt", //set cookie jar
        CURLOPT_CUSTOMREQUEST  =>"GET",        //set request type post or get
        CURLOPT_POST           =>false,        //set to GET
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 20,      // timeout on connect
        CURLOPT_TIMEOUT        => 20,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );

    $ch0      = curl_init( $url0 );
    curl_setopt_array( $ch0, $options );
    $content0 = curl_exec( $ch0 );
    curl_close( $ch0 );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;

    echo $content; ?>

这是javascript:

<script type="text/javascript">
  //<![CDATA[
  (function() {
    var a = function() {
        try {
          return !!window.addEventListener
        } catch (e) {
          return !1
        }
      },
      b = function(b, c) {
        a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)
      };
    b(function() {
      var a = document.getElementById('cf-content');
      a.style.display = 'block';
      setTimeout(function() {
        var t, r, a, f, YvDgwfU = {
          "uxTkX": +((+!![] + []) + (!+[] + !![]))
        };
        t = document.createElement('div');
        t.innerHTML = "<a href='/'>x</a>";
        t = t.firstChild.href;
        r = t.match(/https?:\/\//)[0];
        t = t.substr(r.length);
        t = t.substr(0, t.length - 1);
        a = document.getElementById('jschl-answer');
        f = document.getElementById('challenge-form');;
        YvDgwfU.uxTkX *= +((!+[] + !![] + !![] + !![] + []) + (!+[] + !![] + !![] + !![]));
        YvDgwfU.uxTkX -= +((+!![] + []) + (!+[] + !![] + !![] + !![] + !![] + !![] + !![]));
        YvDgwfU.uxTkX -= +((!+[] + !![] + !![] + !![] + !![] + []) + (+[]));
        a.value = parseInt(YvDgwfU.uxTkX, 10) + t.length;
        f.submit();
      }, 5850);
    }, false);
  })();
  //]]>
</script>

1 个答案:

答案 0 :(得分:0)

&#34; message&#34;在访问示例之前检查浏览器。&#34;将我重定向到&#34;

您正在做的是在网站上触发DDoS规则和/或网站所有者已决定启用此功能。

如果网站没有您正在执行的操作,您应该要求网站所有者将您执行此操作的IP列入白名单。