SMF kıvırmak giriş sorunu php

0 Cevap php

Does any one have have some PHP login curl code for SMF version 1.1.11 I tried and it logs then when I check the curl output, but when the broswer loads, they are no longer logged in

Benim kod

function login($data)
{
    if(function_exists('curl_init' )) {

        $_SESSION['old_url'] = $_SERVER['HTTP_HOST'] .'test';
        // smf needs this sigh
        // create a new cURL resource
        $data = array( 'noverify'=>1 , 'user'=> $data['username'] ,  'passwrd' => $data['password'] ,'hash_passwrd'=>$data['password'], 'cookielength'=>'60');
        $ch = curl_init();
        // set URL and other appropriate options
        curl_setopt($ch, CURLOPT_URL, $_SERVER['HTTP_HOST'] . "/forum/index.php?action=login2");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_HEADER, 0);

        $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)";
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
        curl_setopt($ch, CURLOPT_COOKIEJAR,  dirname(__FILE__).'/cookie.txt');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);


        // grab URL and pass it to the browser
        $a = curl_exec($ch);

        //$ch_temp=curl_copy_handle($ch);

        //print_r($ch_temp);
        // close cURL resource, and free up system resources
        curl_close ($ch); 

    }
}

0 Cevap