Exemple #1
0
function handle_team($f)
{
    $t = parse_team($f);
    if (!$t) {
        echo "Failed to parse team\n";
        return;
    }
    //print_r($t);
    //return;
    if (!valid_team($t)) {
        echo "Invalid team\n";
        return;
    }
    echo "Processing {$t->name} {$t->user_email}\n";
    $user = lookup_user_email_addr($t->user_email);
    $team = lookup_team_name($t->name);
    if ($team) {
        if (!$user) {
            echo "   team exists but user {$t->user_email} doesn't\n";
            return;
        }
        if ($user->id != $team->userid) {
            echo "   team exists but is owned by a different user\n";
            return;
        }
        if ($team->seti_id) {
            if ($team->seti_id == $t->id) {
                echo "   case 1\n";
                update_team($t, $team, $user);
                // update1 case
            } else {
                echo "   team exists but has wrong seti_id\n";
            }
        } else {
            $team2 = lookup_team_seti_id($t->id);
            if ($team2) {
                // update1 case
                echo "   case 2\n";
                update_team($t, $team2, $user);
            } else {
                // update2 case
                echo "   case 3\n";
                update_team($t, $team, $user);
            }
        }
    } else {
        $team = lookup_team_seti_id($t->id);
        if ($team) {
            echo "   A team with same ID but different name exists;\n";
            echo "   Please report this to {$t->user_email};\n";
        } else {
            echo "   Adding team\n";
            insert_case($t, $user);
        }
    }
}
 //    if (!preg_match(INVITE_CODES, $invite_code)) {
 //        show_error(tra("The invitation code you gave is not valid."));
 //    }
 //}
 print_r($data);
 exit;
 $new_name = $data['namePerson/friendly'];
 if (!is_valid_user_name($new_name, $reason)) {
     show_error($reason);
 }
 $new_email_addr = $data['contact/email'];
 $new_email_addr = strtolower($new_email_addr);
 if (!is_valid_email_addr($new_email_addr)) {
     show_error("Invalid email address:\n                you must enter a valid address of the form\n                name@domain");
 }
 $user = lookup_user_email_addr($new_email_addr);
 if (!$user) {
     $passwd_hash = random_string();
     $country = $data['contact/country/home'];
     if ($country == "") {
         $country = "International";
     }
     if (!is_valid_country($country)) {
         echo "bad country";
         exit;
     }
     $postal_code = '';
     $user = make_user($new_email_addr, $new_name, $passwd_hash, $country, $postal_code, $project_prefs = "", $teamid = 0);
     if (!$user) {
         show_error("Couldn't create account");
     }
require_once "../inc/user.inc";
check_get_args(array());
$user = get_logged_in_user();
$email_addr = strtolower(post_str("email_addr"));
$passwd = post_str("passwd", true);
page_head(tra("Change email address of account"));
if (!is_valid_email_addr($email_addr)) {
    echo tra("New email address '%1' is invalid.", $email_addr);
} else {
    if (is_banned_email_addr($email_addr)) {
        echo tra("New email address '%1' is invalid.", $email_addr);
    } else {
        if ($email_addr == $user->email_addr) {
            echo tra("New email address is same as existing address. Nothing is changed.");
        } else {
            $existing = lookup_user_email_addr($email_addr);
            if ($existing) {
                echo tra("There's already an account with that email address");
            } else {
                $passwd_hash = md5($passwd . $user->email_addr);
                // deal with the case where user hasn't set passwd
                // (i.e. passwd is account key)
                //
                if ($passwd_hash != $user->passwd_hash) {
                    $passwd = $user->authenticator;
                    $passwd_hash = md5($passwd . $user->email_addr);
                }
                if ($passwd_hash != $user->passwd_hash) {
                    echo tra("Invalid password.");
                } else {
                    $passwd_hash = md5($passwd . $email_addr);