Taken from Krapan's post [url="http://www.torrenttrader.org/index.php?showtopic=675"]here[/url] and modified to fit 2.x.
Dont forget to backup!
SQL:
And voila, thanks mod works on 2.x :P
Tested and working.
Dont forget to backup!
SQL:
CREATE TABLE `thanks` (
`torrentid` int(11) NOT NULL default '0',
`userid` int(11) NOT NULL default '0',
`id` int(11) NOT NULL auto_increment,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=743;Open torrent-details.php and find (or wherever it is you want to add it...): $a = mysql_fetch_assoc($speedQ);
$totalspeed = mksize($a["totalspeed"]) . "/s";
}else{
$totalspeed = "No Activity";
}
Below, add:
// Thanx mod
$torrentid = $_GET["id"];
$thanks_sql = mysql_query("SELECT * FROM thanks where torrentid=$torrentid");
$thanks_all = mysql_numrows($thanks_sql);
if ($thanks_all) {
while($rows_t = mysql_fetch_array($thanks_sql)) {
$thanks_userid = $rows_t["userid"];
$user_sql = mysql_query("SELECT * FROM users where id=$thanks_userid");
$rows_a = mysql_fetch_array($user_sql);
$username_t = $rows_a["username"];
$thanksby = $thanksby."<a href='userdetails.php?id=$thanks_userid'>$username_t</a>, ";
}
$t_userid = $CURUSER["id"];
$tsql = mysql_query("SELECT COUNT(*) FROM thanks where torrentid=$torrentid and userid=$t_userid");
$trows = mysql_fetch_array($tsql);
$t_ab = $trows[0];
if ($t_ab == "0" && $CURUSER["id"] != $row["owner"]) {
$thanksby = $thanksby." <form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" value=\"Say Thanks!\">
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
</form>";
}
else {
$thanksby = $thanksby." <form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" value=\"Say Thanks!\" disabled>
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
</form>";
}
}
else {
if ($CURUSER["id"] == $row["owner"]){
$thanksby = $thanksby." <form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" value=\"Say Thanks!\" disabled>
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
</form>";
}
else
$thanksby = "No Thanks Yet
<form action=\"thanks.php\" method=\"post\">
<input type=\"submit\" name=\"submit\" value=\"Say Thanks!\">
<input type=\"hidden\" name=\"torrentid\" value=\"$torrentid\">
</form>
";
} print("<br><table><tr>
<td valign=top><table border=0 width=100 cellspacing=0 cellpadding=0><tr><td class=alt5 align=center><b>Thanks by</b></td>
</tr></table></td><td width=100%>" . $thanksby . "</td></tr></table>");
//Thanx mod end
Create a file called thanks.php and paste this:
<?
require("backend/functions.php");
dbconn();
$userid = $CURUSER["id"];
$torrentid = $_POST["torrentid"];
if (isset($userid) && isset($torrentid))
{
$res = mysql_query("INSERT INTO thanks (torrentid, userid) VALUES ($torrentid, $userid)");
header("Location: $SITEURL/torrents-details.php?id=$torrentid&thanks=1");
}
else {
header("Location: $SITEURL/index.php");
}
?>And voila, thanks mod works on 2.x :P
Tested and working.
