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
TT Mod Thanks & Likes (added to pdo)
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2020-06-04 08:02:48
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]

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>&nbsp;");
   }
   }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");
   }
   }
like.png
like.png
unlike.png
unlike.png
Untitled.png
Untitled.png
Untitled1.png
Untitled1.png
2020-06-05 08:07:21
first post updated split functions so now say thanks to download and likes/reactions are seperate
2020-06-11 01:55:45
I should make likes for comments
2020-06-11 06:10:32
add anything you wish  (y) been distracted with server but this can go a few places just the link to the controllermethod/page needs changing ive updated 1st post, the type in likes table need to be changed comment for comment, forum for forum etc

for comments its this line in commenttable function
print('<th align="right">' . $edit . $delete . '[<a href="$site_config[SITEURL]/report?comment=' . $row["id"] . '">Report</a>] Posted: ' . date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row["added"])) . '<a id="comment' . $row["id"] . '"></a></th>');
2020-06-11 07:58:49
"m-jay, post: 68715, member: 20288":

add anything you wish  (y) been distracted with server but this can go a few places just the link to the controllermethod/page needs changing ive updated 1st post, the type in likes table need to be changed comment for comment, forum for forum etc

for comments its this line in commenttable function
print('<th align="right">' . $edit . $delete . '[<a href="$site_config[SITEURL]/report?comment=' . $row["id"] . '">Report</a>] Posted: ' . date("d-m-Y \\a\\t H:i:s", utc_to_tz_time($row["added"])) . '<a id="comment' . $row["id"] . '"></a></th>');


This is capable of comment likes already? I'll run my code and do a bit different for V3-stock, tables are easy to generate and paste in to code. "username liked this", "2 up votes", "2 down votes", "rep +5" etc etc
2020-06-11 11:02:19
[ATTACH type="full" alt="Trophies43.png"]5587[/ATTACH]

Trophies. Earn trophies (badges) for using certain parts of the site. Will show off to all, some will be hard to find and some will be redeemable as Prestige trophies (so your connection is your only hope for remedying in seedbonus page.

Hovering over that book and start reveal the tooltip that explains the reason for their trophy. New table, setup so they can only earn it one time (no primary key in table), works a charm.

Moods mod updated to check, uses new table, added while loop thats all.

So far, its just for forums.php


// TROPHIE: FIRST FORUM TOPIC
       SQL_Query_exec("INSERT INTO users_trophies (userid, trophie, reason, trophiepic) VALUES
       ($CURUSER[id], 'First Forum Topic', 'Earned Bookworm Trophie for posting their first forum topic.', 'images/trophies/firstforumtopic.png')");


And torrents-details.php


// TROPHIE: FIRST TORRENT COMMENT
   SQL_Query_exec("INSERT INTO users_trophies (userid, trophie, reason, trophiepic) VALUES
   ($CURUSER[id], 'First Comment', 'Earned Star Trophie for posting their first torrent comment.', 'images/trophies/firstcomment.png')");


The rest is vector/PNG in /images/trophies/*

Somewhere in functions.php torrenttable()


$trophieq = SQL_Query_exec("SELECT userid, trophie, trophiepic, reason FROM users_trophies LEFT JOIN users ON users.id = users_trophies.userid WHERE users_trophies.userid = $result2[user]");
           if (mysql_num_rows($trophieq)){
               while($trophie = mysql_fetch_assoc($trophieq)) {
           
               // Retrieve users trophies - June 11, 2020
               $trophiename = $trophie["trophie"];
               $reasonalt   = $trophie["reason"];
               $trophiepic  = $trophie["trophiepic"];
           
               echo "<span style='float:left;padding-right:3px'><img src='$site_config[SITEURL]/$trophiepic' title='$reasonalt' style='height:25px' /></span>";
               }
           }else{
               echo "<div style='font-size:12px;color:#C0C0C0'>(none yet)</div>";
           }
           echo "</div>";


SQL:


CREATE TABLE `users_trophies` (
 `userid` int(10) unsigned NOT NULL DEFAULT 0,
 `trophie` text NOT NULL,
 `reason` text NOT NULL,
 `trophiepic` text NOT NULL,
 UNIQUE KEY `userfriend` (`userid`,`reason`) USING HASH
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Untitled.png
Untitled.png
2020-06-16 07:24:44
hard to get motivated at minute but made a start on forums just need some more conditions turn on/off ive also made hide one forum were you can not see replys unless you say thanks to first posts, work in progress but nearly there

the method/page

   // Thanks on forum
   public function forum(){
   dbconn();
   global $site_config, $CURUSER;
   $topicid = (int)$_GET['id'];
   if (!is_valid_id($topicid));
   DB::run("INSERT INTO thanks (user, thanked, added, type) VALUES (?, ?, ?, ?)",[$CURUSER['id'], $topicid, get_date_time(), 'forum']);
   header("Refresh: 3;url=$site_config[SITEURL]/forum/viewtopic&topicid=$topicid");
   show_error_msg("Success", "Thanks you for you forum appreciation.",1);
   }


find in forums
//Get topic posts


add under
/* LIKE MOD */
// this will be site_config['hideforum'] we dont want to block everything
if ($forumid == 1) {
   $res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id LIMIT 1");

   // if its the forum lets see if member has thanked
   $data = DB::run("SELECT user FROM thanks WHERE thanked = ? AND type = ? AND user = ?", [$topicid, 'forum', $CURUSER['id']]);
   $like = $data->fetch(PDO::FETCH_ASSOC);
// like is not there so limit to first post
if (!$like){
   $res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id LIMIT 1");
// like is there so show all
} else {
   $res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id LIMIT $offset,$perpage");
}

// if its not the site_config['hideforum'] display as normal
} else {
   $res = DB::run("SELECT * FROM forum_posts WHERE topicid=$topicid ORDER BY id LIMIT $offset,$perpage");
}



before this line //define buttons and who can use them
    /* LIKE MOD */
   // if not post owner hide replys
   if (!$CURUSER["id"] == $posterid){
       // say thanks
       print ("<a href='$site_config[SITEURL]/likes/forum?id=$topicid'>Say Thanks</a>&nbsp;");
   }


just noticed it could be each post id instead of topic lol
2020-06-16 10:24:22
Hey [USER=20288]@m-jay[/USER] ,

While ur in the forum code, please note the following :-)

When posting new topic >
- Subject is more logical on top of text field, and is actually very small
- Text field for new topic is small

When editing topic >
- Forum post when editing is not saved
If It Ain't Dutch, It Ain't Much!!
2024-01-04 21:56:17
It would be possible to have the magnet side on mysqli v3 for the thank you before downloading, thank you!
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: 9
  • Members: 0
  • Guests online: 9
  • Comments: 3
  • Messages: 1,728