Grouping torrents

Started by sharpie, October 05, 2013, 11:35:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sharpie

#5
cheers pal but i think i have done it i changed

$searchname = substr($row['name'], 0, 9);

to
$searchname = substr($row['name'], 0, 26);

and this brings up the torrents that are the same but in different formats i added a before and after pics first pic is before and second one is after the code change

[attachment deleted by admin]

elephant

Similar torrents is a hack. If you want to do it right, I really recommend you look at the gazelle source code and properly normalise your database tables.

sharpie

been working on the similar torrents mod but i want it to show the exact torrent name rather then torrent name that has a similar search field but not quite sure how to do it


////////////// Similar Torrents mod /////////////////////
   $searchname = substr($row['name'], 0, 9);
$query1 = str_replace(" ",".",sqlesc("%".$searchname."%"));
$query2 = str_replace("."," ",sqlesc("%".$searchname."%"));
   //$r = mysql_query("SELECT id, filename,name, size, added, seeders, leechers,times_completed,numfiles,comments,tags, category FROM torrents WHERE name LIKE {$query1} AND id <> '$id' OR name LIKE {$query2} AND id <> '$id' ORDER BY name DESC LIMIT 5") or sqlerr();
   $r = mysql_query("SELECT id, filename,name, size, added, seeders, leechers,times_completed,numfiles,comments,tags, category FROM torrents WHERE name LIKE {$query1} AND seeders >= '0' AND id <> '$id' OR name LIKE {$query2} AND seeders >= '0' AND id <> '$id' ORDER BY added DESC LIMIT 4") or sqlerr();

if (mysql_num_rows($r) > 0)
   {
   $torrents = "<table width=100% class=row3 border=1 cellspacing=0 cellpadding=0>\n" .
   "<tr><td class=colhead width=78%><center>Name/Year</td><td class=colhead align=center>Time/Size</td><td class=colhead align=center>S/C</td><td class=colhead align=center>S/L</td></tr>\n";
   while ($a = mysql_fetch_assoc($r))
   {
   $r2 = mysql_query("SELECT name, image FROM categories WHERE id=$a[category]") or sqlerr(__FILE__, __LINE__);
   $a2 = mysql_fetch_assoc($r2);
   $char = 88; //Max long..
if ($CURUSER['class'] >= UC_USER)
{
   $dl = ("<a href=\"download.php/$a[id]/" . rawurlencode($a["filename"]) . "\"><img align=right src=pic/blank.gif class=dl border=0 title='Download This Torrent' alt=Download></a>\n");
   }
if ($CURUSER['class'] >= UC_POWER_USER)
{
   $nfo = ("<a href=viewnfo.php?id=$a[id]><img align=right src=pic/viewnfo.png border=0 title='View NFO'></a>\n");
   }

if ($a["tags"] == "")
{
     //$keywords = "";
$keywords = "<br>&nbsp;&nbsp;&nbsp;<b><font size= -2>" . htmlspecialchars($a2["name"]) . "</font></b>";
}
else
{
     $tags = explode(",", $a["tags"]);
     //$keywords = "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
     $keywords = "<br>&nbsp;&nbsp;&nbsp;";
     
     foreach ($tags as $tag){
        $tag = str_replace(" ", "",$tag);
        //$keywords .= "<b><a href='browse.php?search=$tag&cat=0&incldead=1'>$tag</a></b> ,";
        $keywords .= "<font size= -2><b>$tag</b></font>, ";
     }
        $keywords  = substr($keywords, 0, (strlen($keywords) - 2));
         
}
//print("<tr><td ><b>Search Tags:</b></td><td>" . $keywords . "</td></tr>\n");

if ($CURUSER['class'] >= UC_OWNER)
{
$del = (" <a href=\"fastdelete.php?id=$a[id]\"><img align=right src=pic/n.png border=0 title='Delete this Torrent' alt='Delete'></a>");
}
$added = "" . get_elapsed_times(sql_timestamp_to_unix_timestamp($a["added"])) . " ago";
   $uprow = "<b>" . (isset($row["username"]) ? ("<a title=$row[username] href=/$row[username].usr". "><font color=\"".get_user_class_color($row["owner_class"])."\">" . htmlspecialchars($row["username"]) . "</font></a></b>") : "<i>(unknown)</i>") . "\n";
   $cat = "<img src=\"/pic/categorypics/$a2[image]\" alt=\"$a2[name]\" title=\"$a2[name]\">";
   $name = $a["name"];
   $torrents .= "<tr class=browse><td><a title=\"$a[name]\"  href=details.php?id=" . $a["id"] . "><b>" . CutName($name, $char) . "</b></a>$keywords<b> $del $dl</td><td style='padding: 1px' align=center>". $added ."<br> ". mksize($a[size]) ."</td><td style='padding: 1px' align=center><b><a href=viewsnatches.php?id=$a[id]>$a[times_completed]</a>/<a href=\"details.php?id=$a[id]&amp;hit=1&amp;tocomm=1\">$a[comments]</a></b></td><td style='padding: 1px' align=center>$a[seeders]/$a[leechers]</td></tr>\n";
   }
   $torrents .= "</table>";
   print("<tr><td class=row5 align=left><b>Related Torrents</b></center></td><td align=left>$torrents</td></tr>\n");
   }
   /////////////////////////////////////////////////////////

elephant

#2
It can be done (but it is a lot of work). Basically you need a torrents_group table that has the group information. Look at the takeupload code in gazelle. They also use sphinx on browse, and memcache site-wide to avoid slow joins.

sharpie

Is there a way where i can group torrents like Gazelle does ie if i upload a flac version it would group with the mp3 version ive uploaded a pic to show you what i mean
Thanks in advance

[attachment deleted by admin]