*** empty log message ***

svn path=/trunk/boinc/; revision=5527
This commit is contained in:
David Anderson 2005-02-25 00:41:22 +00:00
parent b7a1351c74
commit 2534035cae
6 changed files with 218 additions and 18 deletions

View File

@ -25283,3 +25283,16 @@ Janus 24 Feb 2005
user/
account_*_done.php
David 24 Feb 2005
- Finish server-side support for account management.
Changed all inputs to GET, all outputs to XML
Added get_info and set_info functions
html/
inc/
db.inc
user/
am_create.php
am_get_info.php (new)
am_query.php
am_set_info.php (new)

View File

@ -45,6 +45,16 @@ function lookup_user_id($id) {
return null;
}
function lookup_user_email_addr($email_addr) {
$result = mysql_query("select * from user where email_addr='$email_addr'");
if ($result) {
$user = mysql_fetch_object($result);
mysql_free_result($result);
return $user;
}
return null;
}
function lookup_host($id) {
$result = mysql_query("select * from host where id=$id");
if ($result) {
@ -95,6 +105,15 @@ function lookup_app($id) {
return null;
}
function lookup_tentative_user($nonce) {
$result = mysql_query("select * from tentative_user where nonce='$nonce'");
if ($result) {
$tu = mysql_fetch_object($result);
mysql_free_result($result);
return $tu;
}
return null;
}
// apply this to any user-supplied strings used in queries
//

View File

@ -1,17 +1,41 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/xml.inc");
db_init();
$nonce = process_user_text($_POST["nonce"]);
$email_addr = process_user_text($_POST["email_addr"]);
$nonce = process_user_text($_GET["nonce"]);
$email_addr = process_user_text($_GET["email_addr"]);
xml_header();
function reply($x) {
echo "<am_create_reply>
$x
</am_create_reply>
";
exit();
}
function error($x) {
reply("<error>$x</error>");
}
function success() {
reply("<success/>");
}
if (strlen($nonce)==0) {
echo "status=".urlencode("no nonce ID");
error("missing nonce ID");
}
if (strlen($email_addr)==0) {
echo "status=".urlencode("no email addr");
error("missing email addr");
}
$config = get_config();
if (parse_bool($config, "disable_account_creation")) {
error("account creation disabled");
}
$result = mysql_query(
@ -25,9 +49,9 @@ if ($result) {
";
$headers = "";
mail($email_addr, $subject, $body, $headers);
echo "status=OK";
success();
} else {
echo "status=".urlencode("error");
error("database error");
}
?>

53
html/user/am_get_info.php Normal file
View File

@ -0,0 +1,53 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/xml.inc");
$auth = process_user_text($_GET["account_key"]);
xml_header();
function reply($x) {
echo "<am_get_info_reply>
$x
</am_get_info_reply>
";
exit();
}
function error($x) {
reply("<error>$x</error>");
}
function success($x) {
reply("<success/>\n$x");
}
db_init();
$user = lookup_user_auth($auth);
if (!$user) {
error("no such user");
}
$name = urlencode($user->name);
$country = urlencode($user->country);
$postal_code = urlencode($user->postal_code);
$url = urlencode($user->url);
success(
"<name>$name</name>
<country>$country</country>
<postal_code>$postal_code</postal_code>
<global_prefs>
$user->global_prefs
</global_prefs>
<project_prefs>
$user->project_prefs
</project_prefs>
<url>$url</url>
<send_email>$user->send_email</send_email>
<show_hosts>$user->show_hosts</show_hosts>
");
?>

View File

@ -1,20 +1,37 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/xml.inc");
$nonce = process_user_text($_POST["nonce"]);
$nonce = process_user_text($_GET["nonce"]);
$tuser = lookup_tentative_user($nonce);
xml_header();
if (!$tuser) {
$x = urlencode("nonce not found");
echo "status=$x\n";
function reply($x) {
echo "<am_query_reply>
$x
</am_query_reply>
";
exit();
}
function error($x) {
reply("<error>$x</error>");
}
function success($x) {
reply("<success/>\n$x");
}
db_init();
$tuser = lookup_tentative_user($nonce);
if (!$tuser) {
error("nonce not found");
}
if (!$tuser->confirmed) {
echo "status=OK&confirmed=0\n";
exit();
success("<confirmed>0</confirmed>");
}
$user = lookup_user_email_addr($tuser->email_addr);
@ -29,11 +46,8 @@ if (!$user) {
}
if (!$user) {
$x = urlencode("couldn't create user record");
echo "status=$x\n";
exit();
error("couldn't create user record");
}
echo "status=OK&account_key=$user->authenticator\n";
success("<account_key>$user->authenticator</account_key>");
?>

77
html/user/am_set_info.php Normal file
View File

@ -0,0 +1,77 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/xml.inc");
xml_header();
function reply($x) {
echo "<am_set_info_reply>
$x
</am_set_info_reply>
";
exit();
}
function error($x) {
reply("<error>$x</error>");
}
function success($x) {
reply("<success/>\n$x");
}
db_init();
$auth = process_user_text($_GET["account_key"]);
$user = lookup_user_auth($auth);
if (!$user) {
error("no such user");
}
$name = process_user_text($_GET["name"]);
$country = $_GET["country"];
if ($country && !is_valid_country($country)) {
error("invalid country");
}
$postal_code = process_user_text($_GET["postal_code"]);
$global_prefs = process_user_text($_GET["global_prefs"]);
$project_prefs = process_user_text($_GET["project_prefs"]);
$url = process_user_text($_GET["url"]);
$send_email = process_user_text($_GET["send_email"]);
$show_hosts = process_user_text($_GET["show_hosts"]);
$query = "";
if ($name) {
$query .= " name='$name', ";
}
if ($country) {
$query .= " country='$country', ";
}
if ($postal_code) {
$query .= " postal_code='$postal_code', ";
}
if ($global_prefs) {
$query .= " global_prefs='$global_prefs', ";
}
if ($project_prefs) {
$query .= " project_prefs='$project_prefs', ";
}
if ($url) {
$query .= " url='$url', ";
}
if ($send_email != null) {
$query .= " send_email='$send_email', ";
}
if ($show_hosts != null) {
$query .= " show_hosts='$show_hosts', ";
}
$result = mysql_query("update user set $query seti_id=seti_id where id=$user->id");
if ($result) {
success("");
} else {
error("database error");
}
?>