verifyusr.php3 4.41 KB
Newer Older
1
2
3
<?php
include("defs.php3");

4
5
6
#
# Standard Testbed Header
#
7
PAGEHEADER("Confirm Verification");
8

9
#
10
# Only known and logged in users can be verified. 
11
#
12
$uid = GETLOGIN();
13
LOGGEDINORDIE($uid, CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER);
14
15
16
17
18
19
20
21
22
23

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

#
24
# Grab the status and do the modification.
25
#
26
27
$query_result =
    DBQueryFatal("select status from users where uid='$uid'");
28

29
30
if (($row = mysql_fetch_row($query_result)) == 0) {
    TBERROR("Database Error retrieving status for $uid!", 1);
31
}
32
$status = $row[0];
33
34

#
35
36
37
38
39
40
41
42
# 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);
}

43
#
44
45
46
47
48
49
50
51
# The user is logged in, so all we need to do is confirm the key.
# Make sure it matches.
#
$keymatch = GENKEY($uid);

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

54
55
56
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
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
85
	 TBGroupLeader($pid, $gid, $leader_uid);
86
	 TBUserInfo($leader_uid, $leader_name, $leader_email);
87
88
89
90
91
92
93

	 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>",
94
95
96
97
98
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".
		"Testbed Ops\n".
		"Utah Network Testbed\n",
		"From: $TBMAIL_APPROVAL\n".
		"Bcc: $TBMAIL_AUDIT\n".
		"Errors-To: $TBMAIL_WWW");
118
	 }
119
120
121
     }
}

122
if (strcmp($status, TBDB_USERSTATUS_UNVERIFIED) == 0) {
123
    DBQueryFatal("update users set status='active' where uid='$uid'");
124

125
126
127
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".
	   "Testbed Ops\n",
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

135
    echo "<p>".
136
137
138
         "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 ".
139
	 "that are now available to you will appear.\n";
140
}
141
elseif (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0) {
142
    DBQueryFatal("update users set status='unapproved' where uid='$uid'");
143

144
145
146
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".
	   "Testbed Ops\n",
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

154
155
    INFORMLEADERS($uid);

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

#
# Standard Testbed Footer
# 
PAGEFOOTER();
169
170
?>