A complete user-management system for PHP apps
Warning This repository is no longer maintained!
For more info, see Project Update and Alternatives ↓
Contents
User Monkey is a plug-and-play complete user-management system written in PHP and bundled into a single file. It enables you to easily add support for features where user sign up is required, such as posts/ comments, paywalled content, saving preferences, spam reduction, etc. All the commonly required features are included as standard and there's also an optional UI.
- Registration
- Log in / Log out
- Account Deletion
- Password Resets
- Account Verification
- Editing Account Info
- Link Social Media Accounts
- Gravatar Picture Support
There's also an optional UI, which includes the screens for all the above opperations (registration, authentication, profile page, account settings, etc)
A live demo of the running project can be viewed at: code.as93.net/user-monkey (demo no longer available)
This app was developed in 2010-12, and used across several of my apps, and other peoples projects for almost 10 years after. It served it's purpose as a simple single-file user-management system, but times have moved on, and there are now some much better alternatives out there. I strongly recommend against using this project in any production application.
If your looking for a PHP-based user management system, I'd recomend either UserFrosting or UserSpice. Both are widley used, fully tested, clearly documented and serve their purpose well.
/* First start a session, if not already started */
if(session_id() == '') { session_start(); }
/* Next include the PHP classes (see demo folder for Db class)*/
include_once $_SERVER['DOCUMENT_ROOT']."/user-monkey/php/Db.class.php"; // Database Class
include_once $_SERVER['DOCUMENT_ROOT']."/user-monkey/php/UserActions.class.php";// User Actions Class
/* Connect to the database */
$db = new Db();
$db->connect();
/* Create an instance of the UserActions class */
$ua = new UserActions();
$register = new Register();
$success = $register->registerUser($username,$email,$password,"standard");
$logIn = new Login();
$success = $logIn->start($username, $password);
$ua = new UserActions();
$ua->logOut();
$settings = new UserActions();
$success = $settings->resetPassword($userId, $password);
$settings = new UserSettings();
$success = $settings->changeEmail($userId, $password, $email);
$settings = new UserSettings();
$success = $settings->changeUsername($userId, $password, $username);
$settings = new UserSettings();
$success = $settings->deleteAccount($userId, $password);
$activationObject = new VerifyAccount($userId);
$activationObject->setUrl("http://example.com");
$activationObject->sendActivationEmail();
$act = new VerifyAccount($userId);
$success = $act->attemptActivate($code);
If $success
is false, then the $object->getMessage();
method can be called that will return a short string informing why the action could not be completed (e.g. "Unable to create account - username already taken"). For example:
$register = new Register();
$success = $register->registerUser($username,$email,$password,"standard");
if(!$success){
echo $register->getMessage();
}
There is an optional UI included (see source). It's themable, but here's some screenshots of it running...
Contributions are welcome :)
Changes can be submitted by opening a pull request - if you're new to GitHub, see the documentation for a step-by-step guide on how to submit edits to projects. All submissions must abide by the Contributor Covenant Code of Conduct.
User Monkey is licensed under MIT © Alicia Sykes 2012-22.
For information, see TLDR Legal > MIT
Expand MIT License
The MIT License (MIT)
Copyright (c) Alicia Sykes <alicia@omg.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sub-license, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included install
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANT ABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
© Alicia Sykes 2012
Licensed under MIT
Thanks for visiting :)