summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-09-11 21:56:51 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-09-11 22:14:28 +0200
commitc5014b0752d2544cfb04522bda164e89246702bd (patch)
tree55e2158c7c06228026d6c852711374f4d09f12c0 /web
parent396e50bdc88feae9d0048d1c3dab776388d96dc7 (diff)
downloadaurweb-c5014b0752d2544cfb04522bda164e89246702bd.tar.xz
Remove superfluous function valid_user()
This helper function was almost 100% identical to uid_from_username(). Switch to using uid_from_username(), which has a much better name and implementation, everywhere. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web')
-rw-r--r--web/html/addvote.php2
-rw-r--r--web/lib/acctfuncs.inc.php27
2 files changed, 2 insertions, 27 deletions
diff --git a/web/html/addvote.php b/web/html/addvote.php
index 0372518..d152941 100644
--- a/web/html/addvote.php
+++ b/web/html/addvote.php
@@ -24,7 +24,7 @@ if (has_credential(CRED_TU_ADD_VOTE)) {
$error = "";
if (!empty($_POST['user'])) {
- if (!valid_user($_POST['user'])) {
+ if (!uid_from_username($_POST['user'])) {
$error.= __("Username does not exist.");
} else {
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index f718a77..ee8f0e3 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -479,7 +479,7 @@ function try_login() {
}
$dbh = DB::connect();
- $userID = valid_user($_REQUEST['user']);
+ $userID = uid_from_username($_REQUEST['user']);
if (user_suspended($userID)) {
$login_error = __('Account suspended');
@@ -609,31 +609,6 @@ function valid_username($user) {
}
/**
- * Determine if a username exists in the database
- *
- * @param string $user Username to check in the database
- *
- * @return string|void Return user ID if in database, otherwise void
- */
-function valid_user($user) {
- if (!$user) {
- return false;
- }
-
- $dbh = DB::connect();
-
- $q = "SELECT ID FROM Users WHERE ";
- $q.= "Username = " . $dbh->quote($user);
- $result = $dbh->query($q);
- if (!$result) {
- return null;
- }
-
- $row = $result->fetch(PDO::FETCH_NUM);
- return $row[0];
-}
-
-/**
* Determine if a user already has a proposal open about themselves
*
* @param string $user Username to checkout for open proposal