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 = 15; if ($count) { list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam); $query = "SELECT torrents.id, torrents.category, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.numfiles,torrents.filename,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"); ?>
" : ""); print("\n"); $i++; } $alllink = "
(Show all)
"; $ncats = count($cats); $nrows = ceil($ncats/$catsperrow); $lastrowcols = $ncats % $catsperrow; if ($lastrowcols != 0) { if ($catsperrow - $lastrowcols != 1) { print(""); } print("\n"); } ?>
" . htmlspecialchars($cat[name]) . " $alllink
$alllink\n"); ?>


Search results for \"" . htmlspecialchars($searchstr) . "\"\n"); if ($count) { print($pagertop); 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"); } } stdfoot(); ?>