Ok due to growing amount of requests relating to, or limited by, anonymous uploads, I wrote a quick fix for it. The idea is to always insert an owner, but check for an anonymity flag for the torrent. That way mods will be easier to write, and stats and such would be easier to gather.
I'm hoping TS will add this into 2.04 if enough people want mods requiring this fix.
ALTER TABLE `torrents` ADD `anon` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `owner`;
torrents-upload.php
find:
//anonymous upload
$anonyupload = unesc($_POST["anonycheck"]);
if ($anonyupload == "yes") {
$uploaderid = "0";
}else{
$uploaderid = $CURUSER["id"];
}
replace with:
//anonymous upload
$anonyupload = unesc($_POST["anonycheck"]);
$uploaderid = $CURUSER["id"];
if ($anonyupload == "yes") {
$anon = "yes";
} else {
$anon = "no";
}
find:
$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).", '".$uploaderid."',
".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$type."', '" . get_date_time() . "',
'".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."',
'".$langid."')");
replace with:
$ret = mysql_query("INSERT INTO torrents (filename, owner, anon, name, descr, image1, image2, category, added, info_hash,
size, numfiles, save_as, announce, external, nfo, torrentlang) VALUES (".sqlesc($fname).", '".$uploaderid."', '".$anon."',
".sqlesc($name).", ".sqlesc($descr).", '".$inames[0]."', '".$inames[1]."', '".$type."', '" . get_date_time() . "',
'".$infohash."', '".$torrentsize."', '".$filecount."', ".sqlesc($fname).", '".$announce."', '".$external."', '".$nfo."',
'".$langid."')");
(Or just add anon and '".$anon."' to the query if you're using a modified one...)
torrents-details.php
find:
//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.image2, torrents.announce, torrents.numfiles, torrents.freeleech, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, torrentlang.name AS lang_name, torrentlang.image AS lang_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or die(mysql_error());
replace with:
//GET ALL MYSQL VALUES FOR THIS TORRENT
$res = mysql_query("SELECT torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, torrents.nfo, torrents.last_action, torrents.numratings, torrents.name, torrents.owner, torrents.anon,torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.external, torrents.image1, torrents.image2, torrents.announce, torrents.numfiles, torrents.freeleech, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.numratings, categories.name AS cat_name, torrentlang.name AS lang_name, torrentlang.image AS lang_image, categories.parent_cat as cat_parent, users.username, users.privacy FROM torrents LEFT JOIN categories ON torrents.category = categories.id LEFT JOIN torrentlang ON torrents.torrentlang = torrentlang.id LEFT JOIN users ON torrents.owner = users.id WHERE torrents.id = $id") or die(mysql_error());
(or add torrents.anon to the query if you're using a modified one)
find:
if ($row["username"])
replace with:
if ($row["anon"] == "no")
torrents-edit.php
find:
$updateset[] = "freeleech = '".$_POST["freeleech"]."'";
below, add:
$updateset[] = "anon = '" . ($_POST["anon"] ? "yes" : "no") . "'";
find:
if ($row["external"] != "yes"){
echo "<tr><td align=right><B>Free Leech: </b></TD><TD><input type=\"checkbox\" name=\"freeleech\"" . (($row["freeleech"] == "1") ? " checked=\"checked\"" : "" ) . " value=\"1\" />Leeching is free? (Only Uploading Counts)<br>";
}
below, add:
if (($site_config['ANONYMOUSUPLOAD']) && ($row['owner'])) {
echo "<tr><td align=right><B>Upload anonymous: </b></TD><TD><input type=\"checkbox\" name=\"anon\"" . (($row["anon"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"1\" />(Your userid will not be associated to this upload)<br>";
}
That should be it. Tested on my test site, working fine. Now we can get to work on those mods requiring an owner :)