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
Like Button Mod [In Progress]
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods in Progress

2020-03-02 14:24:04
This is a like button i have made it is fully working but doesn't show names of members who have thanked yet. Ive tried a join query with no luck so if any one can help would be very appreciated.

I havent tested this on v3 but it is fine on mine so any issues let me know and ill look at the query's

Its just like button on torrents for now but im going to add to forum as well here is the db structure
$id = table id
$lid = like id/ type so we can add others thanks, love etc like is type 1
$uid = user id
$pid = post id, this will be torrent id, shoutbox comment id, forumpost id, comment id etc

In torrent-details.php find
echo "</table></fieldset><br /><br />";

// $srating IS RATING VARIABLE


above add
// like mod
if(isset($_POST['like'])) {
   SQL_Query_exec("INSERT INTO likes (lid, uid, pid) VALUES (1, $CURUSER['id'], $row['id']));
   header('Location: '.$_SERVER['REQUEST_URI']);
   exit;
} elseif (isset($_POST['unlike'])) {
   SQL_Query_exec("DELETE FROM likes WHERE lid=1 AND uid=$CURUSER['id'] AND pid= $row['id']");
   header('Location: '.$_SERVER['REQUEST_URI']);
   exit;
}

/* Check Database */
$res2 = SQL_Query_exec("SELECT * FROM likes WHERE lid=1 AND uid=$CURUSER['id'] AND pid= $row['id']");
$row = mysqli_fetch_row($re2);
$likes = $row[0];

if (!$likes) {

   /* If No Result Like */
   print("<tr><td align='left'><b>Likes</b></td><td><form action='' method='post'>
             <input type='submit' name='like' value='Like' />
         </form></br></td></tr>");

} else {

   /* If Result UnLike */
   print("<tr><td align='left'><b>Likes</b></td><td><form action='' method='post'>
             <input type='submit' name='unlike' value='Unlike' />
         </form></br></td></tr>");

}


sql
CREATE TABLE IF NOT EXISTS `likes` (
 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 `lid` int(10) NOT NULL DEFAULT 0,
 `uid` int(10) NOT NULL DEFAULT 0,
 `pid` int(10) NOT NULL DEFAULT 0,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;





2020-03-02 23:13:33
I may play with this later, but do you think $row("username") would get you where you are wanting to be instead of printing $row("uid")? Thanks for making it. Perhaps something like SELECT id, username FROM users query? Im just guessing without testing. Its just a thought
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-03-03 07:18:50
Ive removed that for now and just left the button because it caused a issue with torrent comments for some reason
ive added to comments as well but
noticed now it will need another column for post type at minute i like everything with id 1
Just need to try forum comments
2020-03-03 07:50:36
Minor errors in the code. Mainly the queries. I remember having an issue with single quoting things like $row['id']. inside of a sql query. I forget why, but I believe you cant/shouldnt do that.  My editor reminded me about it because I forget everything lol. If im wrong, please educate me on what I missed :)

Missing a double quote at the end of this line
SQL_Query_exec("INSERT INTO likes (lid, uid, pid) VALUES (1, $CURUSER['id'], $row['id']));


My editor is happy with this code
// like mod
if(isset($_POST['like'])) {
   SQL_Query_exec("INSERT INTO likes (lid, uid, pid) VALUES (1, $CURUSER[id], $row[id])");
   header('Location: '.$_SERVER['REQUEST_URI']);
   exit;
} elseif (isset($_POST['unlike'])) {
   SQL_Query_exec("DELETE FROM likes WHERE lid=1 AND uid=$CURUSER[id] AND pid= $row[id]");
   header('Location: '.$_SERVER['REQUEST_URI']);
   exit;
}

/* Check Database */
$res2 = SQL_Query_exec("SELECT * FROM likes WHERE lid=1 AND uid=$CURUSER[id] AND pid= $row[id]");
$row = mysqli_fetch_row($re2);
$likes = $row[0];

if (!$likes) {

   /* If No Result Like */
   print("<tr><td align='left'><b>Likes</b></td><td><form action='' method='post'>
             <input type='submit' name='like' value='Like' />
         </form></br></td></tr>");

} else {

   /* If Result UnLike */
   print("<tr><td align='left'><b>Likes</b></td><td><form action='' method='post'>
             <input type='submit' name='unlike' value='Unlike' />
         </form></br></td></tr>");

}

TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-03-03 08:50:50
If you could add this hack with yours, it would be great

[url='https://www.torrenttrader.xyz/index.php?threads/mod-torrent-appreciation-links-ttv3.9939/']Here Link[/url]
2020-03-03 17:12:42
I hope to add more emotions angry, love, thanks - on torrents it seems easy  but comments are causing headache but we keep trying
I looked at that mod spirtblue in torrent-details near top dont forgot to add columns to big query torrent.angry, torrent.love, etc
2020-03-03 23:02:57
"m-jay, post: 68089, member: 20288":

I hope to add more emotions angry, love, thanks - on torrents it seems easy  but comments are causing headache but we keep trying
I looked at that mod spirtblue in torrent-details near top dont forgot to add columns to big query torrent.angry, torrent.love, etc

even too true! lol
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: 8
  • Members: 0
  • Guests online: 8
  • Comments: 3
  • Messages: 1,728