*** empty log message ***

svn path=/trunk/boinc/; revision=2797
This commit is contained in:
David Anderson 2003-12-15 02:31:29 +00:00
parent e2454a6f06
commit d9ac291a03
15 changed files with 211 additions and 150 deletions

View File

@ -8471,3 +8471,29 @@ David 12 Dec 2003
client/
app.C
David 14 Dec 2003
- added "has_profile" flag to user table;
whenever a user has a profile,
display a "profile icon" linking to it.
Also write it to XML files
- Change file_upload_handler to put its log file
in the right directory
db/
boinc_db.C,h
scheme.sql
html_user/
host.inc
host_user.php
index.php
profile.inc
team.inc
top_hosts.php
user.inc
util.inc
py/Boinc/
database.py
sched/
db_dump.C
file_upload_handler.C

View File

@ -17,6 +17,9 @@
// Contributor(s):
//
// $Log$
// Revision 1.27 2003/12/15 02:31:27 boincadm
// *** empty log message ***
//
// Revision 1.26 2003/12/12 21:10:38 boincadm
// *** empty log message ***
//
@ -212,7 +215,7 @@ void DB_USER::db_print(char* buf){
"teamid=%d, venue='%s', url='%s', send_email=%d, show_hosts=%d, "
"posts=%d, "
"seti_id=%d, seti_nresults=%d, seti_last_result_time=%d, "
"seti_total_cpu=%.15e, signature='%s'",
"seti_total_cpu=%.15e, signature='%s', has_profile=%d",
id,
create_time,
email_addr,
@ -235,7 +238,8 @@ void DB_USER::db_print(char* buf){
seti_nresults,
seti_last_result_time,
seti_total_cpu,
signature
signature,
has_profile
);
unescape_single_quotes(email_addr);
unescape_single_quotes(name);
@ -273,6 +277,7 @@ void DB_USER::db_parse(MYSQL_ROW &r) {
seti_last_result_time = safe_atoi(r[i++]);
seti_total_cpu = safe_atof(r[i++]);
strcpy2(signature, r[i++]);
has_profile = atoi(r[i++]);
}
void DB_TEAM::db_print(char* buf){

View File

@ -171,6 +171,7 @@ struct USER {
int seti_last_result_time; // time of last result (UNIX)
double seti_total_cpu; // number of CPU seconds
char signature[256];
bool has_profile;
void clear();
};

View File

@ -1,10 +1,12 @@
/* If you add/change anything, update
boinc_db.C,h
and if needed:
py/Boinc/database.py
html_user/
create_account_action.php
team_create_action.php
/* If you add/change anything, update
boinc_db.C,h
and if needed:
py/Boinc/database.py
html_user/
create_account_action.php
team_create_action.php
sched/
db_dump.C
*/
/* Fields are documented in boinc_db.h */
/* Do not replace this with an automatically generated schema */
@ -82,6 +84,7 @@ create table user (
seti_last_result_time integer not null,
seti_total_cpu double not null,
signature varchar(254),
has_profile smallint not null,
primary key (id)
);

View File

@ -37,7 +37,7 @@ function show_host($host, $private, $ipprivate) {
if (!$private) {
$user = lookup_user_id($host->userid);
if ($user && $user->show_hosts) {
row2("Owner", "<a href=show_user.php?userid=$user->id>$user->name</a>");
row2("Owner", user_links($user));
} else {
row2("Owner", "Anonymous");
}
@ -106,21 +106,19 @@ function show_host($host, $private, $ipprivate) {
}
function host_table_start($title, $private) {
function host_table_start($title, $private, $show_owner) {
start_table();
row1($title, 7);
echo "<tr>";
echo "<th>ID<br><font size=-2>Click for more info</font></th>\n";
if ($private) {
echo "<th>Name
<br><font size=-2>Click for more info</font>
</th>\n
echo "<th>Name</th>\n
";
} else {
echo "<th>
Rank<br><font size=-2>Click for more info</font>
</th>
";
echo "<th>Owner</th>\n";
echo "<th>Rank</th>";
if ($show_owner) {
echo "<th>Owner</th>\n";
}
}
echo "
<th><a href=top_hosts.php?sort_by=expavg_credit>Recent average credit</a></th>
@ -142,7 +140,7 @@ function host_nresults($host) {
// so it's OK to show the domain name etc.
// If private is false, show the owner's name only if they've given permission
//
function show_host_row($host, $i, $private) {
function show_host_row($host, $i, $private, $show_owner) {
$result = mysql_query("select * from user where id = $host->userid");
$user = mysql_fetch_object($result);
mysql_free_result($result);
@ -150,15 +148,22 @@ function show_host_row($host, $i, $private) {
echo "<tr>";
if ($private) {
echo "<td>
<a href=show_host_detail.php?hostid=$host->id&private=1>
$host->domain_name</a></td>
<a href=show_host_detail.php?hostid=$host->id&private=1>$host->id</a>
</td>
";
echo "<td> $host->domain_name";
} else {
echo "<td><a href=show_host_detail.php?hostid=$host->id>$i</a></td>\n";
if ($user->show_hosts) {
echo "<td><a href=show_user.php?userid=$user->id>$user->name</a></td>\n";
} else {
echo "<td>Anonymous</td>\n";
echo "<td>
<a href=show_host_detail.php?hostid=$host->id>$host->id</a>
</td>
<td>$i</td>\n
";
if ($show_owner) {
if ($user->show_hosts) {
echo "<td>", user_links($user), "</td>\n";
} else {
echo "<td>Anonymous</td>\n";
}
}
}
printf("

View File

@ -13,19 +13,19 @@
$user = mysql_fetch_object($result);
mysql_free_result($result);
page_head("Computers belonging to $user->name");
host_table_start("Computers belonging to $user->name", false);
host_table_start("Computers belonging to $user->name", false, false);
$private = false;
} else {
$user = get_logged_in_user();
$userid = $user->id;
page_head("Your computers");
host_table_start("Your computers", true);
host_table_start("Your computers", true, false);
$private = true;
}
$i = 1;
$result = mysql_query("select * from host where userid=$userid order by expavg_credit desc");
while ($host = mysql_fetch_object($result)) {
show_host_row($host, $i, $private);
show_host_row($host, $i, $private, false);
$i++;
}
mysql_free_result($result);

View File

@ -49,6 +49,11 @@ if (project_is_stopped()) {
<li><a href=".URL_BASE."forum/help_desk.php>Questions and problems</a>
</ul>
<h3><a href=stats.php>Project totals and leader boards</a></h3>
<ul>
<li><a href=top_users.php>Top users</a>
<li><a href=top_hosts.php>Top hosts</a>
<li><a href=top_teams.php>Top teams</a>
</ul>
";
}
echo "

View File

@ -228,7 +228,6 @@ function process_create_results() {
$response1 = sanitize_html($response1);
$response2 = sanitize_html($response2);
if ($profile_info) {
$query = 'UPDATE profile SET '
." response1 = '$response1',"
." response2 = '$response2',"
@ -236,8 +235,12 @@ function process_create_results() {
." has_picture = '$hasPicture',"
." hide_email = '$hide_email'"
." WHERE userid = '$user->id'";
$result = mysql_query($query);
if (!$result) {
profile_error_page("Couldn't update profile: database error");
exit();
}
} else {
$query = 'INSERT INTO profile SET '
." userid = '$user->id',"
." language = '$language',"
@ -245,13 +248,13 @@ function process_create_results() {
." response2 = '$response2',"
." has_picture = '$hasPicture',"
." hide_email = '$hide_email'";
}
$result = mysql_query($query);
if (!$result) {
profile_error_page("Couldn't create profile: database error!");
exit();
$result = mysql_query($query);
if (!$result) {
profile_error_page("Couldn't create profile: database error");
exit();
}
$q = "update user set has_profile=1 where id=$user->id";
mysql_query($q);
}
show_result_page();
@ -399,42 +402,37 @@ function show_user_table($members, $offset, $numToDisplay, $cols, $descriptor=nu
// 2) the first MAX_DESC_LENGTH characters from the response1 field of said user's profile.
function get_profile_summary($profile) {
$sql = "SELECT * FROM profile WHERE userid = " . $profile['userid'];
$result = mysql_query($sql);
$sql = "SELECT name FROM user WHERE id = " . $profile['userid'];
$result2 = mysql_query($sql);
$sql = "SELECT * FROM profile WHERE userid = " . $profile['userid'];
$result = mysql_query($sql);
$sql = "SELECT name FROM user WHERE id = " . $profile['userid'];
$result2 = mysql_query($sql);
if (!$result || !$result2) {
echo "Database error!"; // Change this to a standard error page.
exit();
}
if (!$result || !$result2) {
echo "Database error!"; // Change this to a standard error page.
exit();
}
$row = mysql_fetch_assoc($result);
$row2 = mysql_fetch_assoc($result2);
$row = mysql_fetch_assoc($result);
$row2 = mysql_fetch_assoc($result2);
mysql_free_result($result);
mysql_free_result($result2);
mysql_free_result($result);
mysql_free_result($result2);
$description = "";
$description = "";
if (strlen($row['response1']) != 0) {
$temp = $row['response1'];
$description = "(\"" . sub_sentence(strip_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
if (strlen($row['response1']) != 0) {
$temp = $row['response1'];
$description = "(\"" . sub_sentence(strip_tags($temp), ' ', MAX_DESC_LENGTH, true) . "\")";
}
}
$summary = "<a href=\"" . URL_BASE . "view_profile.php?userid=" . $profile['userid'] . "\">" . $row2['name'] . "</a> " . $description;
return $summary;
$summary = "<a href=\"" . URL_BASE . "view_profile.php?userid=" . $profile['userid'] . "\">" . $row2['name'] . "</a> " . $description;
return $summary;
}
// Displays a user's profile (if they have one);
function show_profile($userid, $verify_mode=false) {
if (!$userid) {
profile_error_page("No user ID was specified.<p>");
exit();
}
$user = get_user_from_id($userid);
if (!$user) {
@ -464,98 +462,97 @@ function show_profile($userid, $verify_mode=false) {
echo "<a href=create_profile.php>[Edit Your Profile]</a>";
}
start_table_noborder();
echo "<tr><td>";
show_profile_summary($user, $profile_info, $can_edit, $verify_mode);
echo "</tr></td>";
echo "<br><br>";
show_profile_heading1();
echo "<tr><td>", $profile_info['response1'], "<br><br></td></tr>";
echo ":", $profile_info['response1'];
echo "<br><br>";
show_profile_heading2();
echo "<tr><td>", $profile_info['response2'], "</td></tr>";
end_table();
echo ":", $profile_info['response2'];
if (!$verify_mode) {
page_tail();
}
}
function show_profile_summary($user, $profile_info, $can_edit, $verify_mode) {
echo "
<table border=0 cellpadding = 1 width=100%>\n
<tr><td><h1>$user->name</h1></td><td align=\"center\">";
echo "
<h2>User profile: $user->name</h2>
";
if (!$can_edit && !$verify_mode) {
show_view_buttons($user->id);
}
if (!$can_edit && !$verify_mode) {
show_view_buttons($user->id);
}
echo "</td></tr>\n<tr><td colspan=\"2\">\n";
// Only display an image if the user has uploaded one;
if ($profile_info['has_picture']) {
//echo "<a href=\"" , URL_BASE, IMAGE_PATH , $user->id , '.jpg' . "\"><img align=left vspace=6 hspace=9 src=\"" , URL_BASE, IMAGE_PATH , $user->id , '_sm.jpg' . "\"></a>\n";
echo "<br><img vspace=6 hspace=9 src=\"" , URL_BASE, IMAGE_PATH , $user->id , '.jpg' . "\">\n";
}
// Only display an image if the user has uploaded one;
if (!$verify_mode && $profile_info['has_picture']) {
echo "<a href=\"" , URL_BASE, IMAGE_PATH , $user->id , '.jpg' . "\"><img align=left vspace=6 hspace=9 src=\"" , URL_BASE, IMAGE_PATH , $user->id , '_sm.jpg' . "\"></a>\n";
} else if ($verify_mode && $profile_info['has_picture']) {
echo "<a href=\"" , URL_BASE, IMAGE_PATH , $user->id , '.jpg' . "\"><img align=left vspace=6 hspace=9 src=\"" , URL_BASE, IMAGE_PATH , $user->id , '_sm.jpg' . "\"></a>\n";
}
echo "
<br>
<font size=-1>
<b>Country:</b> ", $user->country,
"<br><b>Language:</b> ", $profile_info['language'], "<br>
";
if (!$profile_info['hide_email']) {
echo "<b>Email:</b> <a href=\"mailto:", $user->email_addr, "\">", $user->email_addr, "</a><br>";
}
echo "<b>Total Credit:</b> ", $user->total_credit, "<br>";
echo "
<font size=\"-1\">
<b>Country:</b> ", $user->country, "&nbsp&nbsp<b>Language:</b> ", $profile_info['language'], "<br>";
if (!$profile_info['hide_email']) {
echo "<b>Email:</b> <a href=\"mailto:", $user->email_addr, "\">", $user->email_addr, "</a><br>";
}
echo "<b>Total Credit:</b> ", $user->total_credit, "<br>";
if ($user->teamid) {
$result = mysql_query("select * from team where id = $user->teamid");
$team = mysql_fetch_object($result);
echo "<b>Team:</b> <a href=team_display.php?teamid=$team->id>$team->name</a><br>";
}
echo "
<b>Date Registered:</b> ", date_str($user->create_time), "
</font>
</td></tr>
</table>
<br>\n";
if ($user->teamid) {
$result = mysql_query("select * from team where id = $user->teamid");
$team = mysql_fetch_object($result);
echo "<b>Team:</b> <a href=team_display.php?teamid=$team->id>$team->name</a><br>";
}
echo "
<b>Date Registered:</b> ", date_str($user->create_time), "
</font>
</td></tr>
</table>
<br>\n
";
}
function show_view_buttons($userid) {
echo "
<form action=view_profile.php?userid=$userid method=\"POST\">
<input type=\"submit\" name=\"recommend\" value=\"RECOMMEND\">
<font size=-1><a href=\"javascript:;\" onClick=\"window.open ('explanation.php?val=recommend','_blank','width=350,height=200,left=50,top=150,menubar=0,directories=0,scrollbars=0,resizable=0,status=0')\">what is recommend?</a></font>
<br>
<input type=\"submit\" name=\"reject\" value=\"VOTE TO REJECT\">
<font size=-1><a href=\"javascript:;\" onClick=\"window.open ('explanation.php?val=reject','_blank','width=350,height=200,left=50,top=150,menubar=0,directories=0,scrollbars=0,resizable=0,status=0')\">what is vote to reject?</a></font>
</form>
";
echo "
<form action=view_profile.php?userid=$userid method=\"POST\">
<input type=submit name=recommend value=Recommend>
<font size=-1><a href=\"javascript:;\" onClick=\"window.open ('explanation.php?val=recommend','_blank','width=350,height=200,left=50,top=150,menubar=0,directories=0,scrollbars=0,resizable=0,status=0')\">what is recommend?</a></font>
<br>
<input type=submit name=reject value=\"Vote to reject\">
<font size=-1><a href=\"javascript:;\" onClick=\"window.open ('explanation.php?val=reject','_blank','width=350,height=200,left=50,top=150,menubar=0,directories=0,scrollbars=0,resizable=0,status=0')\">what is vote to reject?</a></font>
</form>
";
}
function process_view_results($vote, $userid) {
if ($vote != "recommend" && $vote != "reject") {
echo "Invalid vote type.<br>";
exit();
}
if ($vote != "recommend" && $vote != "reject") {
echo "Invalid vote type.<br>";
exit();
}
$result = mysql_query("SELECT * FROM profile WHERE userid = $userid");
$profile = mysql_fetch_array($result);
$result = mysql_query("SELECT * FROM profile WHERE userid = $userid");
$profile = mysql_fetch_array($result);
$newValue = $profile[$vote] + 1;
$newresult = mysql_query("UPDATE profile SET $vote = $newValue WHERE userid = $userid");
$newValue = $profile[$vote] + 1;
$newresult = mysql_query("UPDATE profile SET $vote = $newValue WHERE userid = $userid");
page_head("Vote Recorded");
page_head("Vote Recorded");
start_table_noborder();
start_table_noborder();
row1("Thank you");
row1("Thank you");
if ($vote == "recommend") {
rowify("Your recommendation has been recorded.");
} else {
rowify("Your vote to reject has been recorded.");
}
end_table();
echo "<br><a href=\"view_profile.php?userid=", $userid ,"\">Return to profile.</a>";
if ($vote == "recommend") {
rowify("Your recommendation has been recorded.");
} else {
rowify("Your vote to reject has been recorded.");
}
end_table();
echo "<br><a href=\"view_profile.php?userid=", $userid ,"\">Return to profile.</a>";
page_tail();
page_tail();
}
?>

View File

@ -56,7 +56,7 @@ function display_team_page($team, $user) {
row2("Total credit", format_credit($total_credit));
$result = mysql_query("select * from user where id=$team->userid");
$user = mysql_fetch_object($result);
row2("Founder", "<a href=show_user.php?userid=$user->id>$user->name</a>");
row2("Founder", user_links($user));
row2("Country", $team->country);
echo "</table>";
echo "<p>";
@ -78,8 +78,9 @@ function display_team_page($team, $user) {
if (!$user) break;
$user_total_credit = format_credit($user->total_credit);
$user_expavg_credit = format_credit($user->expavg_credit);
$x = user_links($user);
echo "<tr class=row1>
<td align=left>$j) <a href=show_user.php?userid=$user->id>$user->name</a>
<td align=left>$j) $x
<td align=center>$user_total_credit</td>
<td align=center>$user_expavg_credit</td>
<td align=center>$user->country</td>

View File

@ -16,10 +16,10 @@
$sort_clause = "expavg_credit desc, total_credit desc";
}
$result = mysql_query("select * from host order by $sort_clause limit $n offset $offset");
host_table_start("Top computers", false);
host_table_start("Top computers", false, true);
$i = $offset+1;
while ($host = mysql_fetch_object($result)) {
show_host_row($host, $i, false);
show_host_row($host, $i, false, true);
$i++;
}
mysql_free_result($result);

View File

@ -125,16 +125,16 @@ function user_table_start() {
}
function show_user_row($user, $i) {
printf(
"<tr class=row1>
<td>%d</td>
<td><a href=show_user.php?userid=%d>%s</a></td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>\n", $i, $user->id, $user->name, format_credit($user->expavg_credit),
format_credit($user->total_credit), $user->country, time_str($user->create_time));
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>
";
}
?>

View File

@ -455,4 +455,12 @@ function format_credit($cobblestones) {
function project_is_stopped() {
return file_exists("../stop_servers");
}
function user_links($user) {
$x = "<a href=show_user.php?userid=$user->id>$user->name</a>";
if ($user->has_profile) {
$x .= " <a href=view_profile?userid=$user->id><img border=0 src=head.png></a>";
}
return $x;
}
?>

View File

@ -100,7 +100,8 @@ class User(DatabaseObject):
'seti_nresults',
'seti_last_result_time',
'seti_total_cpu',
'signature'
'signature',
'has_profile'
])
class Team(DatabaseObject):

View File

@ -280,6 +280,11 @@ void write_user(USER& user, FILE* f, bool detail, bool show_team) {
user.teamid
);
}
if (user.has_profile) {
fprintf(f,
" <has_profile/>\n"
);
}
if (detail && user.show_hosts) {
sprintf(buf, "where userid=%d", user.id);
while (!host.enumerate(buf)) {

View File

@ -42,10 +42,11 @@ SCHED_CONFIG config;
#define DEBUG_LEVEL SchedMessages::NORMAL
// #define STDERR_FILENAME "file_upload_handler.out"
static const char* STDERR_FILENAME = "../log/file_upload_handler.log";
#define MAX_FILES 32
void get_log_path(char* p) {
char buf[256];
gethostname(buf, 256);
sprintf(p, "../log_%s/file_upload_handler.log", buf);
}
struct FILE_INFO {
char name[256];
@ -335,9 +336,12 @@ int get_key(R_RSA_PUBLIC_KEY& key) {
int main() {
int retval;
R_RSA_PUBLIC_KEY key;
char log_path[256];
if (!freopen(STDERR_FILENAME, "a", stderr)) {
fprintf(stderr, "Can't redirect stderr\n");
get_log_path(log_path);
if (!freopen(log_path, "a", stderr)) {
fprintf(stderr, "Can't open log file\n");
exit(1);
}