[file...] [params...] --announce_list a list of announce URLs - explained below (defaults to '') --httpseeds a list of http seed URLs - explained below (defaults to '') --piece_size_pow2 which power of 2 to set the piece size to (0 = automatic) (defaults to 0) --comment optional human-readable comment to put in .torrent (defaults to '') --filesystem_encoding optional specification for filesystem encoding (set automatically in recent Python versions) (defaults to '') --target optional target file for the torrent (defaults to '') announce_list = optional list of redundant/backup tracker URLs, in the format: url[,url...][|url[,url...]...] where URLs separated by commas are all tried first before the next group of URLs separated by the pipe is checked. If none is given, it is assumed you don't want one in the metafile. If announce_list is given, clients which support it will ignore the value. Examples: http://tracker1.com|http://tracker2.com|http://tracker3.com (tries trackers 1-3 in order) http://tracker1.com,http://tracker2.com,http://tracker3.com (tries trackers 1-3 in a randomly selected order) http://tracker1.com|http://backup1.com,http://backup2.com (tries tracker 1 first, then tries between the 2 backups randomly) httpseeds = optional list of http-seed URLs, in the format: url[|url...] *****/ include_once("config.php"); include_once("functions.php"); // Variable information $tpath = $cfg["torrent_file_path"]; $tfile = $_POST['torrent']; $file = $_GET['path']; $torrent = cleanFileName(StripFolders( trim($file) )) . ".torrent"; $announce = ( $_POST['announce'] ) ? $_POST['announce'] : "http://"; $ancelist = $_POST['announcelist']; $comment = $_POST['comments']; $peice = $_POST['piecesize']; $alert = ( $_POST['alert'] ) ? 1 : "''"; $private = ( $_POST['Private'] == "Private" ) ? true : false; $dht = ( $_POST['DHT'] == "DHT" ) ? true : false; // Let's create the torrent if( !empty( $announce ) && $announce != "http://" ) { // Create maketorrent directory if it doesn't exist if( !is_dir( $tpath ) ) { @mkdir( $tpath ); } // Clean up old files if( @file_exists( $tpath . $tfile ) ) { @unlink( $tpath . $tfile ); } // This is the command to execute $app = "nohup " . $cfg["pythonCmd"] . " -OO " . $cfg["btmakemetafile"] . " " . $announce . " " . escapeshellarg( $cfg['path'] . $file ) . " "; // Is there comments to add? if( !empty( $comment ) ) { $app .= "--comment " . escapeshellarg( $comment ) . " "; } // Set the piece size if( !empty( $peice ) ) { $app .= "--piece_size_pow2 " . $peice . " "; } if( !empty( $ancelist ) ) { $check = "/" . str_replace( "/", "\/", quotemeta( $announce ) ) . "/i"; // if they didn't add the primary tracker in, we will add it for them if( preg_match( $check, $ancelist, $result ) ) $app .= "--announce_list " . escapeshellarg( $ancelist ) . " "; else $app .= "--announce_list " . escapeshellarg ( $announce . "," . $ancelist ) . " "; } // Set the target torrent fiel $app .= "--target " . escapeshellarg( $tpath . $tfile ); // Set to never timeout for large torrents set_time_limit( 0 ); // Let's see how long this takes... $time_start = microtime( true ); // Execute the command -- w00t! exec( $app ); // We want to check to make sure the file was successful $success = false; $raw = @file_get_contents( $tpath . $tfile ); if( preg_match( "/6:pieces([^:]+):/i", $raw, $results ) ) { // This means it is a valid torrent $success = true; // Make an entry for the owner AuditAction($cfg["constants"]["file_upload"], $tfile); // Check to see if one of the flags were set if( $private || $dht ) { // Add private/dht Flags // e7:privatei1e // e17:dht_backup_enablei1e // e20:dht_backup_requestedi1e if( preg_match( "/6:pieces([^:]+):/i", $raw, $results ) ) { $pos = strpos( $raw, "6:pieces" ) + 9 + strlen( $results[1] ) + $results[1]; $fp = @fopen( $tpath . $tfile, "r+" ); @fseek( $fp, $pos, SEEK_SET ); if( $private ) { @fwrite( $fp, "7:privatei1e17:dht_backup_enablei0e20:dht_backup_requestedi0eee" ); } else { @fwrite( $fp, "e7:privatei0e17:dht_backup_enablei1e20:dht_backup_requestedi1eee" ); } @fclose( $fp ); } } } else { // Something went wrong, clean up if( @file_exists( $tpath . $tfile ) ) { @unlink( $tpath . $tfile ); } } // We are done! how long did we take? $time_end = microtime( true ); $diff = duration($time_end - $time_start); // make path URL friendly to support non-standard characters $downpath = urlencode( $tfile ); // Depending if we were successful, display the required information if( $success ) { $onLoad = "completed( '" . $downpath . "', " . $alert. ", '" . $diff . "' );"; } else { $onLoad = "failed( '" . $downpath . "', " . $alert . " );"; } } // This is the torrent download prompt if( !empty( $_GET["download"] ) ) { $tfile = $_GET["download"]; // ../ is not allowed in the file name if (!ereg("(\.\.\/)", $tfile)) { // Does the file exist? if (file_exists($tpath . $tfile)) { // Prompt the user to download the new torrent file. header( "Content-type: application/octet-stream\n" ); header( "Content-disposition: attachment; filename=\"" . $tfile . "\"\n" ); header( "Content-transfer-encoding: binary\n"); header( "Content-length: " . @filesize( $tpath . $tfile ) . "\n" ); // Send the torrent file $fp = @fopen( $tpath . $tfile, "r" ); @fpassthru( $fp ); @fclose( $fp ); AuditAction($cfg["constants"]["fm_download"], $tfile); } else { AuditAction($cfg["constants"]["error"], "File Not found for download: ".$cfg['user']." tried to download ".$tfile); } } else { AuditAction($cfg["constants"]["error"], "ILLEGAL DOWNLOAD: ".$cfg['user']." tried to download ".$tfile); } exit(); } // Strip the folders from the path function StripFolders( $path ) { $pos = strrpos( $path, "/" ) + 1; $path = substr( $path, $pos ); return $path; } // Convert a timestamp to a duration string function duration( $timestamp ) { $years = floor( $timestamp / ( 60 * 60 * 24 * 365 ) ); $timestamp %= 60 * 60 * 24 * 365; $weeks = floor( $timestamp / ( 60 * 60 * 24 * 7 ) ); $timestamp %= 60 * 60 * 24 * 7; $days = floor( $timestamp / ( 60 * 60 * 24 ) ); $timestamp %= 60 * 60 * 24; $hrs = floor( $timestamp / ( 60 * 60 ) ); $timestamp %= 60 * 60; $mins = floor( $timestamp / 60 ); $secs = $timestamp % 60; $str = ""; if( $years >= 1 ) $str .= "{$years} years "; if( $weeks >= 1 ) $str .= "{$weeks} weeks "; if( $days >= 1 ) $str .= "{$days} days "; if( $hrs >= 1 ) $str .= "{$hrs} hours "; if( $mins >= 1 ) $str .= "{$mins} minutes "; if( $secs >= 1 ) $str.="{$secs} seconds "; return $str; } ?> <?php echo $cfg["pagetitle"]; ?> - Torrent Maker /style.css" TYPE="text/css" /> " style="font-family:Tahoma, 'Times New Roman'; font-size:12px;" onLoad=" ">
" cellpadding="4" cellspacing="0">
" background="themes//images/bar.gif">
">
">
Torrent name:
Announcement URL:
Announce List:
Piece size: bytes
Comments:
Private Torrent: >Yes >No
DHT Support: value="DHT">