09 Bookmarks by pdq

Started by Mindless, July 21, 2012, 09:36:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mindless

Yeah i know, but thats what im saying use u-232 as your point of reference, good chance thats shit is all covered and addressed in the release code on github, what more reference can you wish for =]

Kustff

Quote from: Mindless on August 17, 2014, 10:23:10 AM
Quote from: Kustff on August 16, 2014, 09:03:08 PM
I don't know what is the properly code but this mod not 100% ready. Not tested etc.. Is there same problem in u232 bookmark mods?

This mod was created by pdq in 2008 for Tbdev 09, it worked perfect, it was tested, I updated it further for Tbdev 09/u-232, so that was 5 years ago maybe more, but yeah it was never tested or ready, listen to yourself there. Now if you were indeed a coder then this wouldn't even be discussed. Nothing wrong with the bookmark mod so please refrain from posting unfounded statements =]

https://github.com/Bigjoos/U-232-V3/blob/master/delete.php
https://github.com/Bigjoos/U-232-V3/blob/master/include/cleanup/delete_torrents_update.php

Maybe its worth checking what's in the release before jumping to conclusions.

You're right but I'm using tbdev09

Mindless

#9
Quote from: Kustff on August 16, 2014, 09:03:08 PM
I don't know what is the properly code but this mod not 100% ready. Not tested etc.. Is there same problem in u232 bookmark mods?

This mod was created by pdq in 2008 for Tbdev 09, it worked perfect, it was tested, I updated it further for Tbdev 09/u-232, so that was 5 years ago maybe more, but yeah it was never tested or ready, listen to yourself there. Now if you were indeed a coder then this wouldn't even be discussed. Nothing wrong with the bookmark mod so please refrain from posting unfounded statements =]

https://github.com/Bigjoos/U-232-V3/blob/master/delete.php
https://github.com/Bigjoos/U-232-V3/blob/master/include/cleanup/delete_torrents_update.php

Maybe its worth checking what's in the release before jumping to conclusions.

Kustff

Quote from: stoner on August 16, 2014, 06:18:09 PM
Not looked at the code.  But something like that.

I dont think you will need the userid bit though.  Just delete ALL bookmarks with the torrent id which is being deleted.

I don't know what is the properly code but this mod not 100% ready. Not tested etc.. Is there same problem in u232 bookmark mods?

stoner

Not looked at the code.  But something like that.

I dont think you will need the userid bit though.  Just delete ALL bookmarks with the torrent id which is being deleted.

Kustff

Quote from: stoner on August 16, 2014, 04:20:41 PM
Looks like you will need some code in the torrent cleanup section. 

Make it delete any bookmarks associated with that torrent.

Something like this?

Code (php) Select
mysql_query("DELETE FROM bookmarks WHERE torrentid = $torrentid AND userid = $CURUSER[id]");

stoner

Looks like you will need some code in the torrent cleanup section. 

Make it delete any bookmarks associated with that torrent. 

Kustff

I have little problem in here.. When torrent was deleted it's give me a error in my bookmarks.php page..

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/bookmarks.php on line 109

And there is empty bookmark column.

Is there any fixes in this mod?

ndbj

Nevermind.
I coded one myself already.

ndbj

Hi everybody!
Could someone please adapt this mod to be installed in old tbdev source?
It would be very usefull.

I'm running a 2008 tbdev sorce.
Thanks in advance.

Mindless

Credits to pdq.
Xhtml Valid.
Thanks to putyn for some html fixes.

Ok heres the bookmark mod for default install nothing added at all - You can alter it easy and add anonymous,sticky,new ect ect.

This one is not finished as such and will change a lot before its a complete and working mod - Plan is to drop the 3 files and use 1 instead with updated code but until then it works just fine and can be used if you want it.

Run the sql :

Code (sql) Select
CREATE TABLE `bookmarks` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `userid` int(10) unsigned NOT NULL default '0',
  `torrentid` int(10) unsigned NOT NULL default '0',
  `private` enum('yes','no') character set utf8 NOT NULL default 'yes',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


In include/torrent_table_functions.php find :

Code (php) Select
$htmlout .= "<table border='1' cellspacing='0' cellpadding='5'>
   <tr>
   <td class='colhead' align='center'>{$lang["torrenttable_type"]}</td>
   <td class='colhead' align='left'><a href='{$TBDEV['baseurl']}/browse.php?{$oldlink}sort=1&amp;type={$link1}'>{$lang["torrenttable_name"]}</a></td>
   ";

   
Under that add :

Code (php) Select
$htmlout.= ($variant == 'index' ? "<td class='colhead' align='center'><a href='".$TBDEV['baseurl']."/bookmarks.php'><img src='".$TBDEV['pic_base_url']."bookmark.gif'  border='0' alt='Bookmark' title='Bookmark' /></a></td>" : '');

Still there little lower find your mytorrents block :

Code (php) Select
if ($variant == "mytorrents")
        {
            $htmlout .= "<td align='right'>";
            if ($row["visible"] == "no")
                $htmlout .= "<b>".$lang["torrenttable_not_visible"]."</b>";
            else
                $htmlout .= "".$lang["torrenttable_visible"]."";
            $htmlout .= "</td>\n";
        }


Under that add :

Code (php) Select
$bookmarked = (!isset($row["bookmark"]) ? "<a href='bookmark.php?torrent=" . $id . "&amp;action=add'><img src='" . $TBDEV['pic_base_url'] . "bookmark.gif' border='0' alt='Bookmark it!' title='Bookmark it!' /></a>":"<a href='bookmark.php?torrent=" . $id . "&amp;action=delete'><img src='" . $TBDEV['pic_base_url'] . "plus2.gif' border='0' alt='Delete Bookmark!' title='Delete Bookmark!' /></a>");
        if ($variant == "index") 
        $htmlout.="<td align='right'>{$bookmarked}</td>";

       
Save and upload bookmark.php :

Code (php) Select
<?php
//==bookmark.php - by pdq
require_once "include/bittorrent.php";
require_once 
"include/user_functions.php";
dbconn();
loggedinorreturn();

$lang =  array_mergeload_language('global') );

$HTMLOUT='';

if (!
mkglobal("torrent"))
stderr("Error""missing form data");

$userid $CURUSER['id'];
if (!
is_valid_id($userid))
stderr("Error""Invalid ID.");

if (
$userid != $CURUSER["id"])
stderr("Error""Access denied.");

$torrentid $_GET["torrent"];
if (!
is_valid_id($torrentid))
die();

if (!isset(
$torrentid))
stderr("Error""Failed. No torrent selected");

$action = isset($_GET["action"]) ?$_GET["action"] : '';

if (
$action == 'add')
{

$torrentid = (int)$_GET['torrent'];
$sure = isset($_GET['sure'])?$_GET['sure']:'';
if (!
is_valid_id($torrentid))
stderr("Error""Invalid ID.");

$hash md5('s5l6t0mu55yt4hwa7e5'.$torrentid.'add'.'s5l6t0mu55yt4hwa7e5');
if (!
$sure)
 
stderr("Add Bookmark","Do you really want to add this bookmark? Click\n" .
"<a href='?torrent=$torrentid&amp;action=add&amp;sure=1&amp;h=$hash'>here</a> if you are sure."FALSE);

if (
$_GET['h'] != $hash)
stderr('Error','what are you doing?');

function 
addbookmark($torrentid) {
global 
$CURUSER;
if ((
get_row_count("bookmarks""WHERE userid=$CURUSER[id] AND torrentid = $torrentid")) > 0)
stderr("Error""Torrent already bookmarked");
mysql_query("INSERT INTO bookmarks (userid, torrentid) VALUES ($CURUSER[id]$torrentid)") or sqlerr(__FILE__,__LINE__);
}

$HTMLOUT .= addbookmark($torrentid);
$HTMLOUT .="<h2>Bookmark added!</h2>";
}

if (
$action == 'delete')
{
$torrentid = (int)$_GET['torrent'];
$sure = isset($_GET['sure'])?$_GET['sure']:'';
if (!
is_valid_id($torrentid))
stderr("Error""Invalid ID.");

$hash md5('s5l6t0mu55yt4hwa7e5'.$torrentid .'delete'.'s5l6t0mu55yt4hwa7e5');
if (!
$sure)
stderr("Delete Bookmark","Do you really want to delete this bookmark? Click\n" .
"<a href='?torrent=$torrentid&amp;action=delete&amp;sure=1&amp;h=$hash'>here</a> if you are sure."FALSE);

if (
$_GET['h'] != $hash)
stderr('Error','what are you doing?');

function 
deletebookmark($torrentid) {
global 
$CURUSER;
mysql_query("DELETE FROM bookmarks WHERE torrentid = $torrentid AND userid = $CURUSER[id]");
}

$HTMLOUT .= deletebookmark($torrentid);
$HTMLOUT .="<h2>Bookmark deleted!</h2>";
}

elseif (
$action == 'public')
{
$torrentid = (int)$_GET['torrent'];
$sure = isset($_GET['sure'])?$_GET['sure']:'';
if (!
is_valid_id($torrentid))
stderr("Error""Invalid ID.");

$hash md5('s5l6t0mu55yt4hwa7e5'.$torrentid.'public'.'s5l6t0mu55yt4hwa7e5');
if (!
$sure)
stderr("Share Bookmark","Do you really want to mark this bookmark public? Click\n" .
"<a href='?torrent=$torrentid&amp;action=public&amp;sure=1&amp;h=$hash'>here</a> if you are sure."FALSE);

if (
$_GET['h'] != $hash)
stderr('Error','what are you doing?');

function 
publickbookmark($torrentid) {
global 
$CURUSER;
mysql_query("UPDATE bookmarks SET private = 'no' WHERE private = 'yes' AND torrentid = $torrentid AND userid = $CURUSER[id]");
}

$HTMLOUT .= publickbookmark($torrentid);
$HTMLOUT .="<h2>Bookmark made public!</h2>";
}

elseif (
$action == 'private')
{
$torrentid = (int)$_GET['torrent'];
$sure = isset($_GET['sure'])?$_GET['sure']:'';
if (!
is_valid_id($torrentid))
stderr("Error""Invalid ID.");

$hash md5('s5l6t0mu55yt4hwa7e5'.$torrentid.'private'.'s5l6t0mu55yt4hwa7e5');
if (!
$sure)
stderr("Make Bookmark Private","Do you really want to mark this bookmark private? Click\n" .
"<a href='?torrent=$torrentid&amp;action=private&amp;sure=1&amp;h=$hash'>here</a> if you are sure."FALSE);

if (
$_GET['h'] != $hash)
stderr('Error','what are you doing?');

if (!
is_valid_id($torrentid))
stderr("Error""Invalid ID.");

function 
privatebookmark($torrentid) {
global 
$CURUSER;
mysql_query("UPDATE bookmarks SET private = 'yes' WHERE private = 'no' AND torrentid = $torrentid AND userid = $CURUSER[id]");
}

$HTMLOUT .= privatebookmark($torrentid);
$HTMLOUT .="<h2>Bookmark made private!</h2>";
}

if (isset(
$_POST["returnto"]))
$ret "<a href=\"" htmlspecialchars($_POST["returnto"]) . "\">Go back to whence you came</a>";
else
$ret "<a href=\"bookmarks.php\">Go to My Bookmarks</a><br /><br />
<a href=\"browse.php\">Go to Browse</a>"
;
    
$HTMLOUT .= $ret;
print 
stdhead('Bookmark') . $HTMLOUT stdfoot();
?>


Save and upload bookmarks.php :

Code (php) Select
<?php
//==bookmarks.php - by pdq
require_once("include/bittorrent.php");
require_once(
"include/pager_functions.php");
require_once (
"include/user_functions.php");
require_once (
"include/torrenttable_functions.php");
dbconn(false);
loggedinorreturn();

$lang array_mergeload_language('global'), load_language('torrenttable_functions') );

$htmlout='';

function 
bookmarktable($res$variant "index")
{
global 
$TBDEV$CURUSER$lang;
   
$htmlout '';
   
$htmlout .= "
   <span>Icon Legend :
   <img src='
{$TBDEV['pic_base_url']}plus.gif' alt='Delete Bookmark' border='none' /> = Delete Bookmark |
   <img src='
{$TBDEV['pic_base_url']}download.gif' alt='Download Bookmark' border='none' />= Download Torrent |
   <img alt='Bookmark is Private' src='
{$TBDEV['pic_base_url']}key.gif' border='none'  /> = Bookmark is Private |
   <img src='
{$TBDEV['pic_base_url']}public.gif' alt='Bookmark is Public' border='none'  /> = Bookmark is Public</span>
   <table border='1' cellspacing='0' cellpadding='5'>
   <tr>
   <td class='colhead' align='center'>
{$lang["torrenttable_type"]}</td>
   <td class='colhead' align='left'>
{$lang["torrenttable_name"]}</td>";
   

   
$htmlout.= ($variant == 'index' '<td class="colhead" align="center">Delete</td><td class="colhead" align="right">' '') . 'Download</td><td class="colhead" align="right">Share</td>';
    

   if (
$variant == "mytorrents")
   {
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_edit"]}</td>\n";
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_visible"]}</td>\n";
   }

   
$htmlout .= "<td class='colhead' align='right'>{$lang["torrenttable_files"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_comments"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_added"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_size"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_snatched"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_seeders"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_leechers"]}</td>";

   if (
$variant == 'index')
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_uppedby"]}</td>\n";

    
$htmlout .= "</tr>\n";

    while (
$row mysql_fetch_assoc($res)) 
    {
        
$id $row["id"];
        
$htmlout .= "<tr>\n";
        
$htmlout .= "<td align='center' style='padding: 0px'>";
        if (isset(
$row["cat_name"])) 
        {
            
$htmlout .= "<a href='browse.php?cat={$row['category']}'>";
            if (isset(
$row["cat_pic"]) && $row["cat_pic"] != "")
                
$htmlout .= "<img border='0' src='{$TBDEV['pic_base_url']}caticons/{$row['cat_pic']}' alt='{$row['cat_name']}' />";
            else
            {
                
$htmlout .= $row["cat_name"];
            }
            
$htmlout .= "</a>";
        }
        else
        {
            
$htmlout .= "-";
        }
        
$htmlout .= "</td>\n";

        
$dispname htmlspecialchars($row["name"]);
        
$htmlout .= "<td align='left'><a href='details.php?";
        if (
$variant == "mytorrents")
            
$htmlout .= "returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&amp;";
        
$htmlout .= "id=$id";
        if (
$variant == "index")
            
$htmlout .= "&amp;hit=1";
       
      
      
$htmlout .= "'><b>$dispname</b></a>&nbsp;</td>\n";

      
$htmlout.= ($variant == "index" "<td align='center'><a href='bookmark.php?torrent=".$id."&amp;action=delete'><img src='".$TBDEV['pic_base_url']."plus.gif' border='0' alt='Delete Bookmark!' title='Delete Bookmark!' /></a></td>" "");

      
$htmlout.= ($variant == "index" "<td align='center'><a href='download.php?torrent=".$id."'><img src='".$TBDEV['pic_base_url']."download.gif' border='0' alt='Download Bookmark!' title='Download Bookmark!' /></a></td>" "");

  
        
$bm mysql_query("SELECT * FROM bookmarks WHERE torrentid=$id && userid=$CURUSER[id]");
    $bms mysql_fetch_assoc($bm);    
        if (
$bms['private'] == 'yes' && $bms['userid'] == $CURUSER['id']) {
        
$makepriv "<a href='bookmark.php?torrent=".$id."&amp;action=public'><img src='".$TBDEV['pic_base_url']."key.gif' border='0' alt='Mark Bookmark Public!' title='Mark Bookmark Public!' /></a>";
            
        
$htmlout.="". ($variant == "index" "<td align='center'>".$makepriv."</td>" "");
        }
        elseif (
$bms['private'] == 'no' && $bms['userid'] == $CURUSER['id'])
        {
        
$makepriv "<a href='bookmark.php?torrent=".$id."&amp;action=private'><img src='".$TBDEV['pic_base_url']."public.gif' border='0' alt='Mark Bookmark Private!' title='Mark Bookmark Private!' /></a>";
        
$htmlout.="". ($variant == "index" "<td align='center'>".$makepriv."</td>" "");
        }    

        if (
$variant == "mytorrents")
            
$htmlout .= "</td><td align='center'><a href='edit.php?returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&amp;id={$row['id']}'>".$lang["torrenttable_edit"]."</a>\n";
        
        if (
$variant == "mytorrents"
        {
            
$htmlout .= "<td align='right'>";
            if (
$row["visible"] == "no")
                
$htmlout .= "<b>".$lang["torrenttable_not_visible"]."</b>";
            else
                
$htmlout .= "".$lang["torrenttable_visible"]."";
            
$htmlout .= "</td>\n";
        }

        if (
$row["type"] == "single")
        {
            
$htmlout .= "<td align='right'>{$row["numfiles"]}</td>\n";
        }
        else 
        {
            if (
$variant == "index")
            {
                
$htmlout .= "<td align='right'><b><a href='filelist.php?id=$id'>" $row["numfiles"] . "</a></b></td>\n";
            }
            else
            {
                
$htmlout .= "<td align='right'><b><a href='filelist.php?id=$id'>" $row["numfiles"] . "</a></b></td>\n";
            }
        }

        if (!
$row["comments"])
        {
            
$htmlout .= "<td align='right'>{$row["comments"]}</td>\n";
        }
        else 
        {
            if (
$variant == "index")
            {
                
$htmlout .= "<td align='right'><b><a href='details.php?id=$id&amp;hit=1&amp;tocomm=1'>" $row["comments"] . "</a></b></td>\n";
            }
            else
            {
                
$htmlout .= "<td align='right'><b><a href='details.php?id=$id&amp;page=0#startcomments'>" $row["comments"] . "</a></b></td>\n";
            }
        }

        
$htmlout .= "<td align='center'><span style='white-space: nowrap;'>" str_replace(",""<br />"get_date$row['added'],'')) . "</span></td>\n";
        
        
$htmlout .= "<td align='center'>" str_replace(" ""<br />"mksize($row["size"])) . "</td>\n";

           if (
$row["times_completed"] != 1)
           
$_s "".$lang["torrenttable_time_plural"]."";
           else
           
$_s "".$lang["torrenttable_time_singular"]."";
           
$htmlout .= "<td align='center'><a href='snatches.php?id=$id'>" number_format($row["times_completed"]) . "<br />$_s</a></td>\n";

        if (
$row["seeders"]) 
        {
            if (
$variant == "index")
            {
            if (
$row["leechers"]) $ratio $row["seeders"] / $row["leechers"]; else $ratio 1;
            
$htmlout .= "<td align='right'><b><a href='peerlist.php?id=$id#seeders'><font color='" .get_slr_color($ratio) . "'>{$row["seeders"]}</font></a></b></td>\n";
            }
            else
            {
           
$htmlout .= "<td align='right'><b><a class='" linkcolor($row["seeders"]) . "' href='peerlist.php?id=$id#seeders'>{$row["seeders"]}</a></b></td>\n";
            }
        }
        else
        {
           
$htmlout .= "<td align='right'><span class='" linkcolor($row["seeders"]) . "'>" $row["seeders"] . "</span></td>\n";
        }

        if (
$row["leechers"]) 
        {
            if (
$variant == "index")
            
$htmlout .= "<td align='right'><b><a href='peerlist.php?id=$id#leechers'>" .number_format($row["leechers"]) . "</a></b></td>\n";
            else
            
$htmlout .= "<td align='right'><b><a class='" linkcolor($row["leechers"]) . "' href='peerlist.php?id=$id#leechers'>{$row["leechers"]}</a></b></td>\n";
        }
        else
            
$htmlout .= "<td align='right'>0</td>\n";
            if (
$variant == "index")
            
$htmlout .= "<td align='center'>" . (isset($row["username"]) ? ("<a href='userdetails.php?id=" $row["owner"] . "'><b>" htmlspecialchars($row["username"]) . "</b></a>") : "<i>(".$lang["torrenttable_unknown_uploader"].")</i>") . "</td>\n";
            
$htmlout .= "</tr>\n";
            }
            
$htmlout .= "</table>\n";
            return 
$htmlout;
            }
            
//==Bookmarks            
$userid = isset($_GET['id']) ? (int)$_GET['id'] : $CURUSER['id'];
if (!
is_valid_id($userid))
stderr("Error""Invalid ID.");

if (
$userid != $CURUSER["id"])
stderr("Error""Access denied. Try <a href=\"sharemarks.php?id=".$userid."\">Here</a>");

$res mysql_query("SELECT id, username FROM users WHERE id = $userid") or sqlerr();
$arr mysql_fetch_array($res);
$htmlout.="<h1>My Bookmarks</h1>";
$htmlout.="<b><a href='sharemarks.php?id=".$CURUSER['id']."'>My Sharemarks</a></b>";

$res mysql_query("SELECT COUNT(id) FROM bookmarks WHERE userid = $userid");
$row mysql_fetch_array($res);
$count $row[0];

$torrentsperpage $CURUSER["torrentsperpage"];
if (!
$torrentsperpage)
$torrentsperpage 25;

if (
$count) {
$pager pager($torrentsperpage$count"bookmarks.php?");
$query1 "SELECT bookmarks.id as bookmarkid, users.username, users.id as owner, torrents.id, torrents.name, torrents.type, torrents.comments, torrents.leechers, torrents.seeders, categories.name AS cat_name, categories.image AS cat_pic, torrents.save_as, torrents.numfiles, torrents.added, torrents.filename, torrents.size, torrents.views, torrents.visible, torrents.hits, torrents.times_completed, torrents.category FROM bookmarks LEFT JOIN torrents ON bookmarks.torrentid = torrents.id LEFT JOIN users on torrents.owner = users.id LEFT JOIN categories ON torrents.category = categories.id WHERE bookmarks.userid = $userid  ORDER BY torrents.id DESC {$pager['limit']}or sqlerr(__FILE____LINE__); 
$res mysql_query($query1) or sqlerr();
}

if (
$count) {
$htmlout .= $pager['pagertop'];
$htmlout .= bookmarktable($res"index"TRUE);
$htmlout .= $pager['pagerbottom'];
}
print 
stdhead('Bookmarks') . $htmlout stdfoot();
?>


Save and upload sharemarks.php to root :

Code (php) Select
<?php
//sharemarks.php - by pdq
require_once("include/bittorrent.php");
require_once(
"include/pager_functions.php");
require_once (
"include/user_functions.php");
require_once (
"include/torrenttable_functions.php");
dbconn(false);
loggedinorreturn();

$lang array_mergeload_language('global'), load_language('torrenttable_functions') );

$htmlout='';

function 
sharetable($res$variant "index") {
global $TBDEV$CURUSER$lang;
    
$htmlout='';
   
    
$htmlout.="
<span>Icon Legend :
<img src='
{$TBDEV['pic_base_url']}plus.gif' alt='Delete Bookmark' border='none' /> = Delete Bookmark |
<img src='
{$TBDEV['pic_base_url']}download.gif' alt='Download Bookmark' border='none' />= Download Torrent |
<img alt='Bookmark is Private' src='
{$TBDEV['pic_base_url']}key.gif' border='none'  /> = Bookmark is Private |
<img src='
{$TBDEV['pic_base_url']}public.gif' alt='Bookmark is Public' border='none'  /> = Bookmark is Public</span>
<table border='1' cellspacing='0' cellpadding='5'>
<tr>
<td class='colhead' align='center'>Type</td>
<td class='colhead' align='left'>Name</td>"
;

$userid = (int)$_GET['id'];
if (
$CURUSER['id'] == $userid)
$htmlout.= ($variant == 'index' '<td class="colhead" align="center">Download</td><td class="colhead" align="right">' '').'Delete</td>';
else
$htmlout.= ($variant == 'index' '<td class="colhead" align="center">Download</td><td class="colhead" align="right">' '').'Bookmark</td>';
   

   if (
$variant == "mytorrents")
   {
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_edit"]}</td>\n";
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_visible"]}</td>\n";
   }

   
$htmlout .= "<td class='colhead' align='right'>{$lang["torrenttable_files"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_comments"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_added"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_size"]}</td>
   <td class='colhead' align='center'>
{$lang["torrenttable_snatched"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_seeders"]}</td>
   <td class='colhead' align='right'>
{$lang["torrenttable_leechers"]}</td>";

if (
$variant == 'index')
   
$htmlout .= "<td class='colhead' align='center'>{$lang["torrenttable_uppedby"]}</td>\n";

    
$htmlout .= "</tr>\n";

    while (
$row mysql_fetch_assoc($res)) 
    {
        
$id $row["id"];
        
$htmlout .= "<tr>\n";

        
$htmlout .= "<td align='center' style='padding: 0px'>";
        if (isset(
$row["cat_name"])) 
        {
            
$htmlout .= "<a href='browse.php?cat={$row['category']}'>";
            if (isset(
$row["cat_pic"]) && $row["cat_pic"] != "")
                
$htmlout .= "<img border='0' src='{$TBDEV['pic_base_url']}caticons/{$row['cat_pic']}' alt='{$row['cat_name']}' />";
            else
            {
                
$htmlout .= $row["cat_name"];
            }
            
$htmlout .= "</a>";
        }
        else
        {
            
$htmlout .= "-";
        }
        
$htmlout .= "</td>\n";

        
$dispname htmlspecialchars($row["name"]);
        
$htmlout .= "<td align='left'><a href='details.php?";
        if (
$variant == "mytorrents")
            
$htmlout .= "returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&amp;";
        
$htmlout .= "id=$id";
        if (
$variant == "index")
            
$htmlout .= "&amp;hit=1";
        
      
$htmlout .= "'><b>$dispname</b></a>&nbsp;</td>";
      
$htmlout.= ($variant == "index" "<td align='center'><a href=\"download.php?torrent=".$id."\"><img src='".$TBDEV['pic_base_url']."download.gif' border='0' alt='Download Bookmark!' title='Download Bookmark!' /></a></td>" "");
      
      
$bm mysql_query("SELECT * FROM bookmarks WHERE torrentid=$id && userid=$CURUSER[id]");
      
$bms mysql_fetch_assoc($bm);
      
$bookmarked = (empty($bms)?'<a href=\'bookmark.php?torrent=' $id '&amp;action=add\'><img src=\'' $TBDEV['pic_base_url'] . 'bookmark.gif\' border=\'0\' alt=\'Bookmark it!\' title=\'Bookmark it!\'></a>':'<a href="bookmark.php?torrent=' $id '&amp;action=delete"><img src=\'' $TBDEV['pic_base_url'] . 'plus.gif\' border=\'0\' alt=\'Delete Bookmark!\' title=\'Delete Bookmark!\' /></a>');
      
$htmlout.= ($variant == "index" "<td align='center'>{$bookmarked}</td>" "");
      
        if (
$variant == "mytorrents")
            
$htmlout .= "</td><td align='center'><a href='edit.php?returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&amp;id={$row['id']}'>".$lang["torrenttable_edit"]."</a>\n";
        
        if (
$variant == "mytorrents"
        {
            
$htmlout .= "<td align='right'>";
            if (
$row["visible"] == "no")
                
$htmlout .= "<b>".$lang["torrenttable_not_visible"]."</b>";
            else
                
$htmlout .= "".$lang["torrenttable_visible"]."";
            
$htmlout .= "</td>\n";
        }

        if (
$row["type"] == "single")
        {
            
$htmlout .= "<td align='right'>{$row["numfiles"]}</td>\n";
        }
        else 
        {
            if (
$variant == "index")
            {
                
$htmlout .= "<td align='right'><b><a href='filelist.php?id=$id'>" $row["numfiles"] . "</a></b></td>\n";
            }
            else
            {
                
$htmlout .= "<td align='right'><b><a href='filelist.php?id=$id'>" $row["numfiles"] . "</a></b></td>\n";
            }
        }

        if (!
$row["comments"])
        {
            
$htmlout .= "<td align='right'>{$row["comments"]}</td>\n";
        }
        else 
        {
            if (
$variant == "index")
            {
                
$htmlout .= "<td align='right'><b><a href='details.php?id=$id&amp;hit=1&amp;tocomm=1'>" $row["comments"] . "</a></b></td>\n";
            }
            else
            {
                
$htmlout .= "<td align='right'><b><a href='details.php?id=$id&amp;page=0#startcomments'>" $row["comments"] . "</a></b></td>\n";
            }
        }

        
$htmlout .= "<td align='center'><span style='white-space: nowrap;'>" str_replace(",""<br />"get_date$row['added'],'')) . "</span></td>\n";
    
    
$htmlout .= "
    <td align='center'>" 
str_replace(" ""<br />"mksize($row["size"])) . "</td>\n";

        if (
$row["times_completed"] != 1)
          
$_s "".$lang["torrenttable_time_plural"]."";
        else
          
$_s "".$lang["torrenttable_time_singular"]."";
        
$htmlout .= "<td align='center'><a href='snatches.php?id=$id'>" number_format($row["times_completed"]) . "<br />$_s</a></td>\n";

        if (
$row["seeders"]) 
        {
            if (
$variant == "index")
            {
               if (
$row["leechers"]) $ratio $row["seeders"] / $row["leechers"]; else $ratio 1;
                
$htmlout .= "<td align='right'><b><a href='peerlist.php?id=$id#seeders'>
                <font color='" 
.get_slr_color($ratio) . "'>{$row["seeders"]}</font></a></b></td>\n";
            }
            else
            {
                
$htmlout .= "<td align='right'><b><a class='" linkcolor($row["seeders"]) . "' href='peerlist.php?id=$id#seeders'>{$row["seeders"]}</a></b></td>\n";
            }
        }
        else
        {
            
$htmlout .= "<td align='right'><span class='" linkcolor($row["seeders"]) . "'>" $row["seeders"] . "</span></td>\n";
        }

        if (
$row["leechers"]) 
        {
            if (
$variant == "index")
                
$htmlout .= "<td align='right'><b><a href='peerlist.php?id=$id#leechers'>" .
                   
number_format($row["leechers"]) . "</a></b></td>\n";
            else
                
$htmlout .= "<td align='right'><b><a class='" linkcolor($row["leechers"]) . "' href='peerlist.php?id=$id#leechers'>{$row["leechers"]}</a></b></td>\n";
        }
        else
            
$htmlout .= "<td align='right'>0</td>\n";
        
       if (
$variant == "index")
       
$htmlout .= "<td align='center'>" . (isset($row["username"]) ? ("<a href='userdetails.php?id=" $row["owner"] . "'><b>" htmlspecialchars($row["username"]) . "</b></a>") : "<i>(".$lang["torrenttable_unknown_uploader"].")</i>") . "</td>\n";
       
$htmlout .= "</tr>\n";
       }
       
$htmlout .= "</table>\n";
       return 
$htmlout;
       }

//==Sharemarks
$userid = isset($_GET['id']) ? (int)$_GET['id'] : '';

if (!
is_valid_id($userid))
stderr("Error""Invalid ID.");

$res mysql_query("SELECT id, username FROM users WHERE id = $userid") or sqlerr();
$arr mysql_fetch_array($res);
$htmlout.="<h1>Sharemarks for <a href=\"userdetails.php?id=".$userid."\">".$arr['username']."</a></h1>";
$htmlout.="<b><a href=\"bookmarks.php\">My Bookmarks</a></b>";


$res mysql_query("SELECT COUNT(id) FROM bookmarks WHERE userid = $userid");
$row mysql_fetch_array($res);
$count $row[0];

$torrentsperpage $CURUSER["torrentsperpage"];
if (!
$torrentsperpage)
$torrentsperpage 25;

if (
$count) {
$pager pager($torrentsperpage$count"sharemarks.php?");
$query1 "SELECT bookmarks.id as bookmarkid, users.username, users.id as owner, torrents.id, torrents.name, torrents.type, torrents.comments, torrents.leechers, torrents.seeders, categories.name AS cat_name, categories.image AS cat_pic, torrents.save_as, torrents.numfiles, torrents.added, torrents.filename, torrents.size, torrents.views, torrents.visible, torrents.hits, torrents.times_completed, torrents.category FROM bookmarks LEFT JOIN torrents ON bookmarks.torrentid = torrents.id LEFT JOIN users on torrents.owner = users.id LEFT JOIN categories ON torrents.category = categories.id WHERE bookmarks.userid = $userid AND bookmarks.private = 'no' ORDER BY torrents.id DESC {$pager['limit']}or sqlerr(__FILE____LINE__);
$res mysql_query($query1) or sqlerr();
}

if (
$count) {
$htmlout .= $pager['pagertop'];
$htmlout .= sharetable($res"index"TRUE);
$htmlout .= $pager['pagerbottom'];
}
print 
stdhead("Sharemarks for " $arr['username']) . $htmlout stdfoot();
?>


@File userdetails.php find :

Code (php) Select
$HTMLOUT .= begin_main_frame();

Above it add :

Code (php) Select
if ($CURUSER['id'] != $user['id'])
$HTMLOUT .="<h1><a href='{$TBDEV['baseurl']}/sharemarks.php?id=$id'>View sharemarks</a></h1>\n";

   
Last upload the 4 images into the pic folder.