Quick replacement ive made to replace thanks mod which used concat & js and now is extended to likes for comments, torrents etc fully working
[color=rgb(247, 218, 100)]if thanks enabled you must click thanks or message pops up excludes your own torrents
if likes enabled you may like/unlike posts these can be place multiple places[/color]
ill add this to base with config option ? its here for thoughts & suggestions & its nice to share for those on v3 to follow if you wish its just query's that vary a little
ill update this as i go if there is interest
I decided to split into 2 mods thanks & likes
sql help [color=rgb(247, 218, 100)] type = torrent, post, comment, user [/color] id = curuserid [color=rgb(247, 218, 100)]liked = id of thing liked[/color]
config
DOWNLOAD or we can just keep it universal with a message when trying to download
example torrent details hide magnet link
example torrent table hide magnet link ( this is where i link my controller '$site_config[SITEURL]/likes/index )
controller (for v3 make separate pages and change links eg $site_config[SITEURL]/likes/index )
post like buttons on torrent details
[color=rgb(247, 218, 100)]if thanks enabled you must click thanks or message pops up excludes your own torrents
if likes enabled you may like/unlike posts these can be place multiple places[/color]
ill add this to base with config option ? its here for thoughts & suggestions & its nice to share for those on v3 to follow if you wish its just query's that vary a little
ill update this as i go if there is interest
I decided to split into 2 mods thanks & likes
sql help [color=rgb(247, 218, 100)] type = torrent, post, comment, user [/color] id = curuserid [color=rgb(247, 218, 100)]liked = id of thing liked[/color]
CREATE TABLE `thanks` (
`id` int(10) unsigned NOT NULL auto_increment,
`user` int(10) unsigned NOT NULL default '0',
`thanked` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`type` text NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user`),
KEY `thanked` (`thanked`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
CREATE TABLE `likes` (
`id` int(10) unsigned NOT NULL auto_increment,
`user` int(10) unsigned NOT NULL default '0',
`liked` int(10) unsigned NOT NULL default '0',
`added` datetime NOT NULL default '0000-00-00 00:00:00',
`reaction` text NOT NULL,
`type` text NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user`),
KEY `liked` (`liked`)
) ENGINE=MyISAM AUTO_INCREMENT=1 ;
config
// likes
$site_config["forcethanks"] = true; // force members to thanks
$site_config['allowlikes'] = true; // allow likes/unlikes
DOWNLOAD or we can just keep it universal with a message when trying to download
// LIKE MOD
if($site_config["forcethanks"]) {
$data = DB::run("SELECT user FROM thanks WHERE thanked = ? & type = ? & user = ?", [$id, 'torrent', $CURUSER['id']]);
$like = $data->fetch(PDO::FETCH_ASSOC);
if(!$like){
show_error_msg(T_("ERROR"), T_("PLEASE_THANK"), 1);
}
}
example torrent details hide magnet link
// Like Mod
if(!$site_config["forcethanks"]) {
// Magnet
if ($row["external"] == 'yes'){
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=udp://tracker.openbittorrent.com&tr=udp://tracker.publicbt.com\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}else{
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=".$site_config['SITEURL']."/announce.php?passkey=".$CURUSER["passkey"]."\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}
}
if($CURUSER["id"] != $row["owner"] && $site_config["forcethanks"]) {
$data = DB::run("SELECT user FROM thanks WHERE thanked = ? AND type = ? AND user = ?", [$id, 'torrent', $CURUSER['id']]);
$like = $data->fetch(PDO::FETCH_ASSOC);
if($like){
// Magnet
if ($row["external"] == 'yes'){
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=udp://tracker.openbittorrent.com&tr=udp://tracker.publicbt.com\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}else{
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=".$site_config['SITEURL']."/announce.php?passkey=".$CURUSER["passkey"]."\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}
}else {
print("<a href='$site_config[SITEURL]/likes/details?id=$id'><button class='btn btn-sm btn-danger'>Thanks</button></a> ");
}
}else{
if ($row["external"] == 'yes'){
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=udp://tracker.openbittorrent.com&tr=udp://tracker.publicbt.com\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}else{
print ("<a href=\"magnet:?xt=urn:btih:".$row["info_hash"]."&dn=".$row["filename"]."&tr=".$site_config['SITEURL']."/announce.php?passkey=".$CURUSER["passkey"]."\"><button type='button' class='btn btn-sm btn-danger'>Magnet Download</button></a>");
}
}
example torrent table hide magnet link ( this is where i link my controller '$site_config[SITEURL]/likes/index )
case 'magnet':
$magnet = $pdo->run("SELECT info_hash FROM torrents WHERE id=?", [$id])->fetch();
// Like Mod
if(!$site_config["forcethanks"]) {
print("<td class='ttable_col$x' align='center'><a href=\"magnet:?xt=urn:btih:" . $magnet["info_hash"] . "&dn=" . rawurlencode($row['name']) . "&tr=" . $row['announce'] . "?passkey=" . $CURUSER['passkey'] . "\"><img src='" . $site_config['SITEURL'] . "/images/magnetique.png' border='0' title='Download via Magnet' /></a></td>");
}
if($CURUSER["id"] != $row["owner"] && $site_config["forcethanks"]) {
$data = DB::run("SELECT user FROM thanks WHERE thanked = ? AND type = ? AND user = ?", [$id, 'torrent', $CURUSER['id']]);
$like = $data->fetch(PDO::FETCH_ASSOC);
if($like){
print("<td class='ttable_col$x' align='center'><a href=\"magnet:?xt=urn:btih:" . $magnet["info_hash"] . "&dn=" . rawurlencode($row['name']) . "&tr=" . $row['announce'] . "?passkey=" . $CURUSER['passkey'] . "\"><img src='" . $site_config['SITEURL'] . "/images/magnetique.png' border='0' title='Download via Magnet' /></a></td>");
}else {
print ("<td class='ttable_col$x' align='center'><a href='$site_config[SITEURL]/likes/index?id=$id' ><button class='btn btn-sm btn-danger'>Thanks</button></td>");
}
}else{
print("<td class='ttable_col$x' align='center'><a href=\"magnet:?xt=urn:btih:" . $magnet["info_hash"] . "&dn=" . rawurlencode($row['name']) . "&tr=" . $row['announce'] . "?passkey=" . $CURUSER['passkey'] . "\"><img src='" . $site_config['SITEURL'] . "/images/magnetique.png' border='0' title='Download via Magnet' /></a></td>");
}
break;
controller (for v3 make separate pages and change links eg $site_config[SITEURL]/likes/index )
<?php
class Likes extends Controller {
public function __construct(){
}
// Thanks on index
public function index(){
dbconn();
global $site_config, $CURUSER;
$id = (int)$_GET['id'];
if (!is_valid_id($id));
DB::run("INSERT INTO thanks (user, thanked, added, type) VALUES (?, ?, ?, ?)",[$CURUSER['id'], $id, get_date_time(), 'torrent']);
header("Refresh: 3;url=$site_config[SITEURL]/index.php");
show_error_msg("Error", "Thanks you for you appreciation.",1);
}
// Thanks on details
public function details(){
dbconn();
global $site_config, $CURUSER;
$id = (int)$_GET['id'];
if (!is_valid_id($id));
DB::run("INSERT INTO thanks (user, thanked, added, type) VALUES (?, ?, ?, ?)",[$CURUSER['id'], $id, get_date_time(), 'torrent']);
header("Refresh: 3;url=$site_config[SITEURL]/torrents/details?id=$id");
show_error_msg("Error", "Thanks you for you appreciation.",1);
}
public function liketorrent(){
dbconn();
global $site_config, $CURUSER;
$id = (int)$_GET['id'];
if (!is_valid_id($id));
DB::run("INSERT INTO likes (user, liked, added, type, reaction) VALUES (?, ?, ?, ?, ?)",[$CURUSER['id'], $id, get_date_time(), 'torrent', 'like']);
header("Refresh: 3;url=$site_config[SITEURL]/torrents/details?id=$id");
show_error_msg("Error", "Thanks you for you appreciation.",1);
}
public function unliketorrent(){
dbconn();
global $site_config, $CURUSER;
$id = (int)$_GET['id'];
if (!is_valid_id($id));
DB::run("DELETE FROM likes WHERE user=? AND liked=? AND type=?", [$CURUSER['id'], $id, 'torrent']);
header("Refresh: 3;url=$site_config[SITEURL]/torrents/details?id=$id");
show_error_msg("Error", "Sorry you dont like.",1);
}
}
post like buttons on torrent details
// LIKE MOD
if($site_config["allowlikes"]) {
$data = DB::run("SELECT user FROM likes WHERE liked=? AND type=? AND user=? AND reaction=?", [$id, 'torrent', $CURUSER['id'], 'like']);
$likes = $data->fetch(PDO::FETCH_ASSOC);
if($likes){
print("<tr><td align='left'><b>Reaction:</b></td><td><a href='$site_config[SITEURL]/likes/unliketorrent?id=$id'><img src='/images/unlike.png' width='80' height='40' border='0'></a></td></tr>\n");
}else{
print("<tr><td align='left'><b>Reaction:</b></td><td><a href='$site_config[SITEURL]/likes/liketorrent?id=$id'><img src='/images/like.png' width='80' height='40' border='0'></a></td></tr>\n");
}
}

