Filesoup
X   Site Message
(Message will auto close in 2 seconds)


> 

If you would like to advertise your Hosting, Services or Products on Filesoup, please contact Geeker for a quote.

2 Pages V  < 1 2  
Reply to this topicStart new topic
> Torrent Per Page and Sub Pages, T-Xore
hustler263
post May 24 2007, 03:47 AM
Post #16


Spam Soup
Group Icon

Group: Admin
Posts: 1,377
Joined: 16-January 04
From: Florida
Member No.: 61,222
 


I'll be more active in here and again if there are things posted such as plain blatant copies of CSS etc let me know and I will remove them. I have talked to Geeker and Snookered as well regarding some issues regarding things such as this.

This is in fact a section for people to ask question about code and how to for trackers/indexers/crawlers etc. And I do agree with the Hosting type questions and I thank you Jaggi for giving him the correct name to use to look up as you are 100% correct that some people may not know what to look for.

And thank you also to phrostwave for giving a postive response as well.

QUOTE(Jaggi @ May 23 2007, 08:54 PM) *
just pointing out that maybe he didn't know it was called pagination that is why i pointed out and i'll make it known that the term wasn't used in this thread till i pointed it out. Knowing what you want to do and the professional term for it can be two different things. In my honest opinion i have no objection with the person who made this thread and thats why i posted a reply. I do however agree that threads in this forum can get messy but not in the form you mentioned i refer to people asking for hosting, thats one thing that REALLY gets on my nerves, i've already spoken to snookered about it and he's promised to talk to geeker about it, he prolly forgot so i'll chase him up again tongue.gif . But would like to see a seperate forum for host requests i truely believe that subject has no place in this forum. People asking for coding relating to a existing script and that being a tracker, indexer, crawler or site i feel is fine in this forum.


--------------------

Mini Tracker Public Announce URL: http://hustlers-place.com/sbt/announce.php
Hustler's Place Lite Tracker: http://hustlers-place2.com/ttlite/index.php
Hustler's Place Crawler Using Pktorrents: http://hustlers-place2.com/crawler/index.php
Hustler's Place BT Lister: http://hustlers-place.com/mybit/index.php
(New) Hustler's Place Topsites Site: http://hustlers-place.com/topsite/index.php
Hustler's Place VIPTracker: http://hustlers-place2.com/viptracker/index.php This one requires
you to be an active member of our forums!
Go to the top of the pageReport Post
+
guibean
post May 24 2007, 04:28 AM
Post #17


Spam Soup
Group Icon

Group: Contributor
Posts: 120
Joined: 22-September 05
Member No.: 313,949
 


Pagination Script

subcat.php
CODE
<?
require_once "config.php";
connect ($dbhost, $dbuser, $dbpass, $database);
$sort = tsort ($_GET['sort']);

$numreg = 3; // Number the pages
if (!isset($pg)){
    $pg = 0;
}
$inicial = $_GET['pg'] * $numreg;

$result = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort LIMIT $inicial,$numreg") or die (mysql_error());
$result2 = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort") or die (mysql_error());
$result_subcatname = mysql_query("SELECT DISTINCT name,catid,subname,subid FROM categories WHERE subid='".strip_tags(trim($_GET['id']))."'") or die (mysql_error());

$count = mysql_num_rows($result2);
$quantreg = $count;

$namerow =  mysql_fetch_row($result_subcatname);


// Non htmlentities are allowed in title (converted automaticly by function
stheader ('Sub categoria : '.$namerow[0].' > '.$namerow[2]);


if ($count == 0){
    echo '<h1>Nenhum torrent encontrado</h1>';
    footer();
    die;
}

echo '<div id="bread-navi"><a href="index.php">Home</a> &raquo; <a href="cat.php?id='.$namerow[1].'">'.$namerow[0].'</a> &raquo; <a href="subcat.php?id='.$namerow[3].'">'.$namerow[2].'</a></div>';
echo '<h1>'.$count.' torrents em '.$namerow[2].'</h1>';
echo '
    <table class="tor" width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <th width="15%"><a href="subcat.php?id='.strip_tags(trim($_GET['id'])).'&amp;sort=1">Data</a></th>
            <th><a href="subcat.php?id='.strip_tags(trim($_GET['id'])).'&amp;sort=3">Nome</a></th>
            <th width="9%"><a href="subcat.php?id='.strip_tags(trim($_GET['id'])).'&amp;sort=4">Tamanho</a></th>
            <th width="4%"><a href="subcat.php?id='.strip_tags(trim($_GET['id'])).'&amp;sort=5">UL</a></th>
            <th width="4%"><a href="subcat.php?id='.strip_tags(trim($_GET['id'])).'&amp;sort=6">DL</a></th>
            <th width="5%">Saúde</th>
        </tr>';

while ($row = mysql_fetch_array($result)){
extract($row);

    echo '<tr>';
    echo '<td>'.substr($added,-0).'</td>';

// limitar caracteres no nome do torrent
$sub = substr($torrentname,0, 65);

// colocar ... quando o arquivo possuir mais que  50 caracteres
$strlen_var = strlen($torrentname);

if ($strlen_var >= 65)
{
    echo '<td><a href="download.php?id='.$hash.'"><img src="images/d.gif" title="Fazer download do torrent" align="absmiddle"/></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'" title="'.$torrentname.'">'.$sub.'...</a></td>';
}
else
{
    echo '<td><a href="download.php?id='.$hash.'"><img src="images/d.gif" title="Fazer download do torrent" align="absmiddle"/></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'">'.$sub.'</a></td>';
}
    echo '<td align="right">'.torsize($size).'</td>';
    echo '<td class="s">'.getpeer($seeds).'</td>';
    echo '<td class="p">'.getpeer($peers).'</td>';
    echo '<td width="48" align="center"><img src="images/h'.health($peers, $seeds).'.png"></td>';
    echo '</tr>';

}
echo '</table>';

//Paginação

echo "<br>"; // Vai servir só para dar uma linha de espaço entre a paginação e o conteúdo


if ($quantreg%$numreg==0){
    $quant_pg = intval($quantreg/$numreg);
    $quant_pg++;
}
else{
    $quant_pg = ceil($quantreg/$numreg);
    $quant_pg++;
}

echo'<div class="pages">';

//Nao aparecer nada quando o numero minimo for respeitado
if ($quantreg <= $numreg){
echo '';
    footer();
    die;
}


// Verifica se esta na primeira página, se nao estiver ele libera o link para anterior
if ($_GET['pg'] > 0){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']-1)."><b>&laquo; Anterior</b></a>";
}
else{
    echo "";
}

// Faz aparecer os numeros das página entre o ANTERIOR e PROXIMO
for($i_pg=1; $i_pg<$quant_pg;$i_pg++){
    // Verifica se a página que o navegante esta e retira o link do número para identificar visualmente
    if ($_GET['pg'] == ($i_pg-1)){
        echo "&nbsp;<a class=currentpage href=#><b>$i_pg</b></a>&nbsp;";
    }
    else{
        $i_pg2 = $i_pg-1;
        echo "&nbsp;<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=$i_pg2><b>$i_pg</b></a>&nbsp;";
    }
}

// Verifica se esta na ultima página, se nao estiver ele libera o link para próxima
if (($_GET['pg']+2) < $quant_pg){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']+1)."><b>Pr&oacute;ximo &raquo;</b></a>";
}
else{
    echo "";
}
//Fim da paginação

echo "<br />";

footer();
?>


--------------------
Go to the top of the pageReport Post
+
phrostwave
post May 24 2007, 05:27 AM
Post #18


DJ Taktikz / STR Records
Group Icon

Group: Member
Posts: 62
Joined: 7-September 06
Member No.: 411,795

System Specs: (show/hide)




guibean rules!

i cleaned it up a little for people who want to use this on the ak nova, it shows 25 torrents per page, and is translated from Portuguese to English smile.gif

[edit]> the sorting buttons dont work yet, you might want to unlink them if you dont feel like making up that part of the code.

CODE
<?
/*
Subcategory "pagination" by guibean
*/

require_once "config.php";
connect ($dbhost, $dbuser, $dbpass, $database);
$sort = tsort ($_GET['sort']);

$numreg = 25; // Number the pages
if (!isset($pg)){
    $pg = 0;
}
$inicial = $_GET['pg'] * $numreg;

$result = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort LIMIT $inicial,$numreg") or die (mysql_error());
$result2 = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE subid = '".strip_tags(trim($_GET['id']))."' $sort") or die (mysql_error());
$result_subcatname = mysql_query("SELECT DISTINCT name,catid,subname,subid FROM categories WHERE subid='".strip_tags(trim($_GET['id']))."'") or die (mysql_error());

$count = mysql_num_rows($result2);
$quantreg = $count;

$namerow =  mysql_fetch_row($result_subcatname);
stheader ('Subcategory : '.$namerow[0].' > '.$namerow[2]);


if ($count == 0){
    echo '<h1>No torrents yet! Check back soon =D</h1>';
    footer();
    die;
}

echo '<div class="location"><a href="index.php">Home</a> &raquo; <a href="cat.php?id='.$namerow[1].'">'.$namerow[0].'</a> &raquo; <a href="subcat.php?id='.$namerow[3].'">'.$namerow[2].'</a></div>';
echo '<h1>'.$count.' total torrents in '.$namerow[2].'</h1>';
echo '<table class="tor" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><th><a href="?sort=1">Age</a></th><th><a href="?sort=3">Filename</a></th><th><a href="?sort=4">Size</a></th><th><a href="?sort=5">Seeds</a></th><th><a href="?sort=6">Peers</a></th><th>Health</th></tr>';
while ($row = mysql_fetch_array($result)){
extract($row);
$torrentname = str_replace("+"," ",$torrentname);
$torrentname = str_replace("amp;","",$torrentname);
$torrentname = str_replace("%","",$torrentname);
$torrentname = str_replace("[","",$torrentname);
$torrentname = str_replace("]","",$torrentname);
$torrentname = str_replace(" "," ",$torrentname);
$torrentname = str_replace("avi","",$torrentname);
$torrentname = str_replace("S^M","",$torrentname);
$torrentname = str_replace("com","",$torrentname);
$torrentname = str_replace("mp3","",$torrentname);
$torrentname = str_replace("Lynda","",$torrentname);
$torrentname = str_replace("WWW","",$torrentname);
$torrentname = str_replace("www","",$torrentname);
$torrentname = str_replace("-"," ",$torrentname);
$torrentname = str_replace("(","",$torrentname);
$torrentname = str_replace(")","",$torrentname);
$torrentname = str_replace("net","",$torrentname);
$torrentname = str_replace("co.uk","",$torrentname);

$tz = convert_timestamp($row["added"]); // add this

echo '<tr>';
echo '<td width="10%>'.substr($added,-0).'</td>';
echo '<td width="10%">'.get_elapsed_time($tz).' old!</td>';
echo '<td width="60%"><a href="adm/b/torrents/'.$hash.'.torrent"><img src="images/d.gif" alt="[d]" /></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'">'.$torrentname.'</a></td>';
echo '<td width="7%" class="d">'.torsize($size).'</td>';
echo '<td width="5%" class="d">'.getpeer($seeds).'</td>';
echo '<td width="5%" class="d">'.getpeer($peers).'</td>';
echo '<td width="3%" align="center"><img src="images/h'.health($peers, $seeds).'.png"></td>';
echo '</tr>';

}
echo '</table>';

echo "<br>";


if ($quantreg%$numreg==0){
    $quant_pg = intval($quantreg/$numreg);
    $quant_pg++;
}
else{
    $quant_pg = ceil($quantreg/$numreg);
    $quant_pg++;
}

echo'<div class="pages">';

if ($quantreg <= $numreg){
echo '';
    footer();
    die;
}

if ($_GET['pg'] > 0){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']-1)."><b>&laquo; Previous</b></a>";
}
else{
    echo "";
}

for($i_pg=1; $i_pg<$quant_pg;$i_pg++){

    if ($_GET['pg'] == ($i_pg-1)){
        echo "&nbsp;<a class=currentpage href=#><b>$i_pg</b></a>&nbsp;";
    }
    else{
        $i_pg2 = $i_pg-1;
        echo "&nbsp;<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=$i_pg2><b>$i_pg</b></a>&nbsp;";
    }
}

if (($_GET['pg']+2) < $quant_pg){
    echo "<a href=".$_SERVER['PHP_SELF']."?id=".strip_tags(trim($_GET['id']))."&pg=".($_GET['pg']+1)."><b>Next &raquo;</b></a>";
}
else{
    echo "";
}

echo "<br />";

footer();
?>


This post has been edited by phrostwave: May 24 2007, 07:06 AM


--------------------
may 15, 2007 releases - ak nova 1.4 (snapshot), ak tracker 1.0.1 (snapshot).
t-xore 0.4 preconfigured with ibitzy, registration captcha (ive seen it on 18 sites so far!), admin search, user search, and tons of other stuff by me and various other filesoup members!

bNova stylesheet for ak nova 1.4


look for ak nova 1.7 soon! lots of features like forums, dhtml/ajax, two mass scrapes, nicer admin area, plus a ton of other stuff!!
Go to the top of the pageReport Post
+
guibean
post May 25 2007, 04:04 AM
Post #19


Spam Soup
Group Icon

Group: Contributor
Posts: 120
Joined: 22-September 05
Member No.: 313,949
 


it would like to know if somebody could help me to create a paging limit

Exemple




When to pass of the limit of the desired pages to add “…”

equal the image above

help me phrostwave please
Go to the top of the pageReport Post
+
phrostwave
post May 25 2007, 05:19 AM
Post #20


DJ Taktikz / STR Records
Group Icon

Group: Member
Posts: 62
Joined: 7-September 06
Member No.: 411,795

System Specs: (show/hide)




the code below doesnt work yet, but its an idea on how to limit the number paginations to be displayed per page.

CODE
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;


i will post it when i get it working

This post has been edited by phrostwave: May 25 2007, 05:22 AM
Go to the top of the pageReport Post
+
guibean
post May 25 2007, 06:28 PM
Post #21


Spam Soup
Group Icon

Group: Contributor
Posts: 120
Joined: 22-September 05
Member No.: 313,949
 


Complete

CODE
<?
require_once "config.php";
connect ($dbhost, $dbuser, $dbpass, $database);
stheader('');

$rpp = 2; // Quantos registros por página vai ser mostrado
if (!isset($pg)){
    $pg = 0;
}
$inicial = $_GET['pg'] * $rpp;

$result = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE posted_by='".strtolower($_GET['usuario'])."' ORDER BY added DESC LIMIT $inicial,$rpp") or die (mysql_error());
$result2 = mysql_query("SELECT * FROM torrents LEFT JOIN categories ON torrents.subcat = categories.subid WHERE posted_by='".strtolower($_GET['usuario'])."'") or die (mysql_error());

$count = mysql_num_rows($result2);
$tr = $count;

if (mysql_num_rows($result) == 0){
    echo '<div  id="bread-navi"><a href="index.php">Home</a> &raquo; Usu&aacute;rio n&atilde;o possui nenhum torrent enviado!</div><br />';
    echo '<h3><img src="images/award_star_add.png" alt="files" width="16" height="16"> Usu&aacute;rio n&atilde;o possui nenhum torrent enviado!</h3><br />';
    echo '<h2>Usu&aacute;rio n&atilde;o enviou nenhum torrent!</h2>';
}
else{
    $result2 = mysql_query("SELECT uploads FROM users WHERE username ='".$_GET['usuario']."'");
    while ($row = mysql_fetch_array($result2)){
        extract($row);
        echo '<div  id="bread-navi"><a href="index.php">Home</a> &raquo; Torrents enviados por '.$_GET['usuario'].'</div><br />';
        echo '<h3><img src="images/award_star_add.png" alt="files" width="16" height="16"> Torrents enviados por '.$_GET['usuario'].' &raquo; Total: <span class="r">'.$uploads.'</span>&nbsp;Ativos: <span class="s">'.$count.'</span></h3><br />';
        echo '
        <table class="tor" width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr cellpadding="0" cellspacing="5">
        <th width="13%"><a href="index.php?sort=2">Categoria</a></th>
        <th width="9%"><a href="index.php?sort=1">Data</a></th>
        <th><a href="index.php?sort=3">Nome</a></th>
        <th width="9%"><a href="index.php?sort=4">Tamanho</a></th>
        <th width="5%"><a href="index.php?sort=5">UL</a></th>
        <th width="5%"><a href="index.php?sort=6">DL</a></th>
        <th width="5%"><a href="index.php?sort=8">Saúde</a></th></tr>';
    }
    while ($row = mysql_fetch_array($result)){
        extract($row);
        $tz = convert_timestamp($row["added"]); // add this
        echo '<tr>';
        // limitar caracteres no nome da categoria
        $categoria = substr($subname,0, 13);
        
        // inseri (...) quando o arquivo possuir mais caracteres
        $strlen_var = strlen($subname);
        if ($strlen_var >= 13){
            echo '<td><a href="subcat.php?id='.$subid.'" title="'.$subname.'">'.$categoria.'...</a></td>';
        }
        else{
            echo '<td><a href="subcat.php?id='.$subid.'">'.$categoria.'</a></td>';
        }
        echo '<td>'.get_elapsed_time($tz).'</td>';
        
        // limitar caracteres no nome do torrent
        $sub = substr($torrentname,0, 55);
        
        // colocar ... quando o arquivo possuir mais que  50 caracteres
        $strlen_var = strlen($torrentname);
        if ($strlen_var >= 55){
            echo '<td><a href="download.php?id='.$hash.'"><img src="images/d.gif" title="Fazer download do torrent" align="absmiddle"/></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'" title="'.$torrentname.'">'.$sub.'...</a></td>';
        }
        else{
            echo '<td><a href="download.php?id='.$hash.'"><img src="images/d.gif" title="Fazer download do torrent" align="absmiddle"/></a> '.regicon($registration,$tracker).' '.desc($description).'<a href="details.php?id='.$id.'">'.$sub.'</a></td>';
        }
        echo '<td align="right">'.torsize($size).'</td>';
        echo '<td class="s">'.getpeer($seeds).'</td>';
        echo '<td class="p">'.getpeer($peers).'</td>';
        echo '<td align="center"><img src="images/h'.health($peers, $seeds).'.png"></td>';
        echo '</tr>';
    }
    echo '</table><br />';
}

//Paginação

// $tr eh total_records e $rpp eh registros por pagina
    if ($tr%$rpp==0){
        $pages = intval($tr / $rpp)-1;
    }
    else{
        $pages = intval($tr / $rpp);
    }
    
    // calcula quantas paginas serao necessarias
    if ($tr>0){
        $NumRegistroInicial = ($pg*$rpp)+1;
        if ($pg <> $pages){
            $NumRegistroFinal = ($pg*$rpp)+$rpp;
        }
        else{
            $NumRegistroFinal = $tr;
        }
        

        echo'<div class="pages">';

        //Nao aparecer nada quando o numero minimo for respeitado
    if ($tr <= $rpp){
        echo '<br />';
    }
    else {
        echo "<p align=\"center\">Exibindo Torrents de $NumRegistroInicial a $NumRegistroFinal</p>";
        if ($pg <> 0){
            $showpage = $pg - 1;
            echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg=0"><< Primeiro</a>&nbsp;';
            echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg='.$showpage.'">< Anteriores</a>&nbsp;';
        }
        for ($i = $pg-3; $i<$pg; $i++){
            $showpage=$i+1;
            if ($i>=0){
                echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg='.$i.'">'.$showpage.'</a>';
                echo '&nbsp;&nbsp;';
            }
        }
        for ($i = $pg; ($i<=$pages AND $i<=($pg+3)); $i++){
            $showpage=$i+1;
            if ($i == $pg){
                echo '<a class=currentpage href=#><b>'.$showpage.'</b></a></font>&nbsp;';
            }
            else{
                echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg='.$i.'">'.$showpage.'</a>';
                echo '&nbsp;&nbsp;';
            }
        }
        if ($pg < $pages){
            $showpage = $pg + 1;
            echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg='.$showpage.'"> Próximas ></a>&nbsp;';
            echo '<a id=mulink href="'.$PHP_SELF.'?usuario='.$_GET['usuario'].'&pg='.$pages.'"> Último >></a>';
        }
    }
}
echo'</div>';

echo "<br /><br />";

footer();
?>
Go to the top of the pageReport Post
+

2 Pages V  < 1 2
Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
1 Members: OPPZeroCool

 




Internet Advertising | MPAA | Online Loans | Spanish Bible | Telefonos Móviles
-
Lo-Fi Version 0.1921 sec    --    13 queries    GZIP Enabled
Time is now: 28th May 2007 - 07:25 PM