mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
acctfuncs: Fix some whitespace and formatting.
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
parent
fc607aa9f7
commit
61d0358162
1 changed files with 36 additions and 40 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
# Display the standard Account form, pass in default values if any
|
||||
#
|
||||
|
||||
function display_account_form($UTYPE,$A,$U="",$T="",$S="",
|
||||
$E="",$P="",$C="",$R="",$L="",$I="",$N="",$UID=0) {
|
||||
# UTYPE: what user type the form is being displayed for
|
||||
|
@ -35,9 +35,8 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="",
|
|||
print " name='U' value='".$U."'> (".__("required").")</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
# Only TUs or Devs can promote/demote/suspend a user
|
||||
if ($UTYPE == "Trusted User" || $UTYPE == "Developer") {
|
||||
# only TUs or Devs can promote/demote/suspend a user
|
||||
#
|
||||
print "<tr>";
|
||||
print "<td align='left'>".__("Account Type").":</td>";
|
||||
print "<td align='left'><select name=T>\n";
|
||||
|
@ -47,9 +46,9 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="",
|
|||
print "<option value='2'";
|
||||
$T == "Trusted User" ? print " selected>" : print ">";
|
||||
print __("Trusted user")."\n";
|
||||
|
||||
# Only developers can make another account a developer
|
||||
if ($UTYPE == "Developer") {
|
||||
# only developers can make another account a developer
|
||||
#
|
||||
print "<option value='3'";
|
||||
$T == "Developer" ? print " selected>" : print ">";
|
||||
print __("Developer")."\n";
|
||||
|
@ -172,13 +171,14 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
|
|||
# UID: database Users.ID value
|
||||
|
||||
# error check and process request for a new/modified account
|
||||
#
|
||||
global $SUPPORTED_LANGS;
|
||||
|
||||
if(isset($_COOKIE['AURSID']))
|
||||
if(isset($_COOKIE['AURSID'])) {
|
||||
$editor_user = uid_from_sid($_COOKIE['AURSID']);
|
||||
else
|
||||
}
|
||||
else {
|
||||
$editor_user = null;
|
||||
}
|
||||
|
||||
$dbh = db_connect();
|
||||
$error = "";
|
||||
|
@ -211,8 +211,7 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
|
|||
$error = __("Password fields do not match.");
|
||||
}
|
||||
if (!$error && $P != '' && !good_passwd($P))
|
||||
$error =
|
||||
__("Your password must be at least %s characters.",PASSWD_MIN_LEN);
|
||||
$error = __("Your password must be at least %s characters.",PASSWD_MIN_LEN);
|
||||
|
||||
if (!$error && !valid_email($E)) {
|
||||
$error = __("The email address is invalid.");
|
||||
|
@ -266,7 +265,6 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
|
|||
} else {
|
||||
if ($TYPE == "new") {
|
||||
# no errors, go ahead and create the unprivileged user
|
||||
#
|
||||
|
||||
# md5hash the password
|
||||
$P = md5($P);
|
||||
|
@ -299,7 +297,6 @@ function process_account_form($UTYPE,$TYPE,$A,$U="",$T="",$S="",$E="",
|
|||
|
||||
} else {
|
||||
# no errors, go ahead and modify the user account
|
||||
#
|
||||
|
||||
# md5 hash the password
|
||||
$q = "UPDATE Users SET ";
|
||||
|
@ -545,8 +542,7 @@ function search_results_page($UTYPE,$O=0,$SB="",$U="",$T="",
|
|||
|
||||
# Display non-editable account info
|
||||
#
|
||||
function display_account_info($U="",$T="",
|
||||
$E="",$R="",$I="") {
|
||||
function display_account_info($U="", $T="", $E="", $R="", $I="") {
|
||||
# U: value to display for username
|
||||
# T: value to display for account type
|
||||
# E: value to display for email address
|
||||
|
@ -613,7 +609,6 @@ function try_login() {
|
|||
|
||||
if ( isset($_REQUEST['user']) || isset($_REQUEST['passwd']) ) {
|
||||
|
||||
|
||||
$userID = valid_user($_REQUEST['user']);
|
||||
|
||||
if ( user_suspended( $userID ) ) {
|
||||
|
@ -685,8 +680,6 @@ function try_login() {
|
|||
*/
|
||||
function valid_username( $user )
|
||||
{
|
||||
|
||||
#Is it non-empty?
|
||||
if (!empty($user)) {
|
||||
|
||||
#Is username at not too short or too long?
|
||||
|
@ -721,6 +714,7 @@ function valid_user( $user )
|
|||
. mysql_real_escape_string($user). "'";
|
||||
|
||||
$result = mysql_fetch_row(db_query($q, $dbh));
|
||||
|
||||
# Is the username in the database?
|
||||
if ($result[0]) {
|
||||
return $result[0];
|
||||
|
@ -750,7 +744,7 @@ function valid_passwd( $userID, $passwd )
|
|||
|
||||
$result = mysql_fetch_row(db_query($q, $dbh));
|
||||
if ($result[0]) {
|
||||
#is it the right password?
|
||||
# Is it the right password?
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -792,8 +786,9 @@ function user_is_privileged( $id )
|
|||
$dbh = db_connect();
|
||||
$q = "SELECT AccountTypeID FROM Users WHERE ID = '$id'";
|
||||
$result = mysql_fetch_row(db_query($q, $dbh));
|
||||
if( $result[0] > 1)
|
||||
if( $result[0] > 1) {
|
||||
return $result[0];
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
@ -802,8 +797,9 @@ function user_is_privileged( $id )
|
|||
function clear_expired_sessions($dbh = null) {
|
||||
global $LOGIN_TIMEOUT;
|
||||
|
||||
if (empty($dbh))
|
||||
if (empty($dbh)) {
|
||||
$dbh = db_connect();
|
||||
}
|
||||
|
||||
$q = "DELETE FROM Sessions WHERE LastUpdateTS < (UNIX_TIMESTAMP() - $LOGIN_TIMEOUT)";
|
||||
db_query($q, $dbh);
|
||||
|
|
Loading…
Add table
Reference in a new issue