Class PerfectWorldAPI

Description

Perfect World v1.2.6 php API

Extra credits to das7002, tbnanubis, renan7899, twiggy3452, Drakaer, Ronny

  • author: Nicholas R. Grant a.k.a. "Goodlookinguy"
  • version: 2.3b, 2/12/2012
  • copyright: NRGsoft (c) 2003-2012

Located in /includies/classPerfectWorldAPI.php (line 12)


	
			
Class Constant Summary
 DATABASE_HOST = 'localhost'
 MSG_MALFORMED_QUERY = 'Error: A malformed query was executed, program has been terminated.'
 MSG_SESSION_COLLISION = 'Error: Something went very wrong! Blame the php developers!'
 SESSION_CHAR_ID = 'pwCharID'
 SESSION_FINGERPRINT = 'pwFingerprint'
 SESSION_IS_GM = 'pwGM'
 SESSION_NAME = 'PerfectWorldAPI'
 SESSION_USER_ID = 'pwUserID'
Variable Summary
Method Summary
void __construct ()
boolean AddGM (string $username)
void AddUser (string $username, string $password, string $email, [string $question = ''], [string $answer = ''], [string $realName = ''], [int $gender = 0], [string $number = '0'], [string $country = '0'], [string $city = '0'], [string $address = '0'], [string $postalcode = '0'], [int $birthday = 0])
boolean EmailExists (string $email)
boolean EmailIsValid (string $email)
boolean FillUserCharData ([int $userID = 0])
void filterText (string $text, [string $filter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'])
string GetCharacterName ()
mixed GetCharData ([int $charID = 0], [ $forceUpdate = false])
int GetCharID ()
string getFingerprint ()
mixed GetGMList ()
mixed getSessionVariable (string $variable)
mixed GetUserCharIDs ([int $userID = 0])
mixed GetUserData ([int $userID = 0], [ $forceUpdate = false])
string getUserFingerprint ()
int GetUserID ()
string GetUsername ()
void initialize ()
boolean IsGM ()
boolean IsLoggedIn ()
void Login (string $username, string $password, [string $email = ''])
boolean Logout ()
boolean SetCharacter (int $charID)
void setFingerprint ()
void SetLogin (string $userID, [boolean $isGM = false])
void setSessionVariable (string $variable, mixed $value)
void startSession ()
boolean UsernameExists (string $username)
boolean UsernameIsValid (string $username)
boolean verifyFingerprint ()
Variables
static PerfectWorldAPI $Instance (line 50)

Singleton instance of PerfectWorldAPI

  • access: public
mixed $_charData = array() (line 42)
  • access: private
MonkeyDatabase $_database (line 37)

Instance of MonkeyDatabase

  • access: private
mixed $_userData = array() (line 41)
  • access: private
Methods
static method Instance (line 78)

Returns singleton instance of class

  • access: public
static PerfectWorldAPI Instance ()
Constructor __construct (line 57)

Class constructor

void __construct ()
AddGM (line 356)

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

Returns true or false on whether or not query succeeded.

  • access: public
boolean AddGM (string $username)
  • string $username
AddUser (line 289)

Add user to Perfect World database

  • access: public
void AddUser (string $username, string $password, string $email, [string $question = ''], [string $answer = ''], [string $realName = ''], [int $gender = 0], [string $number = '0'], [string $country = '0'], [string $city = '0'], [string $address = '0'], [string $postalcode = '0'], [int $birthday = 0])
  • string $username
  • string $password
  • string $email
  • string $question
  • string $answer
  • string $realName
  • int $gender
  • string $number
  • string $country
  • string $city
  • string $address
  • string $postalcode
  • int $birthday
EmailExists (line 332)

Check if e-mail exists.

  • access: public
boolean EmailExists (string $email)
  • string $email
EmailIsValid (line 316)

Checks if the input e-mail is valid.

  • access: public
boolean EmailIsValid (string $email)
  • string $email
FillUserCharData (line 588)

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

  • access: public
boolean FillUserCharData ([int $userID = 0])
  • int $userID
filterText (line 188)

Returns a string that only contains the characters specified in $filter

  • access: private
void filterText (string $text, [string $filter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_'])
  • string $text
  • string $filter
GetCharacterName (line 690)

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

  • access: public
string GetCharacterName ()
GetCharData (line 554)

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.

  • access: public
mixed GetCharData ([int $charID = 0], [ $forceUpdate = false])
  • int $charID
  • $forceUpdate
GetCharID (line 506)

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

  • access: public
int GetCharID ()
getFingerprint (line 167)

Return session fingerprint

  • access: private
string getFingerprint ()
GetGMList (line 652)

Returns an array map of GMs.

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

  • return: array
  • access: public
mixed GetGMList ()
getSessionVariable (line 129)

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.

  • access: private
mixed getSessionVariable (string $variable)
  • string $variable
GetUserCharIDs (line 623)

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.

  • access: public
mixed GetUserCharIDs ([int $userID = 0])
  • int $userID
GetUserData (line 519)

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.

  • access: public
mixed GetUserData ([int $userID = 0], [ $forceUpdate = false])
  • int $userID
  • $forceUpdate
getUserFingerprint (line 177)

Returns current user fingerprint (Not session fingerprint)

  • access: private
string getUserFingerprint ()
GetUserID (line 434)

Get logged in user ID

  • access: public
int GetUserID ()
GetUsername (line 676)

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

  • access: public
string GetUsername ()
initialize (line 66)

Initialization components run here

  • access: private
void initialize ()
IsGM (line 454)

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

  • access: public
boolean IsGM ()
IsLoggedIn (line 444)

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

  • access: public
boolean IsLoggedIn ()
Login (line 379)

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.

  • access: public
void Login (string $username, string $password, [string $email = ''])
  • string $username
  • string $password
  • string $email
Logout (line 466)

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.

  • access: public
boolean Logout ()
PrintSessionDebugData (line 222)

Print session debug information

  • access: public
void PrintSessionDebugData ()
SetCharacter (line 482)

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.

  • access: public
boolean SetCharacter (int $charID)
  • int $charID
setFingerprint (line 157)

Set session fingerprint

  • access: private
void setFingerprint ()
SetLogin (line 423)

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

  • access: public
void SetLogin (string $userID, [boolean $isGM = false])
  • string $userID
  • boolean $isGM
setSessionVariable (line 115)

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.

  • access: private
void setSessionVariable (string $variable, mixed $value)
  • string $variable
  • mixed $value
startSession (line 90)

Attempt to start user session

  • access: private
void startSession ()
UsernameExists (line 238)

Check if username already exists in database.

  • access: public
boolean UsernameExists (string $username)
  • string $username
UsernameIsValid (line 261)

Checks if username is valid.

  • access: public
boolean UsernameIsValid (string $username)
  • string $username
verifyFingerprint (line 142)

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

  • access: private
boolean verifyFingerprint ()
Class Constants
DATABASE_HOST = 'localhost' (line 13)
DATABASE_NAME = '' (line 16)
DATABASE_PASSWORD = '' (line 15)
DATABASE_USERNAME = 'root' (line 14)
GENDER_FEMALE = 1 (line 270)
GENDER_MALE = 0 (line 269)
MSG_MALFORMED_QUERY = 'Error: A malformed query was executed, program has been terminated.' (line 27)

******************************************************

MSG_SESSION_COLLISION = 'Error: Something went very wrong! Blame the php developers!' (line 28)
SESSION_CHAR_ID = 'pwCharID' (line 22)
SESSION_FINGERPRINT = 'pwFingerprint' (line 20)
SESSION_IS_GM = 'pwGM' (line 23)
SESSION_NAME = 'PerfectWorldAPI' (line 18)
SESSION_USER_ID = 'pwUserID' (line 21)

Documentation generated on Sun, 12 Feb 2012 04:03:22 -0800 by phpDocumentor 1.4.1