From 89dd3b16d87bf5baacc2d83eaba5c6ae8aaa7a5d Mon Sep 17 00:00:00 2001 From: Barry Luong Date: Mon, 5 Aug 2002 23:20:57 +0000 Subject: [PATCH] made some changes in page layout and allowed for per-project database access svn path=/trunk/boinc/; revision=267 --- html/user/db.inc | 12 +++++++----- html/user/home.php | 2 ++ html/user/index.html | 21 +++++++++++++-------- html/user/login.inc | 19 +++++++++++++++++-- html/user/login.php | 2 -- html/user/login_action.php | 20 +++++++++++++------- html/user/prefs.inc | 1 + html/user/prefs.php | 4 ++++ html/user/prefs_add_project_action.php | 9 ++++++++- html/user/prefs_add_project_form.php | 3 +++ html/user/prefs_delete_project.php | 6 ++++++ html/user/prefs_delete_project_confirm.php | 7 ++++++- html/user/prefs_edit_disk_action.php | 3 +++ html/user/prefs_edit_disk_form.php | 4 ++++ html/user/prefs_edit_project_action.php | 3 +++ html/user/prefs_edit_project_form.php | 3 +++ html/user/prefs_edit_projects.php | 5 +++++ html/user/prefs_edit_work_action.php | 3 +++ html/user/prefs_edit_work_form.php | 4 ++++ html/user/user.inc | 21 +++++++++++++++++---- html/user/util.inc | 19 ++++++++++++++++--- 21 files changed, 138 insertions(+), 33 deletions(-) diff --git a/html/user/db.inc b/html/user/db.inc index 99edf72a4d..8897e14b31 100644 --- a/html/user/db.inc +++ b/html/user/db.inc @@ -5,9 +5,10 @@ function db_init() { if (!$retval) { exit(); } - $name = getenv("BOINC_DB_NAME"); - if ($name == NULL) $name = "boinc"; - mysql_select_db($name); + $fp = fopen(db_name, "r"); + $db_name = fgets($fp, 1024); + mysql_select_db($db_name); + fclose($fp); } function lookup_user_auth($auth) { @@ -30,7 +31,9 @@ function show_app($app) { row("ID", $app->id); row("created", time_str($app->create_time)); row("name", $app->name); - row("minimum version", $app->min_version); + row("alpha version", $app->alpha_vers); + row("beta version", $app->beta_vers); + row("production version", $app->prod_vers); row("result template", "
".htmlspecialchars($app->result_xml_template)."
"); echo ""; } @@ -124,7 +127,6 @@ function show_result($result) { row("state", res_state_string($result->state)); row("host ID", $result->hostid); row("sent", time_str($result->sent_time)); - row("report deadline", time_str($result->report_deadline)); row("received", time_str($result->received_time)); row("exit status", $result->exit_status); row("CPU time", $result->cpu_time); diff --git a/html/user/home.php b/html/user/home.php index 5a24bf8162..0a10905581 100644 --- a/html/user/home.php +++ b/html/user/home.php @@ -6,9 +6,11 @@ db_init(); $user = get_user_from_cookie(); + page_head("User home"); if ($user) { show_user_page($user); } else { print_login_form(); } + page_tail(); ?> diff --git a/html/user/index.html b/html/user/index.html index 0c83f5beac..f85a2a089b 100644 --- a/html/user/index.html +++ b/html/user/index.html @@ -1,8 +1,13 @@ -

Test BOINC Project

- -http://localhost/boinc-cgi/cgi - -
Log in or create account -
User page -
Download core client -
Preferences + +BOINC - Berkeley Open Infrastructure for Networked Computing + + +

BOINC - Berkeley Open Infrastructure for Networked Computing

+ + \ No newline at end of file diff --git a/html/user/login.inc b/html/user/login.inc index da7d96cbb3..d6e660816a 100644 --- a/html/user/login.inc +++ b/html/user/login.inc @@ -17,6 +17,20 @@ function print_login_form() { ."
\n" ." \n" ."\n" + ."\n" + ."\n" + ."\n" + ."\n" + ."\n" + ."
If you don't have an account:
Create a new account
\n" + ); + +} + +function print_create_account_form() { + printf( + "
\n" + ."\n" ."\n" ."\n" ." \n" @@ -37,6 +51,7 @@ function print_login_form() { ."\n" ." \n" ." \n" ." \n" ." \n" - ."\n" - ."
To create a new account:
Name or nickname
Country

\n" + ."\n". + "\n" ."
\n" ); } diff --git a/html/user/login.php b/html/user/login.php index 18c849060d..a32c30e8cc 100644 --- a/html/user/login.php +++ b/html/user/login.php @@ -3,7 +3,5 @@ require_once("login.inc"); db_init(); page_head("Log in"); - $user = get_user_from_cookie(); - show_login($user); print_login_form(); ?> diff --git a/html/user/login_action.php b/html/user/login_action.php index 33c2a244c8..58ede38148 100644 --- a/html/user/login_action.php +++ b/html/user/login_action.php @@ -1,21 +1,27 @@ web_password != $HTTP_POST_VARS["existing_password"])) { echo "We have no account with that name and password."; } else { setcookie("auth", $user->authenticator, time()+100000000); - echo "Logged in."; + page_head("User home"); + show_user_page($user); } } else if (strlen($HTTP_POST_VARS["new"])) { + db_init(); $query = sprintf( "select * from user where email_addr='%s'", $HTTP_POST_VARS["new_email_addr"] @@ -32,20 +38,20 @@ $authenticator = random_string(); $email_addr = $HTTP_POST_VARS["new_email_addr"]; $query = sprintf( - "insert into user values(0, %d, '%s', '%s', '%s', '%s', '%s', '%s', 0, 0, 0, 0, 0)", + "insert into user (create_time, email_addr, name, web_password, authenticator, country, postal_code) values(%d, '%s', '%s', '%s', '%s', '%s', %d)", time(), $email_addr, $HTTP_POST_VARS["new_name"], $HTTP_POST_VARS["new_password"], $authenticator, - $HTTP_POST_VARS["country"], + "United States", $HTTP_POST_VARS["postal_code"] ); $result = mysql_query($query); if ($result) { setcookie("auth", $authenticator); echo "Account created. You are being mailed a key that you'll need to run the client.\n"; - mail($email_addr, "SETI@home key", "Your SETI@home key is " . $authenticator); + mail($email_addr, "BOINC key", "Your BOINC key is " . $authenticator); } else { echo "Couldn't create account - please try later.\n"; } diff --git a/html/user/prefs.inc b/html/user/prefs.inc index 405b6fd052..66e4046adf 100644 --- a/html/user/prefs.inc +++ b/html/user/prefs.inc @@ -265,6 +265,7 @@ function prefs_form_projects($prefs) { echo "
master_url>Edit this project\n"; } echo "
Add a project\n"; + echo "
"; } function prefs_form_project($project, $action) { diff --git a/html/user/prefs.php b/html/user/prefs.php index a715bd27a7..89d1765e9d 100644 --- a/html/user/prefs.php +++ b/html/user/prefs.php @@ -8,11 +8,15 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Preferences"); if ($user == NULL) { + //show_login($user); print_login_form(); } else { $prefs = prefs_parse($user->prefs); print_prefs_display($prefs); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_add_project_action.php b/html/user/prefs_add_project_action.php index e3f0aa32ba..431e57b470 100644 --- a/html/user/prefs_add_project_action.php +++ b/html/user/prefs_add_project_action.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Add project"); if ($user == NULL) { print_login_form(); } else { @@ -18,10 +19,16 @@ if ($user == NULL) { if ($i >= 0) { echo "Duplicate project URL\n"; } else { - array_push($prefs->projects, $project); + if ($prefs->projects == null) { + $prefs->projects = array($project); + } else { + array_push($prefs->projects, $project); + } prefs_update($user, $prefs); print_prefs_display($prefs); } } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_add_project_form.php b/html/user/prefs_add_project_form.php index 8fe0816a09..744fc2397d 100644 --- a/html/user/prefs_add_project_form.php +++ b/html/user/prefs_add_project_form.php @@ -8,11 +8,14 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Add project"); if ($user == NULL) { print_login_form(); } else { echo "Add a project:
\n"; prefs_form_project($project, "prefs_add_project_action.php"); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_delete_project.php b/html/user/prefs_delete_project.php index 02a793cdcf..edd0a62323 100644 --- a/html/user/prefs_delete_project.php +++ b/html/user/prefs_delete_project.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Edit project preferences"); if ($user == NULL) { print_login_form(); } else { @@ -16,7 +17,12 @@ if ($user == NULL) { $i = project_index($prefs, $master_url); array_splice($prefs->projects, i, 1); prefs_update($user, $prefs); + echo "Project $master_url deleted"; prefs_form_projects($prefs); + echo "
"; + echo "Preferences\n"; } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_delete_project_confirm.php b/html/user/prefs_delete_project_confirm.php index 76448d03e0..2e38524bbd 100644 --- a/html/user/prefs_delete_project_confirm.php +++ b/html/user/prefs_delete_project_confirm.php @@ -1,8 +1,13 @@ Yes\n"; +echo "
Yes\n"; echo "
No\n"; +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_disk_action.php b/html/user/prefs_edit_disk_action.php index 88670328f6..414604a601 100644 --- a/html/user/prefs_edit_disk_action.php +++ b/html/user/prefs_edit_disk_action.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Preferences"); if ($user == NULL) { print_login_form(); } else { @@ -16,5 +17,7 @@ if ($user == NULL) { prefs_update($user, $prefs); print_prefs_display($prefs); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_disk_form.php b/html/user/prefs_edit_disk_form.php index d8f2c81aab..03a98fb384 100644 --- a/html/user/prefs_edit_disk_form.php +++ b/html/user/prefs_edit_disk_form.php @@ -8,11 +8,15 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Edit Disk Preferences"); if ($user == NULL) { print_login_form(); } else { $prefs = prefs_parse($user->prefs); prefs_form_disk($user, $prefs); + echo "Preferences\n"; } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_project_action.php b/html/user/prefs_edit_project_action.php index 03382e8b18..4468d44c0b 100644 --- a/html/user/prefs_edit_project_action.php +++ b/html/user/prefs_edit_project_action.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Preferences"); if ($user == NULL) { print_login_form(); } else { @@ -19,5 +20,7 @@ if ($user == NULL) { prefs_update($user, $prefs); print_prefs_display($prefs); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_project_form.php b/html/user/prefs_edit_project_form.php index eb6e91fa7a..37df546b13 100644 --- a/html/user/prefs_edit_project_form.php +++ b/html/user/prefs_edit_project_form.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Edit project preferences"); if ($user == NULL) { print_login_form(); } else { @@ -16,5 +17,7 @@ if ($user == NULL) { $i = project_index($prefs, $master_url); prefs_form_project($prefs->projects[$i], "prefs_edit_project_action.php"); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_projects.php b/html/user/prefs_edit_projects.php index 45651e1664..50414a96b4 100644 --- a/html/user/prefs_edit_projects.php +++ b/html/user/prefs_edit_projects.php @@ -8,11 +8,16 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Edit Project Prefrences"); if ($user == NULL) { print_login_form(); } else { $prefs = prefs_parse($user->prefs); prefs_form_projects($prefs); + echo "
"; + echo "Preferences\n"; } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_work_action.php b/html/user/prefs_edit_work_action.php index 720f3173b0..4303c71346 100644 --- a/html/user/prefs_edit_work_action.php +++ b/html/user/prefs_edit_work_action.php @@ -8,6 +8,7 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Preferences"); if ($user == NULL) { print_login_form(); } else { @@ -16,5 +17,7 @@ if ($user == NULL) { prefs_update($user, $prefs); print_prefs_display($prefs); } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/prefs_edit_work_form.php b/html/user/prefs_edit_work_form.php index 1cc42d3ada..bc23b4964f 100644 --- a/html/user/prefs_edit_work_form.php +++ b/html/user/prefs_edit_work_form.php @@ -8,11 +8,15 @@ include_once("prefs.inc"); db_init(); $user = get_user_from_cookie(); +page_head("Edit Work Preferences"); if ($user == NULL) { print_login_form(); } else { $prefs = prefs_parse($user->prefs); prefs_form_work($user, $prefs); + echo "Preferences\n"; } +echo "

\n"; +page_tail(); ?> diff --git a/html/user/user.inc b/html/user/user.inc index 20612d3dce..9541a3d4ee 100644 --- a/html/user/user.inc +++ b/html/user/user.inc @@ -12,11 +12,24 @@ function show_hosts($user) { } function show_user_page($user) { - page_head("User page"); echo "

$user->name

\n"; - echo "Preferences"; + start_table(); + row("Total credit", $user->total_credit); + if ($user->teamid) { + $result = mysql_query("select * from team where id = $user->teamid"); + $team = mysql_fetch_object($result); + row("Team", "id>$team->name"); + } else { + row("Team", "none"); + } + echo ""; + echo "

\n"; + echo "

"; - show_user($user); - show_hosts($user); } ?> diff --git a/html/user/util.inc b/html/user/util.inc index 2fb7670469..0f28d4fb7f 100644 --- a/html/user/util.inc +++ b/html/user/util.inc @@ -5,9 +5,9 @@ require_once("db.inc"); define("TABLE", ""); define("BG_COLOR", " bgcolor=cccccc "); define("TITLE_COLOR", " bgcolor=000000 "); -define("TITLE_FONT", " "); +define("TITLE_FONT", " "); define("BODY_COLOR", " bgcolor=ffffff "); -define("PROJECT_NAME", "SETI@home"); +define("PROJECT_NAME", "BOINC"); function get_user_from_cookie() { $auth = ""; @@ -30,7 +30,7 @@ function show_login($user) { function page_head($title) { echo "$title\n"; - echo TABLE . "
" . TITLE_FONT . "".PROJECT_NAME.": $title
\n"; + echo TABLE . "" . TITLE_FONT . "".PROJECT_NAME.": $title\n"; } function page_tail() { @@ -62,4 +62,17 @@ function print_country_select() { PassThru("/home/david/boinc/tools/country_select"); } +function print_page_header($title) { + echo "\n"; + echo "\n"; + echo "$title\n"; + echo "\n"; + echo "\n"; + echo "

\n"; +} + +function print_page_end() { + echo ""; +} + ?>