2004-02-02 23:34:39 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2004-02-02 23:34:39 +00:00
|
|
|
|
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");
|
2007-11-07 17:23:29 +00:00
|
|
|
require_once("../inc/team.inc");
|
2007-12-30 22:02:16 +00:00
|
|
|
require_once("../inc/friend.inc");
|
2007-11-12 20:57:15 +00:00
|
|
|
require_once("../inc/forum_db.inc");
|
2008-01-04 22:59:21 +00:00
|
|
|
require_once("../inc/notify.inc");
|
2004-11-07 02:57:02 +00:00
|
|
|
|
2006-12-29 19:01:03 +00:00
|
|
|
function parse_project($f) {
|
|
|
|
$p->total_credit = 0.0;
|
|
|
|
$p->expavg_credit = 0.0;
|
|
|
|
while (!feof($f)) {
|
|
|
|
$buf = fgets($f);
|
|
|
|
if (strstr($buf, "</project>")) break;
|
|
|
|
if ($x = parse_element($buf, "<name>")) {
|
|
|
|
$p->name = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<url>")) {
|
|
|
|
$p->url = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<total_credit>")) {
|
|
|
|
$p->total_credit = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<expavg_credit>")) {
|
|
|
|
$p->expavg_credit = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<id>")) {
|
|
|
|
$p->id = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<country>")) {
|
|
|
|
$p->country = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<team_id>")) {
|
|
|
|
$p->team_id = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<team_name>")) {
|
|
|
|
$p->team_name = $x;
|
|
|
|
}
|
|
|
|
if ($x = parse_element($buf, "<create_time>")) {
|
|
|
|
$p->create_time = $x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $p;
|
|
|
|
}
|
|
|
|
|
|
|
|
function parse_user($f, $user) {
|
|
|
|
$user->projects = array();
|
|
|
|
while (!feof($f)) {
|
|
|
|
$buf = fgets($f);
|
|
|
|
if (strstr($buf, "</user>")) break;
|
|
|
|
if (strstr($buf, "<project>")) {
|
|
|
|
$user->projects[] = parse_project($f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_other_projects($user) {
|
|
|
|
$cpid = md5($user->cross_project_id . $user->email_addr);
|
2007-04-11 22:46:42 +00:00
|
|
|
$url = "http://boinc.netsoft-online.com/get_user.php?cpid=$cpid";
|
2006-12-29 19:01:03 +00:00
|
|
|
$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 {
|
2007-01-04 15:54:10 +00:00
|
|
|
$x = "<a href=\"$project->url"."show_user.php?userid=$project->id\">$project->name</a>";
|
2006-12-29 19:01:03 +00:00
|
|
|
}
|
|
|
|
echo "<tr>
|
|
|
|
<td>$x</td>
|
2008-05-13 21:46:50 +00:00
|
|
|
<td align=\"right\">".number_format($project->total_credit, 0)."</td>
|
|
|
|
<td align=\"right\">".number_format($project->expavg_credit, 0)."</td>
|
|
|
|
<td align=\"right\">".date_str($project->create_time)."</td>
|
2006-12-29 19:01:03 +00:00
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2008-05-13 21:46:50 +00:00
|
|
|
echo "<h3>".tra("Projects in which you are participating")."</h3>";
|
2006-12-29 19:01:03 +00:00
|
|
|
} else {
|
2008-05-15 10:03:04 +00:00
|
|
|
echo "<h3>".tra("Projects in which %1 is participating", $user->name)."</h3>";
|
2006-12-29 19:01:03 +00:00
|
|
|
}
|
|
|
|
start_table();
|
|
|
|
row_heading_array(array(
|
2008-05-21 16:37:11 +00:00
|
|
|
tra("Project")."<br/><span class=\"note\">".tra("Click for user page")."</span>", tra("Total credit"), tra("Average credit"), tra("Since")
|
2006-12-29 19:01:03 +00:00
|
|
|
));
|
|
|
|
foreach($user->projects as $project) {
|
|
|
|
show_project($project);
|
|
|
|
}
|
|
|
|
end_table();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 09:43:17 +00:00
|
|
|
function total_posts($user) {
|
2007-10-28 15:03:14 +00:00
|
|
|
return BoincPost::count("user=$user->id");
|
2006-01-09 09:43:17 +00:00
|
|
|
}
|
|
|
|
|
2004-05-30 21:47:11 +00:00
|
|
|
function show_credit($user) {
|
2007-11-02 14:43:02 +00:00
|
|
|
row2(tra("Total credit"), format_credit_large($user->total_credit));
|
|
|
|
row2(tra("Recent average 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;
|
2007-11-26 00:51:00 +00:00
|
|
|
row1(tra("Computing and credit"));
|
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")) {
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Pending credit"), "<a href=\"pending.php\">".tra("View")."</a>");
|
2006-02-01 04:00:11 +00:00
|
|
|
}
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Computers on this account"), "<a href=\"hosts_user.php\">".tra("View")."</a>");
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Tasks"), "<a href=\"results.php?userid=$user->id\">".tra("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);
|
2008-05-13 21:46:50 +00:00
|
|
|
$x .= "<a href=\"$y\">$name</a><br/>";
|
2005-09-15 18:18:53 +00:00
|
|
|
}
|
2008-05-13 21:46:50 +00:00
|
|
|
$x .= "<br/><span class=\"smalltext\">".tra("Cross-project ID").": $cpid</span>\n";
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Cross-project statistics"), $x);
|
2008-05-28 21:08:26 +00:00
|
|
|
$x = "<a href=cert1.php>Account</a>";
|
|
|
|
if ($user->teamid) {
|
|
|
|
$x .= " | <a href=cert_team.php>Team</a>";
|
|
|
|
}
|
2008-06-02 15:59:20 +00:00
|
|
|
$x .= " | <a href=cert_all.php>Cross-project</a>";
|
2008-05-28 21:08:26 +00:00
|
|
|
row2(tra("Certificate"), $x);
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Stats on your cell phone"), URL_BASE."userw.php?id=$user->id");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
function notify_description($notify) {
|
|
|
|
switch ($notify->type) {
|
|
|
|
case NOTIFY_FRIEND_REQ:
|
2007-12-30 22:02:16 +00:00
|
|
|
return friend_notify_req_web_line($notify);
|
2007-12-18 20:28:08 +00:00
|
|
|
case NOTIFY_FRIEND_ACCEPT:
|
2007-12-30 22:02:16 +00:00
|
|
|
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);
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
2007-12-30 22:02:16 +00:00
|
|
|
return "Unknown notification type: $notify->type";
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
2008-01-14 16:32:34 +00:00
|
|
|
function weak_auth($user) {
|
|
|
|
$x = md5($user->authenticator.$user->passwd_hash);
|
|
|
|
return "{$user->id}_$x";
|
|
|
|
}
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2007-10-30 19:36:27 +00:00
|
|
|
row1(tra("Account information"));
|
|
|
|
row2(tra("Name"), $user->name);
|
2008-01-13 00:12:14 +00:00
|
|
|
row2(tra("Email address"), $email_text);
|
2004-05-14 22:57:59 +00:00
|
|
|
if (strlen($user->url)) {
|
2008-10-17 16:47:02 +00:00
|
|
|
$x = "<a href=http://$user->url>http://$user->url</a>";
|
|
|
|
row2(tra("URL"), $x);
|
2004-05-14 22:57:59 +00:00
|
|
|
}
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Country"), $user->country);
|
|
|
|
row2(tra("Postal code"), $user->postal_code);
|
2008-01-13 00:12:14 +00:00
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time));
|
2008-10-16 04:02:59 +00:00
|
|
|
$url_tokens = url_tokens($user->authenticator);
|
|
|
|
row2(tra("Change"), "<a href=\"edit_email_form.php\">".tra("email address")."</a> | <a href=\"edit_passwd_form.php\">".tra("password")."</a> | <a href=\"edit_user_info_form.php?$url_tokens\">".tra("other account info")."</a>");
|
|
|
|
row2("", "<a href=\"logout.php?$url_tokens\">".tra("Log out")."</a>");
|
2008-05-15 22:05:05 +00:00
|
|
|
row2(tra("User ID")."<br/><span class=\"note\">".tra("Used in community functions")."</span>", $user->id);
|
|
|
|
if (!no_computing()) {
|
|
|
|
row2(tra("Account key")."<br/><span class=\"note\">".tra("Provides full access to your account")."</span>", $user->authenticator);
|
2009-01-05 15:50:33 +00:00
|
|
|
row2(tra("Weak account key")."<br/><span class=\"note\">".tra("Provides %1limited access%2 to your account", "<a href=\"weak_auth.php\">", "</a> ")."</span>", weak_auth($user));
|
2008-05-15 22:05:05 +00:00
|
|
|
}
|
2006-02-12 06:19:00 +00:00
|
|
|
|
2007-11-26 00:51:00 +00:00
|
|
|
row1("<a name=\"prefs\"></a>".tra("Preferences"));
|
2008-05-15 22:05:05 +00:00
|
|
|
if (!no_computing()) {
|
|
|
|
row2(
|
|
|
|
tra("When and how BOINC uses your computer"),
|
|
|
|
"<a href=\"prefs.php?subset=global\">".tra("Computing preferences")."</a>"
|
|
|
|
);
|
|
|
|
}
|
2007-11-26 00:51:00 +00:00
|
|
|
row2(tra("Message boards and private messages"),
|
|
|
|
"<a href=\"edit_forum_preferences_form.php\">".tra("Community preferences")."</a>"
|
|
|
|
);
|
2008-05-15 22:05:05 +00:00
|
|
|
if (!no_computing()) {
|
2009-09-28 16:19:20 +00:00
|
|
|
row2(tra("Preferences for this project"),
|
2008-05-15 22:05:05 +00:00
|
|
|
"<a href=\"prefs.php?subset=project\">".tra("%1 preferences", PROJECT)."</a>"
|
|
|
|
);
|
|
|
|
}
|
2008-01-01 22:29:10 +00:00
|
|
|
}
|
2007-11-26 00:51:00 +00:00
|
|
|
|
2008-01-01 22:29:10 +00:00
|
|
|
function show_community_private($user) {
|
2007-10-30 19:36:27 +00:00
|
|
|
row1(tra("Community"));
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2007-10-28 15:03:14 +00:00
|
|
|
if ($user->has_profile) {
|
2007-11-26 03:05:27 +00:00
|
|
|
$x = "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a> | <a href=\"delete_profile.php\">".tra("Delete")."</a>";
|
2004-02-02 23:34:39 +00:00
|
|
|
} else {
|
2007-10-30 19:36:27 +00:00
|
|
|
$x = "<a href=\"create_profile.php\">".tra("Create")."</a>";
|
2006-02-12 06:19:00 +00:00
|
|
|
}
|
2007-10-30 19:36:27 +00:00
|
|
|
row2(tra("Profile"), $x);
|
2006-10-27 16:06:42 +00:00
|
|
|
$tot = total_posts($user);
|
|
|
|
if ($tot) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
|
2006-10-27 16:06:42 +00:00
|
|
|
}
|
2007-04-29 14:22:28 +00:00
|
|
|
|
2007-11-26 00:51:00 +00:00
|
|
|
row2(tra("Private messages"), pm_notification($user).pm_email_remind($user));
|
2006-02-12 06:19:00 +00:00
|
|
|
|
2007-12-18 20:28:08 +00:00
|
|
|
$notifies = BoincNotify::enum("userid=$user->id");
|
|
|
|
if (count($notifies)) {
|
|
|
|
$x = "";
|
|
|
|
foreach ($notifies as $notify) {
|
2008-01-04 22:59:21 +00:00
|
|
|
$x .= "• ".notify_description($notify)."<br>";
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
2008-05-13 21:46:50 +00:00
|
|
|
$x .= "<a href=\"".notify_rss_url($user)."\"><img vspace=\"4\" border=\"0\" src=\"img/rss_icon.gif\" alt=\"RSS\" /></a>";
|
|
|
|
row2(tra("Notifications"), $x);
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
|
|
|
|
2009-07-22 18:41:02 +00:00
|
|
|
if (!defined('NO_TEAMS')) {
|
|
|
|
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\">".tra("Quit team")."</a>";
|
|
|
|
if (is_team_admin($user, $team)) {
|
|
|
|
$x .= " | <a href=\"team_manage.php?teamid=$user->teamid\">".tra("Administer")."</a>";
|
|
|
|
}
|
2007-11-07 23:59:08 +00:00
|
|
|
|
2009-07-22 18:41:02 +00:00
|
|
|
// if there's a foundership request, notify the founder
|
|
|
|
//
|
|
|
|
if ($user->id==$team->userid && $team->ping_user >0) {
|
2008-05-13 21:46:50 +00:00
|
|
|
$x .= "<span style=\"color:red;\">".tra("(foundership change request pending)")."</span>";
|
2007-11-07 23:59:08 +00:00
|
|
|
}
|
2009-07-22 18:41:02 +00:00
|
|
|
row2(tra("Member of team"), $x);
|
|
|
|
} else {
|
|
|
|
row2(tra("Team"), tra("None")." | <a href=\"team_search.php\">".tra("find a team")."</a>");
|
|
|
|
}
|
|
|
|
|
|
|
|
$teams_founded = BoincTeam::enum("userid=$user->id");
|
|
|
|
foreach ($teams_founded as $team) {
|
|
|
|
if ($team->id != $user->teamid) {
|
|
|
|
$x = "<a href=\"team_display.php?teamid=$team->id\">$team->name</a>";
|
|
|
|
$x .= "| <a href=\"team_manage.php?teamid=".$team->id."\">".tra("Administer")."</a>";
|
|
|
|
if ($team->ping_user > 0) {
|
|
|
|
$x .= "<span style=\"color:red;\">".tra("(foundership change request pending)")."</span>";
|
|
|
|
}
|
|
|
|
row2(tra("Founder but not member of"), $x);
|
|
|
|
}
|
2006-12-29 23:36:24 +00:00
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
|
2008-01-01 22:29:10 +00:00
|
|
|
$friends = BoincFriend::enum("user_src=$user->id and reciprocated=1");
|
2008-05-13 21:46:50 +00:00
|
|
|
$x = "<a href=\"user_search.php\">".tra("Find friends")."</a><br\>\n";
|
2008-01-28 16:12:28 +00:00
|
|
|
$n = count($friends);
|
|
|
|
if ($n) {
|
2008-01-01 22:29:10 +00:00
|
|
|
foreach($friends as $friend) {
|
|
|
|
$fuser = BoincUser::lookup_id($friend->user_dest);
|
|
|
|
$x .= friend_links($fuser);
|
|
|
|
}
|
2008-05-21 16:37:11 +00:00
|
|
|
row2(tra("Friends")." ($n)", $x);
|
2008-01-28 16:12:28 +00:00
|
|
|
} else {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Friends"), $x);
|
2008-01-01 22:29:10 +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) {
|
2007-12-18 20:28:08 +00:00
|
|
|
global $g_logged_in_user;
|
2008-05-15 11:17:40 +00:00
|
|
|
row2(tra("%1 member since", PROJECT), date_str($user->create_time));
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Country"), $user->country);
|
2004-02-02 23:34:39 +00:00
|
|
|
if (strlen($user->url)) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("URL"), "<a href=\"http://$user->url\">http://$user->url</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2008-05-15 22:05:05 +00:00
|
|
|
if (!no_computing()) {
|
|
|
|
show_credit($user);
|
2004-02-02 23:34:39 +00:00
|
|
|
|
2008-05-15 22:05:05 +00:00
|
|
|
if ($user->show_hosts) {
|
|
|
|
row2(tra("Computers"), "<a href=\"".URL_BASE."hosts_user.php?userid=$user->id\">".tra("View")."</a>");
|
|
|
|
} else {
|
|
|
|
row2(tra("Computers"), tra("hidden"));
|
|
|
|
}
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
2006-02-17 22:01:22 +00:00
|
|
|
if ($user->donated == 1) {
|
2006-09-06 20:56:55 +00:00
|
|
|
if (file_exists("../project/donations.inc")) {
|
|
|
|
require_once("../project/donations.inc");
|
|
|
|
$x .= DONATION_LINK;
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Donor"), $x);
|
2006-09-06 20:56:55 +00:00
|
|
|
}
|
2006-02-17 22:01:22 +00:00
|
|
|
}
|
2008-01-01 22:29:10 +00:00
|
|
|
}
|
|
|
|
|
2008-12-29 18:44:11 +00:00
|
|
|
/**
|
|
|
|
* Returns a cacheable community links data object
|
|
|
|
* @param user The users to produce a community links object for
|
|
|
|
*/
|
|
|
|
function get_community_links_object($user){
|
|
|
|
$cache_object->post_count = total_posts($user);
|
|
|
|
$cache_object->user = $user;
|
|
|
|
$cache_object->team = lookup_team($user->teamid);
|
|
|
|
|
|
|
|
$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);
|
2009-02-06 03:40:54 +00:00
|
|
|
$cache_object->friends[] = $fuser;
|
2008-12-29 18:44:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $cache_object;
|
|
|
|
}
|
|
|
|
|
|
|
|
function community_links($clo, $logged_in_user){
|
|
|
|
$user = $clo->user;
|
|
|
|
$team = $clo->team;
|
|
|
|
$friends = $clo->friends;
|
|
|
|
$tot = $clo->post_count;
|
|
|
|
|
2009-07-22 18:41:02 +00:00
|
|
|
if (!defined('NO_TEAMS')) {
|
|
|
|
if ($user->teamid && $team) {
|
|
|
|
row2(tra("Team"), "<a href=\"".URL_BASE."team_display.php?teamid=$team->id\">$team->name</a>");
|
|
|
|
} else {
|
|
|
|
row2(tra("Team"), tra("None"));
|
|
|
|
}
|
2008-01-01 22:29:10 +00:00
|
|
|
}
|
|
|
|
if ($tot) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Message boards"), "<a href=\"".URL_BASE."forum_user_posts.php?userid=$user->id\">".tra("%1 posts", $tot)."</a>");
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
2008-12-29 18:44:11 +00:00
|
|
|
if ($logged_in_user && $logged_in_user->id != $user->id) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Contact"), "<a href=\"pm.php?action=new&userid=".$user->id."\">".tra("Send private message")."</a>");
|
2009-02-06 03:40:54 +00:00
|
|
|
$friend = BoincFriend::lookup($logged_in_user->id, $user->id);
|
2007-12-30 22:02:16 +00:00
|
|
|
if ($friend && $friend->reciprocated) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("This person is a friend"),
|
|
|
|
"<a href=\"friend.php?action=cancel_confirm&userid=$user->id\">".tra("Cancel friendship")."</a>"
|
2007-12-30 22:02:16 +00:00
|
|
|
);
|
2008-01-02 17:52:21 +00:00
|
|
|
} else if ($friend) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Request pending")."</a>");
|
2007-12-30 22:02:16 +00:00
|
|
|
} else {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Friends"), "<a href=\"friend.php?action=add&userid=$user->id\">".tra("Add as friend")."</a>");
|
2008-01-01 22:29:10 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-29 18:44:11 +00:00
|
|
|
|
|
|
|
if ($friends) {
|
2008-01-01 22:29:10 +00:00
|
|
|
$x = null;
|
|
|
|
foreach($friends as $friend) {
|
2008-12-29 18:44:11 +00:00
|
|
|
$x .= friend_links($friend);
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
2008-12-29 18:44:11 +00:00
|
|
|
row2(tra("Friends")." (".sizeof($friends).")", $x);
|
2007-12-18 20:28:08 +00:00
|
|
|
}
|
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) {
|
2008-05-13 21:46:50 +00:00
|
|
|
row2(tra("Profile"), "<a href=\"view_profile.php?userid=$user->id\">".tra("View")."</a>");
|
2004-02-02 23:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-10 18:34:51 +00:00
|
|
|
function is_banned_email_addr($email_addr) {
|
|
|
|
global $banned_email_domains;
|
|
|
|
if (isset($banned_email_domains)) {
|
|
|
|
foreach($banned_email_domains as $d) {
|
|
|
|
$x = strstr($email_addr, $d);
|
|
|
|
if ($x == $d) return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-06-11 19:36:10 +00:00
|
|
|
// the following DB-escapes its args
|
|
|
|
//
|
2007-07-25 15:11:14 +00:00
|
|
|
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;
|
2009-06-10 18:34:51 +00:00
|
|
|
if (is_banned_email_addr($email_addr)) return null;
|
|
|
|
|
2007-07-25 15:11:14 +00:00
|
|
|
$authenticator = random_string();
|
|
|
|
$cross_project_id = random_string();
|
|
|
|
$now = time();
|
|
|
|
if (!is_valid_country($country)) return null;
|
2008-06-11 19:36:10 +00:00
|
|
|
|
2008-12-14 22:18:49 +00:00
|
|
|
$email_addr = BoincDb::escape_string($email_addr);
|
|
|
|
$name = BoincDb::escape_string($name);
|
|
|
|
$passwd_hash = BoincDb::escape_string($passwd_hash);
|
2008-06-11 19:36:10 +00:00
|
|
|
|
2007-10-28 15:03:14 +00:00
|
|
|
$country = BoincDb::escape_string($country);
|
2008-12-14 22:18:49 +00:00
|
|
|
$postal_code = strip_tags(BoincDb::escape_string($postal_code));
|
2007-07-25 15:11:14 +00:00
|
|
|
|
2008-06-24 22:20:40 +00:00
|
|
|
$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')");
|
2007-07-25 15:11:14 +00:00
|
|
|
|
2008-06-24 22:20:40 +00:00
|
|
|
if ($uid) {
|
|
|
|
return BoincUser::lookup_id($uid);
|
2007-07-25 15:11:14 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-14 16:03:47 +00:00
|
|
|
$cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
?>
|