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) . "&"; if(isset($_GET["sort"])) { $type = htmlspecialchars($_GET['sort']); $sort = htmlspecialchars($_GET['d']); if (!is_valid_type($type)) stderr( _("Error"), _("Invalid type")); if (!is_valid_sort($sort)) stderr( _("Error"), _("Invalid sort")); $orderby = "ORDER BY $type $sort"; } else $orderby = "ORDER BY torrents.id DESC"; } $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; if(isset($_GET["sort"])) { $type = $_GET['sort']; if (!is_valid_type($type)) { $msg = "Invalid type: ".$type." Username: ".$CURUSER['username']."(".$_SERVER['REMOTE_ADDR'].")"; new_msg($CURUSER['id'], $GLOBALS['settings']['admin_uid'], $msg); stderr( _("Error"), _("Invalid type")); } $sort = htmlspecialchars($_GET['d']); if (!is_valid_sort($sort)) { $msg = "Invalid sort: ".$sort." Username: ".$CURUSER['username']."(".$_SERVER['REMOTE_ADDR'].")"; new_msg($CURUSER['id'], $GLOBALS['settings']['admin_uid'], $msg); stderr( _("Error"), _("Invalid sort")); } $orderby = "ORDER BY $type $sort"; } else $orderby = "ORDER BY torrents.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; list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "browse.php?" . $addparam); $query = "SELECT users.username, users.anonymous, torrents.id, torrents.category, torrents.description, torrents.leechers, torrents.seeders, torrents.name, torrents.times_completed, torrents.size, torrents.added, FLOOR( ( UNIX_TIMESTAMP() - UNIX_TIMESTAMP(torrents.added) ) / 3600 ) as time_alive, UNIX_TIMESTAMP(torrents.added) as utadded, torrents.comments, torrents.numfiles, torrents.filename, torrents.owner, IF(torrents.nfo <> '', 1, 0) as nfoav, IF(torrents.numratings < $minvotes, 0, ROUND(torrents.ratingsum / torrents.numratings, 1)) AS rating, categories.name AS cat_name, categories.image AS cat_pic, categories.stylesheet AS cat_stylesheet, categories.name AS cat_name, categories.image AS cat_pic, categories.stylesheet AS cat_stylesheet FROM torrents" .$sql_force_index." LEFT JOIN categories ON category = categories.id LEFT JOIN users ON torrents.owner = users.id $where $orderby $limit "; $result = do_mysql_query($query) or die (mysql_error()); while ($record = mysql_fetch_assoc($result) ) { $records[] = $record; } if (isset($cleansearchstr)) stdhead( sprintf( _('Search results for "%s"'), $searchstr) ); else stdhead(); ?>
" : ""); print("\n"); $i++; } $alllink = ""; $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 > 0) { print($pagertop); torrenttable($records, "browse.php?" . $addparam); 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['time_last_browse'] > 60 ) do_mysql_query("UPDATE users SET last_browse=UNIX_TIMESTAMP(NOW()) where id=".$CURUSER['id']); stdfoot(); ?>