Core Boxx – Users 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.

 

TABLE OF CONTENTS

Download & Notes Quick Reference

 

 

DOWNLOAD & NOTES

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

DOWNLOAD LINKS

Download Core Boxx Users Module | GitHubSource Forge

 

LICENSE

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.

 

 

INSTALLATION & REQUIREMENTS

  • Download and set up the “main Core Boxx” if you have not already done so.
  • Import lib/SQL-users.sql into your database.

 

QUICK REFERENCE

This section is a quick walkthrough of the general module structures.

 

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.

 

USER LIBRARY FUNCTIONS

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");
count($search)

Get a count of the number of user entries (mostly for listing and pagination).

  • $search String, optional name/email search.
$entries = $_CORE->Users->count("john");
getAll($search, $page)

Get all or search for users.

  • $search String, optional name/email search.
  • $page Integer, current page number.
$users = $_CORE->Users->getAll("jo", 3);
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"
);

 

 

USER API FUNCTIONS

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

api/users/get/

Get a user by ID or email.

  • $_POST['id'] – Int or string, user ID or email.
api/users/getAll/

Get all or search for users.

  • $_POST['search'] – String, optional name/email.
  • $_POST['page'] – Int, optional current page number.
api/users/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.
api/users/del/

Delete a user.

  • $_POST['id'] Int, the user ID.

 

SESSION API FUNCTIONS

Accessible at http://yoursite.com/api/session/REQUEST/.

api/session/login/ or api/session/logon/

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.
api/users/logoff/ or api/users/logout/

Process user logoff.

Leave a Comment

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