2005-02-25 00:41:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("../inc/db.inc");
|
|
|
|
require_once("../inc/xml.inc");
|
2005-03-23 19:25:00 +00:00
|
|
|
require_once("../inc/team.inc");
|
2005-12-19 07:42:40 +00:00
|
|
|
require_once("../inc/email.inc");
|
2005-02-25 00:41:22 +00:00
|
|
|
|
2006-03-15 22:57:56 +00:00
|
|
|
// do a very cursory check that the given text is valid;
|
|
|
|
// for now, just make sure it has the given start and end tags,
|
|
|
|
// and at least one \n in the middle.
|
|
|
|
// Ideally, we'd like to check that it's valid XML
|
|
|
|
//
|
|
|
|
function bad_xml($text, $start, $end) {
|
|
|
|
$text = trim($text);
|
|
|
|
if (strstr($text, $start) != $text) {
|
|
|
|
return "No start tag";
|
|
|
|
}
|
|
|
|
if (strstr($text, $end) != $end) {
|
|
|
|
return "No end tag";
|
|
|
|
}
|
|
|
|
if (!strstr($text, "\n")) {
|
|
|
|
return "No CR";
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2006-09-06 20:56:55 +00:00
|
|
|
function success($x) {
|
2005-02-25 00:41:22 +00:00
|
|
|
echo "<am_set_info_reply>
|
2006-09-06 20:56:55 +00:00
|
|
|
<success/>
|
2005-02-25 00:41:22 +00:00
|
|
|
$x
|
|
|
|
</am_set_info_reply>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-02 20:37:24 +00:00
|
|
|
xml_header();
|
2006-09-06 20:56:55 +00:00
|
|
|
$retval = db_init_xml();
|
|
|
|
if ($retval) xml_error($retval);
|
2005-03-28 22:26:22 +00:00
|
|
|
|
2005-02-25 00:41:22 +00:00
|
|
|
$auth = process_user_text($_GET["account_key"]);
|
|
|
|
$user = lookup_user_auth($auth);
|
|
|
|
if (!$user) {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-136);
|
2005-02-25 00:41:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$name = process_user_text($_GET["name"]);
|
|
|
|
$country = $_GET["country"];
|
|
|
|
if ($country && !is_valid_country($country)) {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-1, "invalid country");
|
2005-02-25 00:41:22 +00:00
|
|
|
}
|
|
|
|
$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"]);
|
2005-03-23 19:25:00 +00:00
|
|
|
$teamid = get_int("teamid", true);
|
2005-11-13 06:48:26 +00:00
|
|
|
$venue = process_user_text($_GET["venue"]);
|
2005-12-19 07:42:40 +00:00
|
|
|
$email_addr = strtolower(process_user_text($_GET["email_addr"]));
|
|
|
|
$password_hash = process_user_text($_GET["password_hash"]);
|
2005-02-25 00:41:22 +00:00
|
|
|
|
|
|
|
$query = "";
|
|
|
|
if ($name) {
|
|
|
|
$query .= " name='$name', ";
|
|
|
|
}
|
|
|
|
if ($country) {
|
|
|
|
$query .= " country='$country', ";
|
|
|
|
}
|
|
|
|
if ($postal_code) {
|
|
|
|
$query .= " postal_code='$postal_code', ";
|
|
|
|
}
|
|
|
|
if ($global_prefs) {
|
2006-03-15 22:57:56 +00:00
|
|
|
$global_prefs = str_replace("\\r\\n", "\n", $global_prefs);
|
|
|
|
$x = bad_xml($global_prefs, "<global_preferences>", "</global_preferences>");
|
|
|
|
if ($x) {
|
|
|
|
error("Invalid global preferences: $x");
|
|
|
|
}
|
2005-02-25 00:41:22 +00:00
|
|
|
$query .= " global_prefs='$global_prefs', ";
|
|
|
|
}
|
|
|
|
if ($project_prefs) {
|
2006-03-15 22:57:56 +00:00
|
|
|
$project_prefs = str_replace("\\r\\n", "\n", $project_prefs);
|
|
|
|
$x = bad_xml($project_prefs, "<project_preferences>", "</project_preferences>");
|
|
|
|
if ($x) {
|
2006-09-08 19:51:33 +00:00
|
|
|
xml_error(-112, "Invalid project preferences: $x");
|
2006-03-15 22:57:56 +00:00
|
|
|
}
|
2005-02-25 00:41:22 +00:00
|
|
|
$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', ";
|
|
|
|
}
|
|
|
|
|
2006-07-02 14:30:40 +00:00
|
|
|
if (!is_null($teamid)) {
|
|
|
|
if ($teamid==0) {
|
|
|
|
user_quit_team($user);
|
|
|
|
} else {
|
|
|
|
$team = lookup_team($teamid);
|
|
|
|
if ($team) {
|
|
|
|
user_join_team($team, $user);
|
|
|
|
}
|
2005-03-23 19:25:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-13 06:48:26 +00:00
|
|
|
if ($venue) {
|
|
|
|
$query .= " venue='$venue', ";
|
|
|
|
}
|
2005-12-19 07:42:40 +00:00
|
|
|
if ($email_addr && $email_addr!=$user->email_addr) {
|
|
|
|
$old_email_addr = $user->email_addr;
|
|
|
|
$query .= " email_addr='$email_addr', ";
|
|
|
|
}
|
|
|
|
if ($password_hash) {
|
2006-01-12 22:05:41 +00:00
|
|
|
$query .= " passwd_hash='$password_hash', ";
|
2005-12-19 07:42:40 +00:00
|
|
|
}
|
2005-11-13 06:48:26 +00:00
|
|
|
|
2006-01-25 19:02:01 +00:00
|
|
|
if (strlen($query)) {
|
2006-02-02 20:06:36 +00:00
|
|
|
// the seti_id=seti_id is to make the query valid,
|
|
|
|
// since $query ends with a comma at this point
|
|
|
|
//
|
|
|
|
$query = "update user set $query seti_id=seti_id where id=$user->id";
|
2006-01-25 19:02:01 +00:00
|
|
|
$result = mysql_query($query);
|
|
|
|
if ($result) {
|
|
|
|
success("");
|
|
|
|
} else {
|
2006-09-06 20:56:55 +00:00
|
|
|
xml_error(-1, "database error: ".mysql_error());
|
2005-12-19 07:42:40 +00:00
|
|
|
}
|
2005-02-25 00:41:22 +00:00
|
|
|
} else {
|
2006-01-25 19:02:01 +00:00
|
|
|
success("");
|
2005-02-25 00:41:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|