verifyusr.php3 4.53 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2
3
4
5
6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# All rights reserved.
#
7
8
include("defs.php3");

9
10
11
#
# Standard Testbed Header
#
12
PAGEHEADER("Confirm Verification");
13

14
#
15
# Only known and logged in users can be verified. 
16
#
17
$uid = GETLOGIN();
18
LOGGEDINORDIE($uid, CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER);
19
20
21
22
23
24
25
26
27
28

#
# Must provide the key!
# 
if (!isset($key) || strcmp($key, "") == 0) {
    USERERROR("Missing field; ".
              "Please go back and fill out the \"key\" field!", 1);
}

#
29
# Grab the status and do the modification.
30
#
31
32
$query_result =
    DBQueryFatal("select status from users where uid='$uid'");
33

34
35
if (($row = mysql_fetch_row($query_result)) == 0) {
    TBERROR("Database Error retrieving status for $uid!", 1);
36
}
37
$status = $row[0];
38
39

#
40
41
42
43
44
45
46
47
# No multiple verifications!
# 
if (! strcmp($status, TBDB_USERSTATUS_ACTIVE) ||
    ! strcmp($status, TBDB_USERSTATUS_UNAPPROVED)) {
    USERERROR("You have already been verified. If you did not perform ".
	      "this verification, please notify Testbed Operations.", 1);
}

48
#
49
50
51
# The user is logged in, so all we need to do is confirm the key.
# Make sure it matches.
#
52
$keymatch = TBGetVerificationKey($uid);
53
54
55
56

if (strcmp($key, $keymatch)) {
    USERERROR("The given key \"$key\" is incorrect. ".
	      "Please enter the correct key.", 1);
57
58
}

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function INFORMLEADERS($uid) {
    global $TBWWW, $TBMAIL_APPROVAL, $TBMAIL_AUDIT, $TBMAIL_WWW;

    #
    # Get the list of all project/groups this users has tried to join
    # but whose membership messages where delayed until the user verified
    # himself.
    #
    $group_result =
	DBQueryFatal("select * from group_membership ".
		     "where uid='$uid' and trust='none'");

    #
    # Grab user info.
    #
    $userinfo_result =
	DBQueryFatal("select * from users where uid='$uid'");

    $row	 = mysql_fetch_array($userinfo_result);
    $usr_email   = $row[usr_email];
    $usr_URL     = $row[usr_URL];
    $usr_addr    = $row[usr_addr];
    $usr_name    = $row[usr_name];
    $usr_phone   = $row[usr_phone];
    $usr_title   = $row[usr_title];
    $usr_affil   = $row[usr_affil];

     while ($row = mysql_fetch_array($group_result)) {
	 $pid = $row[pid];
	 $gid = $row[gid];

Leigh B. Stoller's avatar
Leigh B. Stoller committed
90
	 TBGroupLeader($pid, $gid, $leader_uid);
91
	 TBUserInfo($leader_uid, $leader_name, $leader_email);
92
93
94
95
96
97
98

	 if (strcmp($leader_uid, $uid)) {
	     #
	     # Send email only if this is not the group leader verifying
	     # his account!
	     # 
	     TBMAIL("$leader_name '$leader_uid' <$leader_email>",
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
		"$uid $pid Project Join Request",
		"$usr_name is trying to join your group $gid in project $pid.".
		"\n".
		"\n".
		"Contact Info:\n".
		"Name:            $usr_name\n".
		"Emulab ID:       $uid\n".
		"Email:           $usr_email\n".
		"User URL:        $usr_URL\n".
		"Title:           $usr_title\n".
		"Affiliation:     $usr_affil\n".
		"Address:         $usr_addr\n".
		"Phone:           $usr_phone\n".
		"\n".
		"Please return to $TBWWW,\n".
		"log in, select the 'New User Approval' page, and enter\n".
		"your decision regarding $usr_name's membership in your\n".
		"project.\n\n".
		"Thanks,\n".
118
		"Testbed Operations\n",
119
120
121
		"From: $TBMAIL_APPROVAL\n".
		"Bcc: $TBMAIL_AUDIT\n".
		"Errors-To: $TBMAIL_WWW");
122
	 }
123
124
125
     }
}

126
if (strcmp($status, TBDB_USERSTATUS_UNVERIFIED) == 0) {
127
    DBQueryFatal("update users set status='active' where uid='$uid'");
128

129
130
131
132
133
134
    TBMAIL($TBMAIL_AUDIT,
	   "User '$uid' has been verified",
	   "\n".
	   "User '$uid' has been verified.\n".
           "Status has been changed from 'unverified' to 'active'\n".
	   "\n".
135
	   "Testbed Operations\n",
136
137
138
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

139
    echo "<p>".
140
141
142
         "Because your membership has already been approved, ".
	 "you are now an active user of emulab. ".
	 "Click on the 'Home' link at your left, and any options ".
143
	 "that are now available to you will appear.\n";
144
}
145
elseif (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0) {
146
    DBQueryFatal("update users set status='unapproved' where uid='$uid'");
147

148
149
150
151
152
153
    TBMAIL($TBMAIL_AUDIT,
	   "User '$uid' has been verified",
	   "\n".
	   "User '$uid' has been verified.\n".
           "Status has been changed from 'newuser' to 'unapproved'\n".
	   "\n".
154
	   "Testbed Operations\n",
155
156
157
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

158
159
    INFORMLEADERS($uid);

160
161
    echo "<p>".
	 "You have now been verified. However, your application ".
Jay Lepreau's avatar
Jay Lepreau committed
162
	 "has not yet been approved by the project leader. You will receive ".
163
	 "email when that has been done.\n";
164
165
}
else {
166
    TBERROR("Bad user status '$status' for $uid!", 1);
167
}
168
169
170
171
172

#
# Standard Testbed Footer
# 
PAGEFOOTER();
173
174
?>