User

API Documentation

\GSPPanel\User

This class allows interaction with users

Methods

AddAdmin(array $params) : array

Adds an administrator

$params requires the following:

  • email: Email address for the new administrator(REQUIRED)
  • password: Plain text password for the new administrator, if empty a random password will be generated
  • mainadmin: 0/1 for main administrator privledges
  • perm: An array of permissions if mainadmin is 0
  • allowedips: A list of allowed IP's
  • servermon_emails: 0/1 will receive emails from the server monitor

Returns the following:

  • error
    • -1 - No email/invalid email
    • -2 - No password(obsolete)
    • -3 - Taken/Blacklisted email
    • -0 - Added successfully
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
AddClient(array $params) : array

Adds a user

$params requires the following:

  • email: Email address for the new user(REQUIRED)
  • password: Plain text password for the new administrator, if empty a random password will be generated
  • status: 0/1 to activate(1) or suspend(0) the account
  • phone: User's phone number
  • firstname: User's first name
  • lastname: User's last name
  • address: User's address
  • city: User's city
  • state: User's state
  • zipcode: User's zipcode
  • country: User's country
  • notes: Account notes
  • billingid: A reference ID sent from billing systems such as WHMCS

Returns the following:

  • error
    • -1 - No email address
    • -2 - Taken/Blacklisted email
    • -3 - The specified billingid is already associated with a user
    • 0 - Added successfully
  • uid: The user id for the new user
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
AddIPBan(string $ip) : void

Bans and IP address or increments the counter if the IP has already been marked for invalid logins

Parameters
NameTypeDescription
$ipstring

IP to ban

AddSubUser(array $params) : array

Adds a subuser

$params requires the following:

  • email: Email for the subuser
  • password: plain text password for the subuser
  • gameserver: Array of permissions for the main users gameservers(ugid => control(permissions))
  • uid: The main user's ID

Returns the following:

  • error
    • -1 - No email
    • -2 - Taken/Blacklisted email
    • -0 - Added successfully
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
DeleteAdmin(integer $uid) : array

Delete the specified administrator

Returns the following:

  • error
    • -1 - No user found
    • -2 - Unable to delete the main administrator
    • -0 - Removed successfully
Parameters
NameTypeDescription
$uidinteger

The user id of the administrator to delete

Returns
TypeDescription
array
DeleteSubUser(integer $subid) : array

Delete the specified subuser

Returns the following:

  • error
    • -1 - No user found
    • -0 - Removed successfully
Parameters
NameTypeDescription
$subidinteger

The subuser's id to delete

Returns
TypeDescription
array
DeleteUser(integer $uid) : array

Delete the specified user and all their services

Returns the following:

  • error
    • -1 - No user found
    • -2 - Unable to remove game, server is offline
    • -3 - Unable to remove game, enable debugging on the remote server
    • -4 - LEGACY - No longer used
    • -0 - Removed successfully
Parameters
NameTypeDescription
$uidinteger

The user id to delete

Returns
TypeDescription
array
EditAdmin(array $params) : array

Edits an administrator

$params requires the following:

  • uid: User id of the adminstrator to edit(REQUIRED)
  • email: Email address for the administrator(REQUIRED)
  • password: Plain text password for the administrator
  • mainadmin: 0/1 for main administrator privledges
  • perm: An array of permissions if mainadmin is 0
  • allowedips: The list of allowed IP's
  • servermon_emails: 0/1 will receive emails from the server monitor

Returns the following:

  • error
    • -1 - No userid
    • -2 - No email address
    • -3 - Cannot remove the main admin
    • -4 - Taken/Blacklisted email
    • -5 - User does not exist
    • -0 - Edited successfully
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
EditClient(array $params) : array

Edits a user

$params requires the following:

  • uid: The user's id(REQUIRED)
  • email: Email address for the user(REQUIRED)
  • password: Plain text password for the user
  • status: 0/1 to activate(1) or suspend(0) the account
  • phone: User's phone number
  • firstname: User's first name
  • lastname: User's last name
  • address: User's address
  • city: User's city
  • state: User's state
  • zipcode: User's zipcode
  • country: User's country
  • notes: Account notes
  • billingid: A reference ID sent from billing systems such as WHMCS

Returns the following:

  • error
    • -1 - No userid
    • -2 - Taken/Blacklisted email
    • -3 - User does not exist
    • -4 - No email address
    • -0 - Edited successfully
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
EditSubUser(array $params) : array

Edits a subuser

$params requires the following:

  • subid: Subuser's id(REQUIRED)
  • uid: Main user's id(REQUIRED)
  • email: Email for the subuser
  • password: plain text password for the subuser
  • gameserver: Array of permissions for the main users gameservers(ugid => control(permissions))

Returns the following:

  • error
    • -1 - Missing subid or uid
    • -2 - Taken/Blacklisted email
    • -3 - User does not exist
    • -0 - Saved successfully
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
EncodePass(string $password, string $typeoverride = null) : string

This encrypts the users password using the encryption type set in settings

Parameters
NameTypeDescription
$passwordstring

The password you want to encrypt

$typeoverridestring

The type to use if not the default

Returns
TypeDescription
stringThe encrypted password
ExpireBans() : void

Expires any bans past the expiration time

GetAdministratorInfo(integer $uid) : array

Returns an array of administrator information

Parameters
NameTypeDescription
$uidinteger

User ID of administrator

Returns
TypeDescription
array
GetClientInfo(integer $uid) : array

Returns an array of client information

Parameters
NameTypeDescription
$uidinteger

User ID

Returns
TypeDescription
array
GetPass(integer $uid, string $type = "user") : string

Returns the user's or subuser's password decoded

Parameters
NameTypeDescription
$uidinteger

The user id of the password you want to decrypt

$typestring

The type of user(user, subuser)

Returns
TypeDescription
stringThe decrypted password
GetSubUserInfo(integer $subid, integer $mainid = "") : array

Returns an array of subuser information

Parameters
NameTypeDescription
$subidinteger

Subusers ID

$mainidinteger

The main user's ID

Returns
TypeDescription
array
ListAdministrators() : array

Returns an array of administrators

Returns
TypeDescription
array
ListSubUsers(integer $uid) : array

Returns an array of sub-users

Parameters
NameTypeDescription
$uidinteger

The UID of the main user

Returns
TypeDescription
array
ListUsers(array $params = array()) : array

Returns an array of users

$params can accept the following:

  • search: A string to search for
  • status: 0 for suspended, 1 for active
  • limit: Amount of results to return
  • order: Field to order results by
Parameters
NameTypeDescription
$paramsarray
Returns
TypeDescription
array
Login(string $email, string $password) : integer

Logs a user in

Returns the following:

  • 1 - Valid login
  • 0 - Invalid login
  • -1 - Suspended
  • -2 - Invalid login IP
Parameters
NameTypeDescription
$emailstring

Users email address

$passwordstring

Users password

Returns
TypeDescription
integer
RecodePasswords(string $type) : void

This will recrypt all the passwords in the database to the new encryption method

Parameters
NameTypeDescription
$typestring

The new type of encryption to use(mcryptnew, plain)

SuspendClient(integer $uid) : array

Suspends a client and all of their services

Returns the following:

  • error
    • -1 - No userid
    • -2 - User does not exist
    • -0 - Suspend successfully
Parameters
NameTypeDescription
$uidinteger

User's id to suspend

Returns
TypeDescription
array
UIDToUser(integer $uid, string $type = "user") : string

Converts a userid to an email address.

Will return System if the uid is -1, and Unknown if it's not found

Parameters
NameTypeDescription
$uidinteger

The userid to get the email to

$typestring

The type of user(subuser/user)

Returns
TypeDescription
string
UnsuspendClient(integer $uid) : array

Unsuspends a client and all of their services

Returns the following:

  • error
    • -1 - No userid
    • -2 - User does not exist
    • -0 - Unsuspend successfully
Parameters
NameTypeDescription
$uidinteger

User's id to unsuspend

Returns
TypeDescription
array
ValidateSession() : void

Validates the users session and refreshes permissions

howManyLoginAttempts(string $ip) : integer

Returns the number of failed login attempts for the specified IP

Parameters
NameTypeDescription
$ipstring

IP to check

Returns
TypeDescription
integer
isIPBanned(string $ip) : boolean

Check to see if an IP is banned or has failed login attempts

Parameters
NameTypeDescription
$ipstring

IP to check

Returns
TypeDescription
boolean
isNewUserValid(string $email, string $existing = "") : boolean

Checks if the email address is valid (not blacklisted and not used by another user)

Parameters
NameTypeDescription
$emailstring

The email address to verify

$existingstring

If its an email change of an existing user specify the existing email

Returns
TypeDescription
boolean
Documentation was generated by phpDocumentor 2.9.0.