View Single Post
  #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