Commit graph

110 commits

Author SHA1 Message Date
canyonknight
1bc78b9dff acctfuncs.inc.php: Allow translation of missing strings
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2014-01-20 15:41:17 +01:00
Lukas Fleischer
2276171b29 Only include current TUs in the last votes list
Do not show users that took part in past TU votes but no longer have TU
powers. Also, fix the sorting column while we're touching these lines.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-28 01:52:40 +02:00
Lukas Fleischer
86d2efaaa0 Exclude running votes from "Last Votes by TU"
Showing running votes potentially allows for tracking votes and
associating yes/no/abstain votes with specific TUs.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-27 10:52:38 +02:00
Lukas Fleischer
2dd3d04f45 Add "Last Votes by TU" list
This shows a list of all Trusted Users and the vote ID of the last
proposal each of the TUs voted on. This list is sorted by vote ID.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-26 17:34:31 +02:00
Lukas Fleischer
d41e40d9d6 Add a vote type to the TU proposal form
There are only four valid reasons for starting a TU vote, so instead of
letting the user choose a vote length, let her pick a reason and set
vote length and quorum based on that selection.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:48:18 +02:00
Lukas Fleischer
9ff082be25 Store the number of TUs when starting a vote
This will be used for automated calculation of vote participation later.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:47:51 +02:00
Lukas Fleischer
6844f6c1d2 Allow for setting an account's inactivity status
This adds a field to the users table and corresponding fields to the
account edit and display forms that allow for setting an (in-)activity
status.

This might turn out to be useful if a user is on vacation and can not
respond to update/orphan/deletion requests.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-08-22 17:43:13 +02:00
canyonknight
cf083cf9ba Remove superfluous search wrapper function
The search_accounts_form() wrapper function doesn't have any
arguments and only makes it unclear what is happening within
account.php

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-04-24 11:05:51 +02:00
Lukas Fleischer
cd59a313b4 Show hint if password is empty during login
A user might have an empty password due to two reasons:

* The user just created an account and needs to set an initial password.
* The password has been reset by the administrator.

In both cases, the user might be confused as to why the login does not
work. Add a message that helps users debug the issue in both cases.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-25 02:15:12 +01:00
canyonknight
cb91942595 Implement IP banning for user registration and user login
Adds a new is_ipbanned() function to determine whether the user
attempting to login or register for an account has their IP
address listed in the "Bans" table.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-24 22:12:17 +01:00
Lukas Fleischer
5660816ea0 Save last login IP address
Save the IP address used for the last login in the "Users" table. This
makes it a bit easier to create IP ban lists for spammers without
looking at web server logs.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-21 22:26:46 +01:00
Lukas Fleischer
de39a712b0 process_account_form(): Highlight errors
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-21 22:26:45 +01:00
Lukas Fleischer
97dd4b0f4d process_account_form(): Allow using empty passwords
If an empty password is passed during account registration, login for
the new user is disabled and a reset key is sent to the new user's
e-mail address so that they can set an initial password manually.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-19 14:03:34 +01:00
Lukas Fleischer
5d31bb2450 Move reset key submission to a separate function
This allows for reusing reset key submission for other things, such as
sending an initial password reset code during account registration.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-03-19 14:03:33 +01:00
canyonknight
cf2ab50b82 Remove checks before calling connection method
Large amount of boilerplate code that checks if a database
connection exists is useless now that the new connection method
automatically does the same check.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
4235d24039 Remove documentation references to database parameter
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8d6c872297 Remove unnecessary database connection parameter from all functions
All functions now have a database connection method that will use
the same database connection. This imitates the functionality of
passing a database connection as an argument and makes it redundant.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:38 +01:00
canyonknight
8e03e68d68 Add database wrapper class and new connection method
Uses the Singleton pattern to ensure all queries use the same
database connection that is released upon script completion.

All database connections should now be called with DB::connect() and
not db_connect().

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-02-10 12:10:37 +01:00
canyonknight
65e93f134f acctfuncs.inc.php: Change wording of account editing message
An error message is printed when the number of affected rows is
0 for an edited account. A count of 0 doesn't imply an error,
only that no changes were made in the database.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-30 09:25:30 +01:00
canyonknight
150b0f9f0a Clear a user's active sessions following account suspension
A suspended user can stay in active sessions. Introduce new function
delete_user_sessions to remove all open sessions for a specific user.
Allows suspensions to take effect immediately.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-30 09:25:30 +01:00
canyonknight
1fd620cc2f acctfuncs.inc.php: Change return type of valid_username function
The function is only determining whether a username is valid,
so it makes more sense to simply return a boolean value.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2013-01-30 09:25:29 +01:00
canyonknight
ec332bb7e6 Fix account privilege escalation vulnerability
A check is only done to verify a Trusted User isn't promoting their
account. An attacker can send tampered account type POST data to
change their "User" level account to a "Developer" account.

Add check so that all users cannot increase their own account
permissions.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-11-29 23:23:12 +01:00
canyonknight
87fe4701cd Fix account editing and hijacking vulnerability
Checks are in place to avoid users getting account editing forms
they shouldn't have access to. The appropriate checks before
editing the account in the backend are not in place.

This vulnerability allows a user to craft malicious POST data to
edit other user accounts, thereby allowing account hijacking.

Add a new flexible function can_edit_account() to determine if
a user has appropriate permissions. Run the permission check before
processing any account information in the backend.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-11-29 23:23:10 +01:00
Lukas Fleischer
14b237ac53 Refactor TU voters list
* Change voters_list() to return an array of voters instead of
  generating HTML code in the library call.

* Change the template to generate HTML code for the list of voters
  instead of displaying the library's return value.

* Use HTML lists.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-10-08 14:08:06 +02:00
Lukas Fleischer
d56a88897b Avoid use of "<b>"/"</b>"
* Use "<label>"/"</label>" for form labels.
* Use "<strong>"/"</strong>" for important text.
* Use "<h4>"/"</h4>" for headings.
* Drop "<b>"/"</b>" everywhere else.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-24 12:23:05 +02:00
canyonknight
6fa2f99e71 acctfuncs.inc.php: Document all functions using PHPDoc format
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-24 02:04:03 +02:00
canyonknight
e84eb4ae54 Overhaul ability to edit own account
* Restructure account.php to remove redundant code.
* Remove own_account_details().
* Rework logic check to default to no access to account edit form.
* Make default account action viewing account info.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:59:45 +02:00
canyonknight
98b6ba9479 Use URL rewriting for user info page
Navigation to the "AccountInfo" page should only require a user to know the
username of the account they are looking for. Update all AUR links that use
the user info page to reflect the new URL.

Before:
AUR_URL/account/?Action=AccountInfo&U=userfoo

After:
AUR_URL/account/userfoo

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:59:21 +02:00
canyonknight
5dfbb783f1 Adjust user directions after registering to reflect new login page
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:58:52 +02:00
canyonknight
e171f6f34e Migrate all DB code to use PDO
All DB code currently uses the quickly aging mysql_* functions. These
functions are strongly discouraged and may eventually be deprecated.

Transition all code to utilize the PDO data access abstraction layer. PDO
allows for consistent query code across multiple databases. This could
potentially allow for someone to use a database other than MySQL with
minimal code changes.

All functions and behaviors are reproduced as faithfully as possible with
PDO equivalents and some changes in code.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-09-18 00:58:46 +02:00
Lukas Fleischer
799c1ead82 Redirect to the home page after successful login
Jump to the home page instead of displaying a page that only tells you
that you're logged in.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-15 22:48:33 +02:00
Lukas Fleischer
2425f963f8 Use virtual path feature for links
Use virtual paths in links (e.g. link to "/packages/" instead of
"/packages.php" etc.) if the virtual path feature is enabled.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-15 22:44:51 +02:00
Lukas Fleischer
f3ce74c714 Merge branch 'maint'
Conflicts:
	web/html/account.php
	web/html/addvote.php
	web/html/pkgsubmit.php
	web/lib/acctfuncs.inc.php
	web/template/actions_form.php
	web/template/pkg_comment_form.php
	web/template/pkg_comments.php
	web/template/pkg_details.php
	web/template/pkg_search_results.php
	web/template/tu_details.php
2012-07-14 22:52:04 +02:00
canyonknight
50e97446bb acctfuncs.inc.php: Make user_suspended() work correctly
Fixes broken account suspension system.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-14 22:18:58 +02:00
Lukas Fleischer
8a5adf46ae acctfuncs.inc.php: Fix "Undefined variable" notices
Initialize the "$details" and "$whovoted" variables with an empty
array/string to suppress a "Undefined variable" notice if the
votes/voters list is empty.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-08 10:31:18 +02:00
canyonknight
c1bb1df2b3 acctfuncs.inc.php: Move XHTML to account_details.php template
XHTML should be eliminated from lib/ as much as possible. This pulls the XHTML
out of the display_account_info function that echoes the code, and moves it
to the new account_details.php template file.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:27:16 +02:00
canyonknight
d8d36d6f4b acctfuncs.inc.php: Make user_is_privileged() work
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:27:11 +02:00
canyonknight
dac62225d3 acctfuncs.inc.php: Allow functions to take DB handle as argument
Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:27:07 +02:00
canyonknight
c15441762c Pull out DB code from trusted user page
* Move DB code in tu.php and tu.php and tu_list.php to new functions in
accfuncs.inc.php
* Centralization of DB code important in a future transition to PDO interface

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:27:04 +02:00
canyonknight
8a59cd6208 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>
2012-07-06 11:27:03 +02:00
canyonknight
82d234c4d5 passreset.php: Pull out DB code
* Move DB code in passreset.php to new functions in acctfuncs.inc.php
* Centralization of DB code important in a future transition to PDO interface

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:27:00 +02:00
canyonknight
f93f1a652f logout.php: Pull out DB code
* Move DB code for removing a session in logout.php to a new function in
acctfuncs.inc.php
* Add ability for clear_expired_sessions function to check for DB connection
* Centralization of DB code important in a future transition to PDO interface

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:59 +02:00
canyonknight
71f2efd7af account_search_results.php: Pull out DB code
* Move DB code from account_search_results.php to already existing function
in acctfuncs.inc.php
* Centralization of DB code important in a future transition to PDO interface

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:54 +02:00
canyonknight
1eea2951fb addvote.php: Pull out DB code
* Verifying a username exists should use already present valid_user function
* Create new functions in acctfuncs.inc.php with SQL queries from addvote.php
* Centralization of DB code important in a future transition to PDO interface

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:51 +02:00
canyonknight
be0cf7f41f acctfuncs.inc.php: Move XHTML to account_search_results.php template
XHTML should be eliminated from lib/ as much as possible. This pulls the XHTML
out of a function that simply echoes the code, and moves it into a more
reasonable template file in account_search_results.php

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:34 +02:00
canyonknight
f78d46c654 acctfuncs.inc.php: Move XHTML to account_edit_form.php template
XHTML should be eliminated from lib/ as much as possible. This pulls the XHTML
out of a function that simply echoes the code, and moves it into a more
reasonable template file in account_edit_form.php

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-07-06 11:26:31 +02:00
canyonknight
2c93f0a98f Implement token system to fix CSRF vulnerabilities
Specially crafted pages can force authenticated users to unknowingly perform
actions on the AUR website despite being on an attacker's website. This
cross-site request forgery (CSRF) vulnerability applies to all POST data on
the AUR.

Implement a token system using a double submit cookie. Have a hidden form
value on every page containing POST forms. Use the newly added check_token() to
verify the token sent via POST matches the "AURSID" cookie value. Random
nature of the token limits potential for CSRF.

Signed-off-by: canyonknight <canyonknight@gmail.com>
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-06-24 10:59:23 +02:00
Lukas Fleischer
132856a938 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>
2012-03-24 10:34:35 +01:00
Lukas Fleischer
985795a210 Add field for PGP key in profile information
This is handy for verifying the PGP key of new Trusted Users. Also, this
could potentially used as a basis to allow signed package uploads in the
future.

Implements FS#29028.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
2012-03-24 10:34:32 +01:00
Lukas Fleischer
e53b91fe52 Escape wildcards in "LIKE" patterns
Percent signs ("%") and underscores ("_") are not escaped by
mysql_real_escape_string() and are interpreted as wildcards if combined
with "LIKE". Write a wrapper function db_escape_like() and use it where
appropriate.

Note that we already fixed this for the RPC interface in commit
da2ebb667b but missed the other places.
This patch should fix all remaining flaws reported in FS#26527.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-25 09:25:43 +02:00