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 show_credit($user) { row2("Total credit", format_credit($user->total_credit)); row2("Recent average credit", format_credit($user->expavg_credit)); project_user_credit($user); } // show donation info (private) function show_user_donations_private($user) { row1("Donations to SETI@home"); if ($user->donated == 0) { row2("Would you like to make a tax-deductible donation to SETI@home?", "click here"); } else { $result = mysql_query("select count(*) as total from donation where userid=$user->id"); $total = mysql_fetch_object($result); if (!$total) return 0; mysql_free_result($result); row2("Number of donations",$total->total); $result = mysql_query("select sum(amount) as sum from donation where userid=$user->id"); $sum = mysql_fetch_object($result); if (!$sum) return 0; mysql_free_result($result); row2("Total amount",$sum->sum); $result = mysql_query("select max(date) as date from donation where userid=$user->id"); $date = mysql_fetch_object($result); if (!$date) return 0; mysql_free_result($result); row2("Last donation received",time_str($date->date)); $anon = "no"; if ($user->donated < 0) { $anon = "yes"; } row2("Anonymous?",$anon); } } // show dynamic user info (private) // function show_user_stats_private($user) { row1("Account statistics"); row2(PROJECT." member since", date_str($user->create_time)); show_credit($user); row2("Pending credit", "View"); if ($user->teamid) { $team = lookup_team($user->teamid); $x = "id>$team->name | Quit this team"; if ($team->userid == $user->id) { $x .= " | management functions"; } row2("Team", $x); } else { row2("Team", "None (find a team)"); } row2("Computers on this account", "View computers"); row2("Results", "id>View"); row2("Stats on your cell phone", URL_BASE."userw.php?id=$user->id"); if ($user->posts) { row2("Message board posts", "id>$user->posts messages"); } } // 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"); row2("", "Change password"); row2("", "Change other account info"); row1("Profile"); $sql = "SELECT * FROM profile WHERE userid = ".$user->id; $result = mysql_query($sql); if (mysql_num_rows($result) != 0) { row2("", "id>View or edit profile"); row2("", "Delete profile"); } else { row2("", "Create"); } row1("Preferences"); row2( "General
specify when and how BOINC uses your computer", "
View or edit general preferences" ); row2(PROJECT."
control resource share and customize graphics", "View or edit ".PROJECT." preferences" ); row2("Forum
configure features and the appearance of the forum", "View or edit forum preferences" ); } // 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"); } if ($user->posts) { row2("Message board posts", "id>$user->posts"); } } 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) { start_table("width=100%"); show_user_info_private($user); show_user_stats_private($user); show_user_donations_private($user); row1("Other"); row2("", "Log out"); row2("Account number
Used in URLs", $user->id); $x = $user->cross_project_id . $user->email_addr; row2( "Cross-project ID
Used in exported accounting data", md5($x) ); 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(USER_TABLE_EXPAVG)." ".tr(USER_TABLE_TOTAL_CREDIT)." "; } else { echo " ".tr(USER_TABLE_EXPAVG)." ".tr(USER_TABLE_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; } ?>