TeamSpeak 3 PHP Framework
1.1.16
Copyright © Planet TeamSpeak. All rights reserved.
Main Page
Related Pages
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Pages
TSDNS.php
Go to the documentation of this file.
1
<?php
2
3
/**
4
* @file
5
* TeamSpeak 3 PHP Framework
6
*
7
* $Id: TSDNS.php 8/31/2012 11:06:09 scp@orilla $
8
*
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
18
*
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
*
22
* @package TeamSpeak3
23
* @version 1.1.16
24
* @author Sven 'ScP' Paulsen
25
* @copyright Copyright (c) 2010 by Planet TeamSpeak. All rights reserved.
26
*/
27
28
/**
29
* @class TeamSpeak3_Adapter_TSDNS
30
* @brief Provides methods to query a TSDNS server.
31
*/
32
class
TeamSpeak3_Adapter_TSDNS
extends
TeamSpeak3_Adapter_Abstract
33
{
34
/**
35
* The TCP port number used by any TSDNS server.
36
*
37
* @var integer
38
*/
39
protected
$default_port = 41144;
40
41
/**
42
* Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote
43
* server.
44
*
45
* @throws TeamSpeak3_Adapter_Exception
46
* @return void
47
*/
48
public
function
syn
()
49
{
50
if
(!isset($this->options[
"port"
]) || empty($this->options[
"port"
])) $this->options[
"port"
] = $this->default_port;
51
52
$this->
initTransport
($this->options);
53
$this->transport->setAdapter($this);
54
55
TeamSpeak3_Helper_Profiler::init
(spl_object_hash($this));
56
57
TeamSpeak3_Helper_Signal::getInstance
()->emit(
"tsdnsConnected"
, $this);
58
}
59
60
/**
61
* The TeamSpeak3_Adapter_FileTransfer destructor.
62
*
63
* @return void
64
*/
65
public
function
__destruct
()
66
{
67
if
($this->
getTransport
() instanceof
TeamSpeak3_Transport_Abstract
&& $this->
getTransport
()->isConnected())
68
{
69
$this->
getTransport
()->disconnect();
70
}
71
}
72
73
/**
74
* Queries the TSDNS server for a specified virtual hostname and returns the result.
75
*
76
* @param string $tsdns
77
* @throws TeamSpeak3_Adapter_TSDNS_Exception
78
* @return TeamSpeak3_Helper_String
79
*/
80
public
function
resolve
($tsdns)
81
{
82
$this->
getTransport
()->sendLine($tsdns);
83
$repl = $this->
getTransport
()->readLine();
84
$this->
getTransport
()->disconnect();
85
86
if
($repl->section(
":"
, 0)->toInt() == 404)
87
{
88
throw
new
TeamSpeak3_Adapter_TSDNS_Exception
(
"unable to resolve TSDNS hostname ("
. $tsdns .
")"
);
89
}
90
91
TeamSpeak3_Helper_Signal::getInstance
()->emit(
"tsdnsResolved"
, $tsdns, $repl);
92
93
return
$repl;
94
}
95
}
TeamSpeak3
Adapter
TSDNS.php
Generated on Thu Sep 13 2012 20:51:28 for TeamSpeak 3 PHP Framework by
1.8.2