I
I
iamdivine2021-03-20 01:31:32
linux
iamdivine, 2021-03-20 01:31:32

Why doesn't curl request work on linux server?

Hello everyone, I'm making a fucking parser with authorization on the site. But one problem.

On Windows, xampp is installed and everything is OK, authorization works, I see data from LAN - cookies are saved.
I make requests - they also work, I see all the information.
I throw files on the host and there I also get cookies, but authorization does not work, and throws it on the login form

function login($url){

    $ch = curl_init();
    if(strtolower((substr($url,0,5))=='https')) {
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_REFERER, $url);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,"admin_login=Ivan_Ivanov&admin_password=123123&admin_key=321321");
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (Windows; U; Windows NT 5.0; En; rv:1.8.0.2) Gecko/20070306 Firefox/1.0.0.4");
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_COOKIEJAR, $_SERVER['DOCUMENT_ROOT'].'/cookie.txt');
    $result=curl_exec($ch);
    var_dump($result);
    //if(strpos($result,"Location: /work/")===false) die('Login incorrect');

    curl_close($ch);

    return $result;
}

login("https://site.ru/work/");


From the server the var dump of the connection is this:
string(645) "HTTP/2 200 server: ddos-guard content-security-policy: upgrade-insecure-requests; set-cookie: __ddg1=yPaa9iSBxaywlYk6wvua; Domain=.site.ru; HttpOnly; Path=/; Expires=Sat, 19-Mar-2022 22:55:27 GMT date: Fri, 19 Mar 2021 22:55:27 GMT content-type: text/html; charset=UTF-8 x-powered-by: PHP/7.4.15

locally everything is ok

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question