Word Lists Nouns - warwickfoster/qurantools GitHub Wiki
app/library/database/user_functions.php
File:Purpose
The code snippet provides a collection of functions for managing user data in a database. The functions allow users to create, update, and retrieve user information, as well as handle login attempts and account locking.
Key Functions
- update_user_by_id Updates a user's information based on the provided column values.
- increment_fail_count_and_time Increments the user's failed login count and sets the last failure time.
- is_lock_time_passed Checks if enough time has elapsed since the user was last locked.
- get_user_by_id Retrieves a user's information based on their user ID.
- update_user Updates a user's information based on the provided column values.
- is_start_of_turn Determines if the current time is the start of a new turn.
Database Table
The functions assume the existence of a USERS
table with the following columns:
- User ID
- User Name
- First Name
- Last Name
- Email Address
- Password
- Fails Count
- Fail Time
Usage
The functions can be used to perform various tasks, such as:
- Creating a new user account.
- Logging in a user.
- Locking an account after multiple failed login attempts.
- Resetting a user's password.
Additional Notes
- The functions use prepared statements to prevent SQL injection attacks.
- The code includes error handling and rollback functionality in case of database errors.
- The
generate_user_name()
function is not included in the code snippet and should be implemented separately. - The account lock time is defined by the
ACCOUNT_LOCK_TIME_MINUTES
constant.
Conclusion
The code snippet provides a comprehensive set of functions for managing user data in a database. The functions are well-written and secure, and they can be easily integrated into an application.