diff --git a/checkin_notes b/checkin_notes index 050efcc483..def8c17ad5 100755 --- a/checkin_notes +++ b/checkin_notes @@ -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 diff --git a/db/boinc_db.C b/db/boinc_db.C index bef6000414..8889dd78b5 100644 --- a/db/boinc_db.C +++ b/db/boinc_db.C @@ -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){ diff --git a/db/boinc_db.h b/db/boinc_db.h index 0ae5c78dd6..796bb359f9 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -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(); }; diff --git a/db/schema.sql b/db/schema.sql index 71d1e0d13f..d802652411 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -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) ); diff --git a/html/user/host.inc b/html/user/host.inc index 73a673c0fd..3176159d22 100644 --- a/html/user/host.inc +++ b/html/user/host.inc @@ -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", "id>$user->name"); + 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 ""; + echo "ID
Click for more info\n"; if ($private) { - echo "Name -
Click for more info - \n + echo "Name\n "; } else { - echo " - Rank
Click for more info - - "; - echo "Owner\n"; + echo "Rank"; + if ($show_owner) { + echo "Owner\n"; + } } echo " Recent average credit @@ -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 ""; if ($private) { echo " - id&private=1> - $host->domain_name + id&private=1>$host->id + "; + echo " $host->domain_name"; } else { - echo "id>$i\n"; - if ($user->show_hosts) { - echo "id>$user->name\n"; - } else { - echo "Anonymous\n"; + echo " + id>$host->id + + $i\n + "; + if ($show_owner) { + if ($user->show_hosts) { + echo "", user_links($user), "\n"; + } else { + echo "Anonymous\n"; + } } } printf(" diff --git a/html/user/hosts_user.php b/html/user/hosts_user.php index b8c81724b9..a301a1ef7e 100644 --- a/html/user/hosts_user.php +++ b/html/user/hosts_user.php @@ -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); diff --git a/html/user/index.php b/html/user/index.php index 6ec69953f7..c8224c07ec 100644 --- a/html/user/index.php +++ b/html/user/index.php @@ -49,6 +49,11 @@ if (project_is_stopped()) {
  • Questions and problems

    Project totals and leader boards

    + "; } echo " diff --git a/html/user/profile.inc b/html/user/profile.inc index 2b51db0cb7..64da104794 100644 --- a/html/user/profile.inc +++ b/html/user/profile.inc @@ -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 = "" . $row2['name'] . " " . $description; - return $summary; + $summary = "" . $row2['name'] . " " . $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.

    "); - exit(); - } - $user = get_user_from_id($userid); if (!$user) { @@ -464,98 +462,97 @@ function show_profile($userid, $verify_mode=false) { echo "[Edit Your Profile]"; } - start_table_noborder(); - echo ""; show_profile_summary($user, $profile_info, $can_edit, $verify_mode); - echo ""; + echo "

    "; show_profile_heading1(); - echo "", $profile_info['response1'], "

    "; + echo ":", $profile_info['response1']; + echo "

    "; show_profile_heading2(); - echo "", $profile_info['response2'], ""; - end_table(); + echo ":", $profile_info['response2']; if (!$verify_mode) { page_tail(); } } function show_profile_summary($user, $profile_info, $can_edit, $verify_mode) { - echo " -\n -\n -

    $user->name

    "; + echo " +

    User profile: $user->name

    + "; - if (!$can_edit && !$verify_mode) { - show_view_buttons($user->id); - } + if (!$can_edit && !$verify_mode) { + show_view_buttons($user->id); + } - echo "
    \n"; + // Only display an image if the user has uploaded one; + if ($profile_info['has_picture']) { + //echo "id , '.jpg' . "\">id , '_sm.jpg' . "\">\n"; + echo "
    id , '.jpg' . "\">\n"; + } - // Only display an image if the user has uploaded one; - if (!$verify_mode && $profile_info['has_picture']) { - echo "id , '.jpg' . "\">id , '_sm.jpg' . "\">\n"; - } else if ($verify_mode && $profile_info['has_picture']) { - echo "id , '.jpg' . "\">id , '_sm.jpg' . "\">\n"; - } + echo " +
    + + Country: ", $user->country, + "
    Language: ", $profile_info['language'], "
    + "; + if (!$profile_info['hide_email']) { + echo "Email: email_addr, "\">", $user->email_addr, "
    "; + } + echo "Total Credit: ", $user->total_credit, "
    "; - echo " - -Country: ", $user->country, "  Language: ", $profile_info['language'], "
    "; - if (!$profile_info['hide_email']) { - echo "Email: email_addr, "\">", $user->email_addr, "
    "; - } - echo "Total Credit: ", $user->total_credit, "
    "; - - if ($user->teamid) { - $result = mysql_query("select * from team where id = $user->teamid"); - $team = mysql_fetch_object($result); - echo "Team: id>$team->name
    "; - } - echo " -Date Registered: ", date_str($user->create_time), " -
    -
    -
    \n"; + if ($user->teamid) { + $result = mysql_query("select * from team where id = $user->teamid"); + $team = mysql_fetch_object($result); + echo "Team: id>$team->name
    "; + } + echo " + Date Registered: ", date_str($user->create_time), " + + + +
    \n + "; } function show_view_buttons($userid) { - echo " -

    - -what is recommend? -
    - -what is vote to reject? -
    -"; + echo " +
    + + what is recommend? +
    + + what is vote to reject? +
    + "; } function process_view_results($vote, $userid) { - if ($vote != "recommend" && $vote != "reject") { - echo "Invalid vote type.
    "; - exit(); - } + if ($vote != "recommend" && $vote != "reject") { + echo "Invalid vote type.
    "; + 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 "
    Return to profile."; + if ($vote == "recommend") { + rowify("Your recommendation has been recorded."); + } else { + rowify("Your vote to reject has been recorded."); + } + end_table(); + echo "
    Return to profile."; - page_tail(); + page_tail(); } ?> diff --git a/html/user/team.inc b/html/user/team.inc index 8165a46cc2..faa9046c5e 100644 --- a/html/user/team.inc +++ b/html/user/team.inc @@ -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", "id>$user->name"); + row2("Founder", user_links($user)); row2("Country", $team->country); echo ""; echo "

    "; @@ -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 " - $j) id>$user->name + $j) $x $user_total_credit $user_expavg_credit $user->country diff --git a/html/user/top_hosts.php b/html/user/top_hosts.php index 3c6547568b..e2e94d2fea 100644 --- a/html/user/top_hosts.php +++ b/html/user/top_hosts.php @@ -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); diff --git a/html/user/user.inc b/html/user/user.inc index 6f54b96746..75c0af2019 100644 --- a/html/user/user.inc +++ b/html/user/user.inc @@ -125,16 +125,16 @@ function user_table_start() { } function show_user_row($user, $i) { - printf( - " - %d - %s - %s - %s - %s - %s - \n", $i, $user->id, $user->name, format_credit($user->expavg_credit), - format_credit($user->total_credit), $user->country, time_str($user->create_time)); + echo " + + $i + ", user_links($user), " + ", format_credit($user->expavg_credit), " + ", format_credit($user->total_credit), " + ", $user->country, " + ", time_str($user->create_time)," + + "; } ?> diff --git a/html/user/util.inc b/html/user/util.inc index a71ab6477b..3e671c2f01 100644 --- a/html/user/util.inc +++ b/html/user/util.inc @@ -455,4 +455,12 @@ function format_credit($cobblestones) { function project_is_stopped() { return file_exists("../stop_servers"); } + +function user_links($user) { + $x = "id>$user->name"; + if ($user->has_profile) { + $x .= " id>"; + } + return $x; +} ?> diff --git a/py/Boinc/database.py b/py/Boinc/database.py index cf5472a1e2..3ab8f34f33 100644 --- a/py/Boinc/database.py +++ b/py/Boinc/database.py @@ -100,7 +100,8 @@ class User(DatabaseObject): 'seti_nresults', 'seti_last_result_time', 'seti_total_cpu', - 'signature' + 'signature', + 'has_profile' ]) class Team(DatabaseObject): diff --git a/sched/db_dump.C b/sched/db_dump.C index ddd7118842..2483249de2 100644 --- a/sched/db_dump.C +++ b/sched/db_dump.C @@ -280,6 +280,11 @@ void write_user(USER& user, FILE* f, bool detail, bool show_team) { user.teamid ); } + if (user.has_profile) { + fprintf(f, + " \n" + ); + } if (detail && user.show_hosts) { sprintf(buf, "where userid=%d", user.id); while (!host.enumerate(buf)) { diff --git a/sched/file_upload_handler.C b/sched/file_upload_handler.C index 2a79c65f9b..222472c061 100644 --- a/sched/file_upload_handler.C +++ b/sched/file_upload_handler.C @@ -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); }