PageRenderTime 641ms CodeModel.GetById 402ms app.highlight 142ms RepoModel.GetById 90ms app.codeStats 0ms

/index.php

http://rapidleech36b.googlecode.com/
PHP | 381 lines | 296 code | 42 blank | 43 comment | 127 complexity | ed1e619434c50fe9927ad787fab46055 MD5 | raw file
  1<?php
  2/*****************************************************
  3 * Rapidleech 36B Rv.8
  4 *
  5 * $Id: index.php - 05apr2010-Idx $
  6 *****************************************************/
  7
  8define('RAPIDLEECH', 'yes');
  9
 10require_once "./global.php";
 11
 12//PROTECTED AREA, REMOVING THIS YOU'RE DEAD MAN!
 13define('BUILD', '23082007');
 14define('CREDITS', '<a href="http://www.rapidleech.com/" style="text-decoration:none"><b>RL</b></a>&nbsp;<b class="footer1">PlugMod rev. ' . $rev_num . '</b> <span class="footer2">' . $dev_name . '</span><br /><small class="footer2">Credits to Pramode &amp; Checkmate &amp; Kloon. Mod by: MsNeil &amp; Idoenk<br />In memoriam our beloving brother, husband and father, Ruud v.Tony(15/03/1978 - 21/07/2009)</small>');
 15define('VERSION', '<small class="footer3"><span>[ olc | ccpb | kaskus ]</span><br />[ Shout: Viant77, Jujuan, Huka, Limpy ]</small>');
 16//END OF PROTECTED AREA
 17//************************
 18// MAIN ...
 19//************************
 20
 21$_REQUEST['premium_acc'] = $_POST['premium_acc'] = isset($_REQUEST['premium_acc']) && $_REQUEST['premium_acc'] == 'on' ? 'on' : false;
 22foreach ($_POST as $key => $value) {
 23	$_GET[$key] = $value;
 24}
 25
 26if (!$_COOKIE) {
 27	if (strstr($_SERVER["HTTP_COOKIE"], ";")) {
 28		foreach (explode("; ", $_SERVER["HTTP_COOKIE"]) as $key => $value) {
 29			list($var, $val) = explode("=", $value);
 30			$_COOKIE[$var] = $val;
 31		}
 32	} else if (!empty($_SERVER ["HTTP_COOKIE"])) {
 33		list ($var, $val) = @explode("=", $_SERVER ["HTTP_COOKIE"]);
 34		$_COOKIE [$var] = $val;
 35	}
 36}
 37
 38require_once(CLASS_DIR . "cookie.php");
 39
 40if (!@file_exists(HOST_DIR . "download/hosts.php")) {
 41	create_hosts_file(HOST_DIR . "download/hosts.php");
 42}
 43
 44require_once (HOST_DIR . "download/hosts.php");
 45
 46if (!empty($_GET["image"])) {
 47	require_once(CLASS_DIR . "http.php");
 48	require_once(CLASS_DIR . "image.php");
 49	exit();
 50}
 51
 52if (isset($_GET["useproxy"]) && (!$_GET["proxy"] || !strstr($_GET["proxy"], ":"))) {
 53	html_error($L->say['wrong_proxy']);
 54} else {
 55	if (!empty($_GET["pauth"])) {
 56		$pauth = $_GET["pauth"];
 57	} else {
 58		$pauth = (!empty($_GET ["proxyuser"]) && !empty($_GET ["proxypass"])) ? base64_encode($_GET ["proxyuser"] . ":" . $_GET ["proxypass"]) : "";
 59	}
 60}
 61
 62if (empty($_GET ["path"]) || $options['download_dir_is_changeable'] == false) {
 63	if (empty($_GET ["host"])) {
 64		$_GET["path"] = (substr($options["download_dir"], 0, 6) != "ftp://") ? realpath(DOWNLOAD_DIR) : $options["download_dir"];
 65	} else {
 66		$_GET["saveto"] = (substr($options["download_dir"], 0, 6) != "ftp://") ? realpath(DOWNLOAD_DIR) : $options["download_dir"];
 67	}
 68}
 69
 70if (empty($_GET ["filename"]) || empty($_GET ["host"]) || empty($_GET ["path"])) {
 71	if (!isset($_POST["link"])) {
 72		if (isset($_GET["idx"])) {
 73			// link was sent from audl
 74			$LINK = (isset($_GET["link"]) ? utf8_strrev(base64_decode($_GET["link"])) : "");
 75		} else {
 76			$LINK = (isset($_GET["link"]) ? $_GET["link"] : "");
 77		}
 78	} else {
 79		$LINK = $_POST["link"];
 80	}
 81
 82	// urldecode, trim, strip * in link
 83	$LINK = urlcleaner(trim(urldecode($LINK)));
 84
 85	if (!$LINK) {
 86
 87		_create_list();
 88
 89		require_once(CLASS_DIR . "main.php");
 90		exit();
 91	} elseif ($limitation_alert === true) {
 92		html_error('Limitation alerted, can not use RL! ' . $msg, 1);
 93	}
 94
 95	check_referer();
 96	// Detect if it doesn't have a protocol assigned
 97	if (substr($LINK, 0, 7) != "http://" && substr($LINK, 0, 6) != "ftp://" && substr($LINK, 0, 6) != "ssl://" && substr($LINK, 0, 8) != "https://" && !stristr($LINK, '://')) {
 98		// Automatically assign http://
 99		$LINK = "http://" . $LINK;
100	}
101
102	if (!empty($_GET["saveto"]) && !$_GET["path"]) {
103		html_error($L->say['path_not_defined']);
104	}
105
106	if (empty($_GET["useproxy"])) {
107		$_GET["proxy"] = "";
108	}
109
110	if (!empty($_GET["domail"]) && !checkmail($_GET["email"])) {
111		html_error($L->say['didnt_enter_mail']);
112		if (!empty($_GET ["split"]) && !is_numeric($_GET ["partSize"])) {
113			html_error($L->say['size_not_true']);
114		}
115	}
116
117	$Url = parse_url($LINK);
118	$Url['path'] = str_replace('%2F', '/', rawurlencode(urldecode($Url['path'])));
119	$LINK = rebuild_url($Url);
120	if (empty($_GET ["referer"])) {
121		$Referer = $Url;
122		// Remove login from Referer
123		unset($Referer['user'], $Referer['pass']);
124		$Referer = rebuild_url($Referer);
125	} else {
126		$Referer = trim(urldecode($_GET ["referer"]));
127	}
128
129	if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') {
130		$LINK = urlcleaner(utf8_strrev(base64_decode($LINK)));
131		$Url = parse_url($LINK);
132		if ($Url['scheme'] != 'http' && $Url['scheme'] != 'https' && $Url['scheme'] != 'ftp') {
133			html_error($L->say['url_unknown']);
134		}
135	}
136
137	if (empty($Url['user']) xor empty($Url['pass'])) {
138		unset($Url['user'], $Url['pass']);
139		$LINK = rebuild_url($Url);
140	}
141
142	if (isset($_GET['user_pass']) && $_GET['user_pass'] == "on" && !empty($_GET['iuser']) && !empty($_GET['ipass'])) {
143		$Url['user'] = $_GET['iuser'];
144		$Url['pass'] = $_GET['ipass'];
145		// Rebuild url
146		$LINK = rebuild_url($Url);
147	}
148	// If Url has user & pass, use them as premium login for plugins and set $auth for direct download.
149	if (!empty($Url['user']) && !empty($Url['pass'])) {
150		if (!$_REQUEST['premium_acc']) $_GET['premium_acc'] = $_POST['premium_acc'] = $_REQUEST['premium_acc'] = 'on';
151		$_GET['premium_user'] = $_POST['premium_user'] = $_REQUEST['premium_user'] = $Url['user'];
152		$_GET['premium_pass'] = $_POST['premium_pass'] = $_REQUEST['premium_pass'] = $Url['pass'];
153		$auth = "&auth=" . urlencode(encrypt(base64_encode(rawurlencode($Url ["user"]) . ":" . rawurlencode($Url ["pass"]))));
154		// We have premium_acc and $auth setted, delete User and Pass from link.
155		unset($Url['user'], $Url['pass']);
156		$LINK = rebuild_url($Url);
157	} else {
158		$auth = "";
159	}
160	$litehead = 1;
161	if (!isset($_GET['dis_plug']) || $_GET ['dis_plug'] != "on") {
162		//check Domain-Host
163		if (isset($_GET["vBulletin_plug"])) {
164			$page_title = $L->say['downloading'];
165			include(TEMPLATE_DIR . 'header.php');
166			require_once(CLASS_DIR . "http.php");
167			require_once(HOST_DIR . "download/vBulletin_plug.php");
168			exit();
169		} else {
170			foreach ($host as $site => $file) {
171				if (preg_match("/^(.+\.)?" . str_replace('.', '\.', $site) . "$/i", $Url ["host"])) {
172					$page_title = $L->say['prep_dl'] . " " . $LINK;
173					$shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
174					include(TEMPLATE_DIR . 'header.php');
175					require_once(CLASS_DIR . "http.php");
176					require_once (HOST_DIR . "DownloadClass.php");
177					require_once(HOST_DIR . 'download/' . $file);
178					$class = substr($file, 0, -4);
179					$firstchar = substr($file, 0, 1);
180					if ($firstchar > 0) {
181						$class = "d" . $class;
182					}
183					if (class_exists($class)) {
184						$hostClass = new $class();
185						$hostClass->Download($LINK);
186					}
187					exit();
188				}
189			}
190		}
191	}
192
193	$page_title = $L->say['leeching'];
194	$shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
195	include(TEMPLATE_DIR . 'header.php');
196
197	$Url = parse_url($LINK);
198	$FileName = isset($Url ["path"]) ? basename($Url ["path"]) : '';
199	$mydomain = $_SERVER['SERVER_NAME'];
200	$myip = $_SERVER['SERVER_ADDR'];
201	if ($options['bw_save'] && preg_match("/($mydomain|$myip)/i", $Url["host"])) {
202		html_error($L->sprintf($L->say['leech_not_allowed'], $mydomain, $myip));
203	}
204	if (isset($_GET ['cookieuse'])) {
205		if (strlen($_GET ['cookie'] > 0)) {
206			$_GET ['cookie'] .= ';' . $_POST ['cookie'];
207		} else {
208			$_GET ['cookie'] = $_POST ['cookie'];
209		}
210	}
211	insert_location("$PHP_SELF?filename=" . urlencode($FileName) . "&host=" . $Url ["host"] . "&port=" . (isset($Url ["port"]) ? $Url ["port"] : '') . "&path=" . (!empty($Url ["path"]) ? urlencode($Url ["path"]) : '') . (!empty($Url ["query"]) ? urlencode("?" . $Url ["query"]) : "") . "&referer=" . urlencode($Referer) . "&email=" . (!empty($_GET ["domail"]) ? $_GET ["email"] : "") . "&partSize=" . (!empty($_GET ["split"]) ? $_GET ["partSize"] : "") . "&method=" . (!empty($_GET ["method"]) ? $_GET ["method"] : '') . (!empty($_GET ["proxy"]) ? "&useproxy=on&proxy=" . $_GET ["proxy"] : "") . "&saveto=" . $_GET ["path"] . "&link=" . urlencode($LINK) . (isset($_GET ["add_comment"]) && $_GET ["add_comment"] == "on" && !empty($_GET ["comment"]) ? "&comment=" . urlencode($_GET ["comment"]) : "") . $auth . ($pauth ? "&pauth=$pauth" : "") . (isset($_GET["idx"]) ? "&idx=" . $_GET["idx"] : "") . "&cookie=" . (!empty($_GET ["cookie"]) ? urlencode(encrypt($_GET ['cookie'])) : '' . "&dis_plug=on"));
212} else {
213	$page_title = 'nYedoTz...';
214	$shortcut_icon = ROOT_URL . IMAGE_DIR . "rsload_2.gif";
215	$litehead = 1;
216	include(TEMPLATE_DIR . 'header.php');
217	check_referer();
218	echo('<div align="center">');
219
220	/* Deprecated of useless and unworth feature for some cases might fail this status.
221	  if ($options['MaxServerJob'] > 0) {
222	  if ($options['MaxServerJob'] <= ongoingGet()) {
223	  html_error($L->sprintf($L->say['maxjob_limited'], $options['MaxServerJob']));
224	  }
225	  } */
226
227	if ($options["limitbyip"]) {
228		if ($ada_acc) {
229			$trheute = $heute + 1;
230			if ($trheute > $options['maximum_free_downloads']) {
231				html_error($msgNya);
232			}
233		}
234	}
235
236	/* Deprecated of useless and unworth feature for some cases might fail this status.
237	  ongoingAdd(); */
238
239	do {
240		$_GET ["filename"] = urldecode(trim($_GET ["filename"]));
241		if (strstr($_GET ["filename"], '?') !== false) list ($_GET ["filename"], $tmp) = explode('?', $_GET ["filename"], 2);
242		$_GET["saveto"] = urldecode(trim($_GET["saveto"]));
243		$_GET["host"] = urldecode(trim($_GET["host"]));
244		$_GET["path"] = urldecode(trim($_GET["path"]));
245		$_GET ["port"] = !empty($_GET ["port"]) ? urldecode(trim($_GET ["port"])) : 80;
246		$_GET ["referer"] = !empty($_GET ["referer"]) ? urldecode(trim($_GET ["referer"])) : 0;
247		$_GET["link"] = urldecode(trim($_GET["link"]));
248		$_GET ["post"] = !empty($_GET ["post"]) ? unserialize(stripslashes(urldecode(trim($_GET ["post"])))) : 0;
249		$_GET ["cookie"] = !empty($_GET ["cookie"]) ? decrypt(urldecode(trim($_GET["cookie"]))) : "";
250		$_GET ["proxy"] = !empty($_GET ["proxy"]) ? $_GET ["proxy"] : "";
251		$redirectto = "";
252
253		$pauth = !empty($_GET ["pauth"]) ? urldecode(trim($_GET ["pauth"])) : '';
254		$_GET['auth'] = isset($_GET['auth']) ? trim($_GET['auth']) : '';
255		if ($_GET['auth'] == "1") {
256			if (!preg_match("|^(?:.+\.)?(.+\..+)$|i", $_GET ["host"], $hostmatch)) html_error('No valid hostname found for authorisation!');
257			$hostmatch = str_replace('.', '_', $hostmatch[1]);
258			if ($premium_acc ["$hostmatch"] && $premium_acc ["$hostmatch"] ["user"] && $premium_acc ["$hostmatch"] ["pass"]) {
259				$auth = base64_encode($premium_acc ["$hostmatch"] ["user"] . ":" . $premium_acc ["$hostmatch"] ["pass"]);
260			} else {
261				html_error('No useable premium account found for this download - please set one in accounts.php');
262			}
263		} elseif (!empty($_GET['auth'])) {
264			$auth = decrypt(urldecode($_GET['auth']));
265			$AUTH ["use"] = true;
266			$AUTH ["str"] = $auth;
267		} else {
268			$auth = $AUTH = false;
269		}
270		$pathWithName = $_GET["saveto"] . PATH_SPLITTER . $_GET["filename"];
271		while (stristr($pathWithName, "\\\\")) {
272			$pathWithName = str_replace("\\\\", "\\", $pathWithName);
273		}
274
275		if (strstr($pathWithName, '?') !== false) list ($pathWithName, $tmp) = explode('?', $pathWithName, 2);
276
277		$ftp = parse_url($_GET["link"]);
278		if ($ftp ["scheme"] == "ftp" && !$_GET ["proxy"]) {
279			$AUTH ["ftp"] = array("login" => !empty($ftp ["user"]) ? $ftp ["user"] : "anonymous", "password" => !empty($ftp ["pass"]) ? $ftp ["pass"] : "anonymous@leechget.com");
280			require_once (CLASS_DIR . "ftp.php");
281			$file = getftpurl($_GET ["host"], !empty($ftp ["port"]) ? $ftp ["port"] : 21, $_GET ["path"], $pathWithName);
282		} else {
283			require_once (CLASS_DIR . "http.php");
284			!empty($_GET ["force_name"]) ? $force_name = urldecode($_GET ["force_name"]) : '';
285			$file = geturl($_GET ["host"], $_GET ["port"], $_GET ["path"], $_GET ["referer"], $_GET ["cookie"], $_GET ["post"], $pathWithName, $_GET ["proxy"], $pauth, $auth, $ftp ["scheme"]);
286		}
287		if ($options['redir'] && $lastError && stristr($lastError, $L->say['_error'] . " " . $L->say['_redirect_to'] . " [")) {
288			$redirectto = trim(cut_str($lastError, $L->say['_error'] . " " . $L->say['_redirect_to'] . " [", "]"));
289			print $L->say['_redirecting_to'] . " <b>$redirectto</b> ... <br />$nn";
290			$_GET ["referer"] = $_GET ["link"];
291			$_GET["link"] = $redirectto;
292			$purl = parse_url($redirectto);
293			if (strstr(basename($redirectto), '?') !== false) list ($_GET ["filename"], $tmp) = explode('?', basename($redirectto));
294			else $_GET ["filename"] = basename($redirectto);
295			// In case the redirect didn't include the host
296			$_GET ["host"] = ($purl ["host"]) ? $purl ["host"] : $_GET ["host"];
297			$_GET ["path"] = $purl ["path"] . ($purl ["query"] ? "?" . $purl ["query"] : "");
298			$_GET ['port'] = $purl ['port'] ? $purl ['port'] : 80;
299			$_GET ['cookie'] = !empty($_GET ["cookie"]) ? urlencode(encrypt($_GET["cookie"])) : "";
300			$lastError = "";
301		}
302	} while ($redirectto && !$lastError);
303
304	/* Deprecated of useless and unworth feature for some cases might fail this status.
305	  ongoingRemove(); */
306
307	if ($lastError) {
308		html_error($lastError, 0);
309	} elseif ($file["bytesReceived"] == $file["bytesTotal"] || $file["size"] == "Unknown") {
310		list($final_link, $current_time) = link_for_file(dirname($pathWithName) . "/" . basename($file["file"]), false, true);
311
312		echo "<script type=\"text/javascript\">pr(100, '" . $file["size"] . "', '" . $file["speed"] . "')</script>";
313		echo $L->sprintf($L->say['_filesaved'], $final_link, $file ["size"], $file ["time"], $file ["speed"]);
314
315		$file["date"] = getNowzone($current_time);
316
317		$tosave = array("name" => $file["file"], "size" => str_replace(" ", "&nbsp;", $file["size"]), "date" => $file["date"], "age" => $L->say['less_a_minute'], "link" => $_GET["link"], "comment" => str_replace("\n", "\\n", str_replace("\r", "\\r", $_GET["comment"])), "ip" => $ipmu);
318		//print_r($tosave);
319		$result = write_file(FILES_LST, serialize($tosave) . "\r\n", 0);
320		$result2 = write_file(IP_L33CH_L0G, serialize(array("name" => $file["file"], "date" => $file["date"], "ip" => $ipmu)) . "\r\n", 0);
321
322		if (!$result || !$result2) {
323			echo $L->say['error_upd_list'] . "<br />";
324		}
325
326		if ($options["limitbytraffic"]) {
327			if ($options["max_trafic"] > 0) {
328				if (!is_numeric($traffic->total)) $traffic->total = 0;
329				$traffic->total += $file["bytesReceived"];
330				$traffic->updTraffic();
331			}
332		}
333
334		if (!empty($_GET ["email"])) {
335			require_once(CLASS_DIR . "mail.php");
336			$_GET ["partSize"] = (isset($_GET ["partSize"]) && is_numeric($_GET ["partSize"]) ? $_GET ["partSize"] * 1024 * 1024 : false);
337			if (xmail($fromaddr, $_GET ["email"], "File " . basename($file ["file"]), "File: " . basename($file ["file"]) . "\r\n" . "Link: " . $_GET ["link"] . (!empty($_GET ["comment"]) ? "\r\n" . "Comments: " . str_replace("\\r\\n", "\r\n", $_GET ["comment"]) : ""), $pathWithName, $_GET ["partSize"], ($_GET ["partSize"] && !empty($_GET ["method"]) ? $_GET ["method"] : ''))) {
338				print $L->sprintf($L->say['mail_file_sent'], $_GET['email'], basename($file['file']));
339			} else {
340				print "<div class='acthistory_result'>" . $L->say['mail_error_send'] . "</div>";
341			}
342		}
343
344		if ($options['new_window']) {
345			print '<br /><a href="javascript:window.close();">' . $L->say['closewin'] . '</a>';
346		} else {
347			/* 			if ($options['pointboost'] > 0 && empty($_GET["idx"])) {
348			  // i'd rather not delete current downloaded file
349			  if(!defined("DOWNLOADED_FILE")){define('DOWNLOADED_FILE', DOWNLOAD_DIR.basename($file["file"]));}
350			  @write_file(DOWNLOADED_FILE, " ");
351			  if($numidx < $options["pointboost"]-1)
352			  {
353			  // generate reload form (link, secondcounterdown, auth, indexnumber)
354			  echo genReload($_GET["link"], 3, $auth, $numidx);
355			  }
356			  } */
357			$rnd = rand(11, 99);
358			// generate delete link
359			echo $L->sprintf($L->say['_del_link'], 'del.php?d=' . str_replace("=", "", rotN(base64_encode($file["date"] . ':' . '4puZ'), $rnd)) . "-" . $rnd, date("M-d, Y - H:i:s", $file["date"]));
360			print "<br /><a id='tdone' href=\"" . $PHP_SELF . "\">[&nbsp;<b><span id='txtdone'>" . $L->say['back_main'] . "&nbsp;]</b></span></a><br />";
361		}
362	} else {
363		@unlink($pathWithName);
364		print $L->say['con_lost'] . "<br /><a href=\"javascript:location.reload();\">" . $L->say['_reload'] . "</a>";
365		print '<script type="text/javascript">setTimeout("location.reload()",1000);</script>';
366	}
367	//check whether this index called from audl.php
368	$audlparam = (isset($_GET["idx"])) ? $_GET["idx"] : '';
369	if ($audlparam != '') {
370		$audlparam = explode('|', $audlparam);
371		$audlparam[0] = ($audlparam[0] != '' ? true : false);
372		if ($audlparam[1] == '') {
373			$audlparam[1] = 'none';
374		}
375		echo autoNext($audlparam[0], true, $audlparam[1]);
376	}
377	echo('</div>');
378	echo('</body>');
379	echo('</html>');
380}
381?>