1) $wherecatin = implode(",",$wherecatina); elseif (count($wherecatina) == 1) $wherea[] = "category = $wherecatina[0]"; if ($showsubcat){ if ($showsource){ if (count($wheresourceina) > 1) $wheresourcein = implode(",",$wheresourceina); elseif (count($wheresourceina) == 1) $wherea[] = "source = $wheresourceina[0]";} if ($showmedium){ if (count($wheremediumina) > 1) $wheremediumin = implode(",",$wheremediumina); elseif (count($wheremediumina) == 1) $wherea[] = "medium = $wheremediumina[0]";} if ($showcodec){ if (count($wherecodecina) > 1) $wherecodecin = implode(",",$wherecodecina); elseif (count($wherecodecina) == 1) $wherea[] = "codec = $wherecodecina[0]";} if ($showstandard){ if (count($wherestandardina) > 1) $wherestandardin = implode(",",$wherestandardina); elseif (count($wherestandardina) == 1) $wherea[] = "standard = $wherestandardina[0]";} if ($showprocessing){ if (count($whereprocessingina) > 1) $whereprocessingin = implode(",",$whereprocessingina); elseif (count($whereprocessingina) == 1) $wherea[] = "processing = $whereprocessingina[0]";} } if ($showteam){ if (count($whereteamina) > 1) $whereteamin = implode(",",$whereteamina); elseif (count($whereteamina) == 1) $wherea[] = "team = $whereteamina[0]";} if ($showaudiocodec){ if (count($whereaudiocodecina) > 1) $whereaudiocodecin = implode(",",$whereaudiocodecina); elseif (count($whereaudiocodecina) == 1) $wherea[] = "audiocodec = $whereaudiocodecina[0]";} $wherebase = $wherea; $search_area = 0; if (isset($searchstr)) { if (!isset($_GET['notnewword']) || !$_GET['notnewword']){ insert_suggest($searchstr, $CURUSER['id']); $notnewword=""; } else{ $notnewword="notnewword=1&"; } $search_mode = intval($_GET["search_mode"] ?? 0); if (!in_array($search_mode,array(0,1,2))) { $search_mode = 0; write_log("User " . $CURUSER["username"] . "," . $CURUSER["ip"] . " is hacking search_mode field in" . $_SERVER['SCRIPT_NAME'], 'mod'); } $search_area = intval($_GET["search_area"] ?? 0) ; if ($search_area == 4) { $searchstr = (int)parse_imdb_id($searchstr); } $like_expression_array =array(); unset($like_expression_array); switch ($search_mode) { case 0: // AND, OR case 1 : { $searchstr = str_replace(".", " ", $searchstr); $searchstr_exploded = explode(" ", $searchstr); $searchstr_exploded_count= 0; foreach ($searchstr_exploded as $searchstr_element) { $searchstr_element = trim($searchstr_element); // furthur trim to ensure that multi space seperated words still work $searchstr_exploded_count++; if ($searchstr_exploded_count > 10) // maximum 10 keywords break; $like_expression_array[] = " LIKE '%" . $searchstr_element. "%'"; } break; } case 2 : // exact { $like_expression_array[] = " LIKE '%" . $searchstr. "%'"; break; } /*case 3 : // parsed { $like_expression_array[] = $searchstr; break; }*/ } $ANDOR = ($search_mode == 0 ? " AND " : " OR "); // only affects mode 0 and mode 1 switch ($search_area) { case 0 : // torrent name { foreach ($like_expression_array as &$like_expression_array_element) $like_expression_array_element = "(torrents.name" . $like_expression_array_element." OR torrents.small_descr". $like_expression_array_element.")"; $wherea[] = implode($ANDOR, $like_expression_array); break; } case 1 : // torrent description { foreach ($like_expression_array as &$like_expression_array_element) $like_expression_array_element = "torrents.descr". $like_expression_array_element; $wherea[] = implode($ANDOR, $like_expression_array); break; } /*case 2 : // torrent small description { foreach ($like_expression_array as &$like_expression_array_element) $like_expression_array_element = "torrents.small_descr". $like_expression_array_element; $wherea[] = implode($ANDOR, $like_expression_array); break; }*/ case 3 : // torrent uploader { foreach ($like_expression_array as &$like_expression_array_element) $like_expression_array_element = "users.username". $like_expression_array_element; if(!isset($CURUSER)) // not registered user, only show not anonymous torrents { $wherea[] = implode($ANDOR, $like_expression_array) . " AND torrents.anonymous = 'no'"; } else { if(get_user_class() > $torrentmanage_class) // moderator or above, show all { $wherea[] = implode($ANDOR, $like_expression_array); } else // only show normal torrents and anonymous torrents from hiself { $wherea[] = "(" . implode($ANDOR, $like_expression_array) . " AND torrents.anonymous = 'no') OR (" . implode($ANDOR, $like_expression_array). " AND torrents.anonymous = 'yes' AND users.id=" . $CURUSER["id"] . ") "; } } break; } case 4 : //imdb url foreach ($like_expression_array as &$like_expression_array_element) $like_expression_array_element = "torrents.url". $like_expression_array_element; $wherea[] = implode($ANDOR, $like_expression_array); break; default : // unkonwn { $search_area = 0; $wherea[] = "torrents.name LIKE '%" . $searchstr . "%'"; write_log("User " . $CURUSER["username"] . "," . $CURUSER["ip"] . " is hacking search_area field in" . $_SERVER['SCRIPT_NAME'], 'mod'); break; } } $addparam .= "search_area=" . $search_area . "&"; $addparam .= "search=" . rawurlencode($searchstr) . "&".$notnewword; $addparam .= "search_mode=".$search_mode."&"; } $where = implode(" AND ", $wherea); if ($wherecatin) $where .= ($where ? " AND " : "") . "category IN(" . $wherecatin . ")"; if ($showsubcat){ if ($wheresourcein) $where .= ($where ? " AND " : "") . "source IN(" . $wheresourcein . ")"; if ($wheremediumin) $where .= ($where ? " AND " : "") . "medium IN(" . $wheremediumin . ")"; if ($wherecodecin) $where .= ($where ? " AND " : "") . "codec IN(" . $wherecodecin . ")"; if ($wherestandardin) $where .= ($where ? " AND " : "") . "standard IN(" . $wherestandardin . ")"; if ($whereprocessingin) $where .= ($where ? " AND " : "") . "processing IN(" . $whereprocessingin . ")"; if ($whereteamin) $where .= ($where ? " AND " : "") . "team IN(" . $whereteamin . ")"; if ($whereaudiocodecin) $where .= ($where ? " AND " : "") . "audiocodec IN(" . $whereaudiocodecin . ")"; } if ($allsec == 1 || $enablespecial != 'yes') { if ($where != "") $where = "WHERE $where "; else $where = ""; $sql = "SELECT COUNT(*) FROM torrents " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $where; } else { if ($where != "") $where = "WHERE $where AND categories.mode = '$sectiontype'"; else $where = "WHERE categories.mode = '$sectiontype'"; $sql = "SELECT COUNT(*), categories.mode FROM torrents LEFT JOIN categories ON category = categories.id " . ($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "") . $where." GROUP BY categories.mode"; } $res = sql_query($sql); $count = 0; while($row = mysql_fetch_array($res)) $count += $row[0]; if ($CURUSER["torrentsperpage"]) $torrentsperpage = (int)$CURUSER["torrentsperpage"]; elseif ($torrentsperpage_main) $torrentsperpage = $torrentsperpage_main; else $torrentsperpage = 50; if ($count) { if ($addparam != "") { if ($pagerlink != "") { if ($addparam[strlen($addparam)-1] != ";") { // & = & $addparam = $addparam . "&" . $pagerlink; } else { $addparam = $addparam . $pagerlink; } } } else { //stderr("in else",""); $addparam = $pagerlink; } //stderr("addparam",$addparam); //echo $addparam; list($pagertop, $pagerbottom, $limit) = pager($torrentsperpage, $count, "?" . $addparam); if ($allsec == 1 || $enablespecial != 'yes'){ $query = "SELECT torrents.id, torrents.sp_state, torrents.promotion_time_type, torrents.promotion_until, torrents.banned, torrents.picktype, torrents.pos_state, torrents.category, torrents.source, torrents.medium, torrents.codec, torrents.standard, torrents.processing, torrents.team, torrents.audiocodec, torrents.leechers, torrents.seeders, torrents.name, torrents.small_descr, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.anonymous,torrents.owner,torrents.url,torrents.cache_stamp,torrents.pt_gen,torrents.tags,torrents.hr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." $where $orderby $limit"; } else{ $query = "SELECT torrents.id, torrents.sp_state, torrents.promotion_time_type, torrents.promotion_until, torrents.banned, torrents.picktype, torrents.pos_state, torrents.category, torrents.source, torrents.medium, torrents.codec, torrents.standard, torrents.processing, torrents.team, torrents.audiocodec, torrents.leechers, torrents.seeders, torrents.name, torrents.small_descr, torrents.times_completed, torrents.size, torrents.added, torrents.comments,torrents.anonymous,torrents.owner,torrents.url,torrents.cache_stamp,torrents.pt_gen,torrents.tags,torrents.hr FROM torrents ".($search_area == 3 || $column == "owner" ? "LEFT JOIN users ON torrents.owner = users.id " : "")." LEFT JOIN categories ON torrents.category=categories.id $where $orderby $limit"; } $res = sql_query($query); } else unset($res); if (isset($searchstr)) stdhead($lang_torrents['head_search_results_for'].$searchstr_ori); elseif ($sectiontype == $browsecatmode) stdhead($lang_torrents['head_torrents']); else stdhead($lang_torrents['head_special']); print("
| ");
displayHotAndClassic();
if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showing bookmarked torrents from all sections;
?>
enable_ad()){
$belowsearchboxad = $Advertisement->get_ad('belowsearchbox');
if (!empty($belowsearchboxad[0])) {
echo " ".$belowsearchboxad[0]." ";
}
}
if($inclbookmarked == 1)
{
print("" . get_username($CURUSER['id']) . $lang_torrents['text_s_bookmarked_torrent'] . ""); } elseif($inclbookmarked == 2) { print("" . get_username($CURUSER['id']) . $lang_torrents['text_s_not_bookmarked_torrent'] . ""); } if ($count) { $rows = []; while ($row = mysql_fetch_assoc($res)) { $rows[] = $row; } print($pagertop); if ($sectiontype == $browsecatmode) torrenttable($rows, "torrents"); elseif ($sectiontype == $specialcatmode) torrenttable($rows, "music"); else torrenttable($rows, "bookmarks"); print($pagerbottom); } else { if (isset($searchstr)) { print(""); stdmsg($lang_torrents['std_search_results_for'] . $searchstr_ori . "\"",$lang_torrents['std_try_again']); } else { stdmsg($lang_torrents['std_nothing_found'],$lang_torrents['std_no_active_torrents']); } } if ($CURUSER){ if ($sectiontype == $browsecatmode) $USERUPDATESET[] = "last_browse = ".TIMENOW; else $USERUPDATESET[] = "last_music = ".TIMENOW; } print(" |