Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
[MOD] Mass Torrent Import
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / v2.08 / v2 Only Mods Complete

Unknown User
2008-03-03 21:06:30
torrents-import.php:

<?

//

//  TorrentTrader v2.x

// Mass Torrent Import (based on torrents-upload.php)

// This file was created: 27/Feb/2008 by TorrentialStorm

//

// http://www.torrenttrader.org

//

//

require_once("backend/functions.php");

dbconn();



$dir = "import";



//ini_set("upload_max_filesize",$max_torrent_size);



$files = array();

$dh = opendir("$dir/");

while (false !== ($file=readdir($dh))) {

if (preg_match("/\.torrent$/i", $file))

$files[] = $file;

}

closedir($dh);





// check access and rights

if ($CURUSER["edit_torrents"] != "yes")

show_error_msg("Error", "Access Denied", 1);



$announce_urls = explode(",", strtolower($site_config["announce_list"]));  //generate announce_urls[] from config.php



if ($takeupload == "yes") {

require_once("backend/parse.php");

stdhead("Upload Complete");

begin_frame("Upload Complete");

echo "<center>";



//check form data

$catid = (int)$_POST["type"];



if (!is_valid_id($catid))

$message = "Please be sure to select a torrent category";



if (empty($message)) {

$r = mysql_query("SELECT name, parent_cat FROM categories WHERE id=$catid");

$r = mysql_fetch_row($r);



echo "<B>Category:</B> ".htmlspecialchars($r[1])." -> ".htmlspecialchars($r[0])."<BR>";

for ($i=0;$i<count($files);$i++) {

$fname = $files[$i];



$descr = "No description given.";



$langid = (int)$_POST["lang"];



preg_match('/^(.+)\.torrent$/si', $fname, $matches);

$shortfname = $torrent = $matches[1];



//parse torrent file

$torrent_dir = $site_config["torrent_dir"];



$TorrentInfo = array();

$TorrentInfo = ParseTorrent("$dir/$fname");





$announce = strtolower($TorrentInfo[0]);

$infohash = $TorrentInfo[1];

$creationdate = $TorrentInfo[2];

$internalname = $TorrentInfo[3];

$torrentsize = $TorrentInfo[4];

$filecount = $TorrentInfo[5];

$annlist = $TorrentInfo[6];

$comment = $TorrentInfo[7];



$message = "<BR><BR><HR><BR><B>$internalname</B><BR><BR>fname: ".htmlspecialchars($fname)."<BR>message: ";



//check announce url is local or external

if (!in_array($announce, $announce_urls, 1))

$external='yes';

else

$external='no';



if (!$site_config["ALLOWEXTERNAL"] && $external == 'yes') {

$message .= "The .torrent you are trying to upload does not have this trackers announce url!";

echo $message;

continue;

}



$name = $internalname;

$name = str_replace(".torrent","",$name);

$name = str_replace("_", " ", $name);



$ret = mysql_query("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang) VALUES (".sqlesc($fname).", '".$CURUSER['id']."', ".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$type."', '" . get_date_time() . "', '".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."', '".$langid."')");



$id = mysql_insert_id();



if (mysql_errno() == 1062) {

$message .= "Torrent already uploaded.";

echo $message;

continue;

}



if($id == 0){

$message .= "No ID. Server error, please report.";

echo $message;

continue;

}



copy("$dir/$files[$i]", "uploads/$id.torrent");



//EXTERNAL SCRAPE

if ($external == "yes") {

$tracker=str_replace("/announce","/scrape",$announce);

$stats = torrent_scrape_url($tracker, $infohash);

$seeders = strip_tags($stats['seeds']);

$leechers = strip_tags($stats['peers']);

$downloaded = strip_tags($stats['downloaded']);



mysql_query("UPDATE torrents SET leechers='".$leechers."', seeders='".$seeders."',times_completed='".$downloaded."',last_action= '".get_date_time()."',visible='yes' WHERE id='".$id."'");

}

//END SCRAPE



write_log("Torrent $id ($name) was Uploaded by $CURUSER[username]");



$message .= "<BR><B>Torrent Uploaded OK</B><BR><a href=torrents-details.php?id=".$id.">View Uploaded Torrent</a><BR><BR>";

echo $message;

@unlink("$dir/$fname");

}

echo "</center>";

end_frame();

stdfoot();

die;

}else

show_error_msg("Upload Failed", $message, 1);



}//takeupload





///////////////////// FORMAT PAGE ////////////////////////



stdhead("Upload");



begin_frame("" . UPLOAD . "");

?>

<form name="upload" enctype="multipart/form-data" action="torrents-import.php" method="post">

<input type="hidden" name="takeupload" value="yes" />

<table border="0" cellspacing="0" cellpadding="6" align="center">

<TR><TD align=right valign=top><B>File List:</B></TD><TD align=left><?

if (!count($files))

echo "Nothing to show.";

else{

foreach ($files as $f)

echo htmlspecialchars($f)."<BR>";

echo "<BR>Total files: ".count($files);

}?></TD></TR>

<?

$category = "<select name=\"type\">\n<option value=\"0\">" . CHOOSE_ONE . "</option>\n";



$cats = genrelist();

foreach ($cats as $row)

$category .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["parent_cat"]) . ": " . htmlspecialchars($row["name"]) . "</option>\n";



$category .= "</select>\n";

print ("<TR><TD align=right>" . TTYPE . ": </td><td align=left>".$category."</td></tr>");





$language = "<select name=\"lang\">\n<option value=\"0\">Unknown/NA</option>\n";



$langs = langlist();

foreach ($langs as $row)

$language .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";



$language .= "</select>\n";

print ("<TR><TD align=right>Language: </td><td align=left>".$language."</td></tr>");



if ($site_config['ANONYMOUSUPLOAD']){ ?>

<TR><TD align=right>Upload Anonymous: </td><td><? printf("<input name=anonycheck value=yes type=radio" . ($anonycheck ? " checked" : "") . ">Yes <input name=anonycheck value=no type=radio" . (!$anonycheck ? " checked" : "") . ">No"); ?> &nbsp;<I>(Your userid will not be associated to this upload)</font>

</td></tr>



<?}?>

<TR><TD align=center colspan=2><input type="submit" value="<?=UPLOADT?>"><BR>

<I>Click Once!</I></form></TD></TR></TABLE>

<?

end_frame();

stdfoot();

?>


Create a folder called import (if you use a different name you'll need to change $dir in the script) and chmod it to 777, place any torrents there.

* Edit: This has been included in v2.04
Unknown User
2008-04-03 14:59:38
Why do I need this mod please?
Unknown User
2008-04-16 01:43:20
"emulienfou, post: 40958":
Why do I need this mod please?

To import multiple torrents at once in stead of once at a time (assuiming from the title and the code), a useful tool and good idea, could save loads of time, but have not tried it
Unknown User
2008-05-31 10:29:12
[bUG]

$torrent_dir = $site_config["torrent_dir"];

haven't any effect

copy("$dir/$files[$i]", "uploads/$id.torrent");

EDIT: furthermore i get an parse error:

Quote:
'Parser Error: Error Opening torrent, unabled to get contents'

EDIT2: ok, the bug emanate from the wrong path
Unknown User
2008-05-31 14:02:24
can i also add images or posters? ;)
Unknown User
2009-12-17 22:43:48
"KjSay, post: 42919":
can i also add images or posters?  ;)

Do you have to make an archive of the torrents? I really need to use this tool as I have 3000 torrents to put up
Unknown User
2009-12-18 00:05:03
No. You just put the .torrent(s) in the import dir.
Unknown User
2009-12-18 09:11:24
"TorrentialStorm, post: 61468":
No. You just put the .torrent(s) in the import dir.
good stuff
Unknown User
2010-02-02 14:02:11
hi

Error : Access Denied ? pls help.
Unknown User
2010-05-06 09:19:33
great code,thanks so much man,works perfect
Unknown User
2010-05-30 18:01:25
It doesn't work for me. I had made exactly as in the tutorial, but nothing happened
2010-10-21 06:13:20
2.06 ne fonctionne pas!

Solution??

~~~~~~~~~//

6.2 does not work!

Solution!??
Unknown User
2011-01-19 01:02:38
Hi Guys,

I am using massively the MASS TORRENT IMPORT MOD. I figured out that the MASS TORRENT IMPORT doesn't disable the DHT, wich is normal because the code is located in TORRENTS-UPLOAD.PHP and not in the TORRENT-IMPORT.PHP. His there a way to put the DISABLE DHT MOD in the TORRENT-IMPORT.PHP file?

Thanx. Regards.
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728