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
[ADDON] Teams
Controls ·  Search New posts · Mark unread

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

Unknown User
2008-06-17 12:23:57
I did a load of work on VIP only torrents (http://www.torrenttrader.org/index.php?showtopic=3913) a couple of years ago for TT1.x and now that I'm moving to 2.x, I needed to re-engineer it. I noticed that some of the code for Teams was there, but this wasn't working at all. I believe this code is functioning OK so I thought I'd put it up here. I've modded my site in other ways too, but I think I've managed to remove those bits of code.

BACKUP FIRST!

This is the way it works;

- Teams are created via the teams button in Control Panel

- User can be a member of one and only one team

- User cannot change their team membership

- Only Admins (class 7) can change a users' team membership (from the users details page)

- Team torrents are hidden from non-team members

- A user who is a team member can choose to make their upload available to anyone or just their team

- A torrent can only belong to either one team, or no team

- Admins can see all torrents, either public or belonging to any team

- A user can change their torrents team settings after upload

- A supermod who is a team member can change a torrents team settings if they are a member of that team

- A users' team membership can only be seen by Admins and another member of that team

And here is the code....

SQL

ALTER TABLE `torrents` ADD `team` VARCHAR( 10 ) NULL DEFAULT '0';


account.php

Find

<? print("<B>IP:</b> " . $CURUSER["ip"] . "\n"); ?><br>

Below add

 <? $res = mysql_query("SELECT name,image FROM teams WHERE id=$CURUSER[team] LIMIT 1") or die(mysql_error());
if (mysql_num_rows($res) == 1) {

$arr = mysql_fetch_assoc($res);

echo "<tr><td colspan=2 align=left><B>Team Member Of:</B><BR>";

echo"<img src='".htmlspecialchars($arr["image"])."'><BR>".sqlesc($arr["name"])."</td></tr>";

} ?><br>

Find and remove (or comment out)

 if ($CURUSER["class"] > 1)
print("<TR><TD align=right class=table_col1><B>Team:</b> </td><TD align=left class=table_col1><select name=teams>\n$teams\n</select></td></tr>");

Find

 <? print("<B>IP:</b> " . $CURUSER["ip"] . "\n"); ?><br>



Below Add

 <? $res = mysql_query("SELECT name,image FROM teams WHERE id=$CURUSER[team] LIMIT 1") or die(mysql_error());
if (mysql_num_rows($res) == 1) {

$arr = mysql_fetch_assoc($res);

echo "<tr><td colspan=2 align=left><B><center>Team Member Of:</B><BR>";

echo"<img src='".htmlspecialchars($arr["image"])."'><BR>".sqlesc($arr["name"])."</center></td></tr>";

} ?><br>

Account-details.php

Find

 if ($CURUSER["class"] > $user["class"]){
print("<tr><td>Class</td><td align=left><select name=class>\n");

$maxclass = $CURUSER["class"];

for ($i = 1; $i < $maxclass; ++$i)

print("<option value=$i" . ($user["class"] == $i ? " selected" : "") . ">$prefix" . get_user_class_name($i) . "\n");

print("</select></td></tr>\n");

}

After Add

 if ($CURUSER['class'] == 7)
{

$teams = "<option value=0>--- None selected ----</option>\n";

$sashok = mysql_query("SELECT id,name FROM teams ORDER BY name") or die;

while ($sasha = mysql_fetch_array($sashok))

$teams .= "<option value=$sasha[id]" . ($user["team"] == $sasha['id'] ? " selected" : "") . ">$sasha[name]</option>\n";

print("<TR><TD>Team</td><TD align=left><select name=teams>\n$teams\n</select></tr>");

}

else

print("<input type=hidden name=teams value=$user[team]>");

Find

 $res = mysql_query("SELECT torrent,uploaded,downloaded FROM peers WHERE userid='$id' AND seeder='yes'");
if (mysql_num_rows($res) > 0)

$seeding = peerstable($res);

$res = mysql_query("SELECT torrent,uploaded,downloaded FROM peers WHERE userid='$id' AND seeder='no'");

if (mysql_num_rows($res) > 0)

$leeching = peerstable($res);

Replace with

 $res = mysql_query("SELECT torrent,uploaded,downloaded FROM peers LEFT JOIN torrents ON torrent = torrents.id WHERE userid='$id' AND seeder='yes' AND (torrents.team = 0 OR torrents.team = ".$CURUSER['team']. " OR ".$CURUSER['class']." = 7)");
if (mysql_num_rows($res) > 0)

$seeding = peerstable($res);

$res = mysql_query("SELECT torrent,uploaded,downloaded FROM peers LEFT JOIN torrents ON torrent = torrents.id WHERE userid='$id' AND seeder='no' AND (torrents.team = 0 OR torrents.team = ".$CURUSER['team']. " OR ".$CURUSER['class']." = 7)");

if (mysql_num_rows($res) > 0)

$leeching = peerstable($res);

Find

 $res = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner='$id' $where") or die(mysql_error());


Replace With

 $res = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner='$id' $where AND (torrents.team = 0 OR torrents.team = ".$CURUSER['team']. " OR ".$CURUSER['class']." = 7)") or die(mysql_error());


Find

 $query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, torrents.anon, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.announce FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE owner = $id $orderby $limit";


Replace with

 $query = "SELECT teams.name AS teamname, teams.image AS teamimage, torrents.team, torrents.id, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, torrents.anon, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, torrents.announce FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id LEFT JOIN teams ON torrents.team = teams.id WHERE torrents.owner = $id AND (torrents.team = 0 OR torrents.team = ".$CURUSER['team']. " OR ".$CURUSER['class']." = 7) $orderby $limit";



Find

 <a href=report.php?user=<?=$user["id"]?>>Report Member</a><BR>
</td>

</tr>

After Add

<?
//team

if (($CURUSER['team'] == $user['team']) OR ($CURUSER['class'] ==7))

{

$res = mysql_query("SELECT name,image FROM teams WHERE id=$user[team] LIMIT 1") or die(mysql_error());

if (mysql_num_rows($res) == 1) {

$arr = mysql_fetch_assoc($res);

echo "<tr><td colspan=2 align=left><B>Team Member Of:</B><BR>";

echo"<img src='".htmlspecialchars($arr["image"])."'><BR>".sqlesc($arr["name"])."<BR><BR><a href=teams-view.php>[View Teams]</a></td></tr>";

}

}

?>

Find

 $res = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner=$id") or die(mysql_error());


Replace with

 $res = mysql_query("SELECT COUNT(*) FROM torrents WHERE owner=$id AND (torrents.team = 0 OR torrents.team = ".$CURUSER['team']. " OR ".$CURUSER['class']." = 7)") or die(mysql_error());


Admin-modtasks.php

Find

 $class = (int)$_POST["class"];


After Add

 $teams = $_POST["teams"];


Find

 mysql_query("UPDATE users SET title='$title', downloaded='$downloaded', uploaded='$uploaded', signature='$signature', avatar='$avatar', ip='$ip', donated='$donated', forumbanned='$forumbanned', warned='$warned', modcomment='$modcomment', enabled='$enabled', invites='$invites' WHERE id=$userid");


Replace with

 mysql_query("UPDATE users SET title='$title', downloaded='$downloaded', uploaded='$uploaded', signature='$signature', avatar='$avatar', ip='$ip', donated='$donated', forumbanned='$forumbanned', warned='$warned', modcomment='$modcomment', enabled='$enabled', invites='$invites', team='$teams' WHERE id=$userid");



Torrents-upload.php

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, anon) 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."','$anon')");


Replace With

 $ret = mysql_query("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, team) 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."','$anon','".$team."')");



Find

 $langid = (0 + $_POST["lang"]);

After add

 $team = (0 + $_POST["teams"]);


Find

//end requests

After Add

//teams

if ($CURUSER["team"] != 0)

{

$userteam = $CURUSER["team"];

$teams = "<option value=0>--- None selected ----</option>\n";

$sashok = mysql_query("SELECT id,name FROM teams WHERE id = $userteam ORDER BY name") or die;

while ($sasha = mysql_fetch_array($sashok))

$teams .= "<option value=$sasha[id]" . ($user["team"] == $sasha['id'] ? " selected" : "") . ">$sasha[name]</option>\n";

print("<TR><td align=right>Team</td><TD align=left><select name=teams>\n$teams\n</select></tr>");

}

Index.php

Find

 $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.image AS cat_pic, categories.parent_cat AS cat_parent, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id WHERE visible = 'yes' AND banned = 'no' ORDER BY id DESC LIMIT 25";


Replace with

 $query = "SELECT users.team AS userteam, teams.id AS teamsid, teams.name AS teamname, teams.image AS teamimage, torrents.team, torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.image AS cat_pic, categories.parent_cat AS cat_parent, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN users ON torrents.owner = users.id WHERE (".$CURUSER['team']." = torrents.team OR torrents.team = 0 OR ".$CURUSER['class']." = 7) AND visible = 'yes' AND banned = 'no' ORDER BY id DESC LIMIT 25";



functions.php

Find

 $dispname = "<b>".$smallname."</b>";


Below add

 if ($row["team"]!= 0)
$dispname .= " <img src='".$row["teamimage"]."' border='0' alt = '".$row["teamname"]."'>";

Find

 function langlist() {
$ret = array();

$res = mysql_query("SELECT id, name, image FROM torrentlang ORDER BY sort_index, id");

while ($row = mysql_fetch_array($res))

$ret[] = $row;

return $ret;

}

Below Add

 function teamslist() {
$ret = array();

$res = mysql_query("SELECT id, name FROM teams ORDER BY name");

while ($row = mysql_fetch_array($res))

$ret[] = $row;

return $ret;

}

Mostactivetorrents_block.php

Find

 //$where = "WHERE external !='yes'" 


Below Add

 $where = "WHERE team = 0";



Seedwanted_block.php

Find

 $seederswantedquery = mysql_query("SELECT id,name,seeders,leechers FROM torrents WHERE seeders ='0' and external !='yes' ORDER BY leechers DESC LIMIT 5")or die(mysql_error());


Replace with

 $seederswantedquery = mysql_query("SELECT id,name,seeders,leechers FROM torrents WHERE seeders ='0' and external !='yes' AND team = 0 ORDER BY leechers DESC LIMIT 5")or die(mysql_error());



Torrents-edit.php

Find

$updateset[] = "torrentlang = " . (0 + $language);

After add

$updateset[] = "team = " . (0 + $team);


Find

/END TORRENTLANG

After Add

 //UPDATE TEAM DROPDOWN
$teamsdropdown = "<select name=\"team\"><option value=0>--- None Selected ---</option>\n";

$teams = teamslist();

foreach ($teams as $teams) {

if (($CURUSER['class'] == 7) OR ($teams["id"] == $CURUSER['team']))

{

$teamsdropdown .= "<option value=\"" . $teams["id"] . "\"";

if ($teams["id"] == $row["team"])

$teamsdropdown .= " selected=\"selected\"";

$teamsdropdown .= ">" . htmlspecialchars($teams["name"]) . "</option>\n";

}

}

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

//END team

Find

echo "<tr><td align=right><B>Language: </b></TD><TD>".$langdropdown."</TD></TR>";

After Add

 if (($CURUSER['class'] == 7) OR ($CURUSER['id'] == $row['owner'] AND $CURUSER['team'] != 0))
{

echo "<tr><td align=right><B>Team: </b></TD><TD>".$teamsdropdown."</TD></TR>";

}

rss.php (if you have one)

Find

 // by category ? 
if (!$cat){

$catvar ="WHERE visible='yes'"; //just show last visible

}else{

$catvar ="WHERE categories.id ='$cat' AND visible='yes'";

}

Replace with

 // by category ? 
if (!$cat){

$catvar ="WHERE visible='yes' AND torrents.team = 0"; //just show last visible

}else{

$catvar ="WHERE categories.id ='$cat' AND visible='yes' AND torrents.team = 0";

}

Torrents-today.php

Find

 $query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where AND torrents.added>='$date_time' $orderby $limit";


Replace With

 $query = "SELECT users.team AS userteam, teams.id AS teamsid, teams.name AS teamname, teams.image AS teamimage, torrents.team, torrents.id, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN users ON torrents.owner = users.id $where AND torrents.added>='$date_time' $orderby $limit";



torrents.php

Find

 if ($where != "")
$where = "WHERE $where";

Replace With

 if ($where != "")
$where = "WHERE $where AND (".$CURUSER['team']." = torrents.team OR torrents.team = 0 OR ".$CURUSER['class']."= 7)";

Find

 $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit";


Replace with

 $query = "SELECT users.team AS userteam, teams.id AS teamsid, teams.name AS teamname, teams.image AS teamimage, torrents.team, torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit";



Search.php

find

$wherea[] = "banned = 'no'"

Replace with

 $wherea[] = "banned = 'no' AND (".$CURUSER['team']." = torrents.team OR torrents.team = 0 OR ".$CURUSER['class']."= 7)";


Find

 $query = "SELECT torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit";


Replace with

$query = "SELECT users.team AS userteam, teams.id AS teamsid, teams.name AS teamname, teams.image AS teamimage, torrents.team, torrents.id, torrents.anon, torrents.announce, torrents.category, torrents.leechers, torrents.nfo, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, torrents.external, torrents.freeleech, categories.name AS cat_name, categories.parent_cat AS cat_parent, categories.image AS cat_pic, users.username, users.privacy, IF(torrents.numratings < 2, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN teams ON torrents.team = teams.id LEFT JOIN users ON torrents.owner = users.id $where $parent_check $orderby $limit";


download.php

Find

 $res = mysql_query("SELECT filename, external, announce FROM torrents WHERE id =".intval($id));


Replace with

 $res = mysql_query("SELECT filename, external, announce, team FROM torrents WHERE id =".intval($id));


Find

 show_error_msg("File not found", "The ID and torrent were found, but the torrent is NOT readable!",1);

After add

 if (($CURUSER['team'] != $row['team']) AND ($CURUSER['class'] < 7) AND ($row['team'] != 0))
show_error_msg("Restricted torrent", "The torrent you are attempting to download is restricted.",1);

Hope it works for you!

Cheers

Simon
Unknown User
2008-06-17 22:53:53
hi

i've got some errors...

1)   Unknown column 'torrents.anon' in 'field list'
Unknown User
2008-06-18 08:32:55
"rodriguesp, post: 43660":
hi
i've got some errors...

1) Unknown column 'torrents.anon' in 'field list'

This was based on 2.04 - the anon field is in the torrents table in that version.  If it's not in your version then either remove references to the anon field from the hack or upgrade your table structure.  The anon field isn't used by this hack.

Cheers

Simon
Unknown User
2008-06-20 22:03:42
Thanks a lot, he works very well.

There is some way from which the torrents did not go out in Latest Posters, the image goes out and that by themselves that of the team saw it would like.

Greetings and pardon by my Englihs
Unknown User
2008-06-22 18:29:39
"zape, post: 43751":
Thanks a lot, he works very well.
There is some way from which the torrents did not go out in Latest Posters, the image goes out and that by themselves that of the team saw it would like.

Greetings and pardon by my Englihs

Not a block I use, but this should do it.

latestuploads_block.php

Find

 $latestuploadsquery = mysql_query("SELECT id, name FROM torrents WHERE banned='no' ORDER BY id DESC LIMIT 5")or die(mysql_error());


Replace with

 $latestuploadsquery = mysql_query("SELECT id, name FROM torrents WHERE banned='no' AND (team = 0 OR team = ".$CURUSER['team']." OR ".$CURUSER['class']." = 7) ORDER BY id DESC LIMIT 5")or die(mysql_error());


Cheers

Simon
Unknown User
2008-07-02 18:00:50
"spfunnell, post: 43775":
Not a block I use, but this should do it.
latestuploads_block.php

Find

 $latestuploadsquery = mysql_query("SELECT id, name FROM torrents WHERE banned='no' ORDER BY id DESC LIMIT 5")or die(mysql_error());


Replace with

 $latestuploadsquery = mysql_query("SELECT id, name FROM torrents WHERE banned='no' AND (team = 0 OR team = ".$CURUSER['team']." OR ".$CURUSER['class']." = 7) ORDER BY id DESC LIMIT 5")or die(mysql_error());


Cheers

Simon


Thanks, I will try what he says.

I have other problem, if some user who is not of the Teams enters in torrents details and looks in File List: He can see what contains the Torrent.

Kind regards.
Unknown User
2008-07-05 10:27:46
Hi, thanks for Addon but me have problems... (TTV2.04)

For edit torrents, error: Fatal error: Call to undefined function teamslist() in /****/****/*****/******/*****/******/torrents-edit.php on line 203

And for upload, impossible to choose if torrent parks will be visible in the team or for everybody  :mellow:



And me clik on "Search" --> error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 7) AND visible = 'yes'' at line 1

Thanks for help.

Sorry for my bad english, i'm french...
Unknown User
2008-07-07 18:08:04
"ZTk, post: 44084":
Hi, thanks for Addon but me have problems... (TTV2.04)
For edit torrents, error: Fatal error: Call to undefined function teamslist() in /****/****/*****/******/*****/******/torrents-edit.php on line 203

It sounds as though you haven't included the teamslist function in backend/functions.php.  You need to have;

function teamslist() {

$ret = array();

$res = mysql_query("SELECT id, name FROM teams ORDER BY name");

while ($row = mysql_fetch_array($res))

$ret[] = $row;

return $ret;

}

"ZTk, post: 44084":
And for upload, impossible to choose if torrent parks will be visible in the team or for everybody  :mellow:

You need to fix the above problem first, then you can only make a torrent available to a team, if you are a member of that team.  If you are not a member of a team, you don't see anything.  I do it this way so that users can't see what teams are available, it keeps them private.

"ZTk, post: 44084":
And me clik on "Search" --> error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 7) AND visible = 'yes'' at line 1

That one's my fault, i've changed it in the original posting now.  Change '== 7' to '= 7'

Cheers

Simon
Unknown User
2008-07-11 20:31:20
Thanks for help  :mellow:

functions.php and search fixed and work  :o

But the selection of TEAM is still not visible at the time of the upload torrent, the member forms part of the TEAM well and cannot choose with the upload so that it is visible only by his TEAM



On the other hand, if it publishes the torrent, it can choose the TEAM



Why?

Thanks a lot.
Unknown User
2008-07-12 08:17:45
"ZTk, post: 44295":
Thanks for help  :mellow:
functions.php and search fixed and work  :o

But the selection of TEAM is still not visible at the time of the upload torrent, the member forms part of the TEAM well and cannot choose with the upload so that it is visible only by his TEAM

On the other hand, if it publishes the torrent, it can choose the TEAM

Why?

Thanks a lot.

It seems that I missed a couple of bits from torrents-upload.php

Find

 $langid = (0 + $_POST["lang"]);

After add

 $team = (0 + $_POST["teams"]);


Find

//end requests

After Add

//teams

if ($CURUSER["team"] != 0)

{

$userteam = $CURUSER["team"];

$teams = "--- None selected ----\n";

$sashok = mysql_query("SELECT id,name FROM teams WHERE id = $userteam ORDER BY name") or die;

while ($sasha = mysql_fetch_array($sashok))

$teams .= "

print("Team\n$teams\n");

}

I think that should do it.

Cheers

SImon
Unknown User
2008-07-12 11:16:06
"spfunnell, post: 44302":
Find

//end requests

After Add

//teams

if ($CURUSER["team"] != 0)

{

$userteam = $CURUSER["team"];

$teams = "--- None selected ----\n";

$sashok = mysql_query("SELECT id,name FROM teams WHERE id = $userteam ORDER BY name") or die;

while ($sasha = mysql_fetch_array($sashok))

$teams .= "

print("Team\n$teams\n");

}

I dont find any

//end request
in torrent-upload.php

I placed the code after

//end upload images

and I have this error : Parse error: syntax error, unexpected T_STRING in /***/****/****/******/*****/*****/torrents-upload.php on line 218   :mellow:

Thanks.

My torrent-upload.php:

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=2587"]torrents_upload.php[/url]
torrents_upload.php
Download
Unknown User
2008-07-12 17:43:58
Badly placed  :mellow:   I've edited your code so try this version;

[url="http://devscorner.xyz/applications/core/interface/file/attachment.php?id=2594"]torrents_upload.php[/url]
torrents_upload.php
Download
Unknown User
2008-07-12 21:25:23
Functional!

Thank you very much for your assistance, sincerely!

Big big thanks!!  :mellow:  :o  :o

ZTk
Unknown User
2008-07-12 21:47:36
You're welcome. :mellow:
Unknown User
2008-07-26 17:07:36
i am getting an error in torrents-upload after applying team mod

Parse error: syntax error, unexpected T_STRING in torrents-upload.php on line 373

here is my torrents-upload.php

<?
//

//  TorrentTrader v2.x

// This file was last updated: 09/October/2007 by TorrentialStorm

//

// [url="http://www.torrenttrader.org"]http://www.torrenttrader.org[/url]

//

//

require_once("backend/functions.php");

dbconn();

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

// check access and rights

if ($site_config["MEMBERSONLY"]){

loggedinonly();

if($CURUSER["can_upload"]=="no")

show_error_msg("Error","<font size=2>You do not have permission to upload.<br> Please click </font><a href=uploadapp.php><font color=red size=2><b>here</b></font></a> <font size=2>to fill out an uploader application.</font>",1);

if ($site_config["UPLOADERSONLY"] && $CURUSER["class"] < 4)

show_error_msg("Error", "Only uploaders can upload.",1);

}

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

if($takeupload == "yes") {

require_once("backend/parse.php");

//check form data

foreach(explode(":","type:name") as $v) {

if (!isset($_POST[$v]))

$message = "Missing form data";

}

if (!isset($_FILES["torrent"]))

$message = "Missing form data";

$f = $_FILES["torrent"];

$fname = unesc($f["name"]);

if (empty($fname))

$message = "Empty filename!";

if ($_FILES['nfo']['size'] != 0) {

$nfofile = $_FILES['nfo'];

if ($nfofile['name'] == '')

$message = "No NFO!";

if (!preg_match('/^(.+)\.nfo$/si', $nfofile['name'], $fmatches))

$message = "Invalid filename (not a .NFO).";

if ($nfofile['size'] == 0)

$message = "0-byte NFO";

if ($nfofile['size'] > 65535)

$message = "NFO is too big! Max 65,535 bytes.";

$nfofilename = $nfofile['tmp_name'];

if (@!is_uploaded_file($nfofilename))

$message = "NFO upload failed";

$nfo = 'yes';

}

$descr = unesc($_POST["descr"]);

if (!$descr)

$descr = "No description given.";

$langid = (0 + $_POST["lang"]);

$team = (0 + $_POST["teams"]);

if (!is_valid_id($langid))

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

$catid = (0 + $_POST["type"]);

if (!is_valid_id($catid))

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

if (!validfilename($fname))

$message = "Invalid filename!";

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

$message = "Invalid filename (not a .torrent).";

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

if (!empty($_POST["name"]))

$torrent = unesc($_POST["name"]);

$tmpname = $f["tmp_name"];

if (!is_uploaded_file($tmpname))

$message = "The file was uploaded, but wasn't found on the temp directoy.";

//end check form data

//parse torrent file

$torrent_dir = $site_config["torrent_dir"];

$nfo_dir = $site_config["nfo_dir"];

//if(!copy($f, "$torrent_dir/$fname"))

if(!move_uploaded_file($tmpname, "$torrent_dir/$fname"))

show_error_msg("Error:","Error: File Could not be copied ".$file." - ".$torrent_dir." - ".$fname."",1);

$TorrentInfo = array();

$TorrentInfo = ParseTorrent("$torrent_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];

/*

//for debug...

print ("<BR><BR>announce: ".$announce."");

print ("<BR><BR>infohash: ".$infohash."");

print ("<BR><BR>creationdate: ".$creationdate."");

print ("<BR><BR>internalname: ".$internalname."");

print ("<BR><BR>torrentsize: ".$torrentsize."");

print ("<BR><BR>filecount: ".$filecount."");

print ("<BR><BR>annlist: ".$annlist."");

print ("<BR><BR>comment: ".$comment."");

*/

//check announce url is local or external

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

$external='yes';

}else{

$external='no';

}

//if externals is turned off

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

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

if ($message)

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

//release name check and adjust

if ($name ==""){

$name = $internalname;

}

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

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

//upload images

$maxfilesize = 512000; // 500kb

$allowed_types = array(

"image/gif" => "gif",

"image/pjpeg" => "jpg",

"image/jpeg" => "jpg",

"image/jpg" => "jpg",

"image/png" => "png"

);

for ($x=0; $x < 2; $x++) {

if (!($_FILES[image.$x]['name'] == "")) {

$y = $x + 1;

if (!array_key_exists($_FILES[image.$x]['type'], $allowed_types))

show_error_msg("Error","Invalid file type! Image $y",1);

if (!preg_match('/^(.+)\.(jpg|gif|png)$/si', $_FILES[image.$x]['name']))

show_error_msg("Invalid image", "This file TYPE is not image!",1);

if ($_FILES[image.$x]['size'] > $maxfilesize)

show_error_msg("Error","Invalid file size! Image $y - Must be less than 500kb",1);

$uploaddir = "".$site_config["torrent_dir"]."/images/";

$ifile = $_FILES[image.$x]['tmp_name'];

$ret = mysql_query("SHOW TABLE STATUS LIKE 'torrents'");

$row = mysql_fetch_array($ret);

$next_id = $row['Auto_increment'];

$ifilename = $next_id . $x . substr($_FILES[image.$x]['name'], strlen($_FILES[image.$x]['name'])-4, 4);

$copy = copy($ifile, $uploaddir.$ifilename);

if (!$copy)

show_error_msg("Error","Error occured uploading image! - Image $y",1);

$inames[] = $ifilename;

}

}

//end upload images

//anonymous upload

$anonyupload = unesc($_POST["anonycheck"]);

if ($anonyupload == "yes") {

$uploaderid = "0";

}else{

$uploaderid = $CURUSER["id"];

}

$ret = mysql_query("INSERT INTO torrents (filename, owner, name, descr, image1, image2, category, added, info_hash, size, numfiles, save_as, announce, external, nfo, torrentlang, anon, team) 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."','$anon','".$team."')");

$id = mysql_insert_id();

if (mysql_errno() == 1062)

show_error_msg("Upload Failed", "Torrent already uploaded.", 1);

//Update the members uploaded torrent count

/*if ($ret){

mysql_query("UPDATE users SET torrents = torrents + 1 WHERE id = $userid");*/

if($id == 0){

unlink("$torrent_dir/$fname");

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

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

}

rename("$torrent_dir/$fname", "$torrent_dir/$id.torrent");

if ($nfo == 'yes') {

move_uploaded_file($nfofilename, "$nfo_dir/$id.nfo");

}

//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]");

$query = "INSERT INTO shoutbox (msgid, user, message, date, userid) VALUES (NULL, 'System', 'New Torrent: ".$torrent.". has been uploaded by " .$CURUSER['username']. ".', now(), '0')";

mysql_query($query);

//insert email notif, irc, req notif, etc here

// Requests

if (isset($_POST['request'])) {

if ($_POST['request'] > 0) {

/* PM for requested user */

$res = mysql_query("SELECT `userid` FROM `requests` WHERE `id` = ". ($_POST['request'] + 0)) or die(mysql_error());

$re_msg = "Your request \"$torrent\" was filled by " . $CURUSER["username"] . ".You can download it

."/torrents-details.php?id=$id\"]HERE";

while($row = mysql_fetch_assoc($res)) {

mysql_query("INSERT INTO messages (poster, sender, receiver, added, msg) VALUES(0, 0, $row[userid], '" .

get_date_time(time()+(3600)) . "', " . sqlesc($re_msg) . ")") or die(mysql_error());

}

/* Fill request */

$filledurl = "http://www.infamoustracker.org/torrents-details.php?id=$id";

// @mysql_query("UPDATE requests SET WHERE `id` = ". ($_POST['request'] + 0));

mysql_query ("UPDATE requests SET filled = '$filledurl', filledby = $CURUSER[id] WHERE id = ". $_POST[request] ."") or die(mysql_error());

mysql_query("DELETE FROM `addedrequests` WHERE `requestid` = ". ($_POST['request'] + 0));

write_log("The request ($torrent) was filled by " . $CURUSER["username"] . "");

//Update points

}

}

//Uploaded ok message (update later)

if ($external=='no')

$message = "Torrent Uploadeded OK:<BR><BR>".$name." was uploaded.<BR><BR>  Please remember to re-download so that your passkey is added and you can seed this torrent<BR><BR><a href=download.php?id=".$id.">Download Now</a><BR><a href=torrents-details.php?id=".$id.">View Uploaded Torrent</a><BR><BR>";

else

$message = "Torrent Uploadeded OK:<BR><BR>".$name." was uploaded.<BR><BR><a href=torrents-details.php?id=".$id.">View Uploaded Torrent</a><BR><BR>";

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

die();

}//takeupload

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

stdhead("Upload");

begin_frame("" . UPLOAD_RULES . "");

echo "<b>".stripslashes($site_config["UPLOADRULES"])."</b>";

echo "<BR>";

end_frame();

begin_frame("" . UPLOAD . "");

?>

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

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

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

<?

print ("<TR><TD align=right valign=top>" . ANNOUNCE . ": </td><td align=left>");

while (list($key,$value) = each($announce_urls)) {

echo "<B>$value</B><br>";

}

if ($site_config["ALLOWEXTERNAL"]){

echo "<BR><B>This site accepts ALL external torrents also!</B>";

}

print ("</td></tr>");

print ("<TR><TD align=right>" . TORRENT_FILE . ": </td><td align=left> <input type=file name=torrent size=50 value=" . $_FILES['torrent']['name'] . ">\n</td></tr>");

print ("<TR><TD align=right>" . NFO . ": </td><td align=left> <input type=file name=nfo size=50 value=" . $_FILES['nfo']['name'] . "><br />\n</td></tr>");

print ("<TR><TD align=right>" . TNAME . ": </td><td align=left><input type=text name=name size=60 value=" . $_POST['name'] . "><BR>This will be taken from .torrent if left empty\n</td></tr>");

print ("<TR><TD align=right>Images</b>: </td><td align=left>Max File Size: 500kb<br>Accepted Formats: .gif, .jpg, .png<br><b>Image 1:</b>&nbsp&nbsp<input type=file name=image0 size=50><br><b>Image 2:</b>&nbsp&nbsp<input type=file name=image1 size=50>\n</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</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'] && $site_config["MEMBERSONLY"] ){ ?>

<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>

<?

}

//Request filled?

if ($site_config["REQUESTSON"]){

$sql_request = "SELECT `id`, `request` FROM requests WHERE filledby=0 ORDER BY `request` ASC";

$res = mysql_query($sql_request) or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) > 0) {

$request = "<select name=\"request\">\n<option value=\"0\">(Chose the request to be filled)</option>\n";

while($row = mysql_fetch_array($res)) {

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

}

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

//                tr("If your upload is to fill a request, select it here", $request , 1);

print("<tr><td align=right>If your upload is to fill a request, select it here</td><td

align=left>$request</td></tr>");

}

}

//end requests

//teams

if ($CURUSER["team"] != 0)

{

$userteam = $CURUSER["team"];

$teams = "--- None selected ----\n";

$sashok = mysql_query("SELECT id,name FROM teams WHERE id = $userteam ORDER BY name") or die;

while ($sasha = mysql_fetch_array($sashok))

$teams .= "

print("Team\n$teams\n");

}

print ("<TR><TD align=center colspan=2>" . TDESC . "</td></tr></table>");

require_once("backend/bbcode.php");

print ("".textbbcode("upload","descr","$descr")."");

?>

<BR><BR><CENTER><input type="submit" value="<? print("" . UPLOADT . "\n"); ?>"><BR>

<I>Click Once! - Uploading an image may take longer</I>

</CENTER>

</form>

<?

end_frame();

stdfoot();

?>
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: 3
  • Members: 0
  • Guests online: 3
  • Comments: 3
  • Messages: 1,728