Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function new_session($user, $pass) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://www.irccloud.com/chat/auth-formtoken");
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- $fields = "POST";
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
- $output = curl_exec($ch);
- curl_close($ch);
- preg_match('#"token"\:"(.*)"#', $output, $token);
- print("TOKEN: " . $output . "\n");
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://www.irccloud.com/chat/login/");
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
- curl_setopt($ch, CURLOPT_TIMEOUT, 30);
- curl_setopt($ch, CURLINFO_HEADER_OUT, false);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_COOKIESESSION, true);
- //curl_setopt($ch, CURLOPT_COOKIEFILE, ".".$user."cookie");
- curl_setopt($ch, CURLOPT_COOKIEJAR, ".".$user."cookie");
- curl_setopt($ch, CURLOPT_VERBOSE, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('x-auth-formtoken: '.$token[1]));
- $fields = "email=".$user."&password=".$pass."&token=".$token[1];
- print("FIELDS: " . $fields . "\n");
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
- $output = curl_exec($ch);
- curl_close($ch);
- //print("OUT: " . $output . "\n");
- $json = json_decode($output, true);
- //print($json);
- return $json['session'];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement