微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

curl没有登录到cpanel

如何解决curl没有登录到cpanel

| 我有这个很棒的PHP类,它曾经让我登录cpanel并调用了我想要的任何路径。现在它坏了:
<?PHP
class cPanel {
  var $cPanelUser   = \"\";
  var $cPanelPass   = \"\";
  var $cPanelDomain = \"\";
  var $cPanelPort   = 0;
  var $cPanelRel    = \"\";
  var $cPanelRoot   = \"\";

  function cPanel($cPanelDomain,$cPanelPort,$authUser,$authPass) {
    $this->cPanelDomain = $cPanelDomain;
    $this->cPanelPort = $cPanelPort;
    $this->cPanelUser = $authUser;
    $this->cPanelPass = $authPass;
    //Root path of cPanel to load pages begining with /

    $this->cPanelRoot = \"http\".($this->cPanelPort==2083 ? \"s\" : \"\").\"://\".$this->cPanelDomain.\":\".$this->cPanelPort.\"/frontend/x3/\";
    //Relative path of cPanel to load pages not begining with /
    $this->cPanelRel = $this->cPanelRoot.\"\";
  }
  function fetchPage($cPanelPage,$sPostvars = \"\") {
    $curl = curl_init();
    $loginf = sprintf(\"[%s]:[%s]\",$this->cPanelUser,$this->cPanelPass);

    //Build the path. If it begins with / we go and paste at root
    if ($cPanelPage[0] == \'/\') {
      $url = $this->cPanelRoot.substr($cPanelPage,1);
    }
    else {
      //Build the path - if begins with / we go and paste relative
      $url = $this->cPanelRel.$cPanelPage;
    }

    curl_setopt ($curl,CURLOPT_URL,$url.\"?\".$sPostvars);
    curl_setopt ($curl,CURLOPT_TIMEOUT,30);
    curl_setopt ($curl,CURLOPT_USERAGENT,sprintf(\"Mozilla/%d.0\",rand(4,5)));
    curl_setopt ($curl,CURLOPT_FOLLOWLOCATION,1);
    curl_setopt ($curl,CURLOPT_RETURNTRANSFER,CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt ($curl,CURLOPT_SSL_VERIFYHOST,CURLOPT_FAILONERROR,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
    curl_setopt ($curl,CURLOPT_USERPWD,$loginf);
    $html = curl_exec ($curl);
    echo \'Errors: \' . curl_errno($curl) . \' \' . curl_error($curl) . \'<br><br>\';
    echo $html;
    curl_close ($curl);

    //print_r($url);
    return $html;
  }

}
我在一台服务器上使用此脚本,并调用尝试在另一台服务器上登录并运行fastastico脚本。这是错误输出错误:7无法连接到主机 我已多次检查用户名和密码。     

解决方法

        您遇到的错误似乎比php / curl相关问题更像是一种连接问题。 这台机器可以上网吗? 是否正确配置了其DNS服务器? 您可以向cPanel主机支付1英镑吗? cPanel主机中是否有阻止您的新防火墙?     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。