Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ba_login = 'asd';
- $ba_password = 'asdasd';
- $ba_user_agent = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.107 Safari/537.36';
- // заголовки для главной страницы
- $ba_get_main_headers = array(
- 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
- 'Upgrade-Insecure-Requests: 1',
- 'Accept-Encoding: gzip, deflate, sdch',
- 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
- 'Connection: keep-alive',
- 'Host: www.britishairways.com',
- 'User-Agent: '.$ba_user_agent,
- );
- // получаем cookies с главной страницы сайта
- $ba_get_main = post('http://www.britishairways.com/travel/home/public/ru_ru', array(
- 'headers' => $ba_get_main_headers,
- 'cookies' => 'Allow_BA_Cookies=accepted; BA_COUNTRY_CHOICE_COOKIE=RU; BA_LANGUAGE_CHOICE_COOKIE=RU'
- ));
- preg_match('/name\="eId" value\="(.*?)"/isu', $ba_get_main_content_result, $ba_eId);
- // заголовки для авторизации
- $ba_user_auth_headers = array(
- 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
- 'Accept-Encoding: gzip, deflate',
- 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4',
- 'Content-Length: 83',
- 'Content-Type: application/x-www-form-urlencoded',
- 'Connection: keep-alive',
- 'Host: www.britishairways.com',
- 'Origin: http://www.britishairways.com',
- 'Referer: http://www.britishairways.com/travel/home/public/ru_ru',
- 'Upgrade-Insecure-Requests: 1',
- 'User-Agent: '.$ba_user_agent
- );
- // авторизация
- $ba_user_auth = post('https://www.britishairways.com/travel/loginr/public/ru_ru', array(
- 'headers' => $ba_user_auth_headers,
- 'params' => 'Directional_Login=&eId='.$ba_eId[1].'&source=headerbtn&password='.$ba_password.'&membershipNumber='.urlencode($ba_login),
- 'cookies' => $ba_get_main['cookies'].'; Allow_BA_Cookies=accepted; BA_COUNTRY_CHOICE_COOKIE=RU; BA_LANGUAGE_CHOICE_COOKIE=RU'
- ));
- echo baFilesUrlReplace(gzdecode($ba_user_auth['content']));
- function printR($array = null) {
- echo '<pre>';
- print_r($array);
- echo '</pre>';
- }
- function baFilesUrlReplace($content = null) {
- return preg_replace('/\/cms\/global\/styles\//isu', 'https://www.britishairways.com/cms/global/styles/', $content);
- }
- function post($url = null, $params = null) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- if(isset($params['params'])) {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params['params']);
- }
- if(isset($params['headers'])) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $params['headers']);
- }
- if(isset($params['cookies'])) {
- curl_setopt($ch, CURLOPT_COOKIE, $params['cookies']);
- }
- $result = curl_exec($ch);
- list($headers, $result) = explode("\r\n\r\n", $result, 4);
- preg_match_all('|Set-Cookie: (.*);|U', $headers, $parse_cookies);
- $cookies = implode(';', $parse_cookies[1]);
- curl_close($ch);
- return array('headers' => $headers, 'cookies' => $cookies, 'content' => $result);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement