Class: DpUniverse
SOURCE LOCATION: /lib/dpuniverse.php
Class Overview
|
A DutchPIPE universe, handling objects, users, pages, etc. (rules of nature)
|
METHODS:
|
Methods Summary
| DpUniverse |
__construct() |
Constructs this universe based on a universe ini file |
| void |
addAlertEvent() |
Adds a user to the listener list of the given event |
| mixed |
&findDpObject() |
Finds an object in the universe with the given unique id |
| object|boolean |
&findUser() |
Finds the user with the given user name or id. |
| array |
&getAlertEvent() |
Gets list of listening users to the given event |
| object Reference |
&getDpObject() |
Finds or makes an object in the universe with the given pathname |
| integer |
getGuestCnt() |
Gets an unique suffix to make Guest#x names |
| array |
getObjectList() |
Gets a list of all objects in this DutchPIPE universe |
| int |
getRandAvatarNr() |
Gets a random avatar image number in order to give guests an avatar |
| int |
getRandCaptcha() |
Gets db row key of a random CAPTCHA code for the user registration page |
| array |
&getUsers() |
Gets an array with user object references of all users on this site |
| void |
logoutUser() |
Logs out a given registered user and turns the user into a guest |
| object The |
&newDpObject() |
Creates a new object in the universe |
| void |
removeAlertEvent() |
Removes a user from the listener list of the given event |
| void |
validateCaptcha() |
Attempts the second step in registering a new user, validates CAPTCHA |
| boolean |
validateCaptcha2() |
Validates a given CAPTCHA code against the code in the database |
| boolean |
validateExisting() |
Attempts to login the given user object of a guest as a registered user |
| boolean |
validateNewUser() |
Attempts the first step in registering a new user, throws CAPTCHA |
Methods
Constructor __construct [line 178]
DpUniverse __construct(
[string
$iniFile = 'dpuniverse-ini.php']
)
Constructs this universe based on a universe ini file
| PARAMETERS: |
string |
$iniFile |
path to settings file for this universe |
addAlertEvent [line 1755]
void addAlertEvent(
string
$event , string
&$who
)
Adds a user to the listener list of the given event
| PARAMETERS: |
string |
$event |
Name of the event |
| string |
&$who |
User listening to event |
mixed &findDpObject(
string
$unique_id
)
Finds an object in the universe with the given unique id
| PARAMETERS: |
string |
$unique_id |
the object's unique string id |
| RETURNS: | mixed | Object reference if found, FALSE otherwise |
object|boolean &findUser(
string
$userName
)
Finds the user with the given user name or id.
| PARAMETERS: |
string |
$userName |
user name or id of player |
| RETURNS: | object|boolean | the found player or FALSE if not found |
getAlertEvent [line 1789]
array &getAlertEvent(
string
$event
)
Gets list of listening users to the given event
| PARAMETERS: |
string |
$event |
Name of the event |
| RETURNS: | array | Users listening to event |
object Reference &getDpObject(
string
$pathname , [string
$sublocation = FALSE]
)
Finds or makes an object in the universe with the given pathname
If an object with the given pathname exists, a reference to that object is returned. Otherwise a new instance of the class found at $pathname is created and returned. The object can have a unique location, given with $pathname, or just be based on $pathname, with a sublocation handling multiple objects. For example, the URL in uour browser contains the following bit for the DutchPIPE "about" page: location=/page/about.php It is a unique page with a unique location. The manual however is not based on many unique locations, but just one object which spawns pages based on the sublocation given in the URL: location=/page/manual.php&sublocation=index.html
| PARAMETERS: |
string |
$pathname |
a path within dpuniverse/ |
| string |
$sublocation |
optional sublocation |
| RETURNS: | object Reference | to instance of $pathname |
| SEE: | DpUniverse::newDpObject() |
integer getGuestCnt(
)
Gets an unique suffix to make Guest#x names
| RETURNS: | integer | A unique number, currently a counter |
getNrOfAvatars [line 1704]
int getNrOfAvatars(
)
Gets the available number of avatars images
Searches the DPUNIVERSE_AVATAR_STD_PATH directory for files ending with "_body.gif".
int getNrOfUsers(
)
Gets the number of users on this site
| RETURNS: | int | number of users on this site |
getObjectList [line 1834]
array getObjectList(
)
Gets a list of all objects in this DutchPIPE universe
| RETURNS: | array | A list of all objects in this DutchPIPE universe |
| SEE: | DpUser::actionOblist() |
| SINCE: | DutchPIPE 0.4.0 |
getRandAvatarNr [line 1686]
int getRandAvatarNr(
)
Gets a random avatar image number in order to give guests an avatar
Checks the avatar image directory for images with the format: public/avatar/user<number>.gif for possible numbers.
getRandCaptcha [line 717]
int getRandCaptcha(
)
Gets db row key of a random CAPTCHA code for the user registration page
Used to seperate software robots from real people during registration. Codes aren't generated on the fly and as such not really random because the CPU time penalty is too high. A directory with pre-generated codes exists and a database table with info. A cronjob makes one every hour and replaces the oldest one in the database. Then we obtain a random entry here. This should do it for now, but your milleague might vary and the situation might change as spambots get smarter.
| RETURNS: | int | CAPTCHA database row key |
getUniverseInfo [line 1223]
array getUniverseInfo(
)
Gets an array with information about the universe
The following array is returned: array( 'memory_usage' : <int Universe memory usage in bytes> 'nr_of_objects' : <int Number of objects in the universe> 'nr_of_users' : <int Number of users in the universe> 'nr_of_environments' : <int Number of environments in the universe> 'nr_of_timeouts' : <int Number of "timeouts" in the universe> );
| RETURNS: | array | universe information |
array &getUsers(
)
Gets an array with user object references of all users on this site
| RETURNS: | array | user object references of all users |
handleCurrentDpUserRequest [line 237]
void handleCurrentDpUserRequest(
[array
&$rDpServer = NULL] , [array
&$rServerVars = NULL] , [array
&$rSessionVars = NULL] , [array
&$rCookieVars = NULL] , [array
&$rGetVars = NULL] , [array
&$rPostVars = NULL] , [array
&$rFilesVars = NULL]
)
Handles user requests passed on from the DutchPIPE server
Called each time a user's browser does a normal page or AJAX request. Several variables are passed which represent their corresponding PHP global arrays: $_SERVER, $_COOKIE, etc.
| PARAMETERS: |
array |
&$rDpServer |
Reference to the server object |
| array |
&$rServerVars |
User server variables |
| array |
&$rSessionVars |
User session variables |
| array |
&$rCookieVars |
User cookie variables |
| array |
&$rGetVars |
User get variables |
| array |
&$rPostVars |
User post variables |
| array |
&$rFilesVars |
User files variables |
void logoutUser(
object
&$user
)
Logs out a given registered user and turns the user into a guest
| PARAMETERS: |
object |
&$user |
user to logout |
object The &newDpObject(
string
$pathname , [string
$sublocation = FALSE]
)
Creates a new object in the universe
You MUST call this function to create new objects in a DutchPIPE universe, don't use the 'new' construct directly. The object can have a unique location, given with $pathname, or just be based on $pathname, with a sublocation handling multiple objects. For example, the URL in uour browser contains the following bit for the DutchPIPE "about" page: location=/page/about.php It is a unique page with a unique location. The manual however is not based on many unique locations, but just one object which spawns pages based on the sublocation given in the URL: location=/page/manual.php&sublocation=index.html
| PARAMETERS: |
string |
$pathname |
path to code from universe base path |
| string |
$sublocation |
optional sublocation |
| RETURNS: | object The | newly created object |
removeAlertEvent [line 1772]
void removeAlertEvent(
string
$event , string
&$who
)
Removes a user from the listener list of the given event
| PARAMETERS: |
string |
$event |
Name of the event |
| string |
&$who |
User listening to event |
showStatusMemoryGetUsage [line 1810]
void showStatusMemoryGetUsage(
)
Shows a line with memory and universe info
validateCaptcha [line 1463]
void validateCaptcha(
object
&$user
)
Attempts the second step in registering a new user, validates CAPTCHA
| PARAMETERS: |
object |
&$user |
user to register |
validateCaptcha2 [line 1568]
boolean validateCaptcha2(
string
$captchaId , string
$captchaGivenCode
)
Validates a given CAPTCHA code against the code in the database
| PARAMETERS: |
string |
$captchaId |
Captcha id given by the validation form |
| string |
$captchaGivenCode |
User input |
| RETURNS: | boolean | TRUE if the given code was valid, FALSE otherwise |
validateExisting [line 1248]
boolean validateExisting(
object
&$user
)
Attempts to login the given user object of a guest as a registered user
| PARAMETERS: |
object |
&$user |
user to validate |
| RETURNS: | boolean | TRUE for succesful login, FALSE otherwise |
validateNewUser [line 1421]
boolean validateNewUser(
object
&$user
)
Attempts the first step in registering a new user, throws CAPTCHA
| PARAMETERS: |
object |
&$user |
user to register |
| RETURNS: | boolean | TRUE to continue to CAPTCHA, FALSE for errors |
|
|