• Hey Guest, we're evolving the future of TeaSpeak.
    You're invited to join the discussion here!

Beim Versuch ein Client i_icon_id zu uploaden, kommt ein Fehler (ts3admin.class.php)

h1web

Well-known member
Hey :)

der Henker hat ein Script gebaut, welches dem User erlaubt das Client Icon mittels einem Webscript zu setzen.
Leider kommt bei der aktuellen TeaSpeak Version folgender Fehler:

Code:
ErrorID: 1540 | Message: convert error extra_msg=Invalid argument (stoi) ) [data]
Das interessante dabei ist, dass das Icon aber auf den Server hochgeladen wird (es erscheint in der Icon liste des Servers!)
Nur eben wird es nicht zum jeweiligen Client als i_icon_id gesetzt.

Code:
<?php

session_start();
require_once 'lib/ts3admin.class.php';
$website_name = "IconAPI"; //Website Name
$ts3ip = "127.0.0.1"; //TS3IP
$ts3port = "9987"; //TS3Port
$ts3qport = "10011"; //TS3Query Port
$ts3user = "serveradmin"; //TS3User Login
$ts3pass = ""; //TS3Query Login

if(isset($_POST['username'])){
    $username = $_POST['username'];
    
    $tsAdmin = new ts3admin($ts3ip, $ts3qport);
    if($tsAdmin->getElement('success', $tsAdmin->connect())) {
        $tsAdmin->login($ts3user, $ts3pass);
        $tsAdmin->setName($website_name);
        $tsAdmin->selectServer($ts3port);
        $clients = $tsAdmin->clientList("-uid -ip -groups -info");
        
        //Find the Client by fetching the Connected IP Adress:
        if($_SERVER['HTTP_CF_CONNECTING_IP']){
            $remoteAddr = $_SERVER['HTTP_CF_CONNECTING_IP'];
        } else {
            $remoteAddr = $_SERVER['REMOTE_ADDR'];
        }
        
        foreach($clients['data'] as $client) {
            $cname = $client['client_nickname'];
            $ip = $client['connection_client_ip'];
            $uid = $client['client_unique_identifier'];
            $groups = $client['client_servergroups'];
            $version = $client['client_version'];
            $platform = $client['client_platform'];
            $clid = $client['clid'];
            $cid = $client['cid'];
            $dbid = $client['client_database_id'];
            $time = time();
            $rid = rand("1", "999999");
            $idname = $time.$rid;
            
            if($remoteAddr == $ip){
                
                //Magic Stuff begins here:
                $endfile = $idname."_".$username;
                
                file_put_contents("dicons/$endfile.png", fopen("https://minotar.net/avatar/$username.png", 'r'));
                $debugger = $tsAdmin->uploadIcon("dicons/$endfile.png");
                $iconID = $debugger['data'][0]['name'];
                $iconID = str_replace("/icon_", "", $iconID);
                
                $permissions = array();
                $permissions['i_icon_id'] = array("$iconID", "0");
                
                $tsAdmin->clientAddPerm($dbid, $permissions);
                
                header("Location: ?icon_set");
                die();
                
            }
        }
        
        echo "HANDLED!";
        
    } else {
        die("ERROR WHILE CONNECTING TO TS3 SERVER!");
    }
        
}
?>
<form action="" method="POST">
    <h1>Simple TS3 Icon System with IP-TS3 Check.</h1>
    <input type="text" name="username" placeholder="Username">
    <button>Set TS3 Icon</button>
</form>
Quelle: https://raw.githubusercontent.com/FlareNetwork/simple-ts3-icon-set-web-panel/master/index.php
 

h1web

Well-known member
Trace output, it looks more like a "path" error? Because TheHenker said, its working on Tea*Speak, just not for TeaSpeak.
The permissions of the folders are writeable.


Code:
[2019-02-01 11:59:01] [INFO]  QUERY | Got new client from 192.168.0.4:59375
[2019-02-01 11:59:01] [DEBUG]   GEN | Could not find requested file. Abs path: "./files/server_2/icons//icon_1043752837"|./files/server_2/icons//icon_1043752837. (path=./files/server_2/icons//icon_1043752837, parent=./files/server_2/icons)
[2019-02-01 11:59:01] [DEBUG]   GEN | Created file upload key=31YcKHPcVOfSX5sn for ./files/server_2/icons/icon_1043752837 (754 bytes)
[2019-02-01 11:59:01] [INFO]   FILE | Got new client from 192.168.0.4:45051
[2019-02-01 11:59:01] [ERROR]  FILE | [0|192.168.0.4:45051|unconnected] Remote peer closed the connection
[2019-02-01 11:59:01] [DEBUG]  FILE | [0|192.168.0.4:45051|unconnected] Transferring data with the TS protocol
[2019-02-01 11:59:01] [DEBUG]  FILE | [0|192.168.0.4:45051|unconnected] Disconnecting client. Connection state: 0 Flush IO: true
[2019-02-01 11:59:01] [DEBUG]  FILE | [2|192.168.0.4:45051| Icon-API] Initialized file transfer for file './files/server_2/icons/icon_1043752837' (Type: upload)
[2019-02-01 11:59:01] [DEBUG]  FILE | [2|192.168.0.4:45051| Icon-API] Received local file size 0. Target size if 754
[2019-02-01 11:59:01] [DEBUG]   GEN | Could not find requested file. Abs path: "./files/server_2/avatars//icon_1043752837"|./files/server_2/avatars//icon_1043752837. (path=./files/server_2/avatars//icon_1043752837, parent=./files/server_2/avatars)
[2019-02-01 11:59:01] [DEBUG]     2 | [192.168.0.4:59373/Icon-API | 8][Command] Execution throws invalid_argument exception (stoi).
 

WolverinDEV

TeaSpeak Team
Staff member
Administrator
No thats not the issue there :)
Within the upload you're may missing the parameter overwrite, resume or size or clientftfid.
Use trace mode to debug your commands :)
 

h1web

Well-known member
How to use the trace mode, i already have set the log to 0 (trace), i dont get more than just these lines.

Also: The Script is working on TeamSpeak :)
 

WolverinDEV

TeaSpeak Team
Staff member
Administrator
There are the terminal and the log level.
Wherever you've got the posted thing above wasnt in trace :D

And yep because sometimes Tea*Speak wants and sometimes Tea*Speak dont wants specific stuff.
 

h1web

Well-known member
So i think the problem is, we cannot set the absolute path within the Script.

./files/server_2/icons/...

any chance we can set this in the ts3admin.class or in teaspeak config? :p

Code:
[2019-02-03 10:57:31] [DEBUG]  FILE | [0|xxx|unconnected] Transferring data with the TS protocol
[2019-02-03 10:57:31] [DEBUG]  FILE | [2|xxx| á…Ÿá…Ÿá…Ÿá…Ÿ] Initialized file transfer for file './files/server_2/icons/icon_1006483330' (Type: download)
[2019-02-03 10:57:31] [DEBUG]  FILE | [2|xxx| á…Ÿá…Ÿá…Ÿá…Ÿ] Received local file size 0. Target size if 0
[2019-02-03 10:57:31] [INFO]   FILE | [2|xxx| á…Ÿá…Ÿá…Ÿá…Ÿ] File transfer complete!
[2019-02-03 10:57:31] [DEBUG]  FILE | [2|xxx| á…Ÿá…Ÿá…Ÿá…Ÿ] Disconnecting client. Connection state: 0 Flush IO: true
my teaspeak server is not in the path ./files from the script
 

WolverinDEV

TeaSpeak Team
Staff member
Administrator
As I've already said the error you get isnt the actual file uploading mechanism. Its an invalid or missing parameter.
In the section you posted above everything works totally fine.

You should may post a trace log of the query command which you've issues with the query library :)