verifyusr.php3 2.85 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
if (strcmp($status, TBDB_USERSTATUS_UNVERIFIED) == 0) {
55
56
57
58
59
60
61
    $query_result = mysql_db_query($TBDBNAME,
	"update users set status='active' where uid='$uid'");
    if (!$query_result) {
        $err = mysql_error();
        TBERROR("Database Error setting status for $uid: $err\n", 1);
    }

62
63
64
65
66
67
68
69
70
71
    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");

72
73
    echo "<p>".
         "Because your project leader has already approved ".
Jay Lepreau's avatar
Jay Lepreau committed
74
	 "your membership in the project, you are now an active user ".
Leigh B. Stoller's avatar
Leigh B. Stoller committed
75
	 "of emulab.  Click on the 'Home' link at your left, and any options ".
76
	 "that are now available to you will appear.\n";
77
}
78
elseif (strcmp($status, TBDB_USERSTATUS_NEWUSER) == 0) {
79
80
81
82
83
84
85
    $query_result = mysql_db_query($TBDBNAME,
	"update users set status='unapproved' where uid='$uid'");
    if (!$query_result) {
        $err = mysql_error();
        TBERROR("Database Error setting status for $uid: $err\n", 1);
    }

86
87
88
89
90
91
92
93
94
95
    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");

96
97
    echo "<p>".
	 "You have now been verified. However, your application ".
Jay Lepreau's avatar
Jay Lepreau committed
98
	 "has not yet been approved by the project leader. You will receive ".
99
	 "email when that has been done.\n";
100
101
}
else {
102
    TBERROR("Bad user status '$status' for $uid!", 1);
103
}
104
    
105
106
107
108
109

#
# Standard Testbed Footer
# 
PAGEFOOTER();
110
111
?>