function search($params) { $list = array(); $tried = false; if (strlen($params->keywords)) { $kw = BoincDb::escape_string($params->keywords); $name_lc = strtolower($kw); $list2 = get_teams("name='{$name_lc}'", $params->active); merge_lists($list2, $list, 20); $name_lc = escape_pattern($name_lc); $list2 = get_teams("name like '" . $name_lc . "%'", $params->active); merge_lists($list2, $list, 5); $list2 = get_teams("match(name) against ('{$kw}')", $params->active); merge_lists($list2, $list, 5); $list2 = get_teams("match(name, description) against ('{$kw}')", $params->active); //echo "<br>keyword matches: ",sizeof($list2); merge_lists($list2, $list, 3); $tried = true; } if (strlen($params->country) && $params->country != 'None') { $country = BoincDb::escape_string($params->country); $list2 = get_teams("country = '{$country}'", $params->active); //echo "<br>country matches: ",sizeof($list2); merge_lists($list2, $list, 1); $tried = true; } if ($params->type and $params->type > 1) { $list2 = get_teams("type={$params->type}", $params->active); //echo "<br>type matches: ",sizeof($list2); merge_lists($list2, $list, 2); $tried = true; } if (!$tried) { $list = get_teams("id>0", $params->active); } return $list; }
function search($params) { $list = array(); $tried = false; if (strlen($params->keywords)) { $kw = BoincDb::escape_string($params->keywords); $name_lc = strtolower($kw); $name_lc = escape_pattern($name_lc); $list2 = get_teams("name='{$name_lc}'", $params->active); merge_lists($list2, $list, 20); $list2 = get_teams("name like '" . $name_lc . "%'", $params->active); merge_lists($list2, $list, 5); $list2 = get_teams("match(name) against ('{$kw}')", $params->active); merge_lists($list2, $list, 5); $list2 = get_teams("match(name, description) against ('{$kw}')", $params->active); //echo "<br>keyword matches: ",sizeof($list2); merge_lists($list2, $list, 3); $tried = true; } if (strlen($params->country) && $params->country != 'None') { $list2 = get_teams("country = '{$params->country}'", $params->active); //echo "<br>country matches: ",sizeof($list2); merge_lists($list2, $list, 1); $tried = true; } if ($params->type and $params->type > 1) { $list2 = get_teams("type={$params->type}", $params->active); //echo "<br>type matches: ",sizeof($list2); merge_lists($list2, $list, 2); $tried = true; } if (!$tried) { $list = get_teams("id>0", $params->active); } if (sizeof($list) == 0) { echo 'No teams were found matching your criteria. Try another search. <p>Or you can <a href="team_create_form.php">create a new team</a>.</p> <p>'; team_search_form($params); } else { echo "The following teams match one or more of your search criteria.\n\t\t\tTo join a team, click its name to go to the team page, then click <strong>Join this team</strong>.</p>\n\t\t\t<p>"; sort_list($list); show_list($list); echo "<h2>Change your search</h2>"; team_search_form($params); } }