verifyusr.php3 7.25 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. 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
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];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
81 82 83 84 85 86 87
    $usr_addr    = stripslashes($row[usr_addr]);
    $usr_addr2	 = stripslashes($row[usr_addr2]);
    $usr_city	 = stripslashes($row[usr_city]);
    $usr_state	 = stripslashes($row[usr_state]);
    $usr_zip	 = stripslashes($row[usr_zip]);
    $usr_country = stripslashes($row[usr_country]);
    $usr_name    = stripslashes($row[usr_name]);
88
    $usr_phone   = $row[usr_phone];
Leigh B. Stoller's avatar
Leigh B. Stoller committed
89 90
    $usr_title   = stripslashes($row[usr_title]);
    $usr_affil   = stripslashes($row[usr_affil]);
91 92 93 94 95

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

Leigh B. Stoller's avatar
Leigh B. Stoller committed
96 97
	 TBProjLeader($pid, $projleader_uid);
	 TBGroupLeader($pid, $gid, $grpleader_uid);
98

Leigh B. Stoller's avatar
Leigh B. Stoller committed
99
	 if (!strcmp($projleader_uid, $uid)) {
100
	     #
Leigh B. Stoller's avatar
Leigh B. Stoller committed
101
	     # Project leader verifying himself. 
102
	     # 
Leigh B. Stoller's avatar
Leigh B. Stoller committed
103 104 105 106 107 108 109 110 111 112 113
	     TBUserInfo($projleader_uid, $leader_name, $leader_email);
	     TBGroupUnixInfo($pid, $pid, $unix_gid, $unix_name);

	     $projinfo_result =
		 DBQueryFatal("select * from projects where pid='$pid'");

	     $row		= mysql_fetch_array($projinfo_result);
	     $proj_name		= stripslashes($row[name]);
	     $proj_URL          = $row[URL];
	     $proj_funders      = stripslashes($row[funders]);
	     $proj_public       = ($row[public] ? "Yes" : "No");
114
	     $proj_linked       = ($row[linked_to_us] ? "Yes" : "No");
Leigh B. Stoller's avatar
Leigh B. Stoller committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
	     $proj_whynotpublic = stripslashes($row[public_whynot]);
	     $proj_members      = $row[num_members];
	     $proj_pcs          = $row[num_pcs];
	     $proj_plabpcs      = $row[num_pcplab];
	     $proj_ronpcs       = $row[num_ron];
	     $proj_why		= stripslashes($row[why]);
	     $proj_expires      = $row[expires];
	     
	     TBMAIL($TBMAIL_APPROVAL,
		"New Project '$pid' ($uid)",
		"'$usr_name' wants to start project '$pid'.\n".
		"\n".
		"Name:            $usr_name ($uid)\n".
		"Returning User?: No\n".
		"Email:           $usr_email\n".
		"User URL:        $usr_URL\n".
		"Project:         $proj_name\n".
		"Expires:         $proj_expires\n".
		"Project URL:     $proj_URL\n".
		"Public URL:      $proj_public\n".
		"Why Not Public:  $proj_whynotpublic\n".
136
		"Linked to Us?:   $proj_linked\n".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
		"Funders:         $proj_funders\n".
		"Title:           $usr_title\n".
		"Affiliation:     $usr_affil\n".
		"Address 1:       $usr_addr\n".
		"Address 2:       $usr_addr2\n".
		"City:            $usr_city\n".
		"State:           $usr_state\n".
		"ZIP/Postal Code: $usr_zip\n".
		"Country:         $usr_country\n".
		"Phone:           $usr_phone\n".
		"Members:         $proj_members\n".
		"PCs:             $proj_pcs\n".
		"Planetlab PCs:   $proj_plabpcs\n".
		"RON PCs:         $proj_ronpcs\n".
		"Unix GID:        $unix_name ($unix_gid)\n".
		"Reasons:\n$proj_why\n\n".
		"Please review the application and when you have made \n".
		"a decision, go to $TBWWW and\n".
		"select the 'Project Approval' page.\n\n".
		"They are expecting a result within 72 hours.\n", 
		"From: $usr_name '$uid' <$usr_email>\n".
		"Reply-To: $TBMAIL_APPROVAL\n".
		"Errors-To: $TBMAIL_WWW");
	 }
	 else {
	     TBUserInfo($grpleader_uid, $leader_name, $leader_email);
	     $allleaders = TBLeaderMailList($pid,$gid);
	     
	     TBMAIL("$leader_name '$grpleader_uid' <$leader_email>",
166 167 168 169 170 171 172 173 174 175 176
		"$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".
177 178 179 180
		"Address 1:       $usr_addr\n".
		"Address 2:       $usr_addr2\n".
		"City:            $usr_city\n".
		"State:           $usr_state\n".
Chad Barb's avatar
Chad Barb committed
181 182
		"ZIP/Postal Code: $usr_zip\n".
		"Country:         $usr_country\n".
183 184 185 186 187 188 189
		"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".
190
		"Testbed Operations\n",
191
		"From: $TBMAIL_APPROVAL\n".
192
		"Cc: $allleaders\n".
193 194
		"Bcc: $TBMAIL_AUDIT\n".
		"Errors-To: $TBMAIL_WWW");
195
	 }
196 197 198
     }
}

199
if (strcmp($status, TBDB_USERSTATUS_UNVERIFIED) == 0) {
200
    DBQueryFatal("update users set status='active' where uid='$uid'");
201

202 203 204 205 206 207
    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".
208
	   "Testbed Operations\n",
209 210 211
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

212
    echo "<p>".
213 214 215
         "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 ".
216
	 "that are now available to you will appear.\n";
217
}
218
elseif (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0) {
219
    DBQueryFatal("update users set status='unapproved' where uid='$uid'");
220

221 222 223 224 225 226
    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".
227
	   "Testbed Operations\n",
228 229 230
	   "From: $TBMAIL_OPS\n".
	   "Errors-To: $TBMAIL_WWW");

231 232
    INFORMLEADERS($uid);

233 234
    echo "<p>".
	 "You have now been verified. However, your application ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
235
	 "has not yet been approved. You will receive ".
236
	 "email when that has been done.\n";
237 238
}
else {
239
    TBERROR("Bad user status '$status' for $uid!", 1);
240
}
241 242 243 244 245

#
# Standard Testbed Footer
# 
PAGEFOOTER();
246 247
?>