Advertisement
Guest User

Untitled

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