Advertisement
Guest User

Untitled

a guest
Feb 12th, 2017
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.23 KB | None | 0 0
  1. //Código do play.php
  2. <?php
  3. $USERNAME = 'admin@filmesonlineuhd.net';
  4. $PASSWORD = '213546879';
  5. $COOKIEFILE = 'cookies.txt';
  6.  
  7. $ch = curl_init();
  8. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  9. curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  12. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  13. curl_setopt($ch, CURLOPT_COOKIEJAR, $COOKIEFILE);
  14. curl_setopt($ch, CURLOPT_COOKIEFILE, $COOKIEFILE);
  15. curl_setopt($ch, CURLOPT_HEADER, 0);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  17. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
  18. curl_setopt($ch, CURLOPT_TIMEOUT, 120);
  19.  
  20. curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLogin');
  21. $data = curl_exec($ch);
  22.  
  23. //echo $data;
  24.  
  25. $formFields = getFormFields($data);
  26.  
  27. //print_r($formFields);
  28.  
  29. $formFields['Email'] = $USERNAME;
  30. $formFields['Passwd'] = $PASSWORD;
  31. unset($formFields['PersistentCookie']);
  32.  
  33. $post_string = '';
  34. foreach($formFields as $key => $value) {
  35. $post_string .= $key . '=' . urlencode($value) . '&';
  36. }
  37.  
  38. $post_string = substr($post_string, 0, -1);
  39.  
  40. curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2');
  41. curl_setopt($ch, CURLOPT_POST, 1);
  42. curl_setopt($ch, CURLOPT_REFERER, 'https://mail.google.com/');
  43. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
  44.  
  45. $result = curl_exec($ch);
  46. //comentado aqui
  47. /*
  48. if (strpos($result, '<title>Redirecting') === false) {
  49. die("Login failed");
  50. var_dump($result);
  51. } else {*/
  52. curl_setopt($ch, CURLOPT_URL, 'https://mail.google.com/mail/h/jeu23doknfnj/?zy=e&f=1');
  53. curl_setopt($ch, CURLOPT_POST, 0);
  54. curl_setopt($ch, CURLOPT_POSTFIELDS, null);
  55.  
  56. $result = curl_exec($ch);
  57. //header('Location:https://mail.google.com/mail/h/jeu23doknfnj/?zy=e&f=1');
  58. var_dump($result);
  59. //}
  60.  
  61. function getFormFields($data)
  62. {
  63. if (preg_match('/(<form.*?id=.?gaia_loginform.*?<\/form>)/is', $data, $matches)) {
  64. $inputs = getInputs($matches[1]);
  65.  
  66. return $inputs;
  67. } else {
  68. die('didnt find login form');
  69. }
  70. }
  71.  
  72. function getInputs($form)
  73. {
  74. $inputs = array();
  75.  
  76. $elements = preg_match_all('/(<input[^>]+>)/is', $form, $matches);
  77.  
  78. if ($elements > 0) {
  79. for($i = 0; $i < $elements; $i++) {
  80. $el = preg_replace('/\s{2,}/', ' ', $matches[1][$i]);
  81.  
  82. if (preg_match('/name=(?:["\'])?([^"\'\s]*)/i', $el, $name)) {
  83. $name = $name[1];
  84. $value = '';
  85.  
  86. if (preg_match('/value=(?:["\'])?([^"\'\s]*)/i', $el, $value)) {
  87. $value = $value[1];
  88. }
  89.  
  90. $inputs[$name] = $value;
  91. }
  92. }
  93. }
  94.  
  95. return $inputs;
  96. }
  97. ?>
  98. //Código do index.php
  99. <?php
  100. //error_reporting(0);
  101. require_once 'vendor/autoload.php';
  102. require_once 'config.php';
  103. require_once 'libs/curl.php';
  104. require_once 'libs/gdrive.php';
  105. require_once 'libs/gphotos.php';
  106.  
  107. $client = new Google_Client();
  108. $client->setClientId(CLIENT_ID);
  109. $client->setClientSecret(CLIENT_SECRET);
  110. $client->setRedirectUri(AUTH_REDIRECT_URL);
  111. $client->setScopes(array('https://www.googleapis.com/auth/drive.metadata.readonly', 'https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/drive.file'));
  112. $client->setAccessType ("offline");
  113. $client->setApprovalPrompt ("force");
  114. if(file_exists("./tokens/accesstoken.txt")) {
  115. $content = file_get_contents("./tokens/accesstoken.txt");
  116. $accessToken = json_decode($content, true) ;
  117. $client->setAccessToken($accessToken);
  118. if($client->isAccessTokenExpired()) {
  119. $currentAccessToken = $client->getAccessToken();
  120. $client->refreshToken($currentAccessToken['refresh_token']);
  121. $newAccessToken = $client->getAccessToken();
  122. $newAccessToken['refresh_token'] = $currentAccessToken['refresh_token'];
  123. file_put_contents("./tokens/accesstoken.txt", json_encode($newAccessToken));
  124. $accessToken = $currentAccessToken;
  125. }
  126.  
  127. if($_GET && $_GET['url']){
  128. $md5url = md5($_GET['url']);
  129. $cachefile = './cached/'.$md5url;
  130. $cachetime = 3600;
  131. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  132. include($cachefile);
  133. exit;
  134. }
  135. ob_start();
  136.  
  137. $url = $_GET['url'];
  138. $posGDrive = strpos($url, 'drive.google.com');
  139. $posDocs = strpos($url, 'docs.google.com');
  140. $posPhotos = strpos($url, 'photos.google.com');
  141. $output = "";
  142. if($posGDrive !== false || $posDocs !== false){
  143. $output = get_google_drive($url, $accessToken['access_token']);
  144. }elseif($posPhotos !== false){
  145. $output = get_google_photos($url);
  146. }
  147. echo $output;
  148.  
  149. $cached = fopen($cachefile, 'w');
  150. fwrite($cached, ob_get_contents());
  151. fclose($cached);
  152. ob_end_flush();
  153. }
  154. } else {
  155. if(isset($_GET['code'])){
  156. $client->authenticate($_GET['code']);
  157. $accessToken = $client->getAccessToken();
  158. file_put_contents("./tokens/accesstoken.txt", json_encode($accessToken));
  159. }else{
  160. $authUrl = $client->createAuthUrl();
  161. header('Location: ' .$authUrl);
  162. exit();
  163. }
  164. $authUrl = $client->createAuthUrl();
  165. }
  166. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement