~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to html/user/create_account_action.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
 
3
 
include_once("../inc/db.inc");
 
3
include_once("../inc/boinc_db.inc");
4
4
include_once("../inc/util.inc");
5
5
include_once("../inc/email.inc");
 
6
include_once("../inc/user.inc");
6
7
 
7
8
function show_error($str) {
8
9
    page_head("Can't create account");
9
10
    echo "$str<br>\n";
10
 
    echo mysql_error();
 
11
    echo BoincDb::error();
11
12
    echo "<p>Click your browser's <b>Back</b> button to try again.\n<p>\n";
12
13
    page_tail();
13
14
    exit();
24
25
    exit();
25
26
}
26
27
 
27
 
db_init();
28
 
init_session();
29
 
 
 
28
// see whether the new account should be pre-enrolled in a team,
 
29
// and initialized with its founder's project prefs
 
30
//
30
31
$teamid = post_int("teamid", true);
31
32
if ($teamid) {
32
33
    $team = lookup_team($teamid);
42
43
}
43
44
 
44
45
if(defined('INVITE_CODES')) {
45
 
    $invite_code = process_user_text($_POST["invite_code"]);
 
46
    $invite_code = process_user_text(post_str("invite_code"));
46
47
    if (strlen($invite_code)==0) {
47
 
        show_error( tr(AC_INVITE_REQUIRED) );
 
48
        show_error(tra("You must supply an invitation code to create an account."));
48
49
    }
49
50
    if (!preg_match(INVITE_CODES, $invite_code)) {
50
 
        show_error( tr(AC_INVITE_INVALID) );
 
51
        show_error(tra("The invitation code you gave is not valid."));
51
52
    }
52
53
53
54
 
54
 
$new_name = process_user_text($_POST["new_name"]);
 
55
$new_name = process_user_text(post_str("new_name"));
55
56
if (strlen($new_name)==0) {
56
57
    show_error("You must supply a name for your account");
57
58
}
59
60
    show_error("HTML tags not allowed in name");
60
61
}
61
62
 
62
 
 
63
 
$new_email_addr = process_user_text($_POST["new_email_addr"]);
 
63
$new_email_addr = process_user_text(post_str("new_email_addr"));
64
64
$new_email_addr = strtolower($new_email_addr);
65
65
if (!is_valid_email_addr($new_email_addr)) {
66
66
    show_error("Invalid email address:
95
95
 
96
96
$passwd_hash = md5($passwd.$new_email_addr);
97
97
 
98
 
$country = $_POST["country"];
 
98
$country = post_str("country");
 
99
if ($country == "") {
 
100
    $country = "International";
 
101
}
99
102
if (!is_valid_country($country)) {
100
103
    echo "bad country";
101
104
    exit();
102
105
}
103
106
 
104
 
$postal_code = strip_tags(process_user_text($_POST["postal_code"]));
 
107
$postal_code = post_str("postal_code", true);
105
108
 
106
 
$authenticator = random_string();
107
 
$cross_project_id = random_string();
108
 
$country = boinc_real_escape_string($country);
109
 
$now = time();
110
 
$query = "insert into user (create_time, email_addr, name, authenticator, country, postal_code, total_credit, expavg_credit, expavg_time, project_prefs, teamid, venue, url, send_email, show_hosts, cross_project_id, passwd_hash) values($now, '$new_email_addr', '$new_name', '$authenticator', '$country', '$postal_code', 0, 0, unix_timestamp(), '$project_prefs', $teamid, 'home', '', 1, 1, '$cross_project_id', '$passwd_hash')";
111
 
$result = mysql_query($query);
112
 
if (!$result) {
 
109
$user = make_user(
 
110
    $new_email_addr, $new_name, $passwd_hash,
 
111
    $country, $postal_code, $project_prefs, $teamid
 
112
);
 
113
if (!$user) {
113
114
    show_error("Couldn't create account");
114
115
}
115
116
 
116
117
// In success case, redirect to a fixed page so that user can
117
118
// return to it without getting "Repost form data" stuff
118
119
 
119
 
$user->name = $new_name;
120
 
$user->email_addr = $new_email_addr;
121
 
$user->authenticator = $authenticator;
122
120
send_auth_email($user, true, false);
123
121
 
124
122
if(defined('INVITE_CODES')) {
125
 
    error_log("New account '$new_name' created using invitation code '$invite_code'");
 
123
    error_log("Account '$new_email_addr' created using invitation code '$invite_code'");
126
124
}
127
125
 
128
 
session_start();
129
 
$_SESSION["authenticator"] = $authenticator;
130
 
Header("Location: home.php?new_acct=1&via_web=1");
131
 
setcookie('auth', $authenticator, time()+3600*24*365);
 
126
$next_url = post_str('next_url', true);
 
127
if ($next_url) {
 
128
    Header("Location: $next_url");
 
129
} else {
 
130
    Header("Location: home.php");
 
131
    send_cookie('init', "1", true);
 
132
    send_cookie('via_web', "1", true);
 
133
}
 
134
send_cookie('auth', $user->authenticator, true);
132
135
 
133
136
?>