Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   BT.Manager (phpMyBitTorrent) (http://www.bvlist.com/forumdisplay.php?f=23)
-   -   help needed on imperialbt torrents.php (http://www.bvlist.com/showthread.php?t=6685)

it53lv 2nd July 2011 12:53

help needed on imperialbt torrents.php
 
1 Attachment(s)
so i cooked up a new look for pagination > screen attached
so i need someone to get top pagination to work
since query is between top and bottom pagination code
top one is not working
code is all right i think i haven't messed anything up
only "Jump to" is still just a placeholder haven't wrote jquery for that jet

so here is my torrents.php
Code:

if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
include("header.php");
require('actb.php');
echo "


  • Jump to
    \"+\"
  • ".$prev."".(($pages > 1) ? $pager : "")."".$next."


";
echo "

Click here to toggle CATEGORIES



";
 $i = 0;
foreach (catlist() as $c) {
$i++;
echo "";
if ($i == 6) {
echo "";
$i = 0;
 }
}
echo "
".$c["name"]."
";
echo"
";
#OBT: Add joe's table-head sorting function:
$sort =  (isset($_GET["sort"])) ? $_GET["sort"] : '';
$type =  (isset($_GET["type"])) ? $_GET["type"] : '';
$orderby = " ORDER BY ".$db_prefix."_torrents.evidence DESC, ";//
if ($sort == 1) $orderby = " ORDER BY ".$db_prefix."_torrents.name $type,  ";//
 
if ($sort == 2){
$orderby = " ORDER BY ".$db_prefix."_torrents.numfiles $type,  ";//
}
if ($sort == 3){
$orderby = " ORDER BY ".$db_prefix."_torrents.comments $type,  ";//
}
if ($sort == 4){
$orderby = " ORDER BY ".$db_prefix."_torrents.category $type,  ";//
}
if ($sort == 5){
$orderby = " ORDER BY ".$db_prefix."_torrents.size $type,  ";
}
if ($sort == 6){
$orderby = " ORDER BY ".$db_prefix."_torrents.times_completed $type,  ";
}
if ($sort == 7){
$orderby = " ORDER BY ".$db_prefix."_torrents.seeders $type,  ";//
}
if ($sort == 8){
$orderby = " ORDER BY ".$db_prefix."_torrents.leechers $type,  ";//
}
 
if ($onlysearch) {
        OpenTable(_btnosearchttl);
        echo _btnosearch;
        CloseTable();
} else {
        if (!isset($page) OR !is_numeric($page) OR $page < 1) $page = 1;
        if (!isset($cat)) $cat = "";
        if (intval($cat) > 0) $catwhere = " AND ".$db_prefix."_torrents.category = ".intval($cat);
        else $catwhere = "";
        $passwhere = " AND ".$db_prefix."_torrents.password IS NULL ";
        $viswhere = "visible = 'yes' AND banned = 'no'";
        if ($user->moderator) $viswhere = "1";
        if ($user->premium) $passwhere = "";
 
        $from = ($page - 1) * $torrent_per_page;
 
        $totsql = "SELECT COUNT(*) as tot FROM ".$db_prefix."_torrents WHERE ".$viswhere.$catwhere.$passwhere.";";
        $sql = "SELECT ".$db_prefix."_torrents.*, IF(".$db_prefix."_torrents.numratings < '".$minvotes."', NULL, ROUND(".$db_prefix."_torrents.ratingsum / ".$db_prefix."_torrents.numratings, 1)) AS rating, ".$db_prefix."_categories.name AS cat_name, ".$db_prefix."_categories.image AS cat_pic, U.username, IF(U.name IS NULL, U.username, U.name) as user_name, U.level as user_level FROM ".$db_prefix."_torrents LEFT JOIN ".$db_prefix."_categories ON category = ".$db_prefix."_categories.id LEFT JOIN ".$db_prefix."_users U ON ".$db_prefix."_torrents.owner = U.id WHERE ".$viswhere.$catwhere.$passwhere.$orderby.$db_prefix."_torrents.added DESC LIMIT ".$from.",".$torrent_per_page.";";
 
        $res = $db->sql_query($sql) or btsqlerror($sql);
        $totres = $db->sql_query($totsql);
 
if (isset($sort))$sort1= "&sort=".$sort."&type=".$type;
else
$sort1="";
if (isset($sort))$sort2= "?sort=".$sort."&type=".$type;
else
$sort2="";
        list ($tot) = $db->sql_fetchrow($totres);
        $db->sql_freeresult($totres);
        if ($db->sql_numrows($res) > 0) {
                $pages = ceil($tot / $torrent_per_page);
 
if($page < $pages & $cat) {
$next = "
  • >
  • ";
    } elseif($page < $pages ) {
    $next = "
  • >
  • ";
    }else{
    $next = "
  • >
  • ";
    }
    if($page > 1 & $cat) {
    $prev = "
  • <
  • "; } elseif($page > 1) {
    $prev = "
  • <
  • ";
    }else{
    $prev = "
  • <
  • ";
    }
    if($cat){
    $pager = "".(($page == 1) ? "
  • 1
  • " : "
  • 1
  • ")."
    ";
    if (($page - 15) > 1) $pager .= "...";
    for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
    $pager .= "".(($i == $page) ? "
  • ".$i."
  • " : "
  • ".$i."
  • ")."
    ";
    }
    if (($page + 15) < $pages) $pager .= "...";
    $pager .= "".(($page == $pages) ? "
  • ".$pages."
  • " : "
  • ".$pages."
  • ")."
    ";
    torrenttable($res);
    }else {
    $pager = "".(($page == 1) ? "
  • 1
  • " : "
  • 1
  • ")."
    ";
    if (($page - 15) > 1) $pager .= "...";
    for ($i = max(2,$page - 15); $i < min($pages, $page + 15); $i++) {
    $pager .= "".(($i == $page) ? "
  • ".$i."
  • " : "
  • ".$i."
  • ")."
    ";
    }
    if (($page + 15) < $pages) $pager .= "...";
    $pager .= "".(($page == $pages) ? "
  • ".$pages."
  • " : "
  • ".$pages."
  • ")."
    ";
    torrenttable($res);
    }
    echo "


    • Jump to
      \"+\"
    • ".$prev."".(($pages > 1) ? $pager : "")."".$next."
    ";
    }
    }
    include("footer.php");
    ?>


    joeroberts 2nd July 2011 14:57

    because you are trying to use
    PHP Code:

    </li>".$prev."".(($pages > 1) ? $pager : "")."".$next."</ul

    on line 10 before it is defind

    it53lv 2nd July 2011 15:10

    explain why this code works for bottom and not top ?
    because i don't see any problem with it since all other li tags are coded in to next and prev functions

    joeroberts 2nd July 2011 15:21

    I did explain in my post you are trying to use information that has not been defined.
    on the bottom of the page it is defined on the top it is not.

    it53lv 2nd July 2011 15:26

    i know that but hove can i move this definition ?

    joeroberts 2nd July 2011 16:11

    PHP Code:

    <?php 
    if (defined('IN_PMBT'))die ("You can't include this file"); 
    define("IN_PMBT",true); 
    include(
    "header.php"); 
    require(
    'actb.php');
    echo 
    "
    <div id=\"forum_filter\" class=\"filter_bar rounded\">
    <span id=\"show_filters\" class=\"clickable\">Click here to toggle CATEGORIES</span>
    </div>
    <div class=\"categories_form\"><div class=\"border\"><div id=\"tbg\">
    <table class=\"bottom\">
    <tr>"
    ;
     
    $i 0
    foreach (
    catlist() as $c) { 
    $i++; 
    echo 
    "<td class=\"bottom\" style=\"padding-bottom: 2px; padding-left: 7px;\" align=\"left\"><input value=\"1\" type=\"checkbox\"><a href=\"torrents.php?cat=".$c["id"]."\">".$c["name"]."</a></td>"
    if (
    $i == 6) { 
    echo 
    "</tr><tr>"
    $i 0
     } 
    }
    echo 
    "</tr></table>";
    echo
    "</div></div></div><div id=\"myborder\"></div>"
    #OBT: Add joe's table-head sorting function: 
    $sort =  (isset($_GET["sort"])) ? $_GET["sort"] : ''
    $type =  (isset($_GET["type"])) ? $_GET["type"] : ''
    $orderby " ORDER BY ".$db_prefix."_torrents.evidence DESC, ";// 
    if ($sort == 1$orderby " ORDER BY ".$db_prefix."_torrents.name $type,  ";// 
     
    if ($sort == 2){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.numfiles $type,  ";// 

    if (
    $sort == 3){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.comments $type,  ";// 

    if (
    $sort == 4){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.category $type,  ";// 

    if (
    $sort == 5){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.size $type,  "

    if (
    $sort == 6){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.times_completed $type,  "

    if (
    $sort == 7){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.seeders $type,  ";// 

    if (
    $sort == 8){ 
    $orderby " ORDER BY ".$db_prefix."_torrents.leechers $type,  ";// 

     
    if (
    $onlysearch) { 
            
    OpenTable(_btnosearchttl); 
            echo 
    _btnosearch
            
    CloseTable(); 
    } else { 
            if (!isset(
    $page) OR !is_numeric($page) OR $page 1$page 1
            if (!isset(
    $cat)) $cat ""
            if (
    intval($cat) > 0$catwhere " AND ".$db_prefix."_torrents.category = ".intval($cat); 
            else 
    $catwhere ""
            
    $passwhere " AND ".$db_prefix."_torrents.password IS NULL "
            
    $viswhere "visible = 'yes' AND banned = 'no'"
            if (
    $user->moderator$viswhere "1"
            if (
    $user->premium$passwhere ""
     
            
    $from = ($page 1) * $torrent_per_page
     
            
    $totsql "SELECT COUNT(*) as tot FROM ".$db_prefix."_torrents WHERE ".$viswhere.$catwhere.$passwhere.";"
            
    $sql "SELECT ".$db_prefix."_torrents.*, IF(".$db_prefix."_torrents.numratings < '".$minvotes."', NULL, ROUND(".$db_prefix."_torrents.ratingsum / ".$db_prefix."_torrents.numratings, 1)) AS rating, ".$db_prefix."_categories.name AS cat_name, ".$db_prefix."_categories.image AS cat_pic, U.username, IF(U.name IS NULL, U.username, U.name) as user_name, U.level as user_level FROM ".$db_prefix."_torrents LEFT JOIN ".$db_prefix."_categories ON category = ".$db_prefix."_categories.id LEFT JOIN ".$db_prefix."_users U ON ".$db_prefix."_torrents.owner = U.id WHERE ".$viswhere.$catwhere.$passwhere.$orderby.$db_prefix."_torrents.added DESC LIMIT ".$from.",".$torrent_per_page.";"
     
            
    $res $db->sql_query($sql) or btsqlerror($sql); 
            
    $totres $db->sql_query($totsql); 
     
    if (isset(
    $sort))$sort1"&sort=".$sort."&type=".$type
    else 
    $sort1=""
    if (isset(
    $sort))$sort2"?sort=".$sort."&type=".$type
    else 
    $sort2=""
            list (
    $tot) = $db->sql_fetchrow($totres); 
            
    $db->sql_freeresult($totres); 
            if (
    $db->sql_numrows($res) > 0) { 
                    
    $pages ceil($tot $torrent_per_page); 
     
    if(
    $page $pages $cat) { 
    $next "<a href=\"torrents.php?page=".($page+1)."&cat=".$cat."\"><li class=\"next\">></li></a>"
    } elseif(
    $page $pages ) { 
    $next "<a href=\"torrents.php?page=".($page+1).$sort1."\"><li class=\"active\">></li></a>"
    }else{ 
    $next "<li class=\"next\">></li>"

    if(
    $page $cat) { 
    $prev "<a href=\"torrents.php?page=".($page-1)."&cat=".$cat."\"><li class=\"prev\"><</li></a>"; } elseif($page 1) { 
    $prev "<a href=\"torrents.php?page=".($page-1).$sort1."\"><li class=\"active\"><</li></a>"
    }else{ 
    $prev "<li class=\"prev\"><</li>"

    if(
    $cat){ 
    $pager "<a href=\"torrents.php?cat=".$cat."\">".(($page == 1) ? "<li class=\"active\">1</li>" "<li class=\"inside2\">1</li>")."</a>"
    if ((
    $page 15) > 1$pager .= "..."
    for (
    $i max(2,$page 15); $i min($pages$page 15); $i++) { 
    $pager .= "<a href=\"torrents.php?page=".$i."&cat=".$cat."\">".(($i == $page) ? "<li class=\"active\">".$i."</li>" "<li class=\"inside2\">".$i."</li>")."</a>"

    if ((
    $page 15) < $pages$pager .= "..."
    $pager .= "<a href=\"torrents.php?page=".$pages."&cat=".$cat."\">".(($page == $pages) ? "<li class=\"active\">".$pages."</li>" "<li class=\"inside2\">".$pages."</li>")."</a>";
    torrenttable($res); 
    }else { 
    $pager "<a href=\"torrents.php".$sort2."\">".(($page == 1) ? "<li class=\"active\">1</li>" "<li class=\"inside2\">1</li>")."</a>"
    if ((
    $page 15) > 1$pager .= "..."
    for (
    $i max(2,$page 15); $i min($pages$page 15); $i++) { 
    $pager .= "<a href=\"torrents.php?page=".$i.$sort1."\">".(($i == $page) ? "<li class=\"active\">".$i."</li>" "<li class=\"inside2\">".$i."</li>")."</a>"

    if ((
    $page 15) < $pages$pager .= "..."
    $pager .= "<a href=\"torrents.php?page=".$pages.$sort1."\">".(($page == $pages) ? "<li class=\"active\">".$pages."</li>" "<li class=\"inside2\">".$pages."</li>")."</a>"
    echo 
    "<div class=\"topic_controls\">
    <ul class=\"pagination bottom left\">
    <li class=\"total pagejump clickable\">Jump to
    <img src=\"
    $siteurl/themes/$theme/pics/imperial/dropdown.png\" alt=\"+\" />
    </li>"
    .$prev."".(($pages 1) ? $pager "")."".$next."</ul>
    <ul class=\"topic_buttons\">
    <li><a href=\"upload.php?op=link\" title=\"\">
    <img src=\"
    $siteurl/themes/$theme/pics/imperial/topic_watch.png\" alt=\"\" />Upload ed2k link</a>
    </li>
    <li><a href=\"upload.php?op=torrent\" title=\"\">
    <img src=\"
    $siteurl/themes/$theme/pics/imperial/page_white_add.png\" alt=\"\" />Upload torrent</a>
    </li>
    </ul>
    </div>"
    ;
    torrenttable($res); 
    }
    echo 
    "<div class=\"topic_controls\">
    <ul class=\"pagination bottom left\">
    <li class=\"total pagejump clickable\">Jump to
    <img src=\"
    $siteurl/themes/$theme/pics/imperial/dropdown.png\" alt=\"+\" />
    </li>"
    .$prev."".(($pages 1) ? $pager "")."".$next."</ul></div>"


    include(
    "footer.php"); 
    ?>


    it53lv 2nd July 2011 16:16

    thankyou :drink:


    All times are GMT +2. The time now is 05:42.

    Powered by vBulletin® Version 3.8.11 Beta 3
    Copyright ©2000 - 2024, vBulletin Solutions Inc.