2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
|
|
|
|
2004-11-07 02:57:02 +00:00
|
|
|
require_once("../inc/credit.inc");
|
2004-11-19 07:33:59 +00:00
|
|
|
require_once("../inc/email.inc");
|
2005-09-15 18:30:17 +00:00
|
|
|
require_once("../inc/util.inc");
|
2004-11-07 02:57:02 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
function pending_credit($user) {
|
2004-12-14 00:57:03 +00:00
|
|
|
$result = mysql_query("select sum(claimed_credit) as total from result where userid=$user->id and (validate_state=0 or validate_state=4)");
|
2004-02-02 23:34:39 +00:00
|
|
|
$foobar = mysql_fetch_object($result);
|
|
|
|
if (!$foobar) return 0;
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $foobar->total;
|
|
|
|
}
|
|
|
|
|
2006-01-09 09:43:17 +00:00
|
|
|
function total_posts($user) {
|
2006-02-12 06:19:00 +00:00
|
|
|
$result = mysql_query(
|
|
|
|
"select count(id) as total from post where user=$user->id"
|
|
|
|
);
|
2006-01-09 09:43:17 +00:00
|
|
|
$foobar = mysql_fetch_object($result);
|
|
|
|
if (!$foobar) return 0;
|
|
|
|
mysql_free_result($result);
|
|
|
|
return $foobar->total;
|
|
|
|
}
|
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
function show_credit($user) {
|
2005-12-22 08:22:44 +00:00
|
|
|
row2(tr(TOTAL_CREDIT), format_credit($user->total_credit));
|
|
|
|
row2(tr(EXPAVG_CREDIT), format_credit($user->expavg_credit));
|
2005-04-08 00:06:52 +00:00
|
|
|
project_user_credit($user);
|
2004-05-30 21:47:11 +00:00
|
|
|
}
|
|
|
|
|
2006-02-12 06:19:00 +00:00
|
|
|
require_once("../inc/stats_sites.inc");
|
2004-02-02 23:34:39 +00:00
|
|
|
// show dynamic user info (private)
|
|
|
|
//
|
|
|
|
function show_user_stats_private($user) {
|
2006-02-12 06:19:00 +00:00
|
|
|
global $cpid_stats_sites;
|
2006-02-13 06:53:46 +00:00
|
|
|
row1("Work done");
|
|
|
|
row2(PROJECT." member since", date_str($user->create_time));
|
2004-05-30 21:47:11 +00:00
|
|
|
show_credit($user);
|
2006-02-01 04:00:11 +00:00
|
|
|
$config = get_config();
|
|
|
|
if (parse_bool($config, "show_results")) {
|
|
|
|
row2("Pending credit", "<a href=pending.php>View</a>");
|
|
|
|
}
|
2006-02-13 06:53:46 +00:00
|
|
|
row2("Computers on this account",
|
|
|
|
"<a href=hosts_user.php>View</a>"
|
|
|
|
);
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Results", "<a href=results.php?userid=$user->id>View</a>");
|
2006-02-12 06:19:00 +00:00
|
|
|
$cpid = md5($user->cross_project_id . $user->email_addr);
|
|
|
|
$x = "";
|
2006-02-14 22:30:42 +00:00
|
|
|
shuffle($cpid_stats_sites);
|
2006-02-12 06:19:00 +00:00
|
|
|
foreach ($cpid_stats_sites as $site) {
|
|
|
|
$name = $site[0];
|
|
|
|
$y = sprintf($site[1], $cpid);
|
|
|
|
$x .= "<a href=$y>$name</a><br>";
|
2005-09-15 18:18:53 +00:00
|
|
|
}
|
2006-02-12 06:19:00 +00:00
|
|
|
$x .= "<br><font size=-2>Cross-project ID: $cpid</font>\n";
|
|
|
|
row2("Cross-project statistics", $x);
|
|
|
|
row2("Stats on your cell phone", URL_BASE."userw.php?id=$user->id");
|
2006-02-13 06:53:46 +00:00
|
|
|
row2("Account number<br><font size=-2>Used in URLs</font>", $user->id);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// show static user info (private)
|
|
|
|
//
|
2004-05-30 21:47:11 +00:00
|
|
|
function show_user_info_private($user) {
|
2004-02-02 23:34:39 +00:00
|
|
|
if (is_valid_email_addr($user->email_addr)) {
|
|
|
|
$email_text = $user->email_addr;
|
|
|
|
} else {
|
|
|
|
$email_text = "Verification pending";
|
|
|
|
}
|
|
|
|
|
|
|
|
row1("Account information");
|
2005-08-07 01:33:15 +00:00
|
|
|
row2("Email address<br>", $email_text);
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Name", $user->name);
|
2004-05-14 22:57:59 +00:00
|
|
|
if (strlen($user->url)) {
|
|
|
|
$x = "http://$user->url";
|
|
|
|
} else {
|
|
|
|
$x = "none";
|
|
|
|
}
|
|
|
|
row2("URL", $x);
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Country", $user->country);
|
|
|
|
row2("Postal code", $user->postal_code);
|
2006-02-12 06:19:00 +00:00
|
|
|
row2("Change", "<a href=edit_email_form.php>email address</a> | <a href=edit_passwd_form.php>password</a> | <a href=edit_user_info_form.php>other account info</a>");
|
2006-02-13 06:53:46 +00:00
|
|
|
row2("", "<a href=logout.php>Log out</a>");
|
2006-02-12 06:19:00 +00:00
|
|
|
|
|
|
|
row1("Community");
|
2004-02-02 23:34:39 +00:00
|
|
|
|
|
|
|
$sql = "SELECT * FROM profile WHERE userid = ".$user->id;
|
|
|
|
$result = mysql_query($sql);
|
|
|
|
if (mysql_num_rows($result) != 0) {
|
2006-02-12 06:19:00 +00:00
|
|
|
$x = "<a href=view_profile.php?userid=$user->id>View or edit</a> | <a href=delete_profile.php>Delete</a>";
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
2006-02-12 06:19:00 +00:00
|
|
|
$x = "<a href=create_profile.php>Create</a>";
|
|
|
|
}
|
|
|
|
row2("Profile", $x);
|
|
|
|
|
|
|
|
if ($user->teamid) {
|
|
|
|
$team = lookup_team($user->teamid);
|
|
|
|
$x = "<a href=team_display.php?teamid=$team->id>$team->name</a>
|
|
|
|
| <a href=team_quit_form.php>Quit team</a>";
|
|
|
|
if ($team->userid == $user->id) {
|
|
|
|
$x .= " | <a href=team_manage.php>management functions</a>";
|
|
|
|
}
|
|
|
|
row2("Team", $x);
|
|
|
|
} else {
|
|
|
|
row2("Team", "None (<a href=team.php>find a team</a>)");
|
|
|
|
}
|
2006-02-17 22:01:22 +00:00
|
|
|
$tot = total_posts($user);
|
2006-02-12 06:19:00 +00:00
|
|
|
if ($tot) {
|
|
|
|
row2("Message boards", "<a href=".URL_BASE."forum_user_posts.php?userid=$user->id>$tot posts</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2005-03-23 19:25:00 +00:00
|
|
|
row1("<a name=prefs>Preferences");
|
2004-08-12 15:06:35 +00:00
|
|
|
row2(
|
2006-02-12 06:19:00 +00:00
|
|
|
"General preferences<br><font size=-2>specify when and how BOINC uses your computer</font>",
|
|
|
|
"<a href=prefs.php?subset=global>View or edit</a>"
|
2004-08-12 15:06:35 +00:00
|
|
|
);
|
2006-02-12 06:19:00 +00:00
|
|
|
row2(PROJECT." preferences<br><font size=-2>control resource share and customize graphics</font>",
|
|
|
|
"<a href=prefs.php?subset=project>View or edit</a>"
|
2004-08-12 15:06:35 +00:00
|
|
|
);
|
2006-02-12 06:19:00 +00:00
|
|
|
row2("Message board preferences<br><font size=-2>configure features and appearance of message boards</font>",
|
|
|
|
"<a href=\"edit_forum_preferences_form.php\">View or edit</a>"
|
2004-09-04 23:37:49 +00:00
|
|
|
);
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// show summary of dynamic and static info (public)
|
2004-10-16 04:12:11 +00:00
|
|
|
//
|
2004-02-02 23:34:39 +00:00
|
|
|
function show_user_summary_public($user) {
|
2005-01-08 19:45:26 +00:00
|
|
|
row2(PROJECT." member since", date_str($user->create_time));
|
2004-02-02 23:34:39 +00:00
|
|
|
row2("Country", $user->country);
|
|
|
|
if (strlen($user->url)) {
|
|
|
|
row2("URL", "<a href=http://$user->url>http://$user->url</a>");
|
|
|
|
}
|
2004-05-30 21:47:11 +00:00
|
|
|
show_credit($user);
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2005-04-08 00:06:52 +00:00
|
|
|
if ($user->teamid && ($team = lookup_team($user->teamid))) {
|
2005-07-10 04:13:15 +00:00
|
|
|
row2("Team", "<a href=".URL_BASE."team_display.php?teamid=$team->id>$team->name</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
|
|
|
row2("Team", "None");
|
|
|
|
}
|
|
|
|
if ($user->show_hosts) {
|
2005-07-10 04:13:15 +00:00
|
|
|
row2("Computers", "<a href=".URL_BASE."hosts_user.php?userid=$user->id>View</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
|
|
|
row2("Computers", "hidden");
|
|
|
|
}
|
2006-02-17 22:01:22 +00:00
|
|
|
$tot = total_posts($user);
|
|
|
|
if ($tot) {
|
|
|
|
row2("Message boards", "<a href=".URL_BASE."forum_user_posts.php?userid=$user->id>$tot posts</a>");
|
|
|
|
}
|
2006-02-16 22:50:28 +00:00
|
|
|
|
2006-02-17 22:01:22 +00:00
|
|
|
if ($user->donated == 1) {
|
|
|
|
require_once("../project/donations.inc");
|
|
|
|
$x .= DONATION_LINK;
|
|
|
|
row2("Donor",$x);
|
|
|
|
}
|
2005-04-08 00:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_profile_link($user) {
|
2004-02-02 23:34:39 +00:00
|
|
|
if ($user->has_profile) {
|
2005-04-08 00:06:52 +00:00
|
|
|
row2("Profile", "<a href=view_profile.php?userid=$user->id>View</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2006-02-01 04:00:11 +00:00
|
|
|
$config = get_config();
|
2004-05-12 17:54:23 +00:00
|
|
|
start_table("width=100%");
|
2004-05-30 21:47:11 +00:00
|
|
|
show_user_info_private($user);
|
2004-02-02 23:34:39 +00:00
|
|
|
show_user_stats_private($user);
|
2005-09-17 21:28:25 +00:00
|
|
|
|
|
|
|
// Does this project accept donations? Then put in a project specific
|
|
|
|
// function to show user donation information in ../project/donations.inc
|
2006-02-17 22:01:22 +00:00
|
|
|
//
|
|
|
|
if (parse_bool($config, "donations_accepted")) {
|
2005-09-15 20:45:11 +00:00
|
|
|
require_once("../project/donations.inc");
|
2005-09-15 18:18:53 +00:00
|
|
|
show_user_donations_private($user);
|
2005-09-15 18:30:17 +00:00
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
end_table();
|
|
|
|
}
|
|
|
|
|
2004-05-31 00:50:06 +00:00
|
|
|
function user_table_start($sort_by) {
|
2004-02-02 23:34:39 +00:00
|
|
|
start_table();
|
|
|
|
echo "
|
|
|
|
<tr>
|
2005-06-23 20:39:02 +00:00
|
|
|
<th>".tr(USER_TABLE_RANK)."</th>
|
|
|
|
<th>".tr(USER_TABLE_NAME)."</th>
|
2004-05-31 00:50:06 +00:00
|
|
|
";
|
|
|
|
if ($sort_by == "total_credit") {
|
|
|
|
echo "
|
2005-12-22 21:46:35 +00:00
|
|
|
<th><a href=top_users.php?sort_by=expavg_credit>".tr(EXPAVG_CREDIT)."</a></th>
|
2005-12-22 08:22:44 +00:00
|
|
|
<th>".tr(TOTAL_CREDIT)."</th>
|
2004-05-31 00:50:06 +00:00
|
|
|
";
|
|
|
|
} else {
|
|
|
|
echo "
|
2005-12-22 08:22:44 +00:00
|
|
|
<th>".tr(EXPAVG_CREDIT)."</th>
|
|
|
|
<th><a href=top_users.php?sort_by=total_credit>".tr(TOTAL_CREDIT)."</a></th>
|
2004-05-31 00:50:06 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
echo "
|
2005-06-23 20:39:02 +00:00
|
|
|
<th>".tr(USER_TABLE_COUNTRY)."</th>
|
|
|
|
<th>".tr(USER_TABLE_PTIME)."</th>
|
2004-02-02 23:34:39 +00:00
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_user_row($user, $i) {
|
|
|
|
echo "
|
|
|
|
<tr class=row1>
|
|
|
|
<td>$i</td>
|
|
|
|
<td>", user_links($user), "</td>
|
|
|
|
<td>", format_credit($user->expavg_credit), "</td>
|
|
|
|
<td>", format_credit($user->total_credit), "</td>
|
|
|
|
<td>", $user->country, "</td>
|
|
|
|
<td>", time_str($user->create_time),"</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2004-11-01 23:10:02 +00:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|