Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
Thread Tools
  #1  
Old 6th July 2009, 13:41
wMan wMan is offline
Banned
 
Join Date: Feb 2008
P2P
Posts: 1,433
Default categories images in browse
my browse.php
as u can see by now to list categories images in browse i need to set every image by writing it in there but what i want is to make them set themselfs from mysql like categories.php when it lists them
one more thing ... for some reason it sets categorie image from css so basicli there is no need for categories.php if i still need to set every image in 2 files but i can't find a way to fix it or even where is that part who sets image from css woud be great if someone coud help out a bit [PHP]<?
ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
parked();
maxsysop ();
$cats = genrelist();
$searchstr = unesc($_GET["search"]);
$cleansearchstr = searchfield($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);
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.id DESC";
$pagerlink = "";
}
$addparam = "";
$wherea = array();
$wherecatina = array();
if ($_GET["incldead"] == 1)
{
$addparam .= "incldead=1&amp;";
if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
elseif ($_GET["incldead"] == 2)
{
$addparam .= "incldead=2&amp;";
$wherea[] = "visible = 'no'";
}
else
$wherea[] = "visible = 'yes'";
$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&amp;";
}
}
}
elseif ($category)
{
if (!is_valid_id($category))
stderr("Error", "Invalid category ID $category");
$wherecatina[] = $category;
$addparam .= "cat=$category&amp;";
}
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&amp;";
}
}
}

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) . "&amp;";
//$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 = 15;
if ($addparam != "") {
if ($pagerlink != "") {
if ($addparam{strlen($addparam)-1} != ";") { // & = &amp;
$addparam = $addparam . "&" . $pagerlink;
} else {
$addparam = $addparam . $pagerlink;
}
}
} else {
$addparam = $pagerlink;
}

if ($count)
{
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.free, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filen ame,torrents.description,torrents.owner,IF(torrent s.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("Failu saraksts");
?>
<table class="categ" border="1" cellpadding="0" cellspacing="5" width="950">
<tbody>
<tr>
<td width="950"><center>
<form method="get" action="browse.php">
<a href="viewrequests.php"><img src="pic/reqs.png" border=0></a><b>Meklēt:</b>
<input name="search" size="40" value="" type="text">
<select name="cat">
<option value="0">(Visi)</option>
<option value="6">Anime/Cartoon</option>
<option value="2">Appz</option>
<option value="13">Docs</option>
<option value="4">Games/PC</option>
<option value="17">Games/PS2</option>
<option value="22">Games/PS3</option>
<option value="23">Games/PSP</option>
<option value="24">Games/Wii</option>
<option value="25">Games/X360</option>
<option value="14">Images</option>
<option value="18">Hentai</option>
<option value="2">MiSC</option>
<option value="12">Mobile</option>
<option value="16">Movies/DVD-RO</option>
<option value="11">Movies/SVCD</option>
<option value="8">Movies/Oldies</option>
<option value="3">Movies/XVID</option>
<option value="7">Linux/Unix</option>
<option value="15">Music/Video</option>
<option value="5">Music/Mp3</option>
<option value="26">Movies/DVDR</option>
<option value="10">Tv/Episodes</option>
<option value="21">Tv/Boxsets</option>
</select>
</select>
<input value="Ok!" type="submit">
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Apskatīt failus</b>
<select name="incldead">
<option value="0">Aktīvos</option>
<option value="1">Arī miru
Reply With Quote
  #2  
Old 6th July 2009, 19:23
djlee's Avatar
djlee djlee is offline
Senior Member
 
Join Date: Mar 2008
Posts: 183
Default
There should already be a column in the cats mysql table for storing the cat image, so first of all make sure those are all setup properly. What id do is set these to stuff like dvdr.gif, xvid,gif, music.gif .. then store all the caticons in a folder called "caticons" in the pic or images directory.

then in bittorrent.php inside the genrelist() function add "image" to the category select fields in the mysql query so it will fetch those images u should have set in the table.

then its simply a case of looping through on the browse page, so for your select list you may wanna use

Code:
foreach ($cats as $cat)
 echo "<option value='".$cat['id']."'>".$cat['name']."</option>";
and for a list of images
Code:
foreach ($cats as $cat)
 echo "<img src='images/caticons/".$cat['image']."' border='0' alt='".$cat['name']."' />";
Reply With Quote
  #3  
Old 7th July 2009, 09:00
wMan wMan is offline
Banned
 
Join Date: Feb 2008
P2P
Posts: 1,433
Default
thanks m8 it lists them but needs a corection because i use those images to not use checkboxes any way thanks
got it work
here is my new browse.php
[php]<?
ob_start("ob_gzhandler");
require_once("include/bittorrent.php");
dbconn(false);
loggedinorreturn();
parked();
maxsysop ();

$cats = genrelist();
$searchstr = unesc($_GET["search"]);
$cleansearchstr = searchfield($searchstr);
if (empty($cleansearchstr))
unset($cleansearchstr);
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.id DESC";
$pagerlink = "";
}
$addparam = "";
$wherea = array();
$wherecatina = array();
if ($_GET["incldead"] == 1)
{
$addparam .= "incldead=1&amp;";
if (!isset($CURUSER) || get_user_class() < UC_ADMINISTRATOR)
$wherea[] = "banned != 'yes'";
}
elseif ($_GET["incldead"] == 2)
{
$addparam .= "incldead=2&amp;";
$wherea[] = "visible = 'no'";
}
else
$wherea[] = "visible = 'yes'";
$category = (int)$_GET["cat"];
$all = $_GET["all"];
if (!$all)
if (!$_GET && $CURUSER["notifs"])
{
$all = True;
foreach ($cats as $cat)
echo "<option value='".$cat['id']."'>".$cat['name']."</option>";
}

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) . "&amp;";
//$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 = 15;
if ($addparam != "") {
if ($pagerlink != "") {
if ($addparam{strlen($addparam)-1} != ";") { // & = &amp;
$addparam = $addparam . "&" . $pagerlink;
} else {
$addparam = $addparam . $pagerlink;
}
}
} else {
$addparam = $pagerlink;
}

if ($count)
{
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.free, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filen ame,torrents.description,torrents.owner,IF(torrent s.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("Failu saraksts");
?>
<table class="categ" border="1" cellpadding="0" cellspacing="5" width="950">
<tbody>
<tr>
<td width="950"><center>
<form method="get" action="browse.php">
<a href="viewrequests.php"><img src="pic/reqs.png" border=0></a><b>Meklēt:</b>
<input name="search" size="40" value="" type="text">
<select name="cat">
<option value="0">(Visi)</option>
<option value="6">Anime/Cartoon</option>
<option value="2">Appz</option>
<option value="13">Docs</option>
<option value="4">Games/PC</option>
<option value="17">Games/PS2</option>
<option value="22">Games/PS3</option>
<option value="23">Games/PSP</option>
<option value="24">Games/Wii</option>
<option value="25">Games/X360</option>
<option value="14">Images</option>
<option value="18">Hentai</option>
<option value="2">MiSC</option>
<option value="12">Mobile</option>
<option value="16">Movies/DVD-RO</option>
<option value="11">Movies/SVCD</option>
<option value="8">Movies/Oldies</option>
<option value="3">Movies/XVID</option>
<option value="7">Linux/Unix</option>
<option value="15">Music/Video</option>
<option value="5">Music/Mp3</option>
<option value="26">Movies/DVDR</option>
<option value="10">Tv/Episodes</option>
<option value="21">Tv/Boxsets</option>
</select>
</select>
<input value="Ok!" type="submit">
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Apskatīt failus</b>
<select name="incldead">
<option value="0">Aktīvos</option>
<option value="1">Arī miru
Reply With Quote
Reply

Tags
browse , categories , images


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to add a search box in browse.php irfan TBDev 0 22nd October 2009 17:25
Need new Images joeroberts BT.Manager (phpMyBitTorrent) 4 19th June 2009 02:02
browse.php ahly Community Cafe 0 12th December 2008 17:12
Images, Baners.... x517530 Template Shares 5 7th November 2008 04:15
Browse Mika Template Shares 3 7th September 2008 20:05



All times are GMT +2. The time now is 09:30. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.