2017-07-07 56 views
0

我開始使用platiqueamspeak.com的TeamSpeak 3 PHP Framework。 我不明白它添加和刪除客戶端的服務器組。 它總是告訴我「無效的ClientID」,這意味着我錯過了一些東西。暱稱爲DatabaseID

我嘗試了很多方法來獲取ID,但沒有任何工作。如果我可以通過客戶端名稱獲得ID,會很好,但我不知道該怎麼做。

此外,手動條目被稱爲「無效」。這裏是我的代碼:

<?php 
require_once ("lib/TeamSpeak3/TeamSpeak3.php"); 
require_once ("config/config.php"); 

// goes into config later 
date_default_timezone_set($config['timezone']); 
// current time 
$the_time = date('Y-m-d h:i a'); 
// setup connection 
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://" . $config["Username"] . ":" . $config["Password"] . "@" . $config["IP"] . ":" . $config["qPort"] . "/?server_port=" . $config["Port"] . "&nickname=" . $config["Nickname"] . ""); 
// query clientlist from virtual server 
$arr_clientList = $ts3_VirtualServer->ClientList(); 
// walk through list of clients 
foreach($arr_clientList as $client) { 
    if ($client["client_type"] == 1) { 
     continue; 
    } 
    echo $client . " benutzt " . $client["client_platform"] . ".\n"; 
    // fetch first connection of specified client^
    $client_created = date('Y-m-d h:i a', $client->client_created); 
    echo $the_time . ' Uhr lokal. '; 
    echo "\n"; 
    echo $client_created . ' Client erstellt. '; 
    $to_time = strtotime($the_time); 
    $from_time = strtotime($client_created); 
    echo "\n"; 
    echo $client . " ist "; 
    if (round(abs($to_time - $from_time)/86400, 2) >= 30) { 
     echo "Stammgast. "; 
     try { 
      $sgid = "7"; 
      $ts3_VirtualServer->serverGroupClientDel($sgid, '12'); 
     } 
     catch(Exception $e) { 
      echo $e->getMessage(); 
     } 
     try { 
      $sgid = "13"; 
      $ts3_VirtualServer->serverGroupClientAdd($sgid, '12'); 
     } 
     catch(Exception $e) { 
      echo $e->getMessage(); 
     } 
    } 
    else if (round(abs($to_time - $from_time)/86400, 2) >= 14) { 
     echo "Member. "; 
     try { 
      $sgid = "29"; 
      $ts3_VirtualServer->serverGroupClientDel($sgid, '12'); 
     } 
     catch(Exception $e) { 
      echo $e->getMessage(); 
     } 
     try { 
      $sgid = "7"; 
      $ts3_VirtualServer->serverGroupClientAdd($sgid, '12'); 
     } 
     catch(Exception $e) { 
      echo $e->getMessage(); 
     } 
    } 
    else if (round(abs($to_time - $from_time)/86400, 2) >= 7) { 
     echo "Rookie. "; 
     try { 
      $sgid = "29"; 
      $ts3_VirtualServer->clientGetByName($client)->serverGroupClientAdd($sgid, '12'); 
     } 
     catch(Exception $e) { 
      echo $e->getMessage(); 
     } 
    } 
    echo "\n"; 
    echo 'Erster connect war ' . round(abs($to_time - $from_time)/86400, 2) . ' Tage früher. '; 
    echo "\n\n"; 
} 
?> 

的config.php:

<?php 

$config = array(); //Creates Config Array 
$config["Username"] = "serveradmin"; 
$config["Password"] = "**********"; 
$config["IP"] = "***********"; //Server IP/Domain 
$config["Port"] = "9987"; //Server Port 
$config["qPort"] = "10011"; // Query Port, Default 10011 
$config["Nickname"] = rawurlencode("Rangsystem".rand(1, 99)); // Random number & Convertes Botname to a URI friendly Format 
$config["timezone"] = 'Europe/Berlin'; 
?> 

回答

0

,我發現我的問題

$ts3_VirtualServer->serverGroupClientDel($sgid, $client); 

$ts3_VirtualServer->serverGroupClientDel($sgid, $client['client_database_id']);