The configuration file
The configuration file serves to both establish your settings and preferences and be a sort of autoloader for the system. When you include the configuration file, it will set your settings and load all the different classes of the system and initialize it.
Settings
The various settings you can use here are universal throughout the system and is your one stop for settings, you won't have to change anything inside the classes in the actual code.
MySQL settings
These settings are used to connect to your MySQL database and is used in most methods and is run in a construction of a PDO object everytime the UserSystem is initialized.
-
DB_PREFACE
This is any preface you would like for the tables created and used by the system. If you were to set this to beus_
(as is the default) each table would have that prepended to its name giving you something likeus_users
. -
DB_LOCATION
This is the address the MySQL server is located at. This will often times just belocalhost
(if so, change it fromlocalhost
to127.0.0.1
to force TCP), but you can use remote servers here as well; whether it be an IP address or an actual domain, it just needs to work in a PDO DSN. -
DB_USERNAME
This is the username used to access your MySQL server. The default isroot
but you could have other users set up as well. -
DB_PASSWORD
This is the password used with the username to access your MySQL server. By default there is no password set forroot
, but you may have a password set forroot
or for your own user. -
DB_DATABASE
This is the database that will be used to hold your tables. You will have to create a table or use an existing one, the recommended one isus
and that will keep the UserSystem tables and data separate from the rest of your site's information, but it can work just as well if the UserSystem tables are bunched in with many other of your own tables. When you run the setup file the system will attempt to create this database if it doesn't exist; however it will not attempt to create the database when you construct the UserSystem. Therefore, if you want to use a different database for just a few lines of script, you'll need to initialize an intentionally empty UserSystem (new UserSystem ("")
), create the database ($UserSystem->DATABASE->query("CREATE DATABASE test")
), and then use that database with a new initialization of UserSystem (new UserSystem ("test")
).
URL settings
These settings are used in displaying links to your users, setting cookies for your site, and can be used by you in your code avoiding hard links to the UserSystem location.
-
SITENAME
This is the name of your website, it is used in sentences likeYour password has changed on SITENAME
and is used to name the cookie$_COOKIE[SITENAME]
so it just needs to be letters and numbers, no spaces. For example, if your site wasThe Face Magazine
you may want to useFaceMagazine
, that will make cookies function, and avoid looking terrible. -
URL_PREFACE
This is the protocol used in links to your site. This is used exclusively in displaying links to your users like this:URL_PREFACE://example.com
. -
DOMAIN_SIMPLE
This is the root URL of your entire website. This is used for the creation (and destruction) of cookies; it needs to be the root URL so that if your UserSystem is onaccounts.example.com
your users can stay logged in even if they are later usingexample.com
orblog.example.com
. -
DOMAIN
This is the URL to where the UserSystem resides. If you have the UserSystem onaccounts.example.com
your would want to put exactly that for this setting. This is used just for displaying links to your users such as:URL_PREFACE://DOMAIN/activate-your-account
. -
ACTIVATE_PG
The location of the page you set up for user activation relative to theDOMAIN
setting. This is only used for displaying links to users like this:URL_PREFACE://DOMAIN/ACTIVATE_PG
. So if your activation script isactivate.php
then you'll use exactly that; if your activation script is/activate/index.php
you can simply putactivate
for this setting. -
RECOVERY_PG
This is the same as theACTIVATE_PG
setting, but for the user account recovery script. -
TWOSTEP_PG
This is the same as theACTIVATE_PG
setting, but for the script to finish logging users in if they have two step authentication enabled.
Extra settings
These settings are for extra features that aren't even required to be changed for the system to work just as you'd like
-
ENCRYPTION
This is just a boolean of whether or not your would like the system to encrypt some of your users' data in the MySQL tables with AES encryption. -
RECAPTCHA_LEVEL
(Not currently employed) This is an integer between 0 and 3 (inclusive: 0, 1, 2, or 3) that dictates how often reCAPTCHAs come up for users. 0 = never; 1 = at registration; 2 = registration + logging in; 3 = registration + login + setting changes.
The following settings are only even necessary if you turned on the previous setting.
-
RECAPTCHA_SITE_KEY
(Not currently employed, is environment variable, so you could set it elsewhere) This is your site key from reCAPTCHA. This is only necessary if you setRECAPTHCA_LEVEL
to >= 1. -
RECAPTCHA_SECRET
(Not currently employed, is environment variable, so your could set it elsewhere) This is your secret key from reCAPTCHA. This is only necessary if you setRECAPTCHA_LEVEL
to >= 1.
Loader
Once your settings are all set, the file then includes the 3 parts of the UserSystem: Utils (base functions for the system), Database (the database functions for the system), and UserSystem (all the other functions for users) and (unless you're currently running tests with the system) starts an instance of the UserSystem in the $UserSystem
variable using all your default options.