So I'm trying to submit the name of a teamspeak 3 channel and the one word channels work fine with using $_POST['channel'] but if the string is two words (separated by a space) then it only uses the first word of the string
Form.php:
<form name="kick" method="POST" action="kick.php">
<select name="channel" id="channel">
<option value="default" name="default" selected>Choose One</option>
<?php
require_once("Teamspeak3/libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://<username redacted>:<password redacted>
@localhost:10011/?server_port=9987");
foreach ($ts3_VirtualServer->channelList() as $ts3_Channel) {
echo "<option value=" . $ts3_Channel["channel_name"] . ">" . $ts3_Channel["channel_name"] . "</option>";
}
?>
</select>
<input type="submit" name="Kick Players"/>
</form>
Kick.php:
<?php session_start();
define('MYSITE', $_SERVER['SERVER_NAME'] . ":8000"); //define what our site is.
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST['channel'] == "default") {
header('Location: http://' . MYSITE . '/panel_error.php?reason=default');
exit();
} else {
$clients = array();
require_once("Teamspeak3/libraries/TeamSpeak3/TeamSpeak3.php");
$ts3_VirtualServer = TeamSpeak3::factory("serverquery://<username redacted>:<password redacted>
@localhost:10011/?server_port=9987");
$channel = $ts3_VirtualServer->channelGetByName($_POST['channel']);
foreach($ts3_VirtualServer->clientList() as $client) {
if($client['cid'] == $channel->getId()) {
$clients[$client->getId()] = $client;
}
}
if(empty($clients)) {
header('Location: http://' . MYSITE . '/panel_error.php?reason=noclients');
exit();
}
$ts3_VirtualServer->clientKick($clients, TeamSpeak3::KICK_SERVER, "You have been kicked from the server!");
header('Location: http://' . MYSITE . '/panel.php');
exit();
}
}
EXAMPLE OF PROBLEM: In the drop down list I choose 'Admin Room'. I submit and when I run:
$channel = $ts3_VirtualServer->channelGetByName($_POST['channel']);
it runs as:
$channel = $ts3_VirtualServer->channelGetByName('Admin');
instead of:
$channel = $ts3_VirtualServer->channelGetByName('Admin Room');
THE ERROR:
C:\path\to\project\kick.php(11): TeamSpeak3_Node_Server->channelGetByName('Admin'); //results in below
Fatal error: Uncaught exception 'TeamSpeak3_Adapter_ServerQuery_Exception' with message 'invalid channelID'