TeamSpeak 3 PHP Framework  1.1.12
TeamSpeak3_Adapter_Blacklist Class Reference

Provides methods to check if an IP address is currently blacklisted. More...

Inheritance diagram for TeamSpeak3_Adapter_Blacklist:
TeamSpeak3_Adapter_Abstract

List of all members.

Public Member Functions

 syn ()
 Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote server.
 __destruct ()
 The TeamSpeak3_Adapter_Blacklist destructor.
 isBlacklisted ($host)
 Returns TRUE if a specified $host IP address is currently blacklisted.
 __sleep ()
 Commit pending data.
 __wakeup ()
 Reconnects to the remote server.
 getProfiler ()
 Returns the profiler timer used for this connection adapter.
 getTransport ()
 Returns the transport object used for this connection adapter.
 getTransportHost ()
 Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object is connected to.
 getTransportPort ()
 Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object is connected to.

Protected Member Functions

 initTransport ($options, $transport="TeamSpeak3_Transport_TCP")
 Loads the transport object object used for the connection adapter and passes a given set of options.

Protected Attributes

 $default_host = "blacklist.teamspeak.com"
 $default_port = 17385
 $build_numbers = null
 $options = null
 $transport = null

Detailed Description

Provides methods to check if an IP address is currently blacklisted.

Definition at line 32 of file Blacklist.php.


Constructor & Destructor Documentation

The TeamSpeak3_Adapter_Blacklist destructor.

Returns:
void

Reimplemented from TeamSpeak3_Adapter_Abstract.

Definition at line 79 of file Blacklist.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
    {
      $this->getTransport()->disconnect();
    }
  }

Member Function Documentation

Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote server.

Returns:
void

Reimplemented from TeamSpeak3_Adapter_Abstract.

Definition at line 61 of file Blacklist.php.

References TeamSpeak3_Helper_Signal\getInstance(), TeamSpeak3_Helper_Profiler\init(), and TeamSpeak3_Adapter_Abstract\initTransport().

  {
    if(!isset($this->options["host"]) || empty($this->options["host"])) $this->options["host"] = $this->default_host;
    if(!isset($this->options["port"]) || empty($this->options["port"])) $this->options["port"] = $this->default_port;

    $this->initTransport($this->options, "TeamSpeak3_Transport_UDP");
    $this->transport->setAdapter($this);

    TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));

    TeamSpeak3_Helper_Signal::getInstance()->emit("blacklistConnected", $this);
  }

Returns TRUE if a specified $host IP address is currently blacklisted.

Parameters:
string$host
Exceptions:
TeamSpeak3_Adapter_Blacklist_Exception
Returns:
boolean

Definition at line 94 of file Blacklist.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    if(ip2long($host) === FALSE)
    {
      $addr = gethostbyname($host);

      if($addr == $host)
      {
        throw new TeamSpeak3_Adapter_Blacklist_Exception("unable to resolve IPv4 address (" . $host . ")");
      }

      $host = $addr;
    }

    $this->getTransport()->send("ip4:" . $host);
    $repl = $this->getTransport()->read(1);
    $this->getTransport()->disconnect();

    if(!count($repl))
    {
      return FALSE;
    }

    return ($repl->toInt()) ? FALSE : TRUE;
  }

Commit pending data.

Returns:
array

Definition at line 85 of file Abstract.php.

  {
    return array("options");
  }

Reconnects to the remote server.

Returns:
void

Definition at line 95 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\syn().

  {
    $this->syn();
  }
TeamSpeak3_Adapter_Abstract::initTransport ( options,
transport = "TeamSpeak3_Transport_TCP" 
) [protected, inherited]

Loads the transport object object used for the connection adapter and passes a given set of options.

Parameters:
array$options
string$transport
Exceptions:
TeamSpeak3_Adapter_Exception
Returns:
void

Definition at line 129 of file Abstract.php.

Referenced by TeamSpeak3_Adapter_FileTransfer\syn(), TeamSpeak3_Adapter_TSDNS\syn(), syn(), TeamSpeak3_Adapter_ServerQuery\syn(), and TeamSpeak3_Adapter_Update\syn().

  {
    if(!is_array($options))
    {
      throw new TeamSpeak3_Adapter_Exception("transport parameters must provided in an array");
    }

    $this->transport = new $transport($options);
  }

Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object is connected to.

Returns:
string

Definition at line 145 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    return $this->getTransport()->getConfig("host", "0.0.0.0");
  }

Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object is connected to.

Returns:
string

Definition at line 156 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    return $this->getTransport()->getConfig("port", "0");
  }

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables