total_credit = 0.0; $p->expavg_credit = 0.0; while (!feof($f)) { $buf = fgets($f); if (strstr($buf, "")) break; if ($x = parse_element($buf, "")) { $p->name = $x; } if ($x = parse_element($buf, "")) { $p->name = $x; } if ($x = parse_element($buf, "")) { $p->url = $x; } if ($x = parse_element($buf, "")) { $p->total_credit = $x; } if ($x = parse_element($buf, "")) { $p->expavg_credit = $x; } if ($x = parse_element($buf, "")) { $p->id = $x; } if ($x = parse_element($buf, "")) { $p->country = $x; } if ($x = parse_element($buf, "")) { $p->team_id = $x; } if ($x = parse_element($buf, "")) { $p->team_name = $x; } if ($x = parse_element($buf, "")) { $p->create_time = $x; } } return $p; } function parse_user($f, $user) { $user->projects = array(); while (!feof($f)) { $buf = fgets($f); if (strstr($buf, "")) break; if (strstr($buf, "")) { $user->projects[] = parse_project($f); } } return $user; } function get_other_projects($user) { $cpid = md5($user->cross_project_id . $user->email_addr); $url = "http://boinc.netsoft-online.com/get_user.php?cpid=$cpid"; $f = fopen($url, "r"); if (!$f) { return $user; } $u = parse_user($f, $user); fclose($f); return $u; } function show_project($project) { if ($project->url == "http://www.worldcommunitygrid.org/") { $x = $project->name; } else { $x = "url"."show_user.php?userid=$project->id\">$project->name"; } echo " $x ".number_format($project->total_credit, 0)." ".number_format($project->expavg_credit, 0)." ".date_str($project->create_time)." "; } function cmp($a, $b) { if ($a->expavg_credit == $b->expavg_credit) return 0; return ($a->expavg_credit < $b->expavg_credit)? 1 : -1; } function show_other_projects($user, $personal) { if (count($user->projects) > 1) { usort($user->projects, "cmp"); if ($personal) { echo "

Projects in which you are participating

"; } else { echo "

Projects in which $user->name is participating

"; } start_table(); row_heading_array(array( "Project
Click for user page", "Total credit", "Average credit", "Since" )); foreach($user->projects as $project) { show_project($project); } end_table(); } } function pending_credit($user) { $result = mysql_query("select sum(claimed_credit) as total from result where userid=$user->id and (validate_state=0 or validate_state=4)"); $foobar = mysql_fetch_object($result); if (!$foobar) return 0; mysql_free_result($result); return $foobar->total; } function total_posts($user) { $result = mysql_query( "select count(id) as total from post where user=$user->id" ); if (!$result) return 0; $foobar = mysql_fetch_object($result); mysql_free_result($result); return $foobar->total; } function show_credit($user) { row2(tr(TOTAL_CREDIT), format_credit($user->total_credit)); row2(tr(EXPAVG_CREDIT), format_credit($user->expavg_credit)); project_user_credit($user); } require_once("../inc/stats_sites.inc"); // show dynamic user info (private) // function show_user_stats_private($user) { global $cpid_stats_sites; row1("Work done"); row2(PROJECT." member since", date_str($user->create_time)); show_credit($user); $config = get_config(); if (parse_bool($config, "show_results")) { row2("Pending credit", "View"); } row2("Computers on this account", "View" ); row2("Results", "id>View"); $cpid = md5($user->cross_project_id . $user->email_addr); $x = ""; shuffle($cpid_stats_sites); foreach ($cpid_stats_sites as $site) { $name = $site[0]; $y = sprintf($site[1], $cpid); $x .= "$name
"; } $x .= "
Cross-project ID: $cpid\n"; row2("Cross-project statistics", $x); row2("Stats on your cell phone", URL_BASE."userw.php?id=$user->id"); row2("Account number
Used in URLs", $user->id); } // show static user info (private) // function show_user_info_private($user) { if (is_valid_email_addr($user->email_addr)) { $email_text = $user->email_addr; } else { $email_text = "Verification pending"; } row1("Account information"); row2("Email address
", $email_text); row2("Name", $user->name); if (strlen($user->url)) { $x = "http://$user->url"; } else { $x = "none"; } row2("URL", $x); row2("Country", $user->country); row2("Postal code", $user->postal_code); row2("Change", "email address | password | other account info"); row2("", "Show private queue"); row2("", "authenticator).">Log out"); row1("Community"); $sql = "SELECT * FROM profile WHERE userid = ".$user->id; $result = mysql_query($sql); if (mysql_num_rows($result) != 0) { $x = "id>View or edit | Delete"; } else { $x = "Create"; } row2("Profile", $x); $tot = total_posts($user); if ($tot) { row2("Message boards", "id>$tot posts"); } row2("Private messages", pm_notification($user)); row1("Teams"); if ($user->teamid) { $team = lookup_team($user->teamid); $x = "id>$team->name | Quit team"; if ($team->userid == $user->id) { $x .= " | management functions"; } row2("Team", $x); } else { row2("Team", "None (find a team)"); } $team_founder = lookup_team_founder($user->id); if ($team_founder) { while ($res = mysql_fetch_object($team_founder)) { if ($res->id != $user->teamid) { row2("founder of", "id>$res->name | id."\">Change team founder"); } } } row1("Preferences"); row2( "General preferences
specify when and how BOINC uses your computer", "
View or edit" ); row2(PROJECT." preferences
control resource share and customize graphics", "View or edit" ); row2("Message board preferences
configure features and appearance of message boards", "View or edit" ); } // show summary of dynamic and static info (public) // function show_user_summary_public($user) { row2(PROJECT." member since", date_str($user->create_time)); row2("Country", $user->country); if (strlen($user->url)) { row2("URL", "url\">http://$user->url"); } show_credit($user); if ($user->teamid && ($team = lookup_team($user->teamid))) { row2("Team", "id\">$team->name"); } else { row2("Team", "None"); } if ($user->show_hosts) { row2("Computers", "id\">View"); } else { row2("Computers", "hidden"); } $tot = total_posts($user); if ($tot) { row2("Message boards", "id\">$tot posts"); } if ($user->donated == 1) { if (file_exists("../project/donations.inc")) { require_once("../project/donations.inc"); $x .= DONATION_LINK; row2("Donor",$x); } } row2("Contact", "id."\">Send private message"); } function show_profile_link($user) { if ($user->has_profile) { row2("Profile", "id\">View"); } } // show a summary of the user. // NOTE: This is intended to be shown only to that user. // it has info that other users aren't supposed to see function show_user_page_private($user) { $config = get_config(); start_table("width=100%"); show_user_info_private($user); show_user_stats_private($user); // Does this project accept donations? Then put in a project specific // function to show user donation information in ../project/donations.inc // if (parse_bool($config, "donations_accepted")) { if (file_exists("../project/donations.inc")) { require_once("../project/donations.inc"); show_user_donations_private($user); } } end_table(); } function user_table_start($sort_by) { start_table(); echo " ".tr(USER_TABLE_RANK)." ".tr(USER_TABLE_NAME)." "; if ($sort_by == "total_credit") { echo " ".tr(EXPAVG_CREDIT)." ".tr(TOTAL_CREDIT)." "; } else { echo " ".tr(EXPAVG_CREDIT)." ".tr(TOTAL_CREDIT)." "; } echo " ".tr(USER_TABLE_COUNTRY)." ".tr(USER_TABLE_PTIME)." "; } function show_user_row($user, $i) { echo " $i ", user_links($user), " ", format_credit($user->expavg_credit), " ", format_credit($user->total_credit), " ", $user->country, " ", time_str($user->create_time)," "; } // decay a user's average credit // function user_decay_credit($user) { $avg = $user->expavg_credit; $avg_time = $user->expavg_time; $now = time(0); update_average($now, 0, 0, $avg, $avg_time); mysql_query("update user set expavg_credit=$avg, expavg_time=$now where id=$user->id"); } // if the user hasn't received new credit for ndays, // decay its average and return true // function user_inactive_ndays($user, $ndays) { $diff = time() - $user->expavg_time; if ($diff > $ndays*86400) { user_decay_credit($user); return true; } return false; } ?>