mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Unify function declaration style
Always put the opening brace on the same line as the beginning of the function declaration. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
985795a210
commit
132856a938
3 changed files with 19 additions and 38 deletions
|
@ -732,8 +732,7 @@ function try_login() {
|
|||
* Returns the username if it is valid
|
||||
* Returns nothing if it isn't valid
|
||||
*/
|
||||
function valid_username( $user )
|
||||
{
|
||||
function valid_username($user) {
|
||||
if (!empty($user)) {
|
||||
|
||||
#Is username at not too short or too long?
|
||||
|
@ -759,8 +758,7 @@ function valid_username( $user )
|
|||
* Checks if the username is valid and if it exists in the database
|
||||
* Returns the username ID or nothing
|
||||
*/
|
||||
function valid_user( $user, $dbh )
|
||||
{
|
||||
function valid_user($user, $dbh) {
|
||||
/* if ( $user = valid_username($user) ) { */
|
||||
if ( $user ) {
|
||||
$q = "SELECT ID FROM Users WHERE Username = '"
|
||||
|
@ -776,8 +774,7 @@ function valid_user( $user, $dbh )
|
|||
return;
|
||||
}
|
||||
|
||||
function good_passwd( $passwd )
|
||||
{
|
||||
function good_passwd($passwd) {
|
||||
if ( strlen($passwd) >= PASSWD_MIN_LEN ) {
|
||||
return true;
|
||||
}
|
||||
|
@ -787,8 +784,7 @@ function good_passwd( $passwd )
|
|||
/* Verifies that the password is correct for the userID specified.
|
||||
* Returns true or false
|
||||
*/
|
||||
function valid_passwd( $userID, $passwd, $dbh )
|
||||
{
|
||||
function valid_passwd($userID, $passwd, $dbh) {
|
||||
if ( strlen($passwd) > 0 ) {
|
||||
# get salt for this user
|
||||
$salt = get_salt($userID);
|
||||
|
@ -830,8 +826,7 @@ function valid_passwd( $userID, $passwd, $dbh )
|
|||
/*
|
||||
* Checks if the PGP key fingerprint is valid (must be 40 hexadecimal digits).
|
||||
*/
|
||||
function valid_pgp_fingerprint ( $fingerprint )
|
||||
{
|
||||
function valid_pgp_fingerprint($fingerprint) {
|
||||
$fingerprint = str_replace(" ", "", $fingerprint);
|
||||
return (strlen($fingerprint) == 40 && ctype_xdigit($fingerprint));
|
||||
}
|
||||
|
@ -839,8 +834,7 @@ function valid_pgp_fingerprint ( $fingerprint )
|
|||
/*
|
||||
* Is the user account suspended?
|
||||
*/
|
||||
function user_suspended( $id, $dbh )
|
||||
{
|
||||
function user_suspended($id, $dbh) {
|
||||
if (!$id) {
|
||||
return false;
|
||||
}
|
||||
|
@ -858,8 +852,7 @@ function user_suspended( $id, $dbh )
|
|||
/*
|
||||
* This should be expanded to return something
|
||||
*/
|
||||
function user_delete( $id, $dbh )
|
||||
{
|
||||
function user_delete($id, $dbh) {
|
||||
$q = "DELETE FROM Users WHERE ID = " . $id;
|
||||
db_query($q, $dbh);
|
||||
return;
|
||||
|
@ -869,8 +862,7 @@ function user_delete( $id, $dbh )
|
|||
* A different way of determining a user's privileges
|
||||
* rather than account_from_sid()
|
||||
*/
|
||||
function user_is_privileged( $id, $dbh )
|
||||
{
|
||||
function user_is_privileged($id, $dbh) {
|
||||
$q = "SELECT AccountTypeID FROM Users WHERE ID = " . $id;
|
||||
$result = db_query($q, $dbh);
|
||||
if ($result) {
|
||||
|
|
|
@ -386,8 +386,7 @@ function chmod_group($path) {
|
|||
|
||||
# obtain the uid given a Users.Username
|
||||
#
|
||||
function uid_from_username($username="", $dbh=NULL)
|
||||
{
|
||||
function uid_from_username($username="", $dbh=NULL) {
|
||||
if (!$username) {
|
||||
return "";
|
||||
}
|
||||
|
@ -407,8 +406,7 @@ function uid_from_username($username="", $dbh=NULL)
|
|||
|
||||
# obtain the uid given a Users.Email
|
||||
#
|
||||
function uid_from_email($email="", $dbh=NULL)
|
||||
{
|
||||
function uid_from_email($email="", $dbh=NULL) {
|
||||
if (!$email) {
|
||||
return "";
|
||||
}
|
||||
|
@ -428,8 +426,7 @@ function uid_from_email($email="", $dbh=NULL)
|
|||
|
||||
# check user privileges
|
||||
#
|
||||
function check_user_privileges()
|
||||
{
|
||||
function check_user_privileges() {
|
||||
$type = account_from_sid($_COOKIE['AURSID']);
|
||||
return ($type == 'Trusted User' || $type == 'Developer');
|
||||
}
|
||||
|
@ -468,8 +465,7 @@ function mkurl($append) {
|
|||
return substr($out, 5);
|
||||
}
|
||||
|
||||
function get_salt($user_id, $dbh=NULL)
|
||||
{
|
||||
function get_salt($user_id, $dbh=NULL) {
|
||||
if(!$dbh) {
|
||||
$dbh = db_connect();
|
||||
}
|
||||
|
@ -482,8 +478,7 @@ function get_salt($user_id, $dbh=NULL)
|
|||
return;
|
||||
}
|
||||
|
||||
function save_salt($user_id, $passwd, $dbh=NULL)
|
||||
{
|
||||
function save_salt($user_id, $passwd, $dbh=NULL) {
|
||||
if(!$dbh) {
|
||||
$dbh = db_connect();
|
||||
}
|
||||
|
@ -494,21 +489,18 @@ function save_salt($user_id, $passwd, $dbh=NULL)
|
|||
return db_query($salting_q, $dbh);
|
||||
}
|
||||
|
||||
function generate_salt()
|
||||
{
|
||||
function generate_salt() {
|
||||
return md5(uniqid(mt_rand(), true));
|
||||
}
|
||||
|
||||
function salted_hash($passwd, $salt)
|
||||
{
|
||||
function salted_hash($passwd, $salt) {
|
||||
if (strlen($salt) != 32) {
|
||||
trigger_error('Salt does not look like an md5 hash', E_USER_WARNING);
|
||||
}
|
||||
return md5($salt . $passwd);
|
||||
}
|
||||
|
||||
function parse_comment($comment)
|
||||
{
|
||||
function parse_comment($comment) {
|
||||
$url_pattern = '/(\b(?:https?|ftp):\/\/[\w\/\#~:.?+=&%@!\-;,]+?' .
|
||||
'(?=[.:?\-;,]*(?:[^\w\/\#~:.?+=&%@!\-;,]|$)))/iS';
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
include_once('aur.inc.php');
|
||||
|
||||
function updates_table($dbh)
|
||||
{
|
||||
function updates_table($dbh) {
|
||||
$key = 'recent_updates';
|
||||
if(!($newest_packages = get_cache_value($key))) {
|
||||
$q = 'SELECT * FROM Packages ORDER BY ModifiedTS DESC LIMIT 10';
|
||||
|
@ -18,8 +17,7 @@ function updates_table($dbh)
|
|||
include('stats/updates_table.php');
|
||||
}
|
||||
|
||||
function user_table($user, $dbh)
|
||||
{
|
||||
function user_table($user, $dbh) {
|
||||
$escuser = db_escape_string($user);
|
||||
$base_q = "SELECT count(*) FROM Packages,Users WHERE Packages.MaintainerUID = Users.ID AND Users.Username='" . $escuser . "'";
|
||||
|
||||
|
@ -37,8 +35,7 @@ function user_table($user, $dbh)
|
|||
include('stats/user_table.php');
|
||||
}
|
||||
|
||||
function general_stats_table($dbh)
|
||||
{
|
||||
function general_stats_table($dbh) {
|
||||
# AUR statistics
|
||||
$q = "SELECT count(*) FROM Packages";
|
||||
$unsupported_count = db_cache_value($q, $dbh, 'unsupported_count');
|
||||
|
|
Loading…
Add table
Reference in a new issue