Advertisement
Th3-822

[rapidleech][u] turbobit.net.php

Jan 11th, 2013 (edited)
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.42 KB | None | 0 0
  1. <?php
  2. ######## Account Info ########
  3. $upload_acc['turbobit_net']['apikey'] = ''; //Set your apikey
  4. ########################
  5.  
  6. $_GET['proxy'] = isset($_GET['proxy']) ? $_GET['proxy'] : '';
  7. $not_done = true;
  8. $continue_up = false;
  9.  
  10. if (!empty($upload_acc['turbobit_net']['apikey'])) {
  11.     $default_acc = true;
  12.     $_REQUEST['up_apikey'] = $upload_acc['turbobit_net']['apikey'];
  13.     $_REQUEST['action'] = 'FORM';
  14.     echo "<b><center>Using Default ApiKey.</center></b>\n";
  15. } else $default_acc = false;
  16.  
  17. if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'FORM') $continue_up = true;
  18. else {
  19.     echo "<table border='0' cellspacing='0' align='center'>
  20.     <form method='POST'>
  21.     <input type='hidden' name='action' value='FORM' />
  22.     <tr><td style='white-space:nowrap;'>&nbsp;API Key*</td><td>&nbsp;<input type='text' name='up_apikey' placeholder='Get it @ https://turbobit.net/user/settings' value='' style='width:250px;' /></td></tr>\n";
  23.     echo "<tr><td colspan='2' align='center'><br /><input type='submit' value='Upload' /></td></tr>\n";
  24.     echo "<tr><td colspan='2' align='center'><small>*You can set it as default in <b>".basename(__FILE__)."</b></small></td></tr>\n";
  25.     echo "</table>\n</form>\n";
  26. }
  27.  
  28. if ($continue_up) {
  29.     $login = $not_done = false;
  30.     $domain = 'turbobit.net';
  31.     $referer = "https://$domain/";
  32.  
  33.     // Login
  34.     echo "<table style='width:600px;margin:auto;'>\n<tr><td align='center'>\n<div id='login' width='100%' align='center'>Login to $domain</div>\n";
  35.  
  36.     $cookie = array('user_lang' => 'en');
  37.     if (!empty($_REQUEST['up_apikey'])) {
  38.         $page = geturl($domain, 443, '/v001/upload/http/server', 0, 0, array('api_key' => urlencode(trim($_REQUEST['up_apikey']))), 0, $_GET['proxy'], $pauth, 0, 'https');is_page($page);
  39.         $json = json2array($page, 'Login Error');
  40.  
  41.         if (empty($json['result'])) {
  42.             if (!empty($json['message'])) html_error('[Login Error] ' . htmlspecialchars($json['message']));
  43.             html_error('[Login Error] Unexpected Reply.');
  44.         }
  45.  
  46.         $login = true;
  47.     } else {
  48.         echo "<b><center>Login not found or empty, using non member upload.</center></b>\n";
  49.         if ($fsize > 209715200) html_error('File is too big for anon upload (> 200 MiB)'); // 200 MiB
  50.     }
  51.  
  52.     // Retrive upload ID
  53.     echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrive upload ID</div>\n";
  54.  
  55.     if ($login) {
  56.         if (empty($json['url'])) html_error('Error: API Upload URL not found.');
  57.         if (empty($json['params']) || !is_array($json['params'])) html_error('Error: API Upload params not found.');
  58.  
  59.         $up_url = $json['url'];
  60.         $post = $json['params'];
  61.     } else {
  62.         $page = geturl($domain, 443, '/', $referer, $cookie, 0, 0, $_GET['proxy'], $pauth, 0, 'https');is_page($page);
  63.  
  64.         if (!preg_match('@https?://s\d+\.turbobit\.net/uploadfile@i', $page, $up_url)) html_error('Error: Upload URL not found.');
  65.  
  66.         $post = array();
  67.         $post['Filename'] = $lname;
  68.         $post['apptype'] = cut_str($page, 'name="apptype" value="', '"');
  69.         $up_url = $up_url[0];
  70.     }
  71.  
  72.     // Uploading
  73.     echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
  74.  
  75.     $url = parse_url($up_url);
  76.     $upfiles = upfile($url['host'], defport($url), $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), 0, 0, $post, $lfile, $lname, 'Filedata', '', $_GET['proxy'], $pauth, 0, $url['scheme']);
  77.  
  78.     // Upload Finished
  79.     echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>\n";
  80.  
  81.     is_page($upfiles);
  82.  
  83.     $json = json2array($upfiles);
  84.     if ((empty($json['result']) || $json['result'] != 'true') || empty($json['id'])) html_error('Upload error: "'.htmlspecialchars($json['message']).'"');
  85.     $id = is_array($json['id']) ? $json['id']['fid'] : $json['id'];
  86.  
  87.     if (!$login) {
  88.         $page = geturl($domain, 443, '/newfile/gridFile/'.$id, $referer."newfile/edit/\r\nX-Requested-With: XMLHttpRequest", $cookie, 0, 0, $_GET['proxy'], $pauth, 0, 'https');is_page($page);
  89.         $json = json2array($page);
  90.         $info = reset($json['rows']);
  91.         if (!empty($info['cell'][7])) $delete_link = sprintf('%sdelete/file/%s/%s', $referer, $id, $info['cell'][7]);
  92.     }
  93.  
  94.     $download_link = "$referer$id.html";
  95. }
  96.  
  97. function json2array($content, $errorPrefix = 'Error') {
  98.     if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  99.     if (empty($content)) html_error("[$errorPrefix]: No content.");
  100.     $content = ltrim($content);
  101.     if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = trim(substr($content, $pos + 4));
  102.     $cb_pos = strpos($content, '{');
  103.     $sb_pos = strpos($content, '[');
  104.     if ($cb_pos === false && $sb_pos === false) html_error("[$errorPrefix]: JSON start braces not found.");
  105.     $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  106.     $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  107.     if (empty($content)) html_error("[$errorPrefix]: No JSON content.");
  108.     $rply = json_decode($content, true);
  109.     if ($rply === NULL) html_error("[$errorPrefix]: Error reading JSON.");
  110.     return $rply;
  111. }
  112.  
  113. //[11-1-2013] Written by Th3-822.
  114. //[07-6-2013] Added login recaptcha support. - Th3-822
  115. //[22-8-2013] Fixed for changes at upload page. - Th3-822
  116. //[06-9-2013] Fixed get fileid. - Th3-822
  117. //[12-2-2017] Removed CAPTCHA (Unsupported ATM) and Fixed Login (There were Huges Typos on It). - Th3-822
  118. //[06-12-2020] Switched to API Upload instead of login. - Th3-822
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement