summaryrefslogtreecommitdiff
path: root/web/lib/aur.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'web/lib/aur.inc.php')
-rw-r--r--web/lib/aur.inc.php44
1 files changed, 24 insertions, 20 deletions
diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 99f5ae4..3368696 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -135,20 +135,19 @@ function new_sid() {
*
* @param string $id User's ID
*
- * @return string Username if it exists, otherwise "None"
+ * @return string Username if it exists, otherwise null
*/
-function username_from_id($id="") {
- if (!$id) {
- return "";
- }
+function username_from_id($id) {
+ $id = intval($id);
+
$dbh = DB::connect();
$q = "SELECT Username FROM Users WHERE ID = " . $dbh->quote($id);
$result = $dbh->query($q);
if (!$result) {
- return "None";
+ return null;
}
- $row = $result->fetch(PDO::FETCH_NUM);
+ $row = $result->fetch(PDO::FETCH_NUM);
return $row[0];
}
@@ -178,6 +177,17 @@ function username_from_sid($sid="") {
}
/**
+ * Format a user name for inclusion in HTML data
+ *
+ * @param string $username The user name to format
+ *
+ * @return void
+ */
+function html_format_username($username) {
+ return $username ? htmlspecialchars($username) : __("None");
+}
+
+/**
* Determine the user's e-mail address in the database using a session ID
*
* @param string $sid User's session ID
@@ -363,20 +373,17 @@ function rm_tree($dirname) {
*
* @param string $username The username of an account
*
- * @return string Return user ID if exists for username, otherwise "None"
+ * @return string Return user ID if exists for username, otherwise null
*/
-function uid_from_username($username="") {
- if (!$username) {
- return "";
- }
+function uid_from_username($username) {
$dbh = DB::connect();
$q = "SELECT ID FROM Users WHERE Username = " . $dbh->quote($username);
$result = $dbh->query($q);
if (!$result) {
- return "None";
+ return null;
}
- $row = $result->fetch(PDO::FETCH_NUM);
+ $row = $result->fetch(PDO::FETCH_NUM);
return $row[0];
}
@@ -387,18 +394,15 @@ function uid_from_username($username="") {
*
* @return string The user's ID
*/
-function uid_from_email($email="") {
- if (!$email) {
- return "";
- }
+function uid_from_email($email) {
$dbh = DB::connect();
$q = "SELECT ID FROM Users WHERE Email = " . $dbh->quote($email);
$result = $dbh->query($q);
if (!$result) {
- return "None";
+ return null;
}
- $row = $result->fetch(PDO::FETCH_NUM);
+ $row = $result->fetch(PDO::FETCH_NUM);
return $row[0];
}