Guest User

Untitled

a guest
Dec 7th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.52 KB | None | 0 0
  1. <?php
  2.  
  3. // enter bouyguestelecom login information
  4. // username = bouygtelecom email or phone number
  5. $username = "xxxxx@bbox.fr";
  6. $password = "yyyyy";
  7. $usernameurlencode = urlencode ( $username );
  8. $passwordurlencode = urlencode ( $password );
  9. $dest_host = "www.services.bouyguestelecom.fr/television-vod/tv-en-direct/channel/";
  10. $proxy_base_url = "/btv/";
  11. $url = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
  12. $path = parse_url ( $url, PHP_URL_PATH );
  13. $segments = explode ( '/', rtrim ( $path, '/' ) );
  14. $name = $segments[count ( $segments ) - 2];
  15.  
  16. $proxied_headers = array ( 'Set-Cookie', 'Content-Type', 'Cookie', 'Location' );
  17.  
  18.  
  19. // Variables you specify in the config file overwrite variables set above.
  20. /*foreach( array('./', '../', '../../') as $path_rel )
  21. {
  22. if( file_exists(dirname(__file__)."/$path_rel" . CONFIG_FILE) )
  23. {
  24. include(dirname(__file__)."/$path_rel" . CONFIG_FILE);
  25. break;
  26. }
  27. }*/
  28.  
  29. //canonical trailing slash
  30. $proxy_base_url_canonical = rtrim ( $proxy_base_url, '/ ' ) . '/';
  31.  
  32. //check if valid
  33. if ( strpos ( $_SERVER['REQUEST_URI'], $proxy_base_url ) !== 0 )
  34. {
  35. echo 'Erreur configuration';
  36. exit;
  37. }
  38.  
  39. //remove base_url and optional index.php from request_uri
  40. $proxy_request_url = substr ( $_SERVER['REQUEST_URI'], strlen ( $proxy_base_url_canonical ) );
  41.  
  42. if ( strpos ( $proxy_request_url, 'index.php' ) === 0 )
  43. $proxy_request_url = ltrim ( substr ( $proxy_request_url, strlen ( 'index.php' ) ), '/' );
  44.  
  45. //final proxied request url
  46. $proxy_request_url = "https://" . rtrim ( $dest_host, '/ ' ) . '/' . $proxy_request_url;
  47.  
  48.  
  49. $ch1 = curl_init ( );
  50.  
  51. curl_setopt ( $ch1, CURLOPT_URL, "https://www.services.bouyguestelecom.fr/television-vod/tv-en-direct/" );
  52. curl_setopt ( $ch1, CURLOPT_RETURNTRANSFER, 1 );
  53. curl_setopt ( $ch1, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0" );
  54. curl_setopt ( $ch1, CURLOPT_SSL_VERIFYPEER, 0 );
  55. curl_setopt ( $ch1, CURLOPT_SSL_VERIFYHOST, 0 );
  56. curl_setopt ( $ch1, CURLOPT_FOLLOWLOCATION, 0 );
  57. curl_setopt ( $ch1, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
  58. curl_setopt ( $ch1, CURLOPT_HEADER, 1 );
  59.  
  60. $headers1[] = 'GET /television-vod/tv-en-direct/ HTTP/1.1';
  61. $headers1[] = 'Host: www.services.bouyguestelecom.fr';
  62. $headers1[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0';
  63. $headers1[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  64. $headers1[] = 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3';
  65. $headers1[] = 'Connection: keep-alive';
  66. $headers1[] = 'Upgrade-Insecure-Requests: 1';
  67.  
  68. curl_setopt ( $ch1, CURLOPT_HTTPHEADER, $headers1 );
  69.  
  70. $res1 = curl_exec ( $ch1 );
  71.  
  72. curl_close ( $ch1 );
  73.  
  74. if ( preg_match ( '#Location: (.*)#', $res1, $r1 ) )
  75. $l1 = trim ( $r1[1] );
  76.  
  77. $min1 = str_replace ( "https://www.mon-compte.bouyguestelecom.fr", "", $l1 );
  78.  
  79. preg_match_all ( '/^Set-Cookie:\s*([^;]*)/mi', $res1, $matchescookie1 );
  80.  
  81. $cookies1 = array ( );
  82.  
  83. foreach ( $matchescookie1[1] as $itemcookie1 )
  84. {
  85. parse_str ( $itemcookie1, $cookie1 );
  86.  
  87. $cookies1 = array_merge ( $cookies1, $cookie1 );
  88. }
  89.  
  90. $PHPSESSID = $cookies1['PHPSESSID'];
  91.  
  92. $ch2 = curl_init ( );
  93.  
  94. curl_setopt ( $ch2, CURLOPT_URL, $l1 );
  95. curl_setopt ( $ch2, CURLOPT_RETURNTRANSFER, 1 );
  96. curl_setopt ( $ch2, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0" );
  97. curl_setopt ( $ch2, CURLOPT_SSL_VERIFYPEER, 0 );
  98. curl_setopt ( $ch2, CURLOPT_SSL_VERIFYHOST, 0 );
  99. curl_setopt ( $ch2, CURLOPT_FOLLOWLOCATION, 0 );
  100. curl_setopt ( $ch2, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
  101. curl_setopt ( $ch2, CURLOPT_HEADER, 1 );
  102.  
  103. $headers2[] = 'GET ' . $min1 . ' HTTP/1.1';
  104. $headers2[] = 'Host: www.mon-compte.bouyguestelecom.fr';
  105. $headers2[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0';
  106. $headers2[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  107. $headers2[] = 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3';
  108. $headers2[] = 'Connection: keep-alive';
  109. $headers2[] = 'Upgrade-Insecure-Requests: 1';
  110.  
  111. curl_setopt ( $ch2, CURLOPT_HTTPHEADER, $headers2 );
  112.  
  113. $res2 = curl_exec ( $ch2 );
  114.  
  115. curl_close ( $ch2 );
  116.  
  117. preg_match_all ( '/^Set-Cookie:\s*([^;]*)/mi', $res2, $matchescookie2 );
  118.  
  119. $cookies2 = array ( );
  120.  
  121. foreach ( $matchescookie2[1] as $itemcookie2 )
  122. {
  123. parse_str ( $itemcookie2, $cookie2 );
  124.  
  125. $cookies2 = array_merge ( $cookies2, $cookie2 );
  126. }
  127.  
  128. $JSESSIONID = $cookies2['JSESSIONID'];
  129.  
  130. preg_match ( '/name="lt" value="(.*?)"/', $res2, $matches2 );
  131.  
  132. $lt = $matches2[1];
  133. $ch3 = curl_init ( );
  134.  
  135. curl_setopt ( $ch3, CURLOPT_URL, "https://www.mon-compte.bouyguestelecom.fr/cas/login;jsessionid=" . $JSESSIONID . "?service=http%3A%2F%2Fwww.services.bouyguestelecom.fr%2Ftelevision-vod%2Fcheck_path" );
  136. curl_setopt ( $ch3, CURLOPT_RETURNTRANSFER, 1 );
  137. curl_setopt ( $ch3, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0" );
  138. curl_setopt ( $ch3, CURLOPT_SSL_VERIFYPEER, 0 );
  139. curl_setopt ( $ch3, CURLOPT_SSL_VERIFYHOST, 0 );
  140. curl_setopt ( $ch3, CURLOPT_FOLLOWLOCATION, 0 );
  141. curl_setopt ( $ch3, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
  142. curl_setopt ( $ch3, CURLOPT_HEADER, 1 );
  143. curl_setopt ( $ch3, CURLOPT_POST, 1 );
  144.  
  145. $str = "username=" . $usernameurlencode . "&password=" . $passwordurlencode . "&rememberMe=true&_rememberMe=on&lt=" . $lt . "&execution=e1s1&_eventId=submit";
  146.  
  147. curl_setopt ( $ch3, CURLOPT_POSTFIELDS, $str );
  148.  
  149. $headers3[] = 'POST /cas/login;jsessionid=' . $JSESSIONID . '?service=http%3A%2F%2Fwww.services.bouyguestelecom.fr%2Ftelevision-vod%2Fcheck_path HTTP/1.1';
  150. $headers3[] = 'Host: www.mon-compte.bouyguestelecom.fr';
  151. $headers3[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0';
  152. $headers3[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  153. $headers3[] = 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3';
  154. $headers3[] = 'Referer: https://www.mon-compte.bouyguestelecom.fr/cas/login?service=http%3A%2F%2Fwww.services.bouyguestelecom.fr%2Ftelevision-vod%2Fcheck_path';
  155. $headers3[] = 'Cookie: JSESSIONID=' . $JSESSIONID . '; NoCookieVu=0';
  156. $headers3[] = 'Connection: keep-alive';
  157. $headers3[] = 'Upgrade-Insecure-Requests: 1';
  158. $headers3[] = 'Content-Type: application/x-www-form-urlencoded';
  159. $headers3[] = "Content-Length: " . iconv_strlen ( $str, 'UTF-8' );
  160.  
  161. curl_setopt ( $ch3, CURLOPT_HTTPHEADER, $headers3 );
  162.  
  163. $res3 = curl_exec ( $ch3 );
  164.  
  165. curl_close ( $ch3 );
  166.  
  167. if ( preg_match ( '#Location: (.*)#', $res3, $r3 ) )
  168. $l3 = trim ( $r3[1] );
  169.  
  170. $min3 = str_replace ( "http://www.services.bouyguestelecom.fr", "", $l3 );
  171. $l31 = str_replace ( "http://www.services.bouyguestelecom.fr", "https://www.services.bouyguestelecom.fr", $l3 );
  172.  
  173. preg_match_all ( '/^Set-Cookie:\s*([^;]*)/mi', $res3, $matchescookie3 );
  174.  
  175. $cookies3 = array ( );
  176.  
  177. foreach ( $matchescookie3[1] as $itemcookie3 )
  178. {
  179. parse_str ( $itemcookie3, $cookie3 );
  180.  
  181. $cookies3 = array_merge ( $cookies3, $cookie3 );
  182. }
  183.  
  184. $CASPRIVACY = $cookies3['CASPRIVACY'];
  185. $SSOID = $cookies3['SSOID'];
  186. $SSO_ACTIVE = $cookies3['SSO_ACTIVE'];
  187. $CASTGC = $cookies3['CASTGC'];
  188. $bi = $cookies3['bi'];
  189. $CASTGR = $cookies3['CASTGR'];
  190. $ch4 = curl_init ( );
  191.  
  192. curl_setopt ( $ch4, CURLOPT_URL, $l31 );
  193. curl_setopt ( $ch4, CURLOPT_RETURNTRANSFER, 1 );
  194. curl_setopt ( $ch4, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0" );
  195. curl_setopt ( $ch4, CURLOPT_SSL_VERIFYPEER, false );
  196. curl_setopt ( $ch4, CURLOPT_SSL_VERIFYHOST, 0 );
  197. curl_setopt ( $ch4, CURLOPT_FOLLOWLOCATION, 0 );
  198. curl_setopt ( $ch4, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
  199. curl_setopt ( $ch4, CURLOPT_HEADER, 1 );
  200.  
  201. $headers4[] = 'GET ' . $min3 . ' HTTP/1.1';
  202. $headers4[] = 'Host: www.services.bouyguestelecom.fr';
  203. $headers4[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0';
  204. $headers4[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  205. $headers4[] = 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3';
  206. $headers4[] = 'Connection: keep-alive';
  207. $headers4[] = 'Cookie: PHPSESSID=' . $PHPSESSID . '; NoCookieVu=0; SSOID=' . $SSOID . '; SSO_ACTIVE=' . $SSO_ACTIVE . '; bi=' . $bi . '';
  208. $headers4[] = 'Connection: keep-alive';
  209. $headers4[] = 'Upgrade-Insecure-Requests: 1';
  210.  
  211. curl_setopt ( $ch4, CURLOPT_HTTPHEADER, $headers4 );
  212.  
  213. $res4 = curl_exec ( $ch4 );
  214.  
  215. curl_close ( $ch4 );
  216.  
  217. preg_match_all ( '/^Set-Cookie:\s*([^;]*)/mi', $res4, $matchescookie4 );
  218.  
  219. $cookies4 = array ( );
  220.  
  221. foreach ( $matchescookie4[1] as $itemcookie4 )
  222. {
  223. parse_str ( $itemcookie4, $cookie4 );
  224.  
  225. $cookies4 = array_merge ( $cookies4, $cookie4 );
  226. }
  227.  
  228. $PHPSESSID1 = $cookies4['PHPSESSID'];
  229.  
  230. if ( preg_match ( '#Location: (.*)#', $res4, $r4 ) )
  231. $l4 = trim ( $r4[1] );
  232.  
  233. $min5 = str_replace ( "https://www.services.bouyguestelecom.fr", "", $proxy_request_url );
  234. $ch6 = curl_init ( );
  235.  
  236. curl_setopt ( $ch6, CURLOPT_URL, $proxy_request_url );
  237. curl_setopt ( $ch6, CURLOPT_RETURNTRANSFER, 1 );
  238. curl_setopt ( $ch6, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0" );
  239. curl_setopt ( $ch6, CURLOPT_SSL_VERIFYPEER, false );
  240. curl_setopt ( $ch6, CURLOPT_SSL_VERIFYHOST, 0 );
  241. curl_setopt ( $ch6, CURLOPT_FOLLOWLOCATION, 0 );
  242. curl_setopt ( $ch6, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
  243. curl_setopt ( $ch6, CURLOPT_HEADER, 0 );
  244.  
  245. $headers6[] = 'GET ' . $min5 . ' HTTP/1.1';
  246. $headers6[] = 'Host: www.services.bouyguestelecom.fr';
  247. $headers6[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0';
  248. $headers6[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
  249. $headers6[] = 'Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3';
  250. $headers6[] = 'Cookie: PHPSESSID=' . $PHPSESSID1 . '; NoCookieVu=0; SSOID=' . $SSOID . '; SSO_ACTIVE=' . $SSO_ACTIVE . '; bi=' . $bi . '';
  251. $headers6[] = 'Connection: keep-alive';
  252. $headers6[] = 'Upgrade-Insecure-Requests: 1';
  253.  
  254. curl_setopt ( $ch6, CURLOPT_HTTPHEADER, $headers6 );
  255.  
  256. $res6 = curl_exec ( $ch6 );
  257.  
  258. curl_close ( $ch6 );
  259.  
  260. $lien = str_replace ( 'https', 'http', str_replace ( "GlobalManifest.m3u8", "04.m3u8", $res6 ) );
  261.  
  262. header ( "Location: " . $lien );
  263.  
  264. ?>
Add Comment
Please, Sign In to add comment