verifyusr.php3 4.94 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# 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 19
LOGGEDINORDIE($uid,
	      CHECKLOGIN_UNVERIFIED|CHECKLOGIN_NEWUSER|CHECKLOGIN_WEBONLY);
20 21 22 23 24 25 26 27 28 29

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

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

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

#
41 42 43 44 45 46 47 48
# 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);
}

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

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

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
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];
82 83 84 85
    $usr_addr2	 = $row[usr_addr2];
    $usr_city	 = $row[usr_city];
    $usr_state	 = $row[usr_state];
    $usr_zip	 = $row[usr_zip];
86
    $usr_country = $row[usr_country];
87 88 89 90 91 92 93 94 95
    $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 Stoller's avatar
Leigh Stoller committed
96
	 TBGroupLeader($pid, $gid, $leader_uid);
97
	 TBUserInfo($leader_uid, $leader_name, $leader_email);
98

99 100
	 $allleaders = TBLeaderMailList($pid,$gid);

101 102 103 104 105 106
	 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>",
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".
118 119 120 121
		"Address 1:       $usr_addr\n".
		"Address 2:       $usr_addr2\n".
		"City:            $usr_city\n".
		"State:           $usr_state\n".
122 123
		"ZIP/Postal Code: $usr_zip\n".
		"Country:         $usr_country\n".
124 125 126 127 128 129 130
		"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".
131
		"Testbed Operations\n",
132
		"From: $TBMAIL_APPROVAL\n".
133
		"Cc: $allleaders\n".
134 135
		"Bcc: $TBMAIL_AUDIT\n".
		"Errors-To: $TBMAIL_WWW");
136
	 }
137 138 139
     }
}

140
if (strcmp($status, TBDB_USERSTATUS_UNVERIFIED) == 0) {
141
    DBQueryFatal("update users set status='active' where uid='$uid'");
142

143 144 145 146 147 148
    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".
149
	   "Testbed Operations\n",
150 151 152
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

153
    echo "<p>".
154 155 156
         "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 ".
157
	 "that are now available to you will appear.\n";
158
}
159
elseif (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0) {
160
    DBQueryFatal("update users set status='unapproved' where uid='$uid'");
161

162 163 164 165 166 167
    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".
168
	   "Testbed Operations\n",
169 170 171
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

172 173
    INFORMLEADERS($uid);

174 175
    echo "<p>".
	 "You have now been verified. However, your application ".
Leigh Stoller's avatar
Leigh Stoller committed
176
	 "has not yet been approved. You will receive ".
177
	 "email when that has been done.\n";
178 179
}
else {
180
    TBERROR("Bad user status '$status' for $uid!", 1);
181
}
182 183 184 185 186

#
# Standard Testbed Footer
# 
PAGEFOOTER();
187 188
?>