class user extends session
Base user class
This is the overarching class which contains (through session extend) all methods utilised for user functionality during a session.
Properties
$cookie_data | ||
$page | ||
$data | ||
$browser | ||
$forwarded_for | ||
$host | ||
$session_id | ||
$ip | ||
$load | ||
$time_now | ||
$update_session_page | ||
$lang | ||
$help | ||
$theme | ||
$date_format | ||
$timezone | ||
$dst | ||
$lang_name | ||
$lang_id | ||
$lang_path | ||
$img_lang | ||
$img_array | ||
$keyoptions |
Methods
extract_current_page(string $root_path)
Extract current session page |
from session | |
extract_current_hostname()
Get valid hostname/port. |
from session | |
session_begin(bool $update_session_page = true)
Start session management |
from session | |
session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
Create a new session |
from session | |
session_kill($new_session = true)
Kills a session |
from session | |
session_gc()
Session garbage collection |
from session | |
set_cookie(string $name, string $cookiedata, int $cookietime)
Sets a cookie |
from session | |
check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
Check for banned user |
from session | |
false |
check_dnsbl($mode, $ip = false)
Check if ip is blacklisted This should be called only where absolutly necessary |
from session |
set_login_key($user_id = false, $key = false, $user_ip = false)
Set/Update a persistent login key |
from session | |
reset_login_keys($user_id = false)
Reset all login keys for the specified user |
from session | |
validate_referer(bool $check_script_path = false)
Check if the request originated from the same page. |
from session | |
unset_admin()
|
from session | |
user()
Constructor to set the lang path |
||
set_custom_lang_path(string $lang_path)
Function to set custom language path (able to use directory outside of phpBB) |
||
setup($lang_set = false, $style = false)
Setup basic user-specific items (style, language, ...) |
||
lang()
More advanced language substitution Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms. |
||
add_lang(mixed $lang_set, bool $use_db = false, bool $use_help = false)
Add Language Items - usedb and usehelp are assigned where needed (only use them to force inclusion) |
||
set_lang($lang, $help, $lang_file, $use_db = false, $use_help = false)
Set language entry (called by add_lang) |
||
mixed |
format_date(int $gmepoch, string $format = false, bool $forcedate = false)
Format user date |
|
get_iso_lang_id()
Get language id currently used by the user |
||
get_profile_fields($user_id)
Get users profile fields |
||
img($img, $alt = '', $width = false, $suffix = '', $type = 'full_tag')
Specify/Get image $suffix is no longer used - we know it. |
||
bool |
optionget(int $key, int $data = false)
Get option bit field from user options. |
|
int|bool |
optionset(int $key, bool $value, int $data = false)
Set option bit field for user options. |
|
leave_newly_registered()
Funtion to make the user leave the NEWLY_REGISTERED system group. |
||
array |
get_passworded_forums()
Returns all password protected forum ids the user is currently NOT authenticated for. |
Details
in session at line 42
public
extract_current_page(string $root_path)
Extract current session page
in session at line 144
public
extract_current_hostname()
Get valid hostname/port.
HTTPHOST is used, SERVERNAME if HTTP_HOST not present.
in session at line 208
public
session_begin(bool $update_session_page = true)
Start session management
This is where all session activity begins. We gather various pieces of information from the client and server. We test to see if a session already exists. If it does, fine and dandy. If it doesn't we'll go on to create a new one ... pretty logical heh? We also examine the system load (if we're running on a system which makes such information readily available) and halt if it's above an admin definable limit.
in session at line 490
public
session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true)
Create a new session
If upon trying to start a session we discover there is nothing existing we jump here. Additionally this method is called directly during login to regenerate the session for the specific user. In this method we carry out a number of tasks; garbage collection, (search)bot checking, banned user comparison. Basically though this method will result in a new session for a specific user.
in session at line 884
public
session_kill($new_session = true)
Kills a session
This method does what it says on the tin. It will delete a pre-existing session. It resets cookie information (destroying any autologin key within that cookie data) and update the users information from the relevant session data. It will then grab guest user information.
in session at line 963
public
session_gc()
Session garbage collection
This looks a lot more complex than it really is. Effectively we are deleting any sessions older than an admin definable limit. Due to the way in which we maintain session data we have to ensure we update user data before those sessions are destroyed. In addition this method removes autologin key information that is older than an admin defined limit.
in session at line 1048
public
set_cookie(string $name, string $cookiedata, int $cookietime)
Sets a cookie
Sets a cookie of the given name with the specified data for the given length of time. If no time is specified, a session cookie will be set.
in session at line 1069
public
check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false)
Check for banned user
Checks whether the supplied user is banned by id, ip or email. If no parameters are passed to the method pre-existing session data is used. If $return is false this routine does not return on finding a banned user, it outputs a relevant message and stops execution.
in session at line 1265
public false
check_dnsbl($mode, $ip = false)
Check if ip is blacklisted This should be called only where absolutly necessary
Only IPv4 (rbldns does not support AAAA records/IPv6 lookups)
in session at line 1362
public
set_login_key($user_id = false, $key = false, $user_ip = false)
Set/Update a persistent login key
This method creates or updates a persistent session key. When a user makes use of persistent (formerly auto-) logins a key is generated and stored in the DB. When they revisit with the same key it's automatically updated in both the DB and cookie. Multiple keys may exist for each user representing different browsers or locations. As with any non-secure-socket no passphrase login this remains vulnerable to exploit.
in session at line 1409
public
reset_login_keys($user_id = false)
Reset all login keys for the specified user
This method removes all current login keys for a specified (or the current) user. It will be called on password change to render old keys unusable
in session at line 1458
public
validate_referer(bool $check_script_path = false)
Check if the request originated from the same page.
in session at line 1495
public
unset_admin()
at line 1535
public
user()
Constructor to set the lang path
at line 1548
public
set_custom_lang_path(string $lang_path)
Function to set custom language path (able to use directory outside of phpBB)
at line 1561
public
setup($lang_set = false, $style = false)
Setup basic user-specific items (style, language, ...)
at line 1949
public
lang()
More advanced language substitution Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms.
Params are the language key and the parameters to be substituted. This function/functionality is inspired by SHS` and Ashe.
Example call: $user->lang('NUMPOSTSIN_QUEUE', 1);
at line 2038
public
add_lang(mixed $lang_set, bool $use_db = false, bool $use_help = false)
Add Language Items - usedb and usehelp are assigned where needed (only use them to force inclusion)
at line 2079
public
set_lang($lang, $help, $lang_file, $use_db = false, $use_help = false)
Set language entry (called by add_lang)
at line 2157
public mixed
format_date(int $gmepoch, string $format = false, bool $forcedate = false)
Format user date
at line 2229
public
get_iso_lang_id()
Get language id currently used by the user
at line 2256
public
get_profile_fields($user_id)
Get users profile fields
at line 2277
public
img($img, $alt = '', $width = false, $suffix = '', $type = 'full_tag')
Specify/Get image $suffix is no longer used - we know it.
;) It is there for backward compatibility.
at line 2367
public bool
optionget(int $key, int $data = false)
Get option bit field from user options.
at line 2385
public int|bool
optionset(int $key, bool $value, int $data = false)
Set option bit field for user options.
at line 2413
public
leave_newly_registered()
Funtion to make the user leave the NEWLY_REGISTERED system group.
at line 2445
public array
get_passworded_forums()
Returns all password protected forum ids the user is currently NOT authenticated for.