do_country && $user->country!=$filter->country) return false; if ($filter->do_profile) { if (!($user->has_profile!=0 xor $filter->has_profile)) return false; } if ($filter->do_team) { if ($filter->team xor $user->teamid!=0) return false; } return true; } function show_user($user) { echo " ", user_links($user), " "; if ($user->teamid) { $team = BoincTeam::lookup_id($user->teamid); echo " id>$team->name "; } else { echo "
"; } echo " ", format_credit($user->expavg_credit), " ", format_credit_large($user->total_credit), " ", $user->country, " ", time_str($user->create_time)," "; } function do_search($order, $filter) { $filtered_list = array(); $nrows_scanned = 0; $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile, donated"; while (1) { if (count($filtered_list) > 500) break; $limit_clause = " limit $nrows_scanned, 1000"; $users = BoincUser::enum_fields($fields, null, $order.$limit_clause); $n = count($users); $nrows_scanned += $n; if ($nrows_scanned > 10000) break; if ($n==0) break; foreach($users as $user) { if (filter_user($user, $filter)) { $filtered_list[] = $user; } } } start_table(); table_header("Name", "Team", "Average credit", "Total credit", "Country", "Joined"); foreach ($filtered_list as $user) { show_user($user); } end_table(); } function search_form() { page_head("User search"); echo "
"; start_table(); row1("Search type", 2, "heading"); row2("User name starts with ", ""); row2("Decreasing sign-up time", ""); row2("Decreasing average credit", ""); row2("Decreasing total credit", ""); row1("Filters", 2, "heading"); row2_init("Country", ""; row2("With profile?", " Either No Yes "); row2("On a team?", " Either No Yes "); row2("", ""); end_table(); echo " "; page_tail(); } function name_search($filter) { $count = 100; $search_string = get_str('search_string'); if (strlen($search_string)<3) { error_page("search string must be at least 3 characters"); } $urls = urlencode($search_string); $s = escape_pattern($search_string); $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile"; $users = BoincUser::enum_fields($fields, "name like '$s%'", "limit $count"); $n=0; foreach ($users as $user) { if (!filter_user($user, $filter)) continue; if ($n==0) { echo "

User names starting with '".htmlspecialchars($search_string)."' $nice_name

\n"; start_table(); table_header("Name", "Team", "Average credit", "Total credit", "Country", "Joined"); } show_user($user); $n++; } end_table(); if (!$n) { echo "No users matching your search criteria."; } } function main() { $search_type = get_str('search_type', true); if ($search_type) { switch ($search_type) { case 'date': $order = 'order by id desc'; break; case 'rac': $order = 'order by expavg_credit desc'; break; case 'total': $order = 'order by total_credit desc'; break; case 'name_prefix': break; default: error_page("missing search type"); } $filter = null; $filter->do_country = false; $filter->do_profile = false; $filter->do_team = false; $country = get_str('country'); if ($country != 'any') { $filter->do_country = true; $filter->country = $country; } switch (get_str('profile')) { case 'yes': $filter->do_profile = true; $filter->profile = true; break; case 'no': $filter->do_profile = true; $filter->profile = false; break; case 'either': $filter->do_profile = false; break; } switch (get_str('team')) { case 'yes': $filter->do_team = true; $filter->team = true; break; case 'no': $filter->do_team = true; $filter->team = false; break; case 'either': $filter->do_team = false; break; } page_head("User search results"); if ($search_type == 'name_prefix') { name_search($filter); } else { do_search($order, $filter); } page_tail(); } else { search_form(); } } main(); $cvs_version_tracker[]="\$Id: user_search.php 13586 2007-09-13 09:46:36Z Rytis $"; //Generated automatically - do not edit ?>