function export($is_user, $dir) { $n = 0; $filename = $is_user ? "{$dir}/user_work" : "{$dir}/team_work"; $f = fopen($filename, "w"); if (!$f) { die("fopen"); } $is_user ? fprintf($f, "<users>\n") : fprintf($f, "<teams>\n"); $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id"); while ($n <= $maxid) { $m = $n + 1000; if ($is_user) { $items = BoincUser::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0"); } else { $items = BoincTeam::enum_fields("id", "id>={$n} and id<{$m} and total_credit>0"); } foreach ($items as $item) { export_item($item, $is_user, $f); } $n = $m; } $is_user ? fprintf($f, "</users>\n") : fprintf($f, "</teams>\n"); fclose($f); system("gzip -f {$filename}"); }
function assign_badges($is_user, $badge_pctiles, $badge_images) { $kind = $is_user ? "user" : "team"; $badges = get_pct_badges($kind . "_pct", $badge_pctiles, $badge_images); $pctiles = get_percentiles($is_user, $badge_pctiles); //echo "thresholds for $kind badges: $pctiles[0] $pctiles[1] $pctiles[2]\n"; $n = 0; $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id"); while ($n <= $maxid) { $m = $n + 1000; if ($is_user) { $items = BoincUser::enum_fields("id, expavg_credit", "id>={$n} and id<{$m} and total_credit>0"); } else { $items = BoincTeam::enum_fields("id, expavg_credit", "id>={$n} and id<{$m} and total_credit>0"); } foreach ($items as $item) { assign_pct_badge($is_user, $item, $pctiles, $badges); // ... assign other types of badges } $n = $m; } }
function assign_all_badges($is_user, $badge_levels, $badge_level_names, $badge_images, $subprojects_list) { $kind = $is_user ? "user" : "team"; // get badges for all subprojects including total // foreach ($subprojects_list as $sp) { $badges[$sp["short_name"]] = get_badges($kind, $badge_level_names, $badge_images, $sp); } $n = 0; $maxid = $is_user ? BoincUser::max("id") : BoincTeam::max("id"); while ($n <= $maxid) { $m = $n + 1000; if ($is_user) { $items = BoincUser::enum_fields("id, total_credit", "id>={$n} and id<{$m} and total_credit>0"); } else { $items = BoincTeam::enum_fields("id, total_credit", "id>={$n} and id<{$m} and total_credit>0"); } // for every user/team // foreach ($items as $item) { // for every subproject (incl. total) // foreach ($subprojects_list as $sp) { if ($sp["short_name"] == "total") { assign_tot_badge($is_user, $item, $badge_levels, $badges["total"]); } else { // appids come from project/project.inc $where_clause = "appid in (" . implode(',', $sp["appids"]) . ")"; assign_sub_badge($is_user, $item, $badge_levels, $badges[$sp["short_name"]], $where_clause); } } } $n = $m; } }
$teamid = get_int("teamid"); $plain = get_int("plain", true); $team = BoincTeam::lookup_id($teamid); if (!$team) { error_page(tra("no such team")); } require_founder_login($user, $team); if ($plain) { header("Content-type: text/plain"); } else { page_head(tra("%1 Email List", $team->name)); start_table(); table_header(array(tra("Member list of %1", $team->name), "colspan=\"6\"")); table_header(tra("Name"), tra("Email address"), tra("Total credit"), tra("Recent average credit"), tra("Country")); } $users = BoincUser::enum_fields("id, email_addr, send_email, name, total_credit, expavg_credit, has_profile, donated, country, cross_project_id, create_time, url", "teamid={$team->id}"); foreach ($users as $user) { if ($plain) { $e = $user->send_email ? "<{$user->email_addr}>" : ""; echo "{$user->name} {$e}\n"; } else { $e = $user->send_email ? "{$user->email_addr}" : ""; table_row(user_links($user, BADGE_HEIGHT_MEDIUM), $e, format_credit($user->total_credit), format_credit($user->expavg_credit), $user->country); } } if (!$plain) { end_table(); echo "<p><a href=\"team_email_list.php?teamid=" . $teamid . "&plain=1\">" . tra("Show as plain text") . "</a></p>"; page_tail(); } $cvs_version_tracker[] = "\$Id\$";
function search_action() { $where = "true"; $search_string = get_str('search_string'); if (strlen($search_string)) { if (strlen($search_string) < 3) { error_page(tra("search string must be at least 3 characters")); } $s = BoincDb::escape_string($search_string); $s = escape_pattern($s); $where .= " and name like '{$s}%'"; } $country = get_str('country'); if ($country != 'any') { $s = BoincDb::escape_string($country); $where .= " and country='{$s}'"; } $t = get_str('team'); if ($t == 'yes') { $where .= " and teamid<>0"; } else { if ($t == 'no') { $where .= " and teamid=0"; } } $t = get_str('profile'); if ($t == 'yes') { $where .= " and has_profile<>0"; } else { if ($t == 'no') { $where .= " and has_profile=0"; } } $search_type = get_str('search_type', true); $order_clause = "id desc"; if ($search_type == 'rac') { $order_clause = "expavg_credit desc"; } else { if ($search_type == 'total') { $order_clause = "total_credit desc"; } } $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile, donated"; $users = BoincUser::enum_fields($fields, $where, "order by {$order_clause} limit 100"); page_head(tra("User search results")); $n = 0; foreach ($users as $user) { if ($n == 0) { start_table(); table_header(tra("Name"), tra("Team"), tra("Average credit"), tra("Total credit"), tra("Country"), tra("Joined")); } show_user($user); $n++; } end_table(); if (!$n) { echo tra("No users match your search criteria."); } 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"); } $s = boinc_real_escape_string($search_string); $s = escape_pattern($s); $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile, donated"; $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 "<h3>User names starting with '" . htmlspecialchars($search_string) . "'</h3>\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."; } }