edit account info

svn path=/trunk/boinc/; revision=778
This commit is contained in:
David Anderson 2002-12-19 18:08:43 +00:00
parent c781418118
commit 0a492376f8
9 changed files with 125 additions and 105 deletions

View File

@ -2727,3 +2727,20 @@ David Dec 18 2002
util.inc
lib/
countries.C,h
David Dec 19 2002
- The Edit Account form now shows current values
directly in input fields.
- Country select popup shows current value
- Improve new account email
html_user/
account_created.php
change_pass_action.php
create_account_action.php
edit.inc
edit_action.php
edit_user_info.php
util.inc
tools/
country_select.C

View File

@ -23,8 +23,6 @@
<a href=prefs.php>View or edit these preferences</a>.
";
send_auth_email($new_email_addr, $authenticator);
page_tail();
?>

View File

@ -28,14 +28,14 @@
printf(
TABLE2."\n"
."<tr><td>Password changed successfully. Use your new password to\n"
." <a href=login.php>login</a> to your account.</td></tr>\n"
." <a href=login_form.php>login</a> to your account.</td></tr>\n"
."</table>\n"
);
} else {
printf(
TABLE2."\n"
."<tr><td>Password was unable to be changed. Continue using your old \n"
."password to <a href=login.php>login</a> to your account. You can try \n"
."password to <a href=login_form.php>login</a> to your account. You can try \n"
."changing your password again later.</td></tr>\n"
."</table>"
);

View File

@ -57,4 +57,5 @@ function show_error($str) {
// In success case, redirect to a fixed page so that user can
// return to it without getting "Repost form data" stuff
send_auth_email($new_email_addr, $authenticator);
Header("Location: account_created.php");

View File

@ -1,32 +1,5 @@
<?php
function print_edit_user_info($user) {
printf(
"<form method=post action=edit_action.php>\n"
.TABLE2."\n"
."<tr><td colspan=2><b>To edit your User Information, fill out the fields that you wish to change.\n"
." You do not need to enter anything into the fields that you wish to keep the same.</td></tr>\n"
."<tr><td colspan=2><br></td></tr>\n"
."<tr>".TD2.LG_FONT."<b>User name:</b></font></td></tr>\n"
);
row2("<input name=my_name type=text size=30>", $user->name);
echo "<tr><td colspan=2><br></td></tr>\n";
echo "<tr>".TD2.LG_FONT."<b>Email address:</b></font></td></tr>\n";
row2("<input name=my_email type=text size=50>", $user->email_addr);
echo "<tr><td colspan=2><br></td></tr>\n";
echo "<tr>".TD2.LG_FONT."<b>Country:</b></font></td></tr>\n";
echo "<tr><td><select name=my_country>\n";
print_country_select();
echo "</select></td>\n";
echo "<td>$user->country</td></tr>\n";
echo "<tr><td colspan=2><br></td></tr>\n";
echo "<tr>".TD2.LG_FONT."<b>Postal (ZIP) code:</b></font></td></tr>\n";
row2("<input name=my_zip type=text size=20>", $user->postal_code);
echo "</table>\n";
echo "<br><br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;<input type=submit value=\"Edit\">\n";
echo "</form>";
}
function print_change_password($user) {
printf(
"<form method=post action=change_pass_action.php>\n"
@ -49,69 +22,70 @@ function print_change_password($user) {
function print_update_ok($e_ok) {
if ($e_ok == EMAIL_EXISTS) {
printf(
TABLE2."\n"
."<tr><td>There's already an account with that email address. Click the <b>Back</b> button\n"
." on your browser to edit your information, or <a href=login.php>login </a>to your \n"
.$project." account.</td></tr>\n"
."<tr><td>Any other changes you've made, if any, were successfully updated.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>There's already an account with that email address.
Click the <b>Back</b> button\n
in your browser to edit your information,
or <a href=login_form.php>login </a>to your \n
".$project." account.</td></tr>\n
<tr><td>Any other changes you've made,
if any, were successfully updated.</td></tr>\n
</table>\n";
} else if ($e_ok == EMAIL_FAIL) {
printf(
TABLE2."\n"
."<tr><td>Your email address failed to be updated. Click the <b>Back</b> button\n"
." on your browser to edit your information, or try again later.</td></tr>\n"
."<tr><td>Any other changes you've made, if any, were successfully updated.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your email address failed to be updated.
Click the <b>Back</b> button\n
in your browser to edit your information,
or try again later.</td></tr>\n
<tr><td>Any other changes you've made,
if any, were successfully updated.</td></tr>\n
</table>\n";
} else if ($e_ok == EMAIL_UPDATED) {
printf(
TABLE2."\n"
."<tr><td>Your information was successfully updated. A new, temporary password will be sent to the\n"
." email address you provided. You must use this new password the next time you login.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your information was successfully updated.
A new, temporary password will be sent to the\n
email address you provided.
You must use this new password the next time you login.
</td></tr>\n</table>\n";
} else {
printf(
TABLE2."\n"
."<tr><td>Your information was successfully updated.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your information was successfully updated.</td></tr>\n
</table>\n";
}
}
function print_update_fail($e_ok) {
if ($e_ok == EMAIL_EXISTS) {
printf(
TABLE2."\n"
."<tr><td>There's already an account with that email address. Click the <b>Back</b> button\n"
." on your browser to edit your information, or <a href=login.php>login </a>to your \n"
.$project." account. </td></tr>\n"
."<tr><td>Any other changes you've made, if any, failed to be updated. Please try again later.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>There's already an account with that email address.
Click the <b>Back</b> button in your browser
to edit your information,
or <a href=login_form.php>login </a>to your \n
".$project." account. </td></tr>\n
<tr><td>Any other changes you've made, if any,
failed to be updated. Please try again later.</td></tr>\n
</table>\n";
} else if ($e_ok == EMAIL_FAIL) {
printf(
TABLE2."\n"
."<tr><td>Your information failed to be updated. Click the <b>Back</b> button\n"
." on your browser to edit your information, or try again later.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your information failed to be updated.
Click the <b>Back</b> button\n
in your browser to edit your information,
or try again later.</td></tr>\n
</table>\n";
} else if ($e_ok == EMAIL_UPDATED) {
printf(
TABLE2."\n"
."<tr><td>Your email address was successfully updated. A new, temporary password will be sent to the\n"
." email address you provided. You must use this new password the next time you login.</td></tr>\n"
."<tr><td>Any other changes you've made, if any, failed to be updated. Please try again later.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your email address was successfully updated.
A new, temporary password will be sent to the\n
email address you provided.
You must use this new password the next time you login.</td></tr>\n
<tr><td>Any other changes you've made, if any,
failed to be updated. Please try again later.</td></tr>\n
</table>\n";
} else {
printf(
TABLE2."\n"
."<tr><td>Your information failed to be updated. Please try again later.</td></tr>\n"
."</table>\n"
);
echo TABLE2."\n
<tr><td>Your information failed to be updated.
Please try again later.</td></tr>\n
</table>\n";
}
}

View File

@ -16,6 +16,12 @@
$my_country = $HTTP_POST_VARS["my_country"];
$my_zip = $HTTP_POST_VARS["my_zip"];
// TODO: we need to keep track of whether email addresses
// have been verified or not (i.e. whether we ever got back
// the authenticator, either via web or from core client)
// The right was to do this is to add a "email_verified"
// flag to the user structure.
// Also, email need not be unique.
if (strlen($my_email)) {
$query = sprintf("select * from user where email_addr='%s'", $my_email);

View File

@ -1,20 +1,29 @@
<?php
require_once("edit.inc");
require_once("util.inc");
require_once("edit.inc");
require_once("util.inc");
db_init();
$authenticator = init_session();
$user = get_user_from_auth($authenticator);
require_login($user);
db_init();
$authenticator = init_session();
$user = get_user_from_auth($authenticator);
require_login($user);
$head = sprintf("Edit %s's User Information", $user->name);
page_head($head);
print_edit_user_info($user);
page_tail();
page_head("Edit user information");
echo "<form method=post action=edit_action.php>\n
".TABLE2."\n
<tr><td align=right><b>User name</b></td>\n
<td><input name=my_name type=text size=30 value='$user->name'></td></tr>
<tr><td align=right><b>Email address</b></td>\n
<td><input name=my_email type=text size=50 value='$user->email_addr'></td></tr>
<tr><td align=right><b>Country:</b></font></td>
<td><select name=my_country>";
print_country_select($user->country);
echo "</select></td></tr>
<tr><td align=right><b>Postal (ZIP) code</b></td>
<td><input name=my_zip type=text size=20 value='$user->postal_code'></td></tr>
<tr><td><br></td><td><input type=submit value='OK'>\n
</table>\n
</form>";
page_tail();
?>

View File

@ -25,13 +25,22 @@ define("PROJECT", "Astropulse");
define("MASTER_URL", "http://maggie.ssl.berkeley.edu/ap/");
// Sends the authenticator to the given email address
//
function send_auth_email($email_addr, $auth) {
mail($email_addr, "Account information for ".PROJECT,
"The URL for this project is \n\n".MASTER_URL."\n\nYour account key is \n\n$auth\n\nCopy this information into the BOINC client.");
mail($email_addr, PROJECT." new account confirmation",
"This email confirms the creation of your account with ".PROJECT.",
a distributed computing project based on BOINC.\n
The URL for this project: ".MASTER_URL."
Your account key: $auth\n
Copy and paste these into the BOINC client when prompted.\n
Please save this email, as you will need the account key
to access your account on the ".PROJECT." web site."
);
}
// Initializes the session and returns the authenticator
// for the session (if any)
//
function init_session() {
session_start();
if (!isset($_SESSION["authenticator"])) {
@ -40,7 +49,8 @@ function init_session() {
return $_SESSION["authenticator"];
}
// requires that the user be logged in
// if not logged in, put up login form and exit
//
function require_login($user) {
if (!$user) {
print_login_form();
@ -65,7 +75,7 @@ function get_user_from_cookie() {
function show_login($user) {
if ($user) {
echo "Logged in as %s.\n", $user->name;
echo "<br><a href=login.php>Log in as someone else.</a>\n";
echo "<br><a href=login_form.php>Log in as someone else.</a>\n";
} else {
echo "Not logged in";
}
@ -122,9 +132,9 @@ function random_string() {
return md5(uniqid(rand()));
}
function print_country_select() {
function print_country_select($country) {
$x = posix_getcwd();
PassThru("$x/country_select");
PassThru("$x/country_select '$country'");
}
function print_login_form() {

View File

@ -21,9 +21,14 @@
#include "countries.h"
int main() {
int main(int argc, char** argv) {
int i;
for (i=0; i<NUM_COUNTRIES; i++) {
printf("<option value=\"%s\">%s\n", countries[i], countries[i]);
printf(
"<option value=\"%s\" %s>%s\n",
countries[i],
!strcmp(countries[i], argv[1])?"checked":"",
countries[i]
);
}
}