Don't like ads? PRO users don't see any ads ;-)

[rapidleech][u] filecloud.io_member.php

By: Th3-822 on Aug 9th, 2012  |  syntax: PHP  |  size: 6.95 KB  |  hits: 155  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. ####### Account Info. ###########
  4. $upload_acc['filecloud_io']['apikey'] = ""; //Set your filecloud.io apikey here.
  5.  
  6. $upload_acc['filecloud_io']['user'] = ""; //Or you can use login...
  7. $upload_acc['filecloud_io']['pass'] = ""; // Requires https support.
  8. ##############################
  9.  
  10. $not_done = true;
  11. $continue_up = false;
  12.  
  13. // Check https support for login.
  14. $usecurl = $cantlogin = false;
  15. if (!extension_loaded('openssl')) {
  16.         if (extension_loaded('curl')) {
  17.                 $cV = curl_version();
  18.                 if (in_array('https', $cV['protocols'], true)) $usecurl = true;
  19.                 else $cantlogin = true;
  20.         } else $cantlogin = true;
  21. }
  22.  
  23. if ($upload_acc['filecloud_io']['apikey']) {
  24.         $_REQUEST['up_apikey'] = $upload_acc['filecloud_io']['apikey'];
  25.         $_REQUEST['action'] = 'FORM';
  26.         echo "<p style='text-align:center;font-weight:bold;'>Using Default Apikey.</p>\n";
  27. }
  28.  
  29. if (!$cantlogin && !empty($upload_acc['filecloud_io']['user']) && !empty($upload_acc['filecloud_io']['pass'])) {
  30.         $_REQUEST['up_uselogin'] = 'yes';
  31.         $_REQUEST['up_login'] = $upload_acc['filecloud_io']['user'];
  32.         $_REQUEST['up_pass'] = $upload_acc['filecloud_io']['pass'];
  33.         $_REQUEST['action'] = 'FORM';
  34.         echo "<p style='text-align:center;font-weight:bold;'>Using Default Login.</p>\n";
  35. }
  36.  
  37. if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'FORM') $continue_up=true;
  38. else {
  39.         echo "<form method='POST'>
  40.         <input type='hidden' name='action' value='FORM' />";
  41.         echo "<div id='apik' style='text-align:center;'>filecloud.io Apikey*<br /><input type='text' id='up_apikey' name='up_apikey' value='' style='width:270px;' />";
  42.         if (!$cantlogin) echo "<br /><br /><input type='checkbox' id='up_uselogin' name='up_uselogin' value='yes' onclick='javascript:showlogin();' />&nbsp;Use login?";
  43.         echo "</div>\n\t<table border='0' style='width:270px;' cellspacing='0' align='center'>";
  44.         if (!$cantlogin) echo "<tr id='tr_user' style='display:none;' align='center'><td>Username</td><td><input type='text' name='up_login' value='' style='width:160px;' /></td></tr>
  45.         <tr id='tr_pass' style='display:none;' align='center'><td>Password</td><td><input type='password' name='up_pass' value='' style='width:160px;' /></td></tr>
  46.         <tr id='tr_note' style='display:none;'><td colspan='2' align='center'>Remember to copy and save your Apikey after upload.<br /><small>Login needs https support.</small></td></tr>\n";
  47.         echo "\t<tr><td colspan='2' align='center'><br /><input type='submit' value='Upload' /></td></tr>
  48.         <tr><td colspan='2' align='center'><small>*You can set it as default in <b>".basename(__FILE__)."</b></small></td></tr>\n</table>\n</form>\n";
  49.         echo "<script type='text/javascript'>/* <![CDATA[ */
  50.         self.resizeTo(700,400);";
  51.         if (!$cantlogin) echo "\n\tfunction showlogin() {
  52.                 if ($('#up_uselogin').is(':checked')) {
  53.                         $('#tr_user,#tr_pass,#tr_note').show();
  54.                         $('#up_apikey').attr('disabled', 'disabled');
  55.                         $('#up_apikey').val('');
  56.                 } else {
  57.                         $('#tr_user,#tr_pass,#tr_note').hide();
  58.                         $('#up_apikey').removeAttr('disabled');
  59.                 }
  60.         }\n\t";
  61.         echo "\n/* ]]> */</script>\n";
  62. }
  63.  
  64. if ($continue_up) {
  65.         $not_done = $uselogin = false;
  66.         $login = true;
  67.  
  68.         if ($fsize < 5120) html_error('The file is too small for upload.'); // They don't accept files under 5 KB :D
  69.  
  70.         // Ping api
  71.         $page = geturl ('api.filecloud.io', 80, '/api-ping.api');is_page($page);
  72.         is_notpresent($page, '"message":"pong"', 'Error: filecloud.io api is down?.');
  73.  
  74.         // Login
  75.         if (!empty($_REQUEST['up_uselogin']) && $_REQUEST['up_uselogin'] == 'yes' && !empty($_REQUEST['up_login']) && !empty($_REQUEST['up_pass'])) {
  76.                 echo "\n<div id='login' width='100%' align='center'>Getting Apikey for filecloud.io</div>\n";
  77.                 $post = array();
  78.                 $post['username'] = urlencode($_REQUEST['up_login']);
  79.                 $post['password'] = urlencode($_REQUEST['up_pass']);
  80.  
  81.                 if (!$usecurl) {
  82.                 $page = geturl ('secure.filecloud.io', 0, '/api-fetch_apikey.api', 'https://secure.filecloud.io/api-fetch_apikey.api', 0, $post, 0, 0, 0, 0, 'https'); // Port is overridden to 443 .
  83.                 is_page($page);
  84.                 } else $page = cURL ('https://secure.filecloud.io/api-fetch_apikey.api', $post);
  85.  
  86.                 is_present($page, '"status":"error"', 'Login Failed: "'.str_replace('\\','',cut_str($page, '"message":"','"')).'"');
  87.                 is_notpresent($page, '"akey":"', "Login Failed: Akey not found.");
  88.                 $_REQUEST['up_apikey'] = cut_str($page, '"akey":"', '"');
  89.                 $uselogin = true;
  90.         } else if(empty($_REQUEST['up_apikey'])) {
  91.                 $login = false;
  92.                 echo "<b><center>Neither Apikey nor Login were found or are empty, using non member upload.</center></b>\n";
  93.         }
  94.  
  95.         if ($login && !$uselogin) { // Check Apikey...
  96.                 $_REQUEST['up_apikey'] = trim($_REQUEST['up_apikey']);
  97.                 echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='apikey' width='100%' align='center'>Checking Apikey</div>\n";
  98.                 $page = geturl ('filecloud.io', 80, '/files.html', '', 'auth='.urlencode($_REQUEST['up_apikey']));is_page($page);
  99.                 is_present($page, 'you are not authorized to view this page', 'Invalid apikey.');
  100.         }
  101.  
  102.         // Retrive upload ID
  103.         echo "<table style='width:600px;margin:auto;'>\n<tr><td align='center'>\n<script type='text/javascript'>document.getElementById('apikey').style.display='none';</script>\n<div id='info' width='100%' align='center'>Retrive upload ID</div>\n";
  104.  
  105.         $page = geturl('api.filecloud.io', 80, '/api-fetch_upload_url.api?response=text', '', 0, array('akey' => $_REQUEST['up_apikey']));is_page($page);
  106.         is_present($page, 'status: error', 'Upload Failed: "'.htmlentities(cut_str($page, 'message: ', "\n")).'"');
  107.  
  108.         if (!preg_match('@upload_url: http://(s\d+\.filecloud\.io)(/[^\r|\n]+)@i', $page, $loc)) html_error('Upload server not found.', 0);
  109.  
  110.         $post = array();
  111.         if ($login) $post['akey'] = $_REQUEST['up_apikey'];
  112.  
  113.         $up_loc = "http://{$loc[1]}{$loc[2]}?response=text";
  114.  
  115.         // Uploading
  116.         echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
  117.  
  118.         $url = parse_url($up_loc);
  119.         $upfiles = upfile($url['host'], !empty($url['port']) ? $url['port'] : 80, $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), '', 0, $post, $lfile, $lname, 'Filedata');
  120.  
  121.         // Upload Finished
  122.         echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>";
  123.  
  124.         is_page($upfiles);
  125.         is_present($upfiles, 'status: error', 'Upload Error: "'.htmlentities(cut_str($upfiles, 'message: ',"\n")).'"');
  126.  
  127.         if (preg_match('@ukey: (\w+)@i', $upfiles, $dl)) {
  128.                 $download_link = 'http://filecloud.io/'.$dl[1];
  129.                 if(preg_match('@name: ([^\r|\n]+)@i', $upfiles, $fn)) $download_link .= '/' . $fn[1];
  130.                 if ($uselogin) echo "\n<table width='100%' border='0'>\n<tr><td width='100' nowrap='nowrap' align='right'>filecloud.io Apikey:<td width='80%'><input value='{$_REQUEST['up_apikey']}' class='upstyles-dllink' readonly='readonly' /></tr>\n</table>\n";
  131.         } else html_error('Download link not found.', 0);
  132. }
  133.  
  134. //[09-8-2012]  (Re)Written by Th3-822.
  135. //[05-11-2012]  Fixed post-upload error msg && added check for min filesize. - Th3-822
  136.  
  137. ?>