Andrew's Web Libraries (AWL)
|
Public Member Functions | |
__construct ( $sid="") | |
Log ( $whatever) | |
Dbg ( $whatever) | |
AllowedTo ( $whatever) | |
GetRoles () | |
AssignSessionDetails ( $u) | |
Login ( $username, $password, $authenticated=false) | |
RenderLoginPanel () | |
LoginRequired ( $groups="") | |
EmailTemporaryPassword ( $username, $email_address, $body_template="") | |
SendTemporaryPassword () | |
_CheckLogin () | |
FormattedDate ( $indate, $type='date') | |
BuildConfirmationHash ( $method, $varname) | |
CheckConfirmationHash ( $method, $varname) | |
Static Public Member Functions | |
static | _CheckLogout () |
Public Attributes | |
$roles | |
$cause = '' | |
$user_no | |
$session_id = 0 | |
$username = 'guest' | |
$fullname = 'Guest' | |
$email = '' | |
$logged_in = false | |
$just_logged_in = false | |
$last_session_start | |
$last_session_end | |
Definition at line 58 of file Session.php.
Session::__construct | ( | $sid = "" | ) |
#- Create a new Session object.
If a session identifier is supplied, or we can find one in a cookie, we validate it and consider the person logged in. We read some useful session and user data in passing as we do this.
The session identifier contains a random value, hashed, to provide validation. This could be hijacked if the traffic was sniffable so sites who are paranoid about security should only do this across SSL.
A worthwhile enhancement would be to add some degree of external configurability to that read.
string | $sid | A session identifier. |
We regularly want to override the SQL for joining against the session record. so the calling application can define a function local_session_sql() which will return the SQL to join (up to and excluding the WHERE clause. The standard SQL used if this function is not defined is: SELECT session.*, usr.* FROM session JOIN usr ON ( user_no )
Definition at line 145 of file Session.php.
Session::_CheckLogin | ( | ) |
The authentication has happened in the server, and we should accept it if so.
Definition at line 717 of file Session.php.
Session::AllowedTo | ( | $whatever | ) |
Checks whether a user is allowed to do something.
The check is performed to see if the user has that role.
string | $whatever | The role we want to know if the user has. |
Definition at line 264 of file Session.php.
Session::AssignSessionDetails | ( | $u | ) |
Internal function used to assign the session details to a user's new session.
object | $u | The user+session object we (probably) read from the database. |
Definition at line 287 of file Session.php.
Session::BuildConfirmationHash | ( | $method, | |
$varname | |||
) |
Build a hash which we can use for confirmation that we didn't get e-mailed a bogus link by someone, and that we actually got here by traversing the website.
string | $method | Either 'GET' or 'POST' depending on the way we will use this. |
string | $varname | The name of the variable which we will confirm |
We include session_start in this because it is never passed to the client and since it includes microseconds would be very hard to predict.
Definition at line 794 of file Session.php.
Session::CheckConfirmationHash | ( | $method, | |
$varname | |||
) |
Check a hash which we created through BuildConfirmationHash
string | $method | Either 'GET' or 'POST' depending on the way we will use this. |
string | $varname | The name of the variable which we will confirm |
Definition at line 817 of file Session.php.
Session::Dbg | ( | $whatever | ) |
DEPRECATED Utility function to log debug stuff with printf expansion, and the ability to enable it selectively.
The enabling is done by setting a variable "$debuggroups[$group] = 1"
string | $group | The name of an arbitrary debug group. |
string | $whatever | A log string |
mixed | $whatever,... | Further parameters to be replaced into the log string a la printf |
Definition at line 233 of file Session.php.
Session::EmailTemporaryPassword | ( | $username, | |
$email_address, | |||
$body_template = "" |
|||
) |
E-mails a temporary password in response to a request from a user.
This could be called from somewhere within the application that allows someone to set up a user and invite them.
This function includes EMail.php to actually send the password.
Definition at line 535 of file Session.php.
Session::FormattedDate | ( | $indate, | |
$type = 'date' |
|||
) |
Function to reformat an ISO date to something nicer and possibly more localised
string | $indate | The ISO date to be formatted. |
string | $type | If 'timestamp' then the time will also be shown. |
Definition at line 754 of file Session.php.
Session::GetRoles | ( | ) |
Internal function used to get the user's roles from the database.
Definition at line 272 of file Session.php.
Session::Log | ( | $whatever | ) |
DEPRECATED Utility function to log stuff with printf expansion.
This function could be expanded to log something identifying the session, but somewhat strangely this has not yet been done.
string | $whatever | A log string |
mixed | $whatever,... | Further parameters to be replaced into the log string a la printf |
Definition at line 203 of file Session.php.
Session::Login | ( | $username, | |
$password, | |||
$authenticated = false |
|||
) |
Attempt to perform a login action.
This will validate the user's username and password. If they are OK then a new session id will be created and the user will be cookied with it for subsequent pages. A logged in session will be created, and the $_POST array will be cleared of the username, password and submit values. submit will also be cleared from $_GET and $GLOBALS, just in case.
string | $username | The user's login name, or at least what they entered it as. |
string | $password | The user's password, or at least what they entered it as. |
string | $authenticated | If true, then authentication has already happened and the password is not checked, though the user must still exist. |
In case someone is running with register_globals on
The authenticate hook needs to:
Definition at line 316 of file Session.php.
Session::LoginRequired | ( | $groups = "" | ) |
Checks that this user is logged in, and presents a login screen if they aren't.
The function can optionally confirm whether they are a member of one of a list of groups, and deny access if they are not a member of any of them.
string | $groups | The list of groups that the user must be a member of one of to be allowed to proceed. |
Definition at line 485 of file Session.php.
Session::RenderLoginPanel | ( | ) |
Renders some HTML for a basic login panel
Definition at line 433 of file Session.php.
Session::SendTemporaryPassword | ( | ) |
Sends a temporary password in response to a request from a user.
This is probably only going to be called from somewhere internal. An external caller will probably just want the e-mail, without the HTML that this displays.
Definition at line 627 of file Session.php.
Session::$roles |
#+ @access private
Definition at line 63 of file Session.php.