\GSPPanel\Machines
Methods
AddIPs(array $params = array()) : array
Add IPs to the machine
$params must contain the following:
- sid: The server ID
- ips: Array of IPs
Returns one of the following in an array format:
- error
- -1 - No server ID provided
- -2 - No ips provided
- 0 - Added successfully
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
AddMachine(array $params) : array
Adds a machine to the database
$params requires the following:
- alias: The name of the server(REQUIRED)
- main_ip: The main IP address of the server(REQUIRED)
- file_location: The location of game server files(REQUIRED if game_server is 1)
- userfile_location: The location for user installs to be placed(REQUIRED if game_server is 1)
- backupfile_location: The location to store user game backups
- listenport: The port the backend should listen on(REQUIRED if game_server is 1)
- os: The operating system of the server(REQUIRED)
- location: The location of the server
- ftpport: The port the FTP server should listen on(0 disables the ftp server)
- httpport: The port the HTTP server should listen on(0 disables the http server)
- game_server: 0/1 to enable this server to host game servers
- slots_quota: The maximum amount of slots this server can hold
- servers_quota: The maximum amount of game servers this server can hold
- debugging: Enables backend debugging on the machine
- fileserver: The machines ID to download files from
- diskthrottle: Only applies to Linux servers, the command to run when copy, delete, and extract commands are ran (e.g ionice -c2 -n7)
- uid: The user id that owns this server, if nothing is specified this server will be a shared server
Returns one of the following in an array format:
- error
- -1 - License limitation reached
- -2 - Field left empty
- 0 - Added successfully
- sid: The new servers id
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
AddUser(array $params) : void
Add a user to a machine if it doesn't already exist, this only works on Linux
$params must contain the following:
- sid: The server ID
- username: Username to add
- password: Password for the user
- homedirectory: The user's home directory on the file system
Returns one of the following in an array format:
- error
- -1 - Missing sid
- -2 - Missing username
- -3 - Missing homedirectory
- -4 - User already exists
- -5 - Error adding user
- 0 - User added
Name | Type | Description |
---|---|---|
$params | array |
Count() : integer
Returns the number of machines
Type | Description |
---|---|
integer |
CreateHTTPData(integer $sid) : array
Create the data file for the HTTP server
Returns one of the following in an array format:
- error
- -1 - No server ID supplied
- -2 - Unable to connect to server
- -3 - Server needs to be updated
- -4 - Server not found in database
- 0 - File written
Name | Type | Description |
---|---|---|
$sid | integer | Server's id to scan the game on |
Type | Description |
---|---|
array |
- Access
- public
DeleteIP(integer $ipid) : array
Delete an IP from the machine
Returns one of the following in an array format:
- error
- -1 - IP has services
- -2 - IP not found
- 0 - IP Removed
Name | Type | Description |
---|---|---|
$ipid | integer | The IPs ID to delete |
Type | Description |
---|---|
array |
DeleteMachine(array $params) : array
Deletes a machine from the database
$params requires the following:
- sid: The server id to delete(REQUIRED)
Returns one of the following in an array format:
- error
- -1 - No server id provided
- -2 - Server has user game servers installed
- -3 - Unable to find server in database
- -4 - Machine is set as the scheduling host
- 0 - Deleted successfully
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
DownloadFile(integer $sid, string $url, string $localfile) : array
Download File to the machine
Returns one of the following in an array format:
- error
- -1 - No server ID supplied
- -2 - No URL supplied
- -3 - No localfile save path supplied
- -4 - Server not found in database
- -5 - Server needs to be updated
- -6 - Unable to connect to server
- 0 - Download Started
- result: result of the downloadfile command
- taskid: The taskid relating to the download
Name | Type | Description |
---|---|---|
$sid | integer | Server's id to scan the game on |
$url | string | URL to download from |
$localfile | string | Location to save file |
Type | Description |
---|---|
array |
- Access
- public
EditMachine(array $params) : array
Edits a machine in the database.
Changing listenport or ftpport will require the backend to be manually restarted
$params requires the following:
- sid: The server's id to edit(REQURIED)
- alias: The name of the server(REQUIRED)
- main_ip: The main IP address of the server(REQUIRED)
- file_location: The location of game server files(REQUIRED if game_server is 1)
- userfile_location: The location for user installs to be placed(REQUIRED if game_server is 1)
- backupfile_location: The location to store user game backups
- listenport: The port the backend should listen on(REQUIRED if game_server is 1)
- os: The operating system of the server(REQUIRED)
- location: The location of the server
- ftpport: The port the FTP server should listen on(0 disables the ftp server)
- httpport: The port the HTTP server should listen on(0 disables the http server)
- game_server: 0/1 to enable this server to host game servers
- slots_quota: The maximum amount of slots this server can hold
- servers_quota: The maximum amount of game servers this server can hold
- debugging: Enables backend debugging on the machine
- fileserver: The machines ID to download files from
- diskthrottle: Only applies to Linux servers, the command to run when copy, delete, and extract commands are ran (e.g ionice -c2 -n7)
- uid: The user id that owns this server, if nothing is specified this server will be a shared server
Returns one of the following in an array format:
- error
- -1 - No server id provided
- -2 - Field left empty
- -3 - Unable to change machine owner, machine has gameservers that belong to other users
- 0 - Saved successfully
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
FindPort(integer $ipid, integer $default, integer $increment) : integer
Finds a usable port on that specified ip.
Does a database search and attempts to connect to the ip/port via sockets
Name | Type | Description |
---|---|---|
$ipid | integer | The ipid to scan for an available port on |
$default | integer | The port to start the scan on |
$increment | integer | The increment to increase $default by if the port is taken |
Type | Description |
---|---|
integer |
GameLocationIPList(array $params = array()) : array
This returns an array of online servers at the specified location.
This function is mainly used for the dropdown lists of locations, servers, and ips to install a users server to
$params can accept the following variables:
- location: Location to return a list for
- gid: Only list machines with the specified game
- offline: Set to true to include offline machines in the list, default is false
- iplist: true/false to return a list of valid ips at the location, per available machine
- currentip: The ipid of the current gameserver
- dedicatedip: If set to 1 it will only return IPs that do not have game servers, default is 0
- uid: Look for servers that belong to the specified user
Returns an array depending on what was requested
- It's best to print_r the array to see the variables for your query
- View admin/manageusergames/ajax-location.tpl to see how the information is handled
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
GetIP(integer $ipid, boolean $alias = false, string $type = "external") : string
Returns an ip address (External or internal) or an alias from an ipid
Name | Type | Description |
---|---|---|
$ipid | integer | The ipid to convert |
$alias | boolean | Return the domain alias instead of the IP (if set) |
$type | string | The type of ip to return(internal/external) |
Type | Description |
---|---|
string |
GetIPs(integer $sid) : array
Returns an array of IPs from the server.
The array contains "ip" and "used"(yes/no)
Name | Type | Description |
---|---|---|
$sid | integer | The server id to retrieve ips from |
Type | Description |
---|---|
array |
GetMachineInfo(integer $sid) : array
Returns an array of machine information
Name | Type | Description |
---|---|---|
$sid | integer | The servers id |
Type | Description |
---|---|
array |
GetOS(integer $sid) : string
Gets the OS of the specified machine
Name | Type | Description |
---|---|---|
$sid | integer | Server's ID to get OS for |
Type | Description |
---|---|
string | Linux or Windows |
GetUsedQuota(string $type, integer $machineid, integer $gid = null) : integer
Returns the amount of used slots or gameservers
Name | Type | Description |
---|---|---|
$type | string | The type you want to return, can be "slots" or "servers" |
$machineid | integer | The server's id you want to return slots for |
$gid | integer | The game id to return the quota for |
Type | Description |
---|---|
integer |
LeastUsedIP(integer $sid) : integer
Returns the ipid of the least used ip on the server that is not dedicated
Name | Type | Description |
---|---|---|
$sid | integer | Server's id |
Type | Description |
---|---|
integer |
ListIPs(integer $sid) : array
Returns an array of IPs on the machine
Name | Type | Description |
---|---|---|
$sid | integer | The servers id |
Type | Description |
---|---|
array |
ListMachines(array $params = array()) : array
Returns an array of machines
$params can use the following (optional):
- os: 0 for Windows, 1 for Linux
- gameserver: 0 for machines that won't host games, 1 for machines that can host games
- uid: List machines that are assigned to the specified user
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
RemoveUser(array $params) : void
Removes a user account from the specified machine, this only works on Linux
$params must contain the following:
- sid: The server ID
- username: Username to remove
Returns one of the following in an array format:
- error
- -1 - Missing sid
- -2 - Missing or invalid username
- -3 - User not found on server
- -4 - Error removing user
- 0 - User removed
Name | Type | Description |
---|---|---|
$params | array |
SendCommand(integer $sid, string $command, boolean $response, string $user = "", string $pingback = "") : mixed
Sends a command to the server
Returns either an integer error, false, or the server's response:
- -1 - Server not found in database
- -2 - Invalid version, might require a backend update to match frontend version
- false - Unable to connect to the server
- Server response
Name | Type | Description |
---|---|---|
$sid | integer | The server id to run the command on |
$command | string | The command to send to the server |
$response | boolean | True/False to wait and receive a response |
$user | string | The username to run the command as(Linux only) |
$pingback | string | The URL to ping back to once the task is completed |
Type | Description |
---|---|
mixed |
SystemInfo(array $params) : array
Retrieves system infomation such as operating system, memory, hdd space, and backend version
$params requires the following:
- sid: The server id to get information from(REQUIRED)
Returns one of the following in an array format:
- error
- -1 - No server id provided
- -2 - Server is offline
- -3 - Server does not exist
- -5 - Backend upgrade required
- 0 - Queried successfully
- os: Array of operating system information(name, edition, servicepack)
- memory: Array of memory information(free, total)
- hd: The hard drive information(drive, freespace, totalsize, percentage used)
- version: The backend version
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
Update(integer $sid) : boolean
Updates the backend with the version required by the frontend
Name | Type | Description |
---|---|---|
$sid | integer | The server's id you want to update |
Type | Description |
---|---|
boolean |
VerifyConnection(integer $sid) : integer
Verifies the connection to the server
Returns one of the following:
- 1 - Online
- 0 - Offline or not in database
- -1 - Invalid version, might require a backend update to match frontend version
Name | Type | Description |
---|---|---|
$sid | integer | Server's id to check |
Type | Description |
---|---|
integer |
VerifyGames(array $params) : array
Lists the games on the specified server
$params requires the following:
- sid: The server id to scan games on(REQUIRED)
- expiretime: The time in seconds for that cached games expire(Optional, default is 86400, 1 day)
- forceupdate: Defaults to retrieving information from cache, set to true to get a live update(Optional)
Returns one of the following in an array format:
- error
- -1 - No server id provided
- -2 - Server is offline
- -3 - Server does not exist
- -4 - No games for that OS (REMOVED)
- -5 - Invalid backend version
- 0 - Queried successfully
- gamelist: Array of game information(game, folder, exists(boolean), size, enabled(boolean), quota)
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
array |
canHostGame(integer $gid, integer $sid) : boolean
Returns true if the machine can host the specified game, this does not check quotas
False will be returned if:
- The game is not enabled for the operating system the machine is running
- The game files don't exist
- The game files cannot be downloaded from the fileserver, if setup
Name | Type | Description |
---|---|---|
$gid | integer | |
$sid | integer |
Type | Description |
---|---|
boolean |
doesUserOwn(array $params) : boolean
Determine if the user owns the specified server or the server for the specified gameserver
$params can use the following:
- uid: User id to match (MANDATORY)
- sid: Server ID to match user to
- ugid: Does user own the server running this gameserver
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
boolean |
getGameCacheData(integer $gid, integer $sid) : array
Returns an array of game information from the cache
Returned array contains: gid, size, exists, enabled
Name | Type | Description |
---|---|---|
$gid | integer | Game ID |
$sid | integer | Machine ID |
Type | Description |
---|---|
array |
hasGameFiles(array $params) : boolean
Returns true if the game files exist on the specified server, will use cache if it's not older then 24 hours
$params can take the following:
- sid: The machines ID (REQURIED)
- gid: The games ID (REQUIRED)
- os: The OS to check files for (e.g. do we want to see if a Windows server has the files for Linux servers so we can download them)
- skipcache: true/false, will automatically be skipped if OS is specified
- expirecache: How long is the cache valid for (default 86400)
Name | Type | Description |
---|---|---|
$params | array |
Type | Description |
---|---|
boolean |
isGameEnabled(integer $gid, integer $sid) : boolean
Returns true if the game is enabled on the specified machine
Name | Type | Description |
---|---|---|
$gid | integer | Game ID |
$sid | integer | Machine ID |
Type | Description |
---|---|
boolean |
isIPUsed(integer $ipid) : boolean
Check if an IP is in use by a game server
Name | Type | Description |
---|---|---|
$ipid | integer |
Type | Description |
---|---|
boolean |
isPortUsed(integer $ipid, integer $port) : boolean
Checks if a port is used Returns true if its used, false if its not
Name | Type | Description |
---|---|---|
$ipid | integer | The ipid to check |
$port | integer | The port to check |
Type | Description |
---|---|
boolean |