made some changes in page layout and allowed for per-project database access

svn path=/trunk/boinc/; revision=267
This commit is contained in:
Barry Luong 2002-08-05 23:20:57 +00:00
parent ac1f13f2a8
commit 89dd3b16d8
21 changed files with 138 additions and 33 deletions

View File

@ -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", "<pre>".htmlspecialchars($app->result_xml_template)."</pre>");
echo "</table>";
}
@ -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);

View File

@ -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();
?>

View File

@ -1,8 +1,13 @@
<h3>Test BOINC Project</h3>
<scheduler>http://localhost/boinc-cgi/cgi</scheduler>
<br><a href=login.php>Log in or create account</a>
<br><a href=home.php>User page</a>
<br><a href=download.php>Download core client</a>
<br><a href=prefs.php>Preferences</a>
<head>
<title>BOINC - Berkeley Open Infrastructure for Networked Computing</title>
</head>
<body text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000>
<h2>BOINC - Berkeley Open Infrastructure for Networked Computing</h2>
<ul>
<li><a href=download.php>Download core client</a></li>
<li><a href=login.php>Log in or create account</a></li>
<li><a href=home.php>User page</a></li>
<li><a href=prefs.php>Preferences</a></li>
<li><a href=team.php>Teams</a></li>
</ul>
</body>

View File

@ -17,6 +17,20 @@ function print_login_form() {
." <td><br></td>\n"
." <td><input type=submit name=old value=\"Log in\"></td>\n"
."</tr>\n"
."</table>\n"
."</form>\n"
."<table>\n"
."<tr><td colspan=2>If you don't have an account:</td></tr>\n"
."<tr><td><a href=create_account.php>Create a new account</a></td></tr>\n"
."</table>\n"
);
}
function print_create_account_form() {
printf(
"<form method=post action=login_action.php>\n"
."<table>\n"
."<tr><td colspan=2>To create a new account:</td></tr>\n"
."<tr>\n"
." <td align=right>Name or nickname</td>\n"
@ -37,6 +51,7 @@ function print_login_form() {
."<tr>\n"
." <td align=right>Country</td>\n"
." <td><select name=country>\n"
);
print_country_select();
printf(
@ -50,8 +65,8 @@ function print_login_form() {
."<tr>\n"
." <td><br></td>\n"
." <td><input type=submit name=new value=\"Create account\"></td>\n"
."</tr>\n"
."</table>\n"
."</tr>\n".
"</table>\n"
."</form>\n"
);
}

View File

@ -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();
?>

View File

@ -1,21 +1,27 @@
<?php
require_once("util.inc");
db_init();
require_once("user.inc");
require_once("db.inc");
if (strlen($HTTP_POST_VARS["old"])) {
db_init();
$query = sprintf(
"select * from user where email_addr='%s'",
$HTTP_POST_VARS["existing_email"]
);
$result = mysql_query($query);
$user = mysql_fetch_object($result);
mysql_free_result($result);
if ($result) {
$user = mysql_fetch_object($result);
mysql_free_result($result);
}
if (!$user or ($user->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";
}

View File

@ -265,6 +265,7 @@ function prefs_form_projects($prefs) {
echo "<br><a href=prefs_edit_project_form.php?master_url=$project->master_url>Edit this project</a>\n";
}
echo "<hr><a href=prefs_add_project_form.php>Add a project</a>\n";
echo "<br>";
}
function prefs_form_project($project, $action) {

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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:<br>\n";
prefs_form_project($project, "prefs_add_project_action.php");
}
echo "<p>\n";
page_tail();
?>

View File

@ -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 "<br>";
echo "<a href=prefs.php>Preferences</a>\n";
}
echo "<p>\n";
page_tail();
?>

View File

@ -1,8 +1,13 @@
<?php
require_once("util.inc");
parse_str(getenv("QUERY_STRING"));
page_head("Delete project confirmation");
echo "Are you sure you want to stop participating in the project $master_url?\n";
echo "<br><a href=prefs_delete_project?master_url=$master_url>Yes</a>\n";
echo "<br><a href=prefs_delete_project.php?master_url=$master_url>Yes</a>\n";
echo "<br><a href=prefs_edit_projects.php>No</a>\n";
echo "<p>\n";
page_tail();
?>

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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 "<a href=prefs.php>Preferences</a>\n";
}
echo "<p>\n";
page_tail();
?>

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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 "<br>";
echo "<a href=prefs.php>Preferences</a>\n";
}
echo "<p>\n";
page_tail();
?>

View File

@ -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 "<p>\n";
page_tail();
?>

View File

@ -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 "<a href=prefs.php>Preferences</a>\n";
}
echo "<p>\n";
page_tail();
?>

View File

@ -12,11 +12,24 @@ function show_hosts($user) {
}
function show_user_page($user) {
page_head("User page");
echo "<h1>$user->name</h1>\n";
echo "<a href=prefs.php>Preferences</a>";
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", "<a href=team_display.php?id=$team->id>$team->name</a>");
} else {
row("Team", "none");
}
echo "</table>";
echo "<p>\n";
echo "<ul>";
echo "<li><a href=show_user.php>Complete user info</a></li>";
echo "<li><a href=show_hosts.php>Host info</a></li>";
echo "<li><a href=prefs.php>Preferences</a></li>";
echo "<li><a href=team.php>Teams</a></li>";
echo "</ul>";
show_user($user);
show_hosts($user);
}
?>

View File

@ -5,9 +5,9 @@ require_once("db.inc");
define("TABLE", "<table cellpadding=10 cellspacing=4 border=0 width=100%>");
define("BG_COLOR", " bgcolor=cccccc ");
define("TITLE_COLOR", " bgcolor=000000 ");
define("TITLE_FONT", " <font color=ff7700> ");
define("TITLE_FONT", " <font color=ffffff> ");
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 "<head><title>$title</title><body " . BG_COLOR . ">\n";
echo TABLE . "<tr " . TITLE_COLOR . "><td>" . TITLE_FONT . "<font size=6><b>".PROJECT_NAME.": $title</b></font></td></tr></table>\n";
echo TABLE . "<tr " . TITLE_COLOR . "><td>" . TITLE_FONT . "<font size=6><b><a href=index.html>".PROJECT_NAME.":</a> $title</b></font></td></tr></table>\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 "<html>\n";
echo "<head>\n";
echo "<title>$title</title>\n";
echo "</head>\n";
echo "<body BGCOLOR=000000 TEXT=FFFFFF LINK=cc99ff VLINK=cc99ff>\n";
echo "<br clear=all><br>\n";
}
function print_page_end() {
echo "</body></html>";
}
?>