TeamSpeak 3 PHP Framework  1.1.16
Copyright © Planet TeamSpeak. All rights reserved.
 All Classes Namespaces Files Functions Variables Pages
API Documentation

Introduction

What is the TS3 PHP Framework?

Initially released in January 2010, the TS3 PHP Framework is a powerful, open source, object-oriented framework implemented in PHP 5 and licensed under the GNU General Public License. It's based on simplicity and a rigorously tested agile codebase. Extend the functionality of your servers with scripts or create powerful web applications to manage all features of your TeamSpeak 3 Server instances.

Tested. Thoroughly. Enterprise-ready and built with agile methods, the TS3 PHP Framework has been unit-tested from the start to ensure that all code remains stable and easy for you to extend, re-test with your extensions, and further maintain.

Why should I use the TS3 PHP Framework rather than other PHP libraries?

The TS3 PHP Framework is a is a modern use-at-will framework that provides individual components to communicate with the TeamSpeak 3 Server.

There are lots of arguments for the TS3 PHP Framework in comparison with other PHP based libraries. It is the most dynamic and feature-rich piece of software in its class. In addition, it's the only PHP library that parses the data spit out of the ServerQuery interface correctly.

Requirements

The TS3 PHP Framework currently supports PHP 5.2.1 or later, but we strongly recommend the most current release of PHP for critical security and performance enhancements. If you want to create a web application using the TS3 PHP Framework, you need a PHP 5 interpreter with a web server configured to handle PHP scripts correctly.

Note that the majority of TS3 PHP Framework development and deployment is done on Apache, so there is more community experience and testing performed on Apache than on other web servers.

Features

Features of the TS3 PHP Framework include:

  • Fully object-oriented PHP 5 and E_STRICT compliant components
  • Access to all TeamSpeak 3 Server features via ServerQuery
  • Integrated full featured and customizable TSViewer interfaces
  • Full support for file transfers to up- and /or download custom icons and other stuff
  • Powerful error handling capablities using exceptions and customizable error messages
  • Query mechanisms for several official services such as the blacklist and auto-update servers
  • Dynamic signal slots for event based scripting
  • ...

Usage Examples

1. Kick all Clients from a Virtual Server

// connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
// query clientlist from virtual server
$arr_ClientList = $ts3_VirtualServer->clientList();
// kick all clients online with a single command
$ts3_VirtualServer->clientKick($arr_ClientList, TeamSpeak3::KICK_SERVER, "evil kick XD");

2. Modify the Settings of each Virtual Server

// connect to local server, authenticate and quickly spawn an object for the server instance
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?use_offline_as_virtual=1");
// walk through list of virtual servers
foreach($ts3_ServerInstance as $ts3_VirtualServer)
{
// modify the virtual servers hostbanner URL only
$ts3_VirtualServer["virtualserver_hostbanner_gfx_url"] = "http://www.example.com/banners/banner01_468x60.jpg";
// modify multiple virtual server properties at once
$ts3_VirtualServer->modify(
"virtualserver_hostbutton_tooltip" => "My Company",
"virtualserver_hostbutton_url" => "http://www.example.com",
"virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
);
}

3. Modify the Permissions of Admins on each Virtual Server

// connect to local server, authenticate and quickly spawn an object for the server instance
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?use_offline_as_virtual=1");
// walk through list of virtual servers
foreach($ts3_ServerInstance as $ts3_VirtualServer)
{
// identify the most powerful group on the virtual server
$ts3_ServerGroup = $ts3_VirtualServer->serverGroupIdentify();
// assign a new permission
$ts3_ServerGroup->permAssign("b_virtualserver_modify_hostbanner", TRUE);
// revoke an existing permission
$ts3_ServerGroup->permRemove("b_virtualserver_modify_maxclients");
}

4. Create a new Virtual Server

// connect to local server and authenticate
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
// create a virtual server and get its ID
$new_sid = $ts3_ServerInstance->serverCreate(
"virtualserver_name" => "My TeamSpeak 3 Server",
"virtualserver_maxclients" => 64,
"virtualserver_hostbutton_tooltip" => "My Company",
"virtualserver_hostbutton_url" => "http://www.example.com",
"virtualserver_hostbutton_gfx_url" => "http://www.example.com/buttons/button01_24x24.jpg",
);

5. Create a hierarchical Channel Stucture

// connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
// create a top-level channel and get its ID
$top_cid = $ts3_VirtualServer->channelCreate(
"channel_name" => "My Channel",
"channel_topic" => "This is a top-level channel",
"channel_flag_permanent" => TRUE,
);
// create a sub-level channel and get its ID
$sub_cid = $ts3_VirtualServer->channelCreate(
"channel_name" => "My Sub-Channel",
"channel_topic" => "This is a sub-level channel",
"channel_flag_permanent" => TRUE,
"cpid" => $top_cid,
);

6. Send a Text Message to outdated Clients

// connect to local server, authenticate and quickly spawn an object for the virtual server on port 9987
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/?server_port=9987");
// connect to default update server
$ts3_UpdateServer = TeamSpeak3::factory("update");
// walk through list of clients on virtual server
foreach($ts3_VirtualServer->clientList() as $ts3_Client)
{
// skip query clients
if($ts3_Client["client_type"]) continue;
// send test message if client build is outdated
if($ts3_Client->getRev() < $ts3_UpdateServer->getClientRev())
{
$ts3_Client->message("[COLOR=red]your client is [B]outdated[/B]... update to [U]" . $ts3_UpdateServer->getClientVersion() . "[/U] now![/COLOR]");
}
}

7. Check if the Server Instance is Outdated or Blacklisted

// connect to local server and authenticate
$ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
// connect to default update server
$ts3_UpdateServer = TeamSpeak3::factory("update");
// send global text message if the server is outdated
if($ts3_ServerInstance->version("build") < $ts3_UpdateServer->getServerRev())
{
$ts3_ServerInstance->message("[COLOR=red]your server is [B]outdated[/B]... update to [U]" . $ts3_UpdateServer->getServerVersion() . "[/U] now![/COLOR]");
}
// connect to default blacklist server
$ts3_BlacklistServer = TeamSpeak3::factory("blacklist");
// send global text message if the server is blacklisted
if($ts3_BlacklistServer->isBlacklisted($ts3_ServerInstance))
{
$ts3_ServerInstance->message("[COLOR=red]your server is [B]blacklisted[/B]... disconnect now![/COLOR]");
}

Speed up new development and reduce maintenance costs by using the TS3 PHP Framework!