1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| $url1= "http://www.one.com/fr/";
$path_cookie = tempnam("./tmp/", $_SERVER['REMOTE_ADDR']."-");
if (!file_exists(realpath($path_cookie))) touch($path_cookie);
// Premier Curl: récupérer un jsessionid
$curl1=curl_init();
curl_setopt($curl1, CURLOPT_URL, $url1);
curl_setopt($curl1, CURLOPT_REFERER, $url1);
curl_setopt($curl1, CURLOPT_USERAGENT, "Kenobi54");
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl1, CURLOPT_COOKIESESSION, true);
curl_setopt($curl1, CURLOPT_FOLLOWLOCATION,true);
curl_setopt($curl1, CURLOPT_COOKIEJAR, realpath($path_cookie));
$output1=curl_exec($curl1);
curl_close($curl1);
// Fin du premier curl
$urlgetparam = "https://www.one.com/admin/login.do";
$url2=substr($output1, strpos($output1, $urlgetparam), 88);
$post="loginDomain=0&domain=".$login."&password1=".$mdp."&loginDomain=Se+connecter";
//Deuxième cURL
$curl2=curl_init();
curl_setopt($curl2, CURLOPT_URL, $url2);
curl_setopt($curl2, CURLOPT_REFERER, $url2);
curl_setopt($curl2, CURLOPT_USERAGENT, "Kenobi54");
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl2, CURLOPT_COOKIESESSION, true);
curl_setopt($curl2, CURLOPT_FOLLOWLOCATION,true);
curl_setopt($curl2, CURLOPT_COOKIEJAR, realpath($path_cookie));
curl_setopt($curl2, CURLOPT_POST, true);
curl_setopt($curl2, CURLOPT_POSTFIELDS, $post);
$output2=curl_exec($curl2);
curl_close($curl2);
echo $output2; |
Partager