PageRenderTime 197ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/ajax.php

http://rapidleech.googlecode.com/
PHP | 425 lines | 376 code | 35 blank | 14 comment | 134 complexity | 9766f1b5cdd14a8342cbba3c0b96f6e5 MD5 | raw file
  1. <?php
  2. error_reporting(0);
  3. set_time_limit(0);
  4. define('RAPIDLEECH', 'yes');
  5. define('CLASS_DIR', 'classes/');
  6. define('CONFIG_DIR', 'configs/');
  7. require_once(CONFIG_DIR."config.php");
  8. require_once(CLASS_DIR . 'other.php');
  9. define ( 'TEMPLATE_DIR', 'templates/'.$options['template_used'].'/' );
  10. $nn = "\r\n";
  11. // For ajax calls, lets make it use less resource as possible
  12. switch ($_GET['ajax']) {
  13. case 'server_stats':
  14. if ($options['server_info'] && $options['ajax_refresh']) {
  15. ob_start();
  16. require(CLASS_DIR.'sinfo.php');
  17. ob_end_clean();
  18. $AjaxReturn = array();
  19. $AjaxReturn['FreeSpace'] = ZahlenFormatieren($frei);
  20. $AjaxReturn['InUse'] = ZahlenFormatieren($belegt);
  21. $AjaxReturn['InUsePercent'] = round($prozent_belegt, '2');
  22. $AjaxReturn['DiskPercent'] = round($prozent_belegt, '2');
  23. $AjaxReturn['DiskSpace'] = ZahlenFormatieren($insgesamt);
  24. $AjaxReturn['CPULoad'] = round($cpulast, '0');
  25. $AjaxReturn['CPUPercent'] = round($cpulast, '2');
  26. echo array_to_json($AjaxReturn);
  27. }
  28. break;
  29. case 'linkcheck':
  30. require_once(CLASS_DIR.'linkchecker.php');
  31. $glinks = array();
  32. if(!empty($_POST['debug'])) {
  33. if($debug == 1)
  34. debug();
  35. else
  36. echo lang(16);
  37. }
  38. if (isset($_POST['submit'])) {
  39. $alllinks = $_POST['links'];
  40. $alllinks = explode(' ', $alllinks);
  41. $alllinks = implode("\n", $alllinks);
  42. $alllinks = explode("\n", $alllinks);
  43. $x = $x2 = 1;
  44. $l = ($_POST['k']) ? false : true;
  45. $d = ($_POST['d']) ? false : true;
  46. $dk = (!$l && !$d) ? true : false;
  47. $alllinks = array_unique($alllinks); //removes duplicates
  48. echo "<div id='listlinks'>\n";
  49. foreach($alllinks as $link) {
  50. if (empty($link)) continue;
  51. $x2++;
  52. $link = trim($link);
  53. $Checked = $skip = $Kl = false;
  54. if (preg_match("/^(http)\:\/\/(www\.)?anonym\.to\/\?/i", $link)) {
  55. $link = explode('?', $link);
  56. unset($link[0]);
  57. $link = implode($link, '?');
  58. $Kl = 'anonym.to';
  59. }
  60. if (preg_match('@^http://(www\.)?((adf\.ly)|([jq]\.gs)|([9u]\.bb))/((\d+/.+)|([^/|\r|\n]+))@i', $link, $m)) {
  61. $page = curl($m[0]);
  62. if (!preg_match("@window\.location = '(((https?:)|(/go/))[^']+)'@i", $page, $match))
  63. if (!preg_match("@self\.location = '(((https?:)|(/go/))[^']+)'@i", $page, $match))
  64. preg_match("@var url = '(((https?:)|(/go/))[^']+)'@i", $page, $match);
  65. if (!empty($match[1]) && $match[1] != $link) {
  66. if (preg_match('@^(?:https?://([^/]+\.)?((adf\.ly)|([jq]\.gs)|([9u]\.bb)))?/go/\w+/([^/|\?]+)@i', $match[1], $b64redir)) $match[1] = base64_decode(urldecode($b64redir[count($b64redir)-1]));
  67. $link = $match[1];
  68. $Kl = 'adf.ly';
  69. } else {
  70. $link = $m[0].' - ERROR.';
  71. $skip = true;
  72. }
  73. }
  74. if (!$skip && preg_match('@^http://(www\.)?zpag\.es/((\d+/.+)|([^/|\r|\n]+))@i', $link, $m)) {
  75. $page = curl($m[0]);
  76. preg_match('/window\.location = "(https?:[^"]+)"/i', $page, $match);
  77. if (!empty($match[1]) && $match[1] != $link) {
  78. $link = $match[1];
  79. $Kl = 'zpag.es';
  80. } else {
  81. $link = $m[0].' - ERROR.';
  82. $skip = true;
  83. }
  84. }
  85. if (!$skip && preg_match('@^http://(?:www\.)?adfoc\.us/(?:serve/\?id=)?(\d+)@i', $link, $m)) {
  86. $page = curl('http://adfoc.us/serve/click/?id='.$m[1].'&servehash=1&timestamp='.time(), 0, 0);
  87. if (!preg_match('@Location: (https?://[^\r|\n]+)@i', $page, $match)) {
  88. $page = curl($m[0], 0, 0);
  89. $page = str_ireplace('http://adfoc.us/serve/click/', '', $page);
  90. preg_match('@var click_url = "(https?://[^\"\s\t<>]+)"@i', $page, $match);
  91. }
  92. if (!empty($match[1]) && $match[1] != $link) {
  93. $link = $match[1];
  94. $Kl = 'adfoc.us';
  95. } else {
  96. $link = $m[0].' - ERROR.';
  97. $skip = true;
  98. }
  99. }
  100. if (!$skip && preg_match('@^http://(www\.)?bc\.vc/(\w+)@i', $link, $m)) {
  101. $page = curl($m[0]);
  102. if (!preg_match('@Location: (https?://[^\r\n]+)@i', $page, $match) && preg_match('@aid:(\d+)\s?,\s?lid:(\d+)\s?,\s?oid:(\d+)@i', $page, $args)) {
  103. $post = array('opt'=>'check_log','args%5Baid%5D'=>$args[1],'args%5Blid%5D'=>$args[2],'&args%5Boid%5D'=>$args[3], 'args%5Bref%5D'=>'');
  104. $L = 'http://bc.vc/fly/ajax.fly.php';
  105. $page = curl($L, $post);
  106. $cookie = GetCookiesArr($page);
  107. $page = curl($L, $post, $cookie);
  108. if (stripos($page, '"message":false') !== false) {
  109. $page = curl($L, $post, $cookie);
  110. $cookie = GetCookiesArr($page, $cookie);
  111. }
  112. $post['opt'] = 'make_log';
  113. sleep(6); // (rand(5,7));
  114. $page = curl($L, $post, $cookie);
  115. preg_match('@"url":"(https?:[^\r\n\"\}\{]+)"@i', $page, $match);
  116. if (!empty($match[1])) $match[1] = stripslashes($match[1]);
  117. unset($L);
  118. }
  119. if (!empty($match[1]) && $match[1] != $link) {
  120. $link = $match[1];
  121. $Kl = 'bv.vc';
  122. } else {
  123. $link = $m[0].' - ERROR.';
  124. $skip = true;
  125. }
  126. }
  127. if (!$skip && preg_match('/^http:\/\/(www\.)?lnk\.co\/\w+/i', $link, $m)) {
  128. $page = curl($m[0],0,0,0);
  129. if (!preg_match('/id=\'linkurl\' href="(https?:[^"]+)"/i', $page, $match))
  130. if (!preg_match("/id='urlholder' value='(https?:[^']+)'/i", $page, $match))
  131. preg_match('@Location: (https?://[^\r|\n]+)@i', $page, $match);
  132. if (!empty($match[1]) && $match[1] != $link) {
  133. $link = $match[1];
  134. $Kl = 'lnk.co';
  135. } else {
  136. $link = $m[0].' - ERROR.';
  137. $skip = true;
  138. }
  139. }
  140. if (!$skip && preg_match('@^http://(\w+\.)?linkbucks\.com/?(link/[^/\r\n]+)?@i' , $link, $m)) {
  141. $page = curl($m[0],0,0,0);
  142. sleep(2); // linkbucks now show a flood warning, waiting 2 seconds.
  143. if (!preg_match("/(?:(?:Linkbucks)|(?:Lbjs)).TargetUrl = '(https?:[^']+)'/i" , $page , $match))
  144. if (!preg_match('/<iframe id="content" src="(https?:[^"]+)"/i' , $page , $match))
  145. preg_match("/Location: (https?:.+)/i", $page, $match);
  146. if (!empty($match[1]) && $match[1] != $link) {
  147. $link = $match[1];
  148. $Kl = 'linkbucks.com';
  149. } else {
  150. $link = $m[0].' - ERROR.';
  151. $skip = true;
  152. }
  153. }
  154. if (!$skip && preg_match('@^http://((\d+\.)|(\w+\.))?((rsmonkey\.com)|((\w+\.)?canhaz\.it))(/\d+)?@i', $link, $m)) {
  155. $page = curl($m[0]);
  156. preg_match("/top\.location\.replace\('(https?:[^']+)'\)/i", $page, $match);
  157. if (!empty($match[1]) && $match[1] != $link) {
  158. $link = $match[1];
  159. $Kl = 'rsmonkey.com';
  160. } else {
  161. $link = $m[0].' - ERROR.';
  162. $skip = true;
  163. }
  164. }
  165. if (!$skip && preg_match('@^http://(?:www\.)?((?:linksafe\.me)|(?:safelinking\.net))/d/([^/\W]+(?:/[^/\r\n]+)?)/?@i', $link, $m)) {
  166. $page = curl($m[0],0,0,0);
  167. if (!preg_match('/Location: (https?:.+)/i', $page, $match))
  168. preg_match('/window\.location="(https?:[^"]+)"/i', $page, $match);
  169. if (!empty($match[1]) && $match[1] != $m[0]) {
  170. $link = $match[1];
  171. $Kl = $m[1];
  172. } else {
  173. $link = $m[0].' - ERROR.';
  174. $skip = true;
  175. }
  176. }
  177. if (!$skip && preg_match('@^http://(?:www\.)?multiupload\.nl/(\w{2}_)?\w+@i', $link, $m)) {
  178. $page = curl($m[0],0,0,0);
  179. if (stristr($page, "the link you have clicked is not available")) {
  180. $link = $m[0].' - Not found.';
  181. $skip = true;
  182. }
  183. if (empty($m[1]) && !$skip) {
  184. if (preg_match_all('@(http://(?:www\.)?multiupload\.nl/(?:\w{2}_\w+))</a@i', $page, $match)) {
  185. foreach ($match[1] as $link) showlink($link, 0, 3, "Removed folder: multiupload.nl");
  186. $Checked = true;
  187. CountandCheck($x);
  188. }
  189. else $link = $m[0].' - ERROR.';
  190. } elseif (!$skip) {
  191. preg_match('/Location: (https?:.+)/i', $page, $match);
  192. if (!empty($match[1]) && $match[1] != $m[0]) {
  193. $link = $match[1];
  194. $Kl = 'multiupload.nl';
  195. } else $link = $m[0].' - ERROR.';
  196. }
  197. }
  198. // Some hosts needs other way to check file and get the filesize
  199. if ($l && !$skip && preg_match('@^https?://(?:[^/]+\.)?mediafire\.com/(?:(?:imageview\.php)|(?:view/))?\?(?:quickkey=)?(\w+)@i', $link, $m)) {
  200. $page = curl('http://www.mediafire.com/api/file/get_info.php?quick_key='.$m[1],0,0,0,0,0);
  201. $link = 'http://www.mediafire.com/?'.$m[1];
  202. $size = '';
  203. if (stripos($page, '<result>Success</result>') !== false && preg_match('@<size>(\d+)</size>@i', $page, $sz) && $sz[1] > 0) {
  204. $chk = 1;
  205. $size = explode(' ', bytesToKbOrMbOrGb($sz[1]));
  206. $size[0] = round($size[0], 2);
  207. $size = implode(' ', $size);
  208. } elseif (stripos($page, '<message>Access denied</message>') !== false) $chk = 2;
  209. else {
  210. $chk = 0;
  211. $page = curl('http://www.mediafire.com/api/folder/get_content.php?folder_key='.$m[1].'&content_type=files',0,0,0,0,0);
  212. if (stripos($page, '<result>Success</result>') !== false && preg_match_all('@<quickkey>([^<]+)</quickkey>@i', $page, $qids)) {
  213. foreach ($qids[1] as $qid) showlink("http://www.mediafire.com/?$qid", 0, 3, 'Removed folder: mediafire.com');
  214. $skip = true;
  215. } elseif (stripos($page, '<message>Access denied</message>') !== false) $chk = 2;
  216. }
  217. if (!$skip) {
  218. showlink($link, $size, $chk);
  219. if ($chk == 1) $glinks[$link] = $size;
  220. }
  221. $Checked = $skip = true;
  222. CountandCheck($x);
  223. }
  224. if ($l && !$skip && preg_match('@^https?://(?:[^/]+\.)?rapidshare\.com/(?:(?:files/(\d+)/([^/#\r\n]+))|(?:\??#!download\|[^\|]+\|(\d+)\|([^\|\r\n]+)))@i', $link, $m)) { // O.O
  225. if (!empty($m[1])) {
  226. $m['id'] = $m[1];
  227. $m['filename'] = $m[2];
  228. } else {
  229. $m['id'] = $m[3];
  230. $m['filename'] = $m[4];
  231. }
  232. $page = curl('http://api.rapidshare.com/cgi-bin/rsapi.cgi', "sub=checkfiles&files={$m['id']}&filenames=".$m['filename'],0,0,0,0);
  233. $page = explode(',', $page);
  234. if ($page[2] > 0) {
  235. if ($page[4] == 1) $chk = 1;
  236. elseif ($page[4] == 3) $chk = 2;
  237. else $chk = 0;
  238. } else $chk = 0;
  239. $link = "http://rapidshare.com/files/{$page[0]}/".$page[1];
  240. if ($chk == 1) {
  241. $size = explode(' ', bytesToKbOrMbOrGb($page[2]));
  242. $size[0] = round($size[0], 2);
  243. $size = implode(' ', $size);
  244. $glinks[$link] = $size;
  245. } else $size = 0;
  246. showlink($link, $size, $chk);
  247. $Checked = $skip = true;
  248. CountandCheck($x);
  249. }
  250. if ($l && !$skip && preg_match('@^https?://(?:[^/]+\.)?share-online\.biz/(?:(?:download\.php\?id=)|(?:dl/))(\w+)@i', $link, $m)) {
  251. $page = curl('http://api.share-online.biz/linkcheck.php?links='.$m[1],0,0,0,0,0);
  252. $page = explode(';', $page);
  253. $page = array_map('trim', $page);
  254. $link = 'http://www.share-online.biz/dl/'.$m[1];
  255. $size = '';
  256. switch ($page[1]) {
  257. case 'OK' : $chk = 1; break;
  258. case 'DELETED' : case 'NOT FOUND' : $chk = 0; break;
  259. default : $chk = 4; break;
  260. }
  261. if ($chk == 1) {
  262. $size = explode(' ', bytesToKbOrMbOrGb($page[3]));
  263. $size[0] = round($size[0], 2);
  264. $size = implode(' ', $size);
  265. $glinks[$link] = $size;
  266. }
  267. showlink($link, $size, $chk);
  268. $Checked = $skip = true;
  269. CountandCheck($x);
  270. }
  271. if ($l && !$skip) {
  272. foreach($sites as $site) {
  273. if (!empty($site['link']) && preg_match('@'.$site['link'].'@i', $link)) {
  274. $szregex = $pattern = $replace = '';
  275. $opt = array();
  276. if (($d || $dk) && !empty($site['szregex'])) $szregex = $site['szregex'];
  277. if (isset($site['pattern'])) $pattern = $site['pattern'];
  278. if (isset($site['replace'])) $replace = $site['replace'];
  279. if (array_key_exists('options', $site) && is_array($site['options'])) $opt = $site['options'];
  280. list($chk, $size) = check($link, $x, $site['regex'], $szregex, $pattern, $replace, $opt);
  281. if ($chk == 1) $glinks[$link] = $size;
  282. flush();//ob_flush();
  283. $Checked = true;
  284. CountandCheck($x);
  285. }
  286. }
  287. }
  288. if (($d || $dk) && !$Checked && $Kl != false) {
  289. showlink($link, 0, 3, "Removed: $Kl");
  290. CountandCheck($x);
  291. flush();
  292. } elseif($d && !$Checked) {
  293. showlink($link, 0, 4, 'Unknown Link');
  294. //CountandCheck($x); //Count?
  295. flush();
  296. }
  297. }
  298. echo "</div>\n";
  299. $time = explode(' ', microtime());
  300. $time = $time[1] + $time[0];
  301. $endtime = $time;
  302. $totaltime = ($endtime - $begintime);
  303. $x--;$x2--;
  304. $plural = ($x == 1) ? '' : lang(19);
  305. ($options['fgc'] == 0) ? $method = 'cURL' : $method = 'file_get_contents';
  306. echo '<p style="text-align:center">';
  307. printf(lang(18),$x,$plural,$totaltime,$method);
  308. echo "</p>\n";
  309. if (count($glinks) > 1 && @is_file('audl.php')) {
  310. $links = '';
  311. $fsize = 0;
  312. $afhs = true; //
  313. foreach ($glinks as $lnk => $sz) {
  314. $links .= "$lnk\n";
  315. if (!empty($sz) && $sz > 0) {
  316. $sz = explode(' ', strtoupper($sz));
  317. switch ($sz[1]) { // KbOrMbOrGbToBytes :D
  318. case 'GB': $sz[0] *= 1024;
  319. case 'MB': $sz[0] *= 1024;
  320. case 'KB': $sz[0] *= 1024;
  321. }
  322. $fsize += $sz[0];
  323. } else $afhs = false;
  324. }
  325. $fsize = explode(' ', bytesToKbOrMbOrGb($fsize));
  326. $fsize[0] = round($fsize[0], 2);
  327. $fsize = implode(' ', $fsize);
  328. $fsize = (!$afhs ? '&gt;' : '').$fsize;
  329. echo "<div style='text-align:center;'>\n";
  330. echo "<br /><form action='".((($pos = strrpos($_SERVER['SCRIPT_NAME'], '/')) !== false) ? substr($_SERVER['SCRIPT_NAME'], 0, $pos + 1).'audl.php?GO=GO' : 'audl.php?GO=GO')."' method='POST' >\n";
  331. echo "<input type='hidden' name='links' value='" . $links . "'>\n";
  332. //$key_array = array("useproxy", "proxy", "proxyuser", "proxypass", "premium_acc", "premium_user", "premium_pass", "cookieuse", "cookie");
  333. //foreach ($key_array as $v) if (array_key_exists($v, $_GET)) echo "<input type='hidden' name='".$v."' value='".$_GET[$v]."' />\n";
  334. if ($x == $x2) $btext = "Send links to AUDL ($fsize)";
  335. else $btext = "Send working links to AUDL ($fsize)";
  336. echo "<input type='submit' value='$btext' />\n";
  337. echo "</form>\n";
  338. echo "</div>\n";
  339. }
  340. flush();
  341. }
  342. break;
  343. }
  344. function CountandCheck(&$x) {
  345. global $maxlinks;
  346. $x++;
  347. if($x > $maxlinks) {
  348. echo '<p style="text-align:center; color: red; background-color: #fec; padding: 3px; border: 2px solid $FFAA00; line-height: 25px">';
  349. printf(lang(17), $maxlinks);
  350. echo("</p></div>\n");
  351. include(TEMPLATE_DIR.'/footer.php');
  352. exit();
  353. }
  354. }
  355. function array_to_json($array){
  356. if (!is_array($array)) return false;
  357. $associative = count(array_diff(array_keys($array), array_keys(array_keys($array))));
  358. if ($associative) {
  359. $construct = array();
  360. foreach ($array as $key => $value){
  361. // We first copy each key/value pair into a staging array,
  362. // formatting each key and value properly as we go.
  363. // Format the key:
  364. if (is_numeric($key)) $key = "key_$key";
  365. $key = "'".addslashes($key)."'";
  366. // Format the value:
  367. if (is_array($value)) $value = array_to_json($value);
  368. elseif(!is_numeric($valu ) || is_string($value)) $value = "'".addslashes($value)."'";
  369. // Add to staging array:
  370. $construct[] = "$key: $value";
  371. }
  372. // Then we collapse the staging array into the JSON form:
  373. $result = "{ " . implode(", ", $construct) . " }";
  374. } else { // If the array is a vector (not associative):
  375. $construct = array();
  376. foreach ($array as $value){
  377. // Format the value:
  378. if (is_array($value)) $value = array_to_json($value);
  379. elseif (!is_numeric($value) || is_string($value)) $value = "'".addslashes($value)."'";
  380. // Add to staging array:
  381. $construct[] = $value;
  382. }
  383. // Then we collapse the staging array into the JSON form:
  384. $result = "[ " . implode(", ", $construct) . " ]";
  385. }
  386. return $result;
  387. }
  388. ?>