Core Boxx – Users Module

 

 

 

SECTION A

DOWNLOAD & LICENSE

Download Core Boxx Users ModuleSource Forge

Core Boxx is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

 

SECTION B

INSTALLATION

Download and set up the “main Core Boxx” if you have not already done so. Then, create your database and import users.sql… Remember to delete this file afterward, that’s all.

 

 

SECTION C

WHAT IS THIS MODULE?

This is a simple user’s module for Core Boxx – With a predefined user table, library, and API. Simply plug this one into Core Boxx, and you get a user system out-of-the-box… Minus the HTML/CSS/Javascript, that is.

 

SECTION D

THE USER TABLE

Field Description
user_id Primary key. The user ID.
user_name The user’s name.
user_email The user’s email address, unique to prevent multiple registrations.
user_password The user’s password.

 

SECTION E

USER LIBRARY FUNCTIONS

Function Description & Quick Example
save($name, $email, $password, $id) Add a new user, or update an existing user.

  • $name String, the user name.
  • $emailString, the user email.
  • $password String, the user’s password, in cleartext.
  • $id Int, pass in the user ID if you want to update an existing user.
echo $_CORE->Users->save(
  "John Doe", "john@doe.com", "PASSWORD"
) ? "OK" : $_CORE->error ;
del($id) Deletes a user.

  • $id Int, the user ID.
echo $_CORE->Users->del(999) ? "OK" : $_CORE->error ;
get($id) Get a user by ID or email.

  • $id Int OR string, the user ID or email.
$user = $_CORE->Users->get(999);
$user = $_CORE->Users->get("john@doe.com");
search($search) Search for a user by email or name.

  • $search – String, search term.
$results = $_CORE->Users->search("jo");
getAll() Get all users.

$users = $_CORE->Users->getAll();
verify($email, $password, $session) Verify the given email and password, mostly used for security checks and login sequence.

  • $email – String, email.
  • $password – String, password.
  • $session – Boolean, register user into $_SESSION['user'] on verification?
$verified = $_CORE->Users->verify(
  "john@doe.com", "PASSWORD"
);

 

 

SECTION F

USER API FUNCTIONS

Accessible at http://yoursite.com/api/users/REQUEST/ and http://yoursite.com/api/session/REQUEST/. These are pretty much a replica of the above library functions, except in REST API format. Feel free to delete api/users.php if you don’t intend to integrate an API.

API/USERS/
Request Description & Parameters
get Get a user by ID or email.

  • $_POST['id'] – Int or string, user ID or email.
getAll Get all users.
search Search users by name or email.

  • $_POST['search'] – String, search term.
save Add or update the user.

  • $_POST['name'] String, the user name.
  • $_POST['email'] String, the user email.
  • $_POST['password'] String, the user’s password, in cleartext.
  • $_POST['level'] String, user-level (“U”ser, “A”dmin, “E”ditor, etc…)
  • $_POST['id'] Int, optional. Pass in the user ID to update instead of insert.
del Delete a user.

  • $_POST['id'] Int, the user ID.
API/SESSION/
login Process user login – Take note, enable session_start() in the core, or start the session somewhere before processing this.

  • $_POST['email'] String, the email.
  • $_POST['password'] String, the password.
logoff Process user logoff.

Leave a Comment

Your email address will not be published. Required fields are marked *