thanks TorrentialStorm.
$thanksl = explode(",", $row['thanks']);
if ($CURUSER['username'] == $row['username'] || !$CURUSER) $leftthanks = true;
foreach ($thanksl as $u) {
$thanks .= ($i>0)?", $u":$u;
if ($u == $CURUSER['username']) $leftthanks = true;
$i++;
}
if (!$thanks) $thanks = "No one yet.";
print("<tr><td align=left><b>Thanks By:</b></td><td>$thanks</td></tr>\n");
if (!$leftthanks) print("<tr><td align=left> </td><td><form action=thanks.php method=POST><input type=hidden name=torrent value=$id><input type=submit value='Thanks!'></form></td></tr>\n");
"Torrential-Storm.co.uk, post: 33304":torrents-details.php, find:
replace with:$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());
$res = mysql_query("SELECT torrents.seeders, torrents.thanks, 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());
find:
print("<tr><td align=left><b>" . HITS . ":</b></td><td>" . $row["hits"] . "</td></tr>\n");
add below:
$thanksl = explode(",", $row['thanks']);
if ($CURUSER['username'] == $row['username'] || !$CURUSER) $leftthanks = true;
foreach ($thanksl as $u) {
$thanks .= ($i>0)?", $u":$u;
if ($u == $CURUSER['username']) $leftthanks = true;
$i++;
}
if (!$thanks) $thanks = "No one yet.";
print("<tr><td align=left><b>Thanks By:</b></td><td>$thanks</td></tr>\n");
if (!$leftthanks) print("<tr><td align=left> </td><td><form action=thanks.php method=POST><input type=hidden name=torrent value=$id><input type=submit value='Thanks!'></form></td></tr>\n");
create "thanks.php":
<?php
require_once("backend/functions.php");
dbconn(false);
loggedinonly();
$id = (int)$_POST['torrent'];
if (!is_valid_id($id)) die;
$res = mysql_query("SELECT `thanks` FROM torrents WHERE id=$id");
$row = mysql_fetch_assoc($res);
mysql_free_result($res);
if (!$row) show_error_msg("Error", "Sorry no .torrent found with this ID, it has probably been deleted.",1);
$thanksl = explode(",", $row['thanks']);
if (in_array($CURUSER['username'], $thanksl)) show_error_msg("Error", "You have already left thanks for this torrent.",1);
mysql_query(sprintf("UPDATE `torrents` SET thanks = CONCAT_WS(',', `thanks`, %s) WHERE `id`=%d", sqlesc($CURUSER['username']), $id)) or die(mysql_error());
header("Refresh: 3;url=torrents-details.php?id=$id");
show_error_msg("Success", "Thanks added.<BR>Redirecting...", 1);
?>
run this query:
ALTER TABLE `torrents` ADD `thanks` LONGTEXT;
No users online
Torrents
Members
Online