TS3 PHP Framework question

Discussion in 'PHP' started by Nicer, Jun 26, 2016.

  1. Nicer

    Nicer Contributing Member

    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 likes this.
  2. Asphyxia

    Asphyxia Web Admin Administrator Super Mod

    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: Jun 26, 2016
  3. Nicer

    Nicer Contributing Member

    Fatal error: Call to undefined function decrypt() in C:\xampp\htdocs\home.php on line 65
    Doesn't work.
     
    Asphyxia likes this.
  4. Asphyxia

    Asphyxia Web Admin Administrator Super Mod

    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: Jun 26, 2016
    Nicer likes this.
  5. Nicer

    Nicer Contributing Member

    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 likes this.
  6. Asphyxia

    Asphyxia Web Admin Administrator Super Mod

    My bad, you'll need to call the function under the TeamSpeak3_Helper_Crypt class.

    Code:
    $testObject = new TeamSpeak3_Helper_Crypt();
    $testObject->decrypt($string);
    
     
    Nicer likes this.
  7. Asphyxia

    Asphyxia Web Admin Administrator Super Mod

    Let me know if that works or if you need more help. :)

    If you find a solution, please post that here.
     
  8. Nicer

    Nicer Contributing Member

    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: Jun 26, 2016
    Asphyxia likes this.
  9. Asphyxia

    Asphyxia Web Admin Administrator Super Mod

    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
     
    Nicer likes this.
  10. Nicer

    Nicer Contributing Member

    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
     
  11. Nicer

    Nicer Contributing Member

    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?
     
    Asphyxia likes this.
  12. Nicer

    Nicer Contributing Member

    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:[email protected]:10011/");
    $ts3_VirtualServer $ts3->serverSelect(1);
    $slots $ts3_VirtualServer->getProperty("virtualserver_clientsonline") - $ts3_VirtualServer->getProperty("virtualserver_queryclientsonline") . "/" $ts3_VirtualServer->virtualserver_maxclients;
    The error is -->
     
  13. Nicer

    Nicer Contributing Member

    Nevermind, I found the solution :D

    PHP:
    require_once("libraries/TeamSpeak3/TeamSpeak3.php");
    $ts3 TeamSpeak3::factory("serverquery://UN:[email protected]: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
     
  14. Nicer

    Nicer Contributing Member

    I meant new usage examples.
     
  15. EscuderoKevin

    EscuderoKevin Active Member


    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 ♥

    http://goo.gl/wwFsFW
     
  16. EscuderoKevin

    EscuderoKevin Active Member

    Sure:

    3 Sheets in Virtual Server Properties , i have printed that manual -.- Page 41 to 43.
     

Share This Page