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->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 "

".tra("Projects in which you are participating")."

"; } else { echo "

".tra("Projects in which %1 is participating", $user->name)."

"; } start_table(); row_heading_array(array( tra("Project")."
".tra("Click for user page")."", tra("Total credit"), tra("Average credit"), tra("Since") )); foreach($user->projects as $project) { show_project($project); } end_table(); } } function total_posts($user) { return BoincPost::count("user=$user->id"); } function show_credit($user) { row2(tra("Total credit"), format_credit_large($user->total_credit)); row2(tra("Recent average 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(tra("Computing and credit")); show_credit($user); $config = get_config(); if (parse_bool($config, "show_results")) { row2(tra("Pending credit"), "".tra("View").""); } row2(tra("Computers on this account"), "".tra("View").""); row2(tra("Tasks"), "id\">".tra("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 .= "
".tra("Cross-project ID").": $cpid\n"; row2(tra("Cross-project statistics"), $x); $x = "Account"; if ($user->teamid) { $x .= " | Team"; } $x .= " | Cross-project"; row2(tra("Certificate"), $x); row2(tra("Stats on your cell phone"), URL_BASE."userw.php?id=$user->id"); } function notify_description($notify) { switch ($notify->type) { case NOTIFY_FRIEND_REQ: return friend_notify_req_web_line($notify); case NOTIFY_FRIEND_ACCEPT: return friend_notify_accept_web_line($notify); case NOTIFY_PM: return pm_web_line($notify); case NOTIFY_SUBSCRIBED_POST: return subscribed_post_web_line($notify); } return "Unknown notification type: $notify->type"; } function weak_auth($user) { $x = md5($user->authenticator.$user->passwd_hash); return "{$user->id}_$x"; } // 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(tra("Account information")); row2(tra("Name"), $user->name); row2(tra("Email address"), $email_text); if (strlen($user->url)) { $x = "http://$user->url"; } else { $x = "none"; } row2(tra("URL"), $x); row2(tra("Country"), $user->country); row2(tra("Postal code"), $user->postal_code); row2(tra("%1 member since", PROJECT), date_str($user->create_time)); row2(tra("Change"), "".tra("email address")." | ".tra("password")." | ".tra("other account info").""); row2("", "authenticator)."\">".tra("Log out").""); row2(tra("User ID")."
".tra("Used in community functions")."", $user->id); if (!no_computing()) { row2(tra("Account key")."
".tra("Provides full access to your account")."", $user->authenticator); row2(tra("Weak account key")."
".tra("Provides")." ".tra("limited access")." ".tra("to your account")."", weak_auth($user)); } row1("".tra("Preferences")); if (!no_computing()) { row2( tra("When and how BOINC uses your computer"), "".tra("Computing preferences")."" ); } row2(tra("Message boards and private messages"), "".tra("Community preferences")."" ); if (!no_computing()) { row2(tra("Resource share and graphics"), "".tra("%1 preferences", PROJECT)."" ); } } function show_community_private($user) { row1(tra("Community")); if ($user->has_profile) { $x = "id\">".tra("View")." | ".tra("Delete").""; } else { $x = "".tra("Create").""; } row2(tra("Profile"), $x); $tot = total_posts($user); if ($tot) { row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); } row2(tra("Private messages"), pm_notification($user).pm_email_remind($user)); $notifies = BoincNotify::enum("userid=$user->id"); if (count($notifies)) { $x = ""; foreach ($notifies as $notify) { $x .= "• ".notify_description($notify)."
"; } $x .= "\"RSS\""; row2(tra("Notifications"), $x); } if ($user->teamid) { $team = lookup_team($user->teamid); $x = "id\">$team->name | ".tra("Quit team").""; if (is_team_admin($user, $team)) { $x .= " | teamid\">".tra("Administer").""; } // if there's a foundership request, notify the founder // if ($user->id==$team->userid && $team->ping_user >0) { $x .= "".tra("(foundership change request pending)").""; } row2(tra("Member of team"), $x); } else { row2(tra("Team"), tra("None")." | ".tra("find a team").""); } $teams_founded = BoincTeam::enum("userid=$user->id"); foreach ($teams_founded as $team) { if ($team->id != $user->teamid) { $x = "id\">$team->name"; $x .= "| id."\">".tra("Administer").""; if ($team->ping_user > 0) { $x .= "".tra("(foundership change request pending)").""; } row2(tra("Founder but not member of"), $x); } } $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); $x = "".tra("Find friends")."\n"; $n = count($friends); if ($n) { foreach($friends as $friend) { $fuser = BoincUser::lookup_id($friend->user_dest); $x .= friend_links($fuser); } row2(tra("Friends")." ($n)", $x); } else { row2(tra("Friends"), $x); } } // show summary of dynamic and static info (public) // function show_user_summary_public($user) { global $g_logged_in_user; row2(tra("%1 member since", PROJECT), date_str($user->create_time)); row2(tra("Country"), $user->country); if (strlen($user->url)) { row2(tra("URL"), "url\">http://$user->url"); } if (!no_computing()) { show_credit($user); if ($user->show_hosts) { row2(tra("Computers"), "id\">".tra("View").""); } else { row2(tra("Computers"), tra("hidden")); } } if ($user->donated == 1) { if (file_exists("../project/donations.inc")) { require_once("../project/donations.inc"); $x .= DONATION_LINK; row2(tra("Donor"), $x); } } } function community_links($user) { global $g_logged_in_user; if ($user->teamid && ($team = lookup_team($user->teamid))) { row2(tra("Team"), "id\">$team->name"); } else { row2(tra("Team"), tra("None")); } $tot = total_posts($user); if ($tot) { row2(tra("Message boards"), "id\">".tra("%1 posts", $tot).""); } if ($g_logged_in_user && $g_logged_in_user->id != $user->id) { row2(tra("Contact"), "id."\">".tra("Send private message").""); $friend = BoincFriend::lookup($g_logged_in_user->id, $user->id); if ($friend && $friend->reciprocated) { row2(tra("This person is a friend"), "id\">".tra("Cancel friendship")."" ); } else if ($friend) { row2(tra("Friends"), "id\">".tra("Request pending").""); } else { row2(tra("Friends"), "id\">".tra("Add as friend").""); } } $friends = BoincFriend::enum("user_src=$user->id and reciprocated=1"); $n = count($friends); if ($n) { $x = null; foreach($friends as $friend) { $fuser = BoincUser::lookup_id($friend->user_dest); $x .= friend_links($fuser); } row2(tra("Friends")." ($n)", $x); } } function show_profile_link($user) { if ($user->has_profile) { row2(tra("Profile"), "id\">".tra("View").""); } } // the following DB-escapes its args // function make_user( $email_addr, $name, $passwd_hash, $country=null, $postal_code=null, $project_prefs=null, $teamid=0 ) { if (!is_valid_email_addr($email_addr)) return null; $authenticator = random_string(); $cross_project_id = random_string(); $now = time(); if (!is_valid_country($country)) return null; $email_addr = process_user_text($email_addr); $name = process_user_text($name); $passwd_hash = process_user_text($passwd_hash); $country = BoincDb::escape_string($country); $postal_code = strip_tags(process_user_text($postal_code)); $uid = BoincUser::insert("(create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$email_addr', '$name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 1, 1, '$cross_project_id', '$passwd_hash')"); if ($uid) { return BoincUser::lookup_id($uid); } else { return null; } } $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?>