"); mysql_select_db($database) or die(errorMessage() . "Can't open the database.

"); require_once ("funcsv2.php"); require_once ("BDecode.php"); require_once ("BEncode.php"); if ($_FILES["torrent"]["error"] != 4) { $fd = fopen($_FILES["torrent"]["tmp_name"], "rb") or die(errorMessage() . "File upload error 1

\n"); is_uploaded_file($_FILES["torrent"]["tmp_name"]) or die(errorMessage() . "File upload error 2

\n"); $alltorrent = fread($fd, filesize($_FILES["torrent"]["tmp_name"])); $array = BDecode($alltorrent); if (!$array) { echo errorMessage() . "Error: The parser was unable to load your torrent. Please re-create and re-upload the torrent.

\n"; endOutput(); exit; } if (isset($array["announce-list"])) { //multiple trackers are listed $found_tracker = false; for ($i = 0; $i < count($array["announce-list"]); $i++) { if (strtolower($array["announce-list"][$i][0]) == $tracker_url) { $found_tracker = true; break; } } if ($found_tracker == false) { echo errorMessage() . "Error: Multiple trackers were found but none of them match the primary announce URL:
$tracker_url

or any alternate URLs:
$announce_url1
$announce_url2
$announce_url3
$announce_url4

Please re-create and re-upload the torrent.

\n"; endOutput(); exit; } } else { //a single tracker is listed if (strtolower($array["announce"]) != $tracker_url) { echo errorMessage() . "Error: The tracker announce URL does not match the primary announce URL:
$tracker_url

or any alternate URLs:
$announce_url1
$announce_url2
$announce_url3
$announce_url4

Please re-create and re-upload the torrent.

\n"; endOutput(); exit; } } if (isset($_POST["httpseed"]) && $_POST["httpseed"] == "enabled" && $_POST["relative_path"] == "") { echo errorMessage() . "Error: HTTP seeding was checked however no relative path was given.

\n"; endOutput(); exit; } if (isset($_POST["httpseed"]) && $_POST["httpseed"] == "enabled" && $_POST["relative_path"] != "") { if (Substr($_POST["relative_path"], -1) == "/") { if (!is_dir($_POST["relative_path"])) { echo errorMessage() . "Error: HTTP seeding relative path ends in / but is not a valid directory.

\n"; endOutput(); exit; } } else { if (!is_file($_POST["relative_path"])) { echo errorMessage() . "Error: HTTP seeding relative path is not a valid file.

\n"; endOutput(); exit; } } } if (isset($_POST["getrightseed"]) && $_POST["getrightseed"] == "enabled" && $_POST["httpftplocation"] == "") { echo errorMessage() . "Error: GetRight HTTP seeding was checked however no URL was given.

\n"; endOutput(); exit; } if (isset($_POST["getrightseed"]) && $_POST["getrightseed"] == "enabled" && (Substr($_POST["httpftplocation"], 0, 7) != "http://" && Substr($_POST["httpftplocation"], 0, 6) != "ftp://") ) { echo errorMessage() . "Error: GetRight HTTP seeding URL must start with http:// or ftp://

\n"; endOutput(); exit; } $hash = @sha1(BEncode($array["info"])); fclose($fd); $target_path = "torrents/"; $target_path = $target_path . basename( clean($_FILES['torrent']['name'])); $move_torrent = move_uploaded_file($_FILES["torrent"]["tmp_name"], $target_path); if ($move_torrent == false) { echo errorMessage() . "Unable to move " . $_FILES["torrent"]["tmp_name"] . " to torrents/

\n"; } } if (isset($_POST["title"])) $title = clean($_POST["title"]); else $title = ""; if (isset($_POST["filename"])) $filename = clean($_POST["filename"]); else $filename = ""; if (isset($_POST["url"])) $url = clean($_POST["url"]); else $url = ""; if (isset($_POST["autoset"])) if (strcmp($_POST["autoset"], "enabled") == 0) { if (strlen($filename) == 0 && isset($array["info"]["name"])) $filename = $array["info"]["name"]; } //figure out total size of all files in torrent $info = $array["info"]; $total_size = 0; if (isset($info["files"])) { foreach ($info["files"] as $file) { $total_size = $total_size + $file["length"]; } } else { $total_size = $info["length"]; } //Validate torrent file, make sure everything is correct $filename = mysql_real_escape_string($filename); $filename = stripslashes($filename); $filename = htmlspecialchars(clean($filename)); $url = htmlspecialchars(mysql_real_escape_string($url)); if ((strlen($hash) != 40) || !verifyHash($hash)) { echo errorMessage() . "Error: Info hash must be exactly 40 hex bytes.

\n"; endOutput(); } if (Substr($url, 0, 7) != "http://" && $url != "") { echo errorMessage() . "Error: The Torrent URL does not start with http:// Make sure you entered a correct URL.

\n"; endOutput(); } if ($GLOBALS["customtitle"] == "true") $query = "INSERT INTO ".$prefix."namemap (info_hash, title, filename, url, size, pubDate) VALUES (\"$hash\", \"$title\", \"$filename\", \"$url\", \"$total_size\", \"" . date("$dateformat") . "\")"; else $query = "INSERT INTO ".$prefix."namemap (info_hash, title, filename, url, size, pubDate) VALUES (\"$hash\", \"$filename\", \"$filename\", \"$url\", \"$total_size\", \"" . date("$dateformat") . "\")"; $status = makeTorrent($hash, true); quickQuery($query); if ($status) { echo "

Torrent was added successfully.

\n"; echo "\"AddAdd Another Torrent
\n"; //rename torrent file to match filename rename("torrents/" . clean($_FILES['torrent']['name']), "torrents/" . $filename . ".torrent"); //make torrent file readable by all chmod("torrents/" . $filename . ".torrent", 0644); //run RSS generator require_once("rss_generator.php"); //Display information from DumpTorrentCGI.php require_once("torrent_functions.php"); } else { echo errorMessage() . "There were some errors. Check if this torrent has been added previously.

\n"; //delete torrent file if it doesn't exist in database $query = "SELECT COUNT(*) FROM ".$prefix."summary WHERE info_hash = '$hash'"; $results = mysql_query($query) or die(errorMessage() . "Can't do SQL query - " . mysql_error() . "

"); $data = mysql_fetch_row($results); if ($data[0] == 0) { if (file_exists("torrents/" . $_FILES['torrent']['name'])) unlink("torrents/" . $_FILES['torrent']['name']); } //make torrent file readable by all chmod("torrents/" . $filename . ".torrent", 0644); endOutput(); } } function endOutput() { require ("config.php"); $tracker_url = $announce_url0; $alt_tracker_url1 = $announce_url1; $alt_tracker_url2 = $announce_url2; $alt_tracker_url3 = $announce_url3; $alt_tracker_url4 = $announce_url4; ?>

HelpHelp

Add Torrent to Tracker Database

Tracker URL:

Alternate Tracker URLs:



Title:"; else ($GLOBALS["customtitle"] != "true"); ?> \n"; ?>
Torrent file: "; else echo 'File uploading not available - no SHA1 function.'; ?>

Use BitTornado HTTP seeding specification (optional)
Relative location of file or directory:
e.g. ../../files/file.zip

Use GetRight HTTP seeding specification (optional)
FTP/HTTP URL of file or directory:
e.g. http://yourwebsite.com/file.zip

Fill in fields below automatically using data from the torrent file.
Info Hash:
File name (optional):
Torrent's URL (optional):

-

Tracker StatisticsReturn to Statistics Page