summaryrefslogtreecommitdiffstats
path: root/web/html/account.php
diff options
context:
space:
mode:
authorcanyonknight <canyonknight@gmail.com>2012-05-23 21:32:52 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2012-07-06 11:27:03 +0200
commit8a59cd620804909400ea526602bffa1e2f3d389c (patch)
treec97350d220f0c306d325541668e54b6c8fdd5586 /web/html/account.php
parent763cbf8373e3373254ad18f5b69fd16efdc6fd5c (diff)
downloadaur-8a59cd620804909400ea526602bffa1e2f3d389c.tar.gz
aur-8a59cd620804909400ea526602bffa1e2f3d389c.tar.xz
account.php: Pull out DB code
* Move DB code in account.php to new functions in acctfuncs.inc.php * Centralization of DB code important in a future transition to PDO interface * Consolidate redudant SQL statements from DisplayAccount and AccountInfo * Consolidation also adds ability to edit accounts based on username Signed-off-by: canyonknight <canyonknight@gmail.com> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/html/account.php')
-rw-r--r--web/html/account.php44
1 files changed, 10 insertions, 34 deletions
diff --git a/web/html/account.php b/web/html/account.php
index 63c3ada4..2a96845e 100644
--- a/web/html/account.php
+++ b/web/html/account.php
@@ -44,17 +44,10 @@ if (isset($_COOKIE["AURSID"])) {
} elseif ($action == "DisplayAccount") {
# the user has clicked 'edit', display the account details in a form
#
- $q = "SELECT Users.*, AccountTypes.AccountType ";
- $q.= "FROM Users, AccountTypes ";
- $q.= "WHERE AccountTypes.ID = Users.AccountTypeID ";
- $q.= "AND Users.ID = ".intval(in_request("ID"));
- $result = db_query($q, $dbh);
- if (!mysql_num_rows($result)) {
+ $row = account_details(in_request("ID"), in_request("U"));
+ if (empty($row)) {
print __("Could not retrieve information for the specified user.");
-
} else {
- $row = mysql_fetch_assoc($result);
-
# double check to make sure logged in user can edit this account
#
if ($atype == "User" || ($atype == "Trusted User" && $row["AccountType"] == "Developer")) {
@@ -71,24 +64,15 @@ if (isset($_COOKIE["AURSID"])) {
} elseif ($action == "AccountInfo") {
# no editing, just looking up user info
#
- $q = "SELECT Users.*, AccountTypes.AccountType ";
- $q.= "FROM Users, AccountTypes ";
- $q.= "WHERE AccountTypes.ID = Users.AccountTypeID ";
- if (isset($_REQUEST["ID"])) {
- $q.= "AND Users.ID = ".intval(in_request("ID"));
- } else {
- $q.= "AND Users.Username = '".db_escape_string(in_request("U")) . "'";
- }
- $result = db_query($q, $dbh);
- if (!mysql_num_rows($result)) {
+ $row = account_details(in_request("ID"), in_request("U"));
+ if (empty($row)) {
print __("Could not retrieve information for the specified user.");
} else {
- $row = mysql_fetch_assoc($result);
- display_account_info($row["Username"],
- $row["AccountType"], $row["Email"], $row["RealName"],
- $row["IRCNick"], $row["PGPKey"], $row["LastVoted"]);
+ display_account_info($row["Username"],
+ $row["AccountType"], $row["Email"], $row["RealName"],
+ $row["IRCNick"], $row["PGPKey"], $row["LastVoted"]);
}
-
+
} elseif ($action == "UpdateAccount") {
# user is submitting their modifications to an existing account
#
@@ -110,18 +94,10 @@ if (isset($_COOKIE["AURSID"])) {
# A normal user, give them the ability to edit
# their own account
#
- $q = "SELECT Users.*, AccountTypes.AccountType ";
- $q.= "FROM Users, AccountTypes, Sessions ";
- $q.= "WHERE AccountTypes.ID = Users.AccountTypeID ";
- $q.= "AND Users.ID = Sessions.UsersID ";
- $q.= "AND Sessions.SessionID = '";
- $q.= db_escape_string($_COOKIE["AURSID"])."'";
- $result = db_query($q, $dbh);
- if (!mysql_num_rows($result)) {
+ $row = own_account_details($_COOKIE["AURSID"]);
+ if (empty($row)) {
print __("Could not retrieve information for the specified user.");
-
} else {
- $row = mysql_fetch_assoc($result);
# don't need to check if they have permissions, this is a
# normal user editing themselves.
#