//Original
function connect() {
if($this->isConnected()) {
$this->addDebugLog('Error: you are already connected!');
return $this->generateOutput(false, array('Error: the script is already connected!'), false);
}
$socket = @fsockopen($this->runtime['host'], $this->runtime['queryport'], $errnum, $errstr, $this->runtime['timeout']);
if(!$socket)
{
$this->addDebugLog('Error: connection failed!');
return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
}
else
{
if(strpos(fgets($socket), 'TS3') !== false)
{
$tmpVar = fgets($socket);
$this->runtime['socket'] = $socket;
return $this->generateOutput(true, array(), true);
}
else
{
$this->addDebugLog('host isn\'t a ts3 instance!');
return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
}
}
}
//my edit version
function connect() {
if($this->isConnected()) {
$this->addDebugLog('Error: you are already connected!');
return $this->generateOutput(false, array('Error: the script is already connected!'), false);
}
$socket = @fsockopen($this->runtime['host'], $this->runtime['queryport'], $errnum, $errstr, $this->runtime['timeout']);
if(!$socket)
{
$this->addDebugLog('Error: connection failed!');
return $this->generateOutput(false, array('Error: connection failed!', 'Server returns: '.$errstr), false);
}
else
{
// if(strpos(fgets($socket), 'TS3') !== false)
$prefix = fgets($socket);
if(strpos($prefix, 'TS3') !== false || strpos($prefix, 'TeaSpeak') !== false)
{
$tmpVar = fgets($socket);
$this->runtime['socket'] = $socket;
return $this->generateOutput(true, array(), true);
}
else
{
$this->addDebugLog('host isn\'t a ts3 instance!');
return $this->generateOutput(false, array('Error: host isn\'t a ts3 instance!'), false);
}
}
}