account.php 4.06 KB
Newer Older
1
<?php
pjmattal's avatar
pjmattal committed
2

3
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
pjmattal's avatar
pjmattal committed
4

5
6
include_once('aur.inc.php');         # access AUR common functions
include_once('acctfuncs.inc.php');   # access Account specific functions
7

eric's avatar
eric committed
8
set_lang();                 # this sets up the visitor's language
eric's avatar
eric committed
9
check_sid();                # see if they're still logged in
eric's avatar
eric committed
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$action = in_request("Action");

$need_userinfo = array(
	"DisplayAccount", "DeleteAccount", "AccountInfo", "UpdateAccount"
);

if (in_array($action, $need_userinfo)) {
	$row = account_details(in_request("ID"), in_request("U"));
}

if ($action == "AccountInfo") {
	html_header(__('Account') . ' ' . $row['Username']);
} else {
	html_header(__('Accounts'));
}
eric's avatar
eric committed
26
27

# Main page processing here
eric's avatar
eric committed
28
#
29
echo "<div class=\"box\">\n";
30
echo "  <h2>".__("Accounts")."</h2>\n";
eliott's avatar
eliott committed
31

eric's avatar
eric committed
32
if (isset($_COOKIE["AURSID"])) {
Dan McGee's avatar
Dan McGee committed
33
	if ($action == "SearchAccounts") {
34
35

		# security check
eric's avatar
eric committed
36
		#
Lukas Fleischer's avatar
Lukas Fleischer committed
37
		if (has_credential(CRED_ACCOUNT_SEARCH)) {
38
39
			# the user has entered search criteria, find any matching accounts
			#
Lukas Fleischer's avatar
Lukas Fleischer committed
40
			search_results_page(in_request("O"), in_request("SB"),
Dan McGee's avatar
Dan McGee committed
41
					in_request("U"), in_request("T"), in_request("S"),
42
43
					in_request("E"), in_request("R"), in_request("I"),
					in_request("K"));
eric's avatar
eric committed
44
45

		} else {
46
47
			# a non-privileged user is trying to access the search page
			#
48
			print __("You are not allowed to access this area.")."<br />\n";
eric's avatar
eric committed
49
50
		}

Dan McGee's avatar
Dan McGee committed
51
	} elseif ($action == "DisplayAccount") {
eric's avatar
eric committed
52
53
		# the user has clicked 'edit', display the account details in a form
		#
canyonknight's avatar
canyonknight committed
54
		if (empty($row)) {
eric's avatar
eric committed
55
56
			print __("Could not retrieve information for the specified user.");
		} else {
57
			/* Verify user has permission to edit the account */
Lukas Fleischer's avatar
Lukas Fleischer committed
58
59
			if (can_edit_account($row)) {
				display_account_form("UpdateAccount", $row["Username"],
60
					$row["AccountTypeID"], $row["Suspended"], $row["Email"],
61
					"", "", $row["RealName"], $row["LangPreference"],
62
					$row["IRCNick"], $row["PGPKey"], $row["SSHPubKey"],
63
					$row["InactivityTS"] ? 1 : 0, $row["ID"]);
64
65
			} else {
				print __("You do not have permission to edit this account.");
eric's avatar
eric committed
66
67
			}
		}
eric's avatar
eric committed
68

69
70
	} elseif ($action == "DeleteAccount") {
		/* Details for account being deleted. */
71
72
		if (can_edit_account($row)) {
			$UID = $row['ID'];
73
74
75
76
			if (in_request('confirm_Delete') && check_token()) {
				user_delete($UID);
				header('Location: /');
			} else {
77
				$username = $row['Username'];
78
79
80
81
82
				include("account_delete.php");
			}
		} else {
			print __("You do not have permission to edit this account.");
		}
Dan McGee's avatar
Dan McGee committed
83
	} elseif ($action == "AccountInfo") {
84
85
		# no editing, just looking up user info
		#
canyonknight's avatar
canyonknight committed
86
		if (empty($row)) {
87
88
			print __("Could not retrieve information for the specified user.");
		} else {
89
			include("account_details.php");
90
		}
canyonknight's avatar
canyonknight committed
91

Dan McGee's avatar
Dan McGee committed
92
	} elseif ($action == "UpdateAccount") {
93
94
		/* Details for account being updated */
		/* Verify user permissions and that the request is a valid POST */
95
		if (can_edit_account($row) && check_token()) {
96
			/* Update the details for the existing account */
Lukas Fleischer's avatar
Lukas Fleischer committed
97
			process_account_form("edit", "UpdateAccount",
98
99
100
					in_request("U"), in_request("T"), in_request("S"),
					in_request("E"), in_request("P"), in_request("C"),
					in_request("R"), in_request("L"), in_request("I"),
101
102
					in_request("K"), in_request("PK"), in_request("J"),
					in_request("ID"));
103
		}
eric's avatar
eric committed
104
	} else {
Lukas Fleischer's avatar
Lukas Fleischer committed
105
		if (has_credential(CRED_ACCOUNT_SEARCH)) {
106
107
			# display the search page if they're a TU/dev
			#
108
			print __("Use this form to search existing accounts.")."<br />\n";
109
			include('search_accounts_form.php');
eric's avatar
eric committed
110

111
		} else {
112
			print __("You are not allowed to access this area.");
113
		}
eric's avatar
eric committed
114
115
116
117
118
	}

} else {
	# visitor is not logged in
	#
Dan McGee's avatar
Dan McGee committed
119
	if ($action == "AccountInfo") {
120
		print __("You must log in to view user information.");
Lukas Fleischer's avatar
Lukas Fleischer committed
121
	} elseif ($action == "NewAccount") {
122
		# process the form input for creating a new account
eric's avatar
eric committed
123
		#
Lukas Fleischer's avatar
Lukas Fleischer committed
124
		process_account_form("new", "NewAccount",
Dan McGee's avatar
Dan McGee committed
125
				in_request("U"), 1, 0, in_request("E"),
126
127
				'', '', in_request("R"), in_request("L"),
				in_request("I"), in_request("K"));
eric's avatar
eric committed
128

eric's avatar
eric committed
129
130
131
	} else {
		# display the account request form
		#
eric's avatar
eric committed
132
		print __("Use this form to create an account.");
Lukas Fleischer's avatar
Lukas Fleischer committed
133
		display_account_form("NewAccount", "", "", "", "", "", "", "", $LANG);
eric's avatar
eric committed
134
135
	}
}
eric's avatar
eric committed
136

eliott's avatar
eliott committed
137
138
echo "</div>";

139
html_footer(AURWEB_VERSION);
140

eric's avatar
eric committed
141
?>