| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,77 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once ("config.php");
|
|
| 4 |
+ |
|
| 5 |
+//Check session only if hiddentracker is TRUE |
|
| 6 |
+if ($hiddentracker == true) |
|
| 7 |
+{
|
|
| 8 |
+ session_start(); |
|
| 9 |
+ |
|
| 10 |
+ if (!$_SESSION['admin_logged_in'] && !$_SESSION['upload_logged_in']) |
|
| 11 |
+ {
|
|
| 12 |
+ //check fails |
|
| 13 |
+ header("Location: authenticate.php?status=error");
|
|
| 14 |
+ exit(); |
|
| 15 |
+ } |
|
| 16 |
+} |
|
| 17 |
+else |
|
| 18 |
+{
|
|
| 19 |
+ //don't run |
|
| 20 |
+ exit(); |
|
| 21 |
+} |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+//if hash isn't of length 40, don't even bother connecting to database |
|
| 25 |
+if (strlen($_GET['hash']) != 40) |
|
| 26 |
+{
|
|
| 27 |
+ header("index.php");
|
|
| 28 |
+ exit(); |
|
| 29 |
+} |
|
| 30 |
+ |
|
| 31 |
+require_once ("funcsv2.php"); //required for errorMessage()
|
|
| 32 |
+ |
|
| 33 |
+//connect to database and turn hash value into a filename |
|
| 34 |
+if ($GLOBALS["persist"]) |
|
| 35 |
+ $db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Tracker error: can't connect to database - " . mysql_error() . "</p>"); |
|
| 36 |
+else |
|
| 37 |
+ $db = mysql_connect($dbhost, $dbuser, $dbpass) or die(errorMessage() . "Tracker error: can't connect to database - " . mysql_error() . "</p>"); |
|
| 38 |
+mysql_select_db($database) or die(errorMessage() . "Tracker error: can't open database $database - " . mysql_error() . "</p>"); |
|
| 39 |
+$query = "SELECT filename FROM ".$prefix."namemap WHERE info_hash = '" . $_GET['hash'] . "'"; |
|
| 40 |
+$results = mysql_query($query) or die(errorMessage() . "Can't do SQL query - " . mysql_error() . "</p>"); |
|
| 41 |
+$row = mysql_fetch_row($results); |
|
| 42 |
+ |
|
| 43 |
+if ($row[0] == null) |
|
| 44 |
+{
|
|
| 45 |
+ //hash doesn't exist in database, error out |
|
| 46 |
+ header("Location: index.php");
|
|
| 47 |
+ exit(); |
|
| 48 |
+} |
|
| 49 |
+else |
|
| 50 |
+ $filename = $row[0]; |
|
| 51 |
+ |
|
| 52 |
+if (!file_exists("./torrents/" . $filename . ".torrent"))
|
|
| 53 |
+{
|
|
| 54 |
+ header("Location: index.php");
|
|
| 55 |
+ exit(); |
|
| 56 |
+} |
|
| 57 |
+ |
|
| 58 |
+//you have be referred from the main website URL then you can download |
|
| 59 |
+if (strpos($_SERVER['HTTP_REFERER'], $website_url . "/") === 0 && strpos($_SERVER['HTTP_REFERER'], "http") === 0) |
|
| 60 |
+{
|
|
| 61 |
+ $stat = stat("./torrents/" . $filename . ".torrent");
|
|
| 62 |
+ header("Content-Type: application/x-bittorrent");
|
|
| 63 |
+ header("Content-Length: " . $stat[7]);
|
|
| 64 |
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", $stat[9]) . " GMT");
|
|
| 65 |
+ header("Content-Disposition: attachment; filename=\"" . $filename . ".torrent\"");
|
|
| 66 |
+ readfile("./torrents/" . $filename . ".torrent");
|
|
| 67 |
+ exit(); |
|
| 68 |
+} |
|
| 69 |
+else |
|
| 70 |
+{
|
|
| 71 |
+ header("Location: index.php");
|
|
| 72 |
+ exit(); |
|
| 73 |
+} |
|
| 74 |
+ |
|
| 75 |
+header('Pragma: no-cache');
|
|
| 76 |
+header('Cache-Control: no-cache, no-store, must-revalidate');
|
|
| 77 |
+?> |
|
| 0 | 78 |
\ No newline at end of file |