Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Problem with Categories in TbDev (http://www.bvlist.com/showthread.php?t=4048)

Extreme86 24th December 2009 21:04

Problem with Categories in TbDev
 
I have Big problem with Categories.
I can't change my Categories.
my Browse.php
Code:




ob_start("ob_gzhandler");



require_once("include/bittorrent.php");





dbconn(false);



loggedinorreturn();

function top5(){

$res = mysql_query("SELECT id,seeders, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 7") or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) > 0) {

print'';

print("\n");

while ($arr = mysql_fetch_assoc($res)) {

$torrname = htmlspecialchars($arr['name']);

if (strlen($torrname) > 55)

$torrname = substr($torrname, 0, 55) . "...";

$ttl = (28*24) - floor((gmtime() - sql_timestamp_to_unix_timestamp($arr["added"])) / 3600);



print("\n");

}

print("
Top 7 TorrentsSeedersLechers
".$torrname."".$arr['seeders']."".number_format($arr['leechers'])."
\n");

} else

print("no torrents here :(");



}

parked();





$cats = genrelist();



$searchstr = unesc($_GET["search"]);

$cleansearchstr = searchfield($searchstr);

if (empty($cleansearchstr))

unset($cleansearchstr);



// sorting by MarkoStamcar



if ($_GET['sort'] && $_GET['type']) {



$column = '';

$ascdesc = '';



switch($_GET['sort']) {

case '1': $column = "name"; break;

case '2': $column = "numfiles"; break;

case '3': $column = "comments"; break;

case '4': $column = "added"; break;

case '5': $column = "size"; break;

case '6': $column = "times_completed"; break;

case '7': $column = "seeders"; break;

case '8': $column = "leechers"; break;

case '9': $column = "owner"; break;

default: $column = "id"; break;

}



switch($_GET['type']) {

case 'asc': $ascdesc = "ASC"; $linkascdesc = "asc"; break;

case 'desc': $ascdesc = "DESC"; $linkascdesc = "desc"; break;

default: $ascdesc = "DESC"; $linkascdesc = "desc"; break;

}





$orderby = "ORDER BY torrents." . $column . " " . $ascdesc;

$pagerlink = "sort=" . intval($_GET['sort']) . "&type=" . $linkascdesc . "&";



} else {



$orderby = "ORDER BY torrents.sticky ASC, torrents.id DESC";

$pagerlink = "";



}



$addparam = "";

$wherea = array();

$wherecatina = array();



if ($_GET["incldead"] == 1)

{

        $addparam .= "incldead=1&";

        if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)

                $wherea[] = "banned != 'yes'";

}

elseif ($_GET["incldead"] == 2)

{

        $addparam .= "incldead=2&";

                $wherea[] = "seeders = '0'";

}

else

 $wherea[] = "seeders >= '1'";

 $category = (int)$_GET["cat"];



$all = $_GET["all"];



if (!$all)

        if (!$_GET && $CURUSER["notifs"])

        {

          $all = True;

          foreach ($cats as $cat)

          {

            $all &= $cat[id];

            if (strpos($CURUSER["notifs"], "[cat" . $cat[id] . "]") !== False)

            {

              $wherecatina[] = $cat[id];

              $addparam .= "c$cat[id]=1&";

            }

          }

        }

        elseif ($category)

        {

          if (!is_valid_id($category))

            stderr("Error", "Invalid category ID $category");

          $wherecatina[] = $category;

          $addparam .= "cat=$category&";

        }

        else

        {

          $all = True;

          foreach ($cats as $cat)

          {

            $all &= $_GET["c$cat[id]"];

            if ($_GET["c$cat[id]"])

            {

              $wherecatina[] = $cat[id];

              $addparam .= "c$cat[id]=1&";

            }

          }

        }



if ($all)

{

        $wherecatina = array();

  $addparam = "";

}



if (count($wherecatina) > 1)

        $wherecatin = implode(",",$wherecatina);

elseif (count($wherecatina) == 1)

        $wherea[] = "category = $wherecatina[0]";



$wherebase = $wherea;



if (isset($cleansearchstr))

{

        $wherea[] = "MATCH (search_text, ori_descr) AGAINST (" . sqlesc($searchstr) . ")";

        //$wherea[] = "0";

        $addparam .= "search=" . urlencode($searchstr) . "&";

        //$orderby = "";

}



$where = implode(" AND ", $wherea);

if ($wherecatin)

        $where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")";



if ($where != "")

        $where = "WHERE $where";



$res = mysql_query("SELECT COUNT(*) FROM torrents $where") or die(mysql_error());

$row = mysql_fetch_array($res);

$count = $row[0];



if (!$count && isset($cleansearchstr)) {

        $wherea = $wherebase;

        //$orderby = "ORDER BY id DESC";

        $searcha = explode(" ", $cleansearchstr);

        $sc = 0;

        foreach ($searcha as $searchss) {

                if (strlen($searchss) <= 1)

                        continue;

                $sc++;

                if ($sc > 5)

                        break;

                $ssa = array();

                foreach (array("search_text", "ori_descr") as $sss)

                        $ssa[] = "$sss LIKE '%" . sqlwildcardesc($searchss) . "%'";

                $wherea[] = "(" . implode(" OR ", $ssa) . ")";

        }

        if ($sc) {

                $where = implode(" AND ", $wherea);

                if ($where != "")

                        $where = "WHERE $where";

                $res = mysql_query("SELECT COUNT(*) FROM torrents $where");

                $row = mysql_fetch_array($res);

                $count = $row[0];

        }

}



$torrentsperpage = $CURUSER["torrentsperpage"];

if (!$torrentsperpage)

        $torrentsperpage = 30;



if ($count)

{

  if ($addparam != "") {

 if ($pagerlink != "") {

  if ($addparam{strlen($addparam)-1} != ";") { // & = &

    $addparam = $addparam . "&" . $pagerlink;

  } else {

    $addparam = $addparam . $pagerlink;

  }

 }

    } else {

 $addparam = $pagerlink;

    }



        list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam);

        $query = "SELECT torrents.id, torrents.nuked, torrents.category, torrents.leechers, torrents.seeders, torrents.request, torrents.scene, torrents.name,  torrents.sticky, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filename,torrents.description,torrents.owner,IF(torrents.nfo <> '', 1, 0) as nfoav," .

//        "IF(torrents.numratings < $minvotes, NULL, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";

        "categories.name AS cat_name, categories.image AS cat_pic, users.username FROM torrents LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit";

        $res = mysql_query($query) or die(mysql_error());

}

else

        unset($res);

if (isset($cleansearchstr))

        stdhead("Search results for \"$searchstr\"");

else

        stdhead("Browse Torrents");



?>









































in



look in:






if ($_GET["incldead"])

$deadchkbox .= " checked=\"checked\"";

?>


































if (isset($cleansearchstr))

print("

Search results for \"" . htmlspecialchars($searchstr) . "\"

\n");



if ($count) {

        print($pagertop);

print("
");

top5();

print("
");

        torrenttable($res);



        print($pagerbottom);

}

else {

        if (isset($cleansearchstr)) {

                print("

Nothing found!

\n");

                print("

Try again with a refined search string.

\n");

        }

        else {

                print("

Nothing here!

\n");

                print("

Sorry pal :(

\n");

        }

}



if ($CURUSER)

 

?>







NEW - New Torrents!

Free download - Torrent freeleech so only upload counts!

  Request - This symbol is at torrentele who made a request for a user!

Sticky - Used in torrents sticky!







// Torrents Needing Seeds mod

$need = mysql_query("SELECT id, name, leechers FROM torrents WHERE seeders = 0 AND leechers > 0 ORDER BY leechers DESC") or sqlerr();

if(mysql_num_rows($need))

{

echo("

Torrents Needing Seeds: $num

");

while($res = mysql_fetch_assoc($need))

{

 echo("$res[name] - ($res[leechers] leecher" . ($res[leechers] > 1 ? "s" : "") . ")");

}

echo("
");

}



stdfoot();



mysql_query("UPDATE users SET last_browse=".gmtime()." where id=".$CURUSER['id']);

?>

An this is my
category.php
Code:


ob_start();

require_once("include/bittorrent.php");

dbconn(false);

loggedinorreturn();

if (get_user_class() < UC_SYSOP) {

die("Access denied.");

}

mysql_connect($mysql_host,$mysql_user,$mysql_pass);

mysql_select_db($mysql_db);

stdhead("Categories");

print("

Categories

\n");

print("
");

print("
\n");



///////////////////// D E L E T E C A T E G O R Y \\\\\\\\\\\\\\\\\\\\\\\\\\\\



$sure = $_GET['sure'];

if($sure == "yes") {

$delid = $_GET['delid'];

$query = "DELETE FROM categories WHERE id=" .sqlesc($delid) . " LIMIT 1";

$sql = mysql_query($query);

echo("Category succesfully deleted! [ Back ]");

end_frame();

stdfoot();

die();

}

$delid = $_GET['delid'];

$name = $_GET['cat'];

if($delid > 0) {

echo("Are you sure you would like to delete this category? ($name) ( Y / N )");

end_frame();

stdfoot();

die();



}



///////////////////// E D I T A C A T E G O R Y \\\\\\\\\\\\\\\\\\\\\\\\\\\\

$edited = $_GET['edited'];

if($edited == 1) {

$id = $_GET['id'];

$cat_name = $_GET['cat_name'];

$cat_img = $_GET['cat_img'];

$query = "UPDATE categories SET

name = '$cat_name',

image = '$cat_img' WHERE id=".sqlesc($id);

$sql = mysql_query($query);

if($sql) {

echo("");

echo("");

echo("
Well done! Your category has been edited succesfully! [ Back ]
");

end_frame();

stdfoot();

die();

}

}



$editid = $_GET['editid'];

$name = $_GET['name'];

$img = $_GET['img'];

if($editid > 0) {

echo("
");

echo("");

echo("
Now editing category "$name"
");

echo("");

echo("");

echo("");

echo("");

echo("");

echo("
Category Name:
Category Image Name:
");

end_frame();

stdfoot();

die();

}



///////////////////// A D D A N E W C A T E G O R Y \\\\\\\\\\\\\\\\\\\\\\\\\\\\

$add = $_GET['add'];

if($add == 'true') {

$cat_name = $_GET['cat_name'];

$cat_img = $_GET['cat_img'];

$query = "INSERT INTO categories SET

name = '$cat_name',

image = '$cat_img'";

$sql = mysql_query($query);

if($sql) {

$success = TRUE;

} else {

$success = FALSE;

}

}

print("Add A New Category!");

print("");

print("");

echo("
");

echo("");

echo("");

echo("");

echo("");

echo("
Category Name:
Category Image Name:
");

if($success == TRUE) {

print("Success!");

}

echo("");

echo("
");



///////////////////// E X I S T I N G C A T E G O R I E S \\\\\\\\\\\\\\\\\\\\\\\\\\\\



print("Existing Categories:");

print("");

print("");

echo("");

echo("");

$query = "SELECT * FROM categories WHERE 1=1";

$sql = mysql_query($query);

while ($row = mysql_fetch_array($sql)) {

$id = $row['id'];

$name = $row['name'];

$img = $row['image'];

echo("");

}



end_frame();

end_frame();

stdfoot();



?>
http://img196.imageshack.us/img196/1613/catgp.jpg
Please Help me.

Bump: What can i change from here for my new Categories. Now its 23 categories. I ant 26 and with my images

Code:

d width=30% align=center>



in



look in:






if ($_GET["incldead"])

$deadchkbox .= " checked=\"checked\"";

?>















ID:Name:Picture:Browse Category:Edit:Delete:
$id $name