PageRenderTime 54ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/hosts/upload/filecloud.io_member.php

https://gitlab.com/dkiller1/rapidleech
PHP | 137 lines | 106 code | 22 blank | 9 comment | 33 complexity | 802952a1f27f94eb161742415a263521 MD5 | raw file
  1. <?php
  2. ####### Account Info. ###########
  3. $upload_acc['filecloud_io']['apikey'] = ""; //Set your filecloud.io apikey here.
  4. $upload_acc['filecloud_io']['user'] = ""; // Or you can use login...
  5. $upload_acc['filecloud_io']['pass'] = ""; // (Requires https support.)
  6. ##############################
  7. $not_done = true;
  8. $continue_up = false;
  9. // Check https support for login.
  10. $usecurl = $cantlogin = false;
  11. if (!extension_loaded('openssl')) {
  12. if (extension_loaded('curl')) {
  13. $cV = curl_version();
  14. if (in_array('https', $cV['protocols'], true)) $usecurl = true;
  15. else $cantlogin = true;
  16. } else $cantlogin = true;
  17. }
  18. if ($upload_acc['filecloud_io']['apikey']) {
  19. $_REQUEST['up_apikey'] = $upload_acc['filecloud_io']['apikey'];
  20. $_REQUEST['action'] = 'FORM';
  21. echo "<p style='text-align:center;font-weight:bold;'>Using Default Apikey.</p>\n";
  22. }
  23. if (!$cantlogin && !empty($upload_acc['filecloud_io']['user']) && !empty($upload_acc['filecloud_io']['pass'])) {
  24. $_REQUEST['up_uselogin'] = 'yes';
  25. $_REQUEST['up_login'] = $upload_acc['filecloud_io']['user'];
  26. $_REQUEST['up_pass'] = $upload_acc['filecloud_io']['pass'];
  27. $_REQUEST['action'] = 'FORM';
  28. echo "<p style='text-align:center;font-weight:bold;'>Using Default Login.</p>\n";
  29. }
  30. if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'FORM') $continue_up=true;
  31. else {
  32. echo "<form method='POST'>
  33. <input type='hidden' name='action' value='FORM' />";
  34. 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;' />";
  35. if (!$cantlogin) echo "<br /><br /><input type='checkbox' id='up_uselogin' name='up_uselogin' value='yes' onclick='javascript:showlogin();' />&nbsp;Use login?";
  36. echo "</div>\n\t<table border='0' style='width:270px;' cellspacing='0' align='center'>";
  37. 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>
  38. <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>
  39. <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";
  40. echo "\t<tr><td colspan='2' align='center'><br /><input type='submit' value='Upload' /></td></tr>
  41. <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";
  42. echo "<script type='text/javascript'>/* <![CDATA[ */
  43. self.resizeTo(700,400);";
  44. if (!$cantlogin) echo "\n\tfunction showlogin() {
  45. if ($('#up_uselogin').is(':checked')) {
  46. $('#tr_user,#tr_pass,#tr_note').show();
  47. $('#up_apikey').attr('disabled', 'disabled');
  48. $('#up_apikey').val('');
  49. } else {
  50. $('#tr_user,#tr_pass,#tr_note').hide();
  51. $('#up_apikey').removeAttr('disabled');
  52. }
  53. }\n\t";
  54. echo "\n/* ]]> */</script>\n";
  55. }
  56. if ($continue_up) {
  57. $not_done = $uselogin = false;
  58. $login = true;
  59. if ($fsize < 5120) html_error('The file is too small for upload.'); // They don't accept files under 5 KB :D
  60. // Ping api
  61. $page = geturl ('api.filecloud.io', 80, '/api-ping.api');is_page($page);
  62. is_notpresent($page, '"message":"pong"', 'Error: filecloud.io api is down?.');
  63. // Login
  64. if (!empty($_REQUEST['up_uselogin']) && $_REQUEST['up_uselogin'] == 'yes' && !empty($_REQUEST['up_login']) && !empty($_REQUEST['up_pass'])) {
  65. echo "\n<div id='login' width='100%' align='center'>Getting Apikey for filecloud.io</div>\n";
  66. $post = array();
  67. $post['username'] = urlencode($_REQUEST['up_login']);
  68. $post['password'] = urlencode($_REQUEST['up_pass']);
  69. if (!$usecurl) {
  70. $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 .
  71. is_page($page);
  72. } else $page = cURL ('https://secure.filecloud.io/api-fetch_apikey.api', $post);
  73. is_present($page, '"status":"error"', 'Login Failed: "'.str_replace('\\','',cut_str($page, '"message":"','"')).'"');
  74. is_notpresent($page, '"akey":"', "Login Failed: Akey not found.");
  75. $_REQUEST['up_apikey'] = cut_str($page, '"akey":"', '"');
  76. $uselogin = true;
  77. } else if(empty($_REQUEST['up_apikey'])) {
  78. $login = false;
  79. echo "<b><center>Neither Apikey nor Login were found or are empty, using non member upload.</center></b>\n";
  80. }
  81. if ($login && !$uselogin) { // Check Apikey...
  82. $_REQUEST['up_apikey'] = trim($_REQUEST['up_apikey']);
  83. echo "<script type='text/javascript'>document.getElementById('login').style.display='none';</script>\n<div id='apikey' width='100%' align='center'>Checking Apikey</div>\n";
  84. $page = geturl ('filecloud.io', 80, '/files.html', '', 'auth='.urlencode($_REQUEST['up_apikey']));is_page($page);
  85. is_present($page, 'you are not authorized to view this page', 'Invalid apikey.');
  86. }
  87. // Retrive upload ID
  88. 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";
  89. $page = geturl('api.filecloud.io', 80, '/api-fetch_upload_url.api?response=text', '', 0, array('akey' => $_REQUEST['up_apikey']));is_page($page);
  90. is_present($page, 'status: error', 'Upload Failed: "'.htmlentities(cut_str($page, 'message: ', "\n")).'"');
  91. if (!preg_match('@upload_url: http://(s\d+\.filecloud\.io)(/[^\r|\n]+)@i', $page, $loc)) html_error('Upload server not found.');
  92. $post = array();
  93. if ($login) $post['akey'] = $_REQUEST['up_apikey'];
  94. $up_loc = "http://{$loc[1]}{$loc[2]}?response=text";
  95. // Uploading
  96. echo "<script type='text/javascript'>document.getElementById('info').style.display='none';</script>\n";
  97. $url = parse_url($up_loc);
  98. $upfiles = upfile($url['host'], !empty($url['port']) ? $url['port'] : 80, $url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''), '', 0, $post, $lfile, $lname, 'Filedata');
  99. // Upload Finished
  100. echo "<script type='text/javascript'>document.getElementById('progressblock').style.display='none';</script>";
  101. is_page($upfiles);
  102. is_present($upfiles, 'status: error', 'Upload Error: "'.htmlentities(cut_str($upfiles, 'message: ',"\n")).'"');
  103. if (preg_match('@ukey: (\w+)@i', $upfiles, $dl)) {
  104. $download_link = 'http://filecloud.io/'.$dl[1];
  105. if(preg_match('@name: ([^\r|\n]+)@i', $upfiles, $fn)) $download_link .= '/' . $fn[1];
  106. 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";
  107. } else html_error('Download link not found.');
  108. }
  109. //[09-8-2012] (Re)Written by Th3-822.
  110. //[05-11-2012] Fixed post-upload error msg && added check for min filesize. - Th3-822
  111. ?>