TS3 PHP Framework question

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Hello,
I am here to ask how to use classes of it (I am noob, i dont know php).

For ex:
I want to decrypt a password in base64 format to enterable format. (something like this nZYkD5OEfy0tZnOAL60Yzmhgh6y=)
I use TS3 PHP framework.
So I ask you, how to load and call the function decript (its located in libraries\TeamSpeak3\Helper\
Thanks.
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
Looks like you are talking about this, yes?
https://docs.planetteamspeak.com/ts..._crypt.html#a96fd338d9ec82cdfc416266b2e6deba3

Code:
$string = base64_decode($string);
$decryp = "";
$length = strlen($string);
$string .= str_repeat(chr(0), (8 - ($length % 8)) % 8);

for ($i = 0; $i < $length; $i += 8) {
    list(, $xl, $xr) = unpack("N2", substr($string, $i, 8));
    $this->decipher($xl, $xr);
    $decryp .= pack("N2", $xl, $xr);
}

return trim($decryp);

It looks like you just call it like:
decrypt($string)

Also, don't be afraid to check documentation. A lot of times documentation can help, sometimes documentation sucks though. Here is the documentation you should look at: https://docs.planetteamspeak.com/ts3/php/framework/index.html

Code:
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
 
Last edited:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Fatal error: Call to undefined function decrypt() in C:\xampp\htdocs\home.php on line 65
Doesn't work.
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
Fatal error: Call to undefined function decrypt() in C:\xampp\htdocs\home.php on line 65
Doesn't work.
Code:
// load framework files
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

Needs to go up at the top of your script. Then somewhere below.. further down, try something like:

https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3___helper___crypt.html
https://docs.planetteamspeak.com/ts3/php/framework/annotated.html

Code:
require_once("libraries/TeamSpeak3/Helper/Signal/Crypt.php");

You could try this if you want. *shrugs*
I have not used the TeamSpeak 3 PHP Framework much. Make sure your directories/files exist and are in the right place.
 
Last edited:

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
require_once("libraries/TeamSpeak3/Helper/Crypt.php");
decrypt("nZYkD5OEfy0tZnOAL60Yzmhgh6yT=");

Results in --> Fatal error: Call to undefined function decrypt() in C:\xampp\htdocs\home.php on line 67

I am really bad at this, am I doing something wrong? :D
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
My bad, you'll need to call the function under the TeamSpeak3_Helper_Crypt class.

Code:
$testObject = new TeamSpeak3_Helper_Crypt();
$testObject->decrypt($string);
 

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
require_once("libraries/TeamSpeak3/Helper/Crypt.php");
decrypt("nZYkD5OEfy0tZnOAL60Yzmhgh6yT=");

Results in --> Fatal error: Call to undefined function decrypt() in C:\xampp\htdocs\home.php on line 67

I am really bad at this, am I doing something wrong? :D
Let me know if that works or if you need more help. :)

If you find a solution, please post that here.
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
God damn.
tons of errors :D

Code:
Warning: Missing argument 1 for TeamSpeak3_Helper_Crypt::__construct(), called in C:\xampp\htdocs\home.php on line 67 and defined in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 61

Notice: Undefined variable: secret in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 64

Fatal error: Uncaught exception 'TeamSpeak3_Helper_Exception' with message 'secret passphrase must contain at least one but less than 56 characters' in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php:165 Stack trace: #0 C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php(64): TeamSpeak3_Helper_Crypt->setSecretKey(NULL) #1 C:\xampp\htdocs\home.php(67): TeamSpeak3_Helper_Crypt->__construct() #2 C:\xampp\htdocs\index.php(35): include('C:\\xampp\\htdocs...') #3 {main} thrown in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 165

edit: Nicer:
{
$this->setDefaultKeys();
$this->setSecretKey($secret);
}
What secretkey should I choose?
 
Last edited:

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
God damn.
tons of errors :D

Code:
Warning: Missing argument 1 for TeamSpeak3_Helper_Crypt::__construct(), called in C:\xampp\htdocs\home.php on line 67 and defined in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 61

Notice: Undefined variable: secret in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 64

Fatal error: Uncaught exception 'TeamSpeak3_Helper_Exception' with message 'secret passphrase must contain at least one but less than 56 characters' in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php:165 Stack trace: #0 C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php(64): TeamSpeak3_Helper_Crypt->setSecretKey(NULL) #1 C:\xampp\htdocs\home.php(67): TeamSpeak3_Helper_Crypt->__construct() #2 C:\xampp\htdocs\index.php(35): include('C:\\xampp\\htdocs...') #3 {main} thrown in C:\xampp\htdocs\libraries\TeamSpeak3\Helper\Crypt.php on line 165

edit: Nicer:
{
$this->setDefaultKeys();
$this->setSecretKey($secret);
}
What secretkey should I choose?
https://docs.planetteamspeak.com/ts3/php/framework/class_team_speak3___helper___crypt.html#details

The above link should provide all the documentation for that class (well not all, but most). I think the secret key is something you choose, like a password or salt. :D
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Well.
PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
require_once("libraries/TeamSpeak3/Helper/Crypt.php");

$string = "nZYkD5OEfy0tZnOAL60Yzmhgh6yT=";
$testObject = new TeamSpeak3_Helper_Crypt();
$testObject->setDefaultKeys();
$testObject->setSecretKey("randompw");
$testObject->decrypt($string);

Error is same as before.. Interesting :D
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Hell yeah, I found the solution! :D
PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
require_once("libraries/TeamSpeak3/Helper/Crypt.php");

$string = "nZYkD5OEfy0tZnOAL60Yzmhgh6yT=";
$testObject = new TeamSpeak3_Helper_Crypt("randomPW");
$testObject->decrypt($string);
But I don't know what is the secret phrase. If I change 1 char of it, code is complety diferent ...

e.Nicer: How do I get secret phrase from my ts3?
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Another question guys...
When I connect on query without selecting server, how do I select the server to able to work with it?

PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3 = TeamSpeak3::factory("serverquery://UN:PW@IP:10011/");
$ts3_VirtualServer = $ts3->serverSelect(1);
$slots = $ts3_VirtualServer->getProperty("virtualserver_clientsonline") - $ts3_VirtualServer->getProperty("virtualserver_queryclientsonline") . "/" . $ts3_VirtualServer->virtualserver_maxclients;
The error is -->
Fatal error: Call to a member function getProperty() on null in C:\xampp\htdocs\status.php on line 37
 

Najsr

Moderator
TeamSpeak Developer
Apr 23, 2016
483
249
167
Nevermind, I found the solution :D

PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3 = TeamSpeak3::factory("serverquery://UN:PW@IP:10011/");
$ts3_VirtualServer = $ts3->serverGetById(1);
$slots = $ts3_VirtualServer->getProperty("virtualserver_clientsonline") - $ts3_VirtualServer->getProperty("virtualserver_queryclientsonline") . "/" . $ts3_VirtualServer->virtualserver_maxclients;
Maybe someone could make new list of functions :D
 

EscuderoKevin

Well-Known Member
Jul 2, 2015
380
181
130
Nevermind, I found the solution :D

PHP:
require_once("libraries/TeamSpeak3/TeamSpeak3.php");
$ts3 = TeamSpeak3::factory("serverquery://UN:PW@IP:10011/");
$ts3_VirtualServer = $ts3->serverGetById(1);
$slots = $ts3_VirtualServer->getProperty("virtualserver_clientsonline") - $ts3_VirtualServer->getProperty("virtualserver_queryclientsonline") . "/" . $ts3_VirtualServer->virtualserver_maxclients;
Maybe someone could make new list of functions :D


I Use This Form:

PHP:
    $ts3_ServerInstance = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."");
    $ts3 = $ts3_ServerInstance->serverGetByPort(9987);

PHP:
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th>IP/PORT</th>
                                            <th>Name</th>
                                            <th>Slots</th>
                                            <th>Uptime</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td><a href="ts3server://<?php echo $ts3->getAdapterHost() ?>/?port=<XXXXXXXX"><?php echo $ts3->getAdapterHost() ?>:<?php echo $PORT></td>
                                                <td><?php echo $ts3->virtualserver_name ?></td>
                                                <td><?php echo $ts3->virtualserver_clientsonline ?> / <?php echo $ts3->virtualserver_maxclients ?></td>
                                                <td><?php echo TeamSpeak3_Helper_Convert::seconds($ts3->virtualserver_uptime) ?></td>
                                            </tr>
                                        </tbody>
                                    </table>

And i have that ♥

wwFsFW
 
Top