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.
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.
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_PREFACEThis is any preface you would like for the tables created and used by the system. If you were to set this to be
us_(as is the default) each table would have that prepended to its name giving you something like
DB_LOCATIONThis is the address the MySQL server is located at. This will often times just be
localhost(if so, change it from
127.0.0.1to 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_USERNAMEThis is the username used to access your MySQL server. The default is
rootbut you could have other users set up as well.
DB_PASSWORDThis is the password used with the username to access your MySQL server. By default there is no password set for
root, but you may have a password set for
rootor for your own user.
DB_DATABASEThis 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 is
usand 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")).
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.
SITENAMEThis is the name of your website, it is used in sentences like
Your password has changed on SITENAMEand is used to name the cookie
$_COOKIE[SITENAME]so it just needs to be letters and numbers, no spaces. For example, if your site was
The Face Magazineyou may want to use
FaceMagazine, that will make cookies function, and avoid looking terrible.
URL_PREFACEThis is the protocol used in links to your site. This is used exclusively in displaying links to your users like this:
DOMAIN_SIMPLEThis 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 on
accounts.example.comyour users can stay logged in even if they are later using
DOMAINThis is the URL to where the UserSystem resides. If you have the UserSystem on
accounts.example.comyour would want to put exactly that for this setting. This is used just for displaying links to your users such as:
ACTIVATE_PGThe location of the page you set up for user activation relative to the
DOMAINsetting. This is only used for displaying links to users like this:
URL_PREFACE://DOMAIN/ACTIVATE_PG. So if your activation script is
activate.phpthen you'll use exactly that; if your activation script is
/activate/index.phpyou can simply put
activatefor this setting.
RECOVERY_PGThis is the same as the
ACTIVATE_PGsetting, but for the user account recovery script.
TWOSTEP_PGThis is the same as the
ACTIVATE_PGsetting, but for the script to finish logging users in if they have two step authentication enabled.
These settings are for extra features that aren't even required to be changed for the system to work just as you'd like
ENCRYPTIONThis 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 set
RECAPTHCA_LEVELto >= 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 set
RECAPTCHA_LEVELto >= 1.
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.