PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/classes/mip.php

http://rapidleech36b.googlecode.com/
PHP | 223 lines | 135 code | 8 blank | 80 comment | 36 complexity | 07147f7cd6696f8b427da7160a9d580e MD5 | raw file
  1. <?php
  2. /*
  3. This value stored in config.php already
  4. //If you need to disable multiple ip support, set to false
  5. $mip_enabled = true;
  6. //Auto change to next ip after start transload process
  7. $mip_arotate = true;
  8. -- end config
  9. Some hosts need to be changed to be compatible with this, they are in the same archive as this file.
  10. INSTRUCTIONS:
  11. Copy this file to the rapidleech root
  12. Create the file /logfile/mip_iplist.txt
  13. Add 1 ip per line on /logfile/mip_iplist.txt
  14. Check php has read access to /logfile/mip_iplist.txt
  15. Apply the modifications
  16. */
  17. /* Required modification 1: (/templates/plugmod/main.php)
  18. ADD
  19. <?php $mip_action = "select"; @include('mip.php'); ?>
  20. AFTER:
  21. <input type="submit" value="<?php echo lang(209); ?>">
  22. OR
  23. <input type="submit" value="Transload File">
  24. */
  25. /* Required modification 2: (/classes/http.php)
  26. REPLACE
  27. $fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 15);
  28. OR
  29. $fp = @stream_socket_client($host,$errno,$errstr);
  30. OR
  31. $fp = @stream_socket_client ( $hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT );
  32. TO:
  33. $mip_action = "download"; @include('mip.php');
  34. */
  35. /* Optional modification: (/classes/http.php)
  36. IF OLDER RAPIDLEECH:
  37. REPLACE
  38. echo "<p>Connected to proxy: <b>".$proxyHost."</b> at port <b>".$proxyPort."</b>...<br />\n";
  39. TO:
  40. echo "<p>Connected to proxy: <b>".$proxyHost."</b> at port <b>".$proxyPort."</b>...<br />\n";
  41. echo "using IP: ".$mip_ip."<br />\n";
  42. REPLACE
  43. echo "<p>Connected to: <b>".$host."</b> at port <b>".$port."</b>...<br />";
  44. TO:
  45. echo "<p>Connected to: <b>".$host."</b> at port <b>".$port."</b>...<br />";
  46. echo "using IP: ".$mip_ip."<br />\n";
  47. IF NEWER RAPIDLEECH:
  48. REPLACE:
  49. echo '<p>'.sprintf(lang(89),$proxyHost,$proxyPort).'<br />';
  50. TO:
  51. echo '<p>'.sprintf(lang(89),$proxyHost,$proxyPort).'<br />';
  52. echo "using IP: ".$mip_ip."<br />\n";
  53. REPLACE
  54. printf(lang(90),$host,$port);
  55. TO:
  56. printf(lang(90),$host,$port);
  57. echo "<br />using IP: ".$mip_ip."<br />\n";
  58. */
  59. /*
  60. END OF INSTRUCTIONS
  61. */
  62. if (!defined('RAPIDLEECH')) {
  63. require ('../404.php');
  64. exit();
  65. }
  66. if (!$options["mip_enabled"]) {
  67. $mip_ip = "Default IP";
  68. $fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 60);
  69. }
  70. elseif (!empty($GLOBALS['page_upload'])) {
  71. $mip_ip = "Default IP (Uploading)";
  72. $fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 60);
  73. }
  74. elseif (!defined('LOG_DIR')) {
  75. $mip_ip = "Default IP (LOG_DIR constant not defined)";
  76. $fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 60);
  77. }
  78. elseif (!function_exists('stream_socket_client')) {
  79. $mip_ip = "Default IP (PHP4)";
  80. $fp = @fsockopen($proxyHost ? $scheme.$proxyHost : $scheme.$host, $proxyPort ? $proxyPort : $port, $errno, $errstr, 60);
  81. }
  82. else {
  83. $mip_error['begin'] = '<p class="r style1">Multiple IP problem: ';
  84. $mip_error['end'] = '</p>';
  85. $mip_error[0] = $mip_error['begin']."Can not read 'logfile/mip_iplist.txt'".$mip_error['end'];
  86. $mip_error[1] = $mip_error['begin']."Can not read 'logfile/mip_as.txt'".$mip_error['end'];
  87. $mip_error[2] = $mip_error['begin']."Can not write 'logfile/mip_as.txt'".$mip_error['end'];
  88. $mip_error[3] = $mip_error['begin']."Can not write 'logfile/mip_iplast.txt'".$mip_error['end'];
  89. if (!isset($mip_iplist)) {
  90. $mip_iplist = @file(LOG_DIR."mip_iplist.txt") or die($mip_error[0]);
  91. foreach ($mip_iplist as &$mip_tmp1) { $mip_tmp1 = trim($mip_tmp1); }
  92. }
  93. if (!file_exists(LOG_DIR."mip_as.txt") || abs(time() - filemtime(LOG_DIR."mip_as.txt")) > 3600) {
  94. @file_put_contents(LOG_DIR."mip_as.txt", "//Multi IP assignation file\r\n", LOCK_EX) or die($mip_error[2]);
  95. }
  96. if (!is_writable(LOG_DIR."mip_as.txt")) { die($mip_error[2]); }
  97. $mip_fileas = @file(LOG_DIR."mip_as.txt") or die($mip_error[1]);
  98. foreach ($mip_fileas as &$mip_tmp1) {
  99. if (strpos($mip_tmp1, "<del>") === false) { unset($mip_tmp1); }
  100. $mip_tmp1 = explode("<del>", trim($mip_tmp1));
  101. }
  102. array_merge($mip_fileas);
  103. if ($mip_action == "select") {
  104. $mip_ip = null;
  105. if ($options["mip_arotate"]) {
  106. $mip_ip = @file_get_contents(LOG_DIR."mip_iplast.txt") or -1;
  107. $mip_ip = intval($mip_ip) + 1;
  108. $mip_ip = (!isset($mip_iplist[$mip_ip]) || trim($mip_iplist[$mip_ip]) == null ? 0 : $mip_ip);
  109. $mip_ip = $mip_iplist[$mip_ip];
  110. }
  111. ?>
  112. <div style="height:5px;"></div>
  113. <select name="source_ip" title="Source IP">
  114. <option value="">Source IP</option>
  115. <?php
  116. foreach ($mip_iplist as $mip_k => $mip_v) {
  117. if (trim($mip_v) == null) { continue; }
  118. echo '<option value="'.$mip_v.'"'.($mip_v == $mip_ip ? ' selected' : '').'>'.$mip_v.'</option>';
  119. }
  120. ?>
  121. </select>
  122. <?php
  123. }
  124. elseif ($mip_action == "download") {
  125. //if (!isset($_GET['image'])) { echo "<br /><br /><br /><br />"; var_export($_GET); echo "<br /><br />"; var_export($_POST); echo "<br /><br /><br /><br />"; }
  126. $mip_found = false;
  127. $mip_rlink = trim(urldecode(isset($_POST['link']) ? $_POST['link'] : $_GET['link']));
  128. $mip_url = $url;
  129. //netload.in Fix 2
  130. if (stripos(strtolower(urldecode($_POST['referer'])), "netload.in/index.php") !== false) {
  131. foreach ($mip_fileas as $mip_file) {
  132. if (stripos($mip_file[2], "/".urldecode($_POST['filename'])) !== false) {
  133. $mip_rlink = $mip_file[0]; break;
  134. }
  135. }
  136. }
  137. //
  138. //netload.in Fix 1
  139. elseif (stripos($mip_rlink, "netload.in/") !== false || stripos($host, "netload.in") !== false) {
  140. if (isset($_GET['source_ip'])) {
  141. $mip_tmp1 = stripos($mip_rlink, "datei") + 5;
  142. $mip_tmp2 = stripos($mip_rlink, ".", $mip_tmp1);
  143. $mip_rlink = "netload.in ".trim(substr($mip_rlink, $mip_tmp1, $mip_tmp2 - $mip_tmp1));
  144. foreach ($mip_fileas as &$mip_file) {
  145. if ($mip_file[0] == $mip_rlink) {
  146. $mip_ip = trim($_GET['source_ip']);
  147. break;
  148. }
  149. }
  150. }
  151. elseif (array_key_exists('ofilename', $_POST)) {
  152. $mip_rlink = "netload.in ".trim($_POST['file_id']);
  153. foreach ($mip_fileas as &$mip_file) {
  154. if ($mip_file[0] == $mip_rlink) {
  155. $mip_url = '/'.trim($_POST['ofilename']);
  156. $mip_ip = $mip_file[1];
  157. @file_put_contents(LOG_DIR."mip_as.txt", $mip_rlink."<del>".trim($mip_ip)."<del>url:".$mip_url."<del>".time()."<del>\r\n", FILE_APPEND | LOCK_EX) or die($mip_error[2]);
  158. break;
  159. }
  160. }
  161. }
  162. elseif (stripos(@$_GET['referer'], 'file_id=') !== false) {
  163. $mip_tmp1 = stripos($_GET['referer'], "file_id=") + 8;
  164. $mip_tmp2 = stripos($_GET['referer'], "&", $mip_tmp1);
  165. $mip_rlink = "netload.in ".trim(substr($_GET['referer'], $mip_tmp1, $mip_tmp2 - $mip_tmp1));
  166. }
  167. }
  168. //
  169. //general Fix
  170. elseif (array_key_exists('mu_cookie', $_POST)) { $mip_rlink = $mip_rlink; }
  171. else { $mip_rlink = trim(urldecode(isset($_POST['referer']) ? $_POST['referer'] : $_GET['referer'])); }
  172. //
  173. if (isset($_GET['source_ip']) && in_array($_GET['source_ip'], $mip_iplist)) {
  174. $mip_ip = $_GET['source_ip'];
  175. @file_put_contents(LOG_DIR."mip_as.txt", $mip_rlink."<del>".trim($mip_ip)."<del>url:".$mip_url."<del>".time()."<del>\r\n", FILE_APPEND | LOCK_EX) or die($mip_error[2]);
  176. @file_put_contents(LOG_DIR."mip_iplast.txt", array_search($mip_ip, $mip_iplist), LOCK_EX) or die($mip_error[3]);
  177. }
  178. else {
  179. foreach ($mip_fileas as $mip_file) {
  180. if (($mip_file[0] == $mip_rlink)) {
  181. $mip_ip = $mip_file[1];
  182. if (!in_array($mip_ip, $mip_iplist)) { $mip_ip = $mip_iplist[0]; }
  183. $mip_found = true;
  184. break;
  185. }
  186. }
  187. if ($mip_found == false) {
  188. $mip_ip = @file_get_contents(LOG_DIR."mip_iplast.txt") or -1;
  189. $mip_ip = intval($mip_ip) + 1;
  190. $mip_ip = (!isset($mip_iplist[$mip_ip]) || trim($mip_iplist[$mip_ip]) == null ? 0 : $mip_ip);
  191. @file_put_contents(LOG_DIR."mip_iplast.txt", $mip_ip, LOCK_EX) or die($mip_error[3]);
  192. $mip_ip = $mip_iplist[$mip_ip];
  193. @file_put_contents(LOG_DIR."mip_as.txt", $mip_rlink."<del>".trim($mip_ip)."<del>url:".$mip_url."<del>".time()."<del>\r\n", FILE_APPEND | LOCK_EX) or die($mip_error[2]);
  194. }
  195. }
  196. $mip_opts = array('socket' => array('bindto' => $mip_ip.':0'));
  197. $mip_context = stream_context_create($mip_opts);
  198. $fp = stream_socket_client("tcp://".($proxyHost ? $scheme.$proxyHost : $scheme.$host).":".($proxyPort ? $proxyPort : $port), $errno, $errstr, 60, STREAM_CLIENT_CONNECT, $mip_context);
  199. }
  200. }
  201. $mip_action = "";
  202. ?>