Constants

DATABASE_HOST

DATABASE_HOST

DATABASE_USERNAME

DATABASE_USERNAME

DATABASE_PASSWORD

DATABASE_PASSWORD

DATABASE_NAME

DATABASE_NAME

SESSION_NAME

SESSION_NAME

SESSION_FINGERPRINT

SESSION_FINGERPRINT

SESSION_USER_ID

SESSION_USER_ID

SESSION_CHAR_ID

SESSION_CHAR_ID

SESSION_IS_GM

SESSION_IS_GM

MSG_MALFORMED_QUERY

MSG_MALFORMED_QUERY

MSG_SESSION_COLLISION

MSG_SESSION_COLLISION

GENDER_MALE

GENDER_MALE

GENDER_FEMALE

GENDER_FEMALE

Properties

$Instance

$Instance : \PerfectWorldAPI

Singleton instance of PerfectWorldAPI

Type

\PerfectWorldAPI

$_database

$_database : \MonkeyDatabase

Instance of MonkeyDatabase

Type

\MonkeyDatabase

$_userData

$_userData : 

Type

$_charData

$_charData : 

Type

Methods

__construct()

__construct() : void

Class constructor

Instance()

Instance() : \PerfectWorldAPI

Returns singleton instance of class

Returns

\PerfectWorldAPI

PrintSessionDebugData()

PrintSessionDebugData() : void

Print session debug information

AddUser()

AddUser(string  $username, string  $password, string  $email, string  $question = '', string  $answer = '', string  $realName = '', integer  $gender, string  $number = '0', string  $country = '0', string  $city = '0', string  $address = '0', string  $postalcode = '0', integer  $birthday) 

Add user to Perfect World database

Parameters

string $username
string $password
string $email
string $question
string $answer
string $realName
integer $gender
string $number
string $country
string $city
string $address
string $postalcode
integer $birthday

UsernameIsValid()

UsernameIsValid(string  $username) : boolean

Checks if username is valid.

Parameters

string $username

Returns

boolean

UsernameExists()

UsernameExists(string  $username) : boolean

Check if username already exists in database.

Parameters

string $username

Returns

boolean

EmailIsValid()

EmailIsValid(string  $email) : boolean

Checks if the input e-mail is valid.

Parameters

string $email

Returns

boolean

EmailExists()

EmailExists(string  $email) : boolean

Check if e-mail exists.

Parameters

string $email

Returns

boolean

SetPassword()

SetPassword(string  $username = '', string  $password, string  $oldPassword = '') : boolean

Sets a password for an account. This can be useful for password resets. If you have them input an old password, be sure to check that the old password length isn't 0. Otherwise they'll be able to overwrite the password without inputting an old password. This isn't a bug in the API, it's by design.

Parameters

string $username
string $password
string $oldPassword

Returns

boolean

GetUsername()

GetUsername(  $userID) : string

Returns logged in username. If user is not logged in, empty string is returned.

Parameters

$userID

Returns

string

GetUserData()

GetUserData(integer  $userID,   $forceUpdate = false) : mixed

Get user's data based on ID or currently logged in account. If the data has already been accessed, it will return that unless forceUpdate is set to true. If empty userID and user is not logged in, function returns false.

Parameters

integer $userID
$forceUpdate

Returns

mixed

IsLoggedIn()

IsLoggedIn() : boolean

Returns true or false on whether or not the user is logged in.

Returns

boolean

GetUserID()

GetUserID() : integer

Get logged in user ID

Returns

integer

AddGMByCharName()

AddGMByCharName(string  $charname) : boolean

Alias of AddGM

Parameters

string $charname

Returns

boolean

AddGM()

AddGM(string  $charname) : boolean

Gives a user GM permissions based on roles.role_name (not users.name).

Returns true or false on whether or not query succeeded.

Parameters

string $charname

Returns

boolean

AddGMByID()

AddGMByID(string  $userID) : boolean

Gives a user GM permissions based on user ID Returns true or false on whether or not query succeeded.

Parameters

string $userID

Returns

boolean

AddGMByUsername()

AddGMByUsername(string  $username) : boolean

Gives a user GM permissions based on user ID Returns true or false on whether or not query succeeded.

Parameters

string $username

Returns

boolean

Login()

Login(string  $username, string  $password, string  $email = '') 

Login to an account. E-Mail parameter is optional. If you plan to use the e-mail parameter, make sure to check if the e-mail length is greater than 0, otherwise it will bypass the e-mail check and allow the user in with just username and password.

Parameters

string $username
string $password
string $email

SetLogin()

SetLogin(string  $userID, boolean  $isGM = false) : void

Set login for user. Do NOT use this to log into account.

Parameters

string $userID
boolean $isGM

LoginByEmail()

LoginByEmail(string  $email, string  $password) 

Login to an account by e-mail address.

Parameters

string $email
string $password

IsGM()

IsGM() : boolean

Returns true or false on whether or not the user is a GM

Returns

boolean

Logout()

Logout() : boolean

Logs out the character by destorying the session variables. The user remains in the same session until they either delete the cookie, restart their browser, or change their session ID.

Returns

boolean

SetCharacter()

SetCharacter(integer  $charID) : boolean

Set character ID for account. If set character fails, function will return false.

If the function succeeds, it will return true and the character ID will be set.

Parameters

integer $charID

Returns

boolean

FillUserCharData()

FillUserCharData(integer  $userID) : boolean

Fill all character data from given user ID. This will not check if data is stored already or not.

Parameters

integer $userID

Returns

boolean

GetUserCharIDs()

GetUserCharIDs(integer  $userID) : mixed

Returns an array of characters from specified user ID. If no ID is put, function grabs characters from currently logged in account. If empty userID and user is not logged in, function returns false.

Parameters

integer $userID

Returns

mixed

GetGMList()

GetGMList() : mixed

Returns an array map of GMs.

Key 'GM Name' returns GM's Name Key 'Online' returns true or false to online status

Returns

mixed —

array

GetOnlineCharList()

GetOnlineCharList() : mixed

Returns an array of online user's names and IDs

Returns

mixed —

array

GetOnlineCharacterList()

GetOnlineCharacterList() : mixed

Returns an array of online user's names and IDs

Returns

mixed —

array

GetCharList()

GetCharList(integer  $limit, integer  $page) : mixed

Get an array of all character's names and IDs (This can return a massive amount of data)

Parameters

integer $limit
integer $page

Returns

mixed —

array

GetCharacterName()

GetCharacterName(  $charID) : string

Returns currently selected character's name. If no character is selected, empty string is returned.

Parameters

$charID

Returns

string

Examples

** File not found :  **

GetCharData()

GetCharData(integer  $charID,   $forceUpdate = false) : mixed

Get character's data based on ID or currently logged in account character. If the data has already been accessed, it will return that unless forceUpdate is set to true. If empty userID and user is not logged in, function returns false.

Parameters

integer $charID
$forceUpdate

Returns

mixed

GetCharID()

GetCharID() : integer

Get character ID if character is set. 0 means that no character is set.

Returns

integer

initialize()

initialize() : void

Initialization components run here

startSession()

startSession() : void

Attempt to start user session (cookie blocks will prevent this from starting)

verifyFingerprint()

verifyFingerprint() : boolean

Verify session fingerprint against user fingerprint. Returns true if fingerprint is the same. Returns false if fingerprint mismatch.

Returns

boolean

setFingerprint()

setFingerprint() : void

Set session fingerprint

setSessionVariable()

setSessionVariable(string  $variable, mixed  $value) : void

Set a session variable.

NOTE: There is mild session data hiding for shared hosts. Beware using this on anything but a dedicated host. As the data could be unhidden fairly easy by another user.

Parameters

string $variable
mixed $value

getUserFingerprint()

getUserFingerprint() : string

Returns current user fingerprint (Not session fingerprint)

Returns

string

getFingerprint()

getFingerprint() : string

Return session fingerprint

Returns

string

getSessionVariable()

getSessionVariable(string  $variable) : mixed

Get a session variable.

NOTE: There is mild session data hiding for shared hosts. Beware using this on anything but a dedicated host. As the data could be unhidden fairly easy by another user.

Parameters

string $variable

Returns

mixed