09 Latest X Torrents On Index

Started by Mindless, July 20, 2012, 08:43:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Daniel

works like a charm  thanks for the code mate  !

Mindless

Add in index.php wherever you want it to show

Code (php) Select
//latest torrents [see limit on config]
        $HTMLOUT .= "<div style='text-align:left;width:80%;border:1px solid blue;padding:5px;'>
        <div style='background:lightgrey;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['latesttorrents_title']}</span></div><br />";

$res = mysql_query("SELECT t.id, t.name, t.category, t.seeders, t.leechers, c.name AS cat_name, c.image AS cat_img ".
"FROM torrents AS t ".
"LEFT JOIN categories AS c ON c.id = t.category ".
"WHERE t.visible='yes' ".
"ORDER BY t.added DESC LIMIT {$TBDEV['latest_torrents_limit']}") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
$HTMLOUT .= "<table width='100%' cellspacing='0' cellpadding='5'><tr>
<td class='colhead' align='center' width='1%'>{$lang['latesttorrents_type']}</td>
<td class='colhead' align='center'>{$lang['latesttorrents_name']}</td>
<td class='colhead' align='center' width='1%'>{$lang['latesttorrents_seeders']}</td>
<td class='colhead' align='center' width='1%'>{$lang['latesttorrents_leechers']}</td></tr>";
while($arr = mysql_fetch_assoc($res))
{
$dispname = htmlspecialchars($arr['name']);
$catname = htmlspecialchars($arr['cat_name']);
$catpic = htmlspecialchars($arr['cat_img']);

$HTMLOUT .= "<tr><td align='center' style='padding:0px;'><a href='/browse.php?cat={$arr['category']}'><img border='0' src='{$TBDEV['pic_base_url']}caticons/{$catpic}' alt='{$catname}' /></a></td>
<td align='left'><a href='/details.php?id={$arr['id']}&amp;hit=1' title='{$dispname}'><b>{$dispname}</b></a></td>
<td align='center'>{$arr['seeders']}</td>
<td align='center'>{$arr['leechers']}</td></tr>";
}
$HTMLOUT .= "</table></div><br />\n";
} else {
// if there are no torrents
$HTMLOUT .= "<div style='text-align:center;border:1px solid blue;background:lightgrey;'><span style='font-weight:bold;font-size:10pt;'>{$lang['latesttorrents_no_torrents']}</span></div></div><br />";
}
//end latest torrents


On lang_index.php after

Code (php) Select
'news_delete'                   => "Delete",

Add

Code (php) Select
#latest torrents
'latesttorrents_title' => $TBDEV['latest_torrents_limit']." Latest Torrents",
'latesttorrents_type' => "Type",
'latesttorrents_name' => "Name",
'latesttorrents_seeders' => "Seeders",
'latesttorrents_leechers' => "Leechers",
'latesttorrents_no_torrents' => "No Torrents Found",


On config.php
before the defines of user classes add

Code (php) Select
//latest torrents limit
$TBDEV['latest_torrents_limit'] = 5; //query limit for latest torrents on index


Thats it! Cheers! Let me know if you have any probs!