diff -Nur oldurfaphp/URFAClient_Connection.php newurfaphp/URFAClient_Connection.php --- oldurfaphp/URFAClient_Connection.php 2010-07-12 00:57:52.563618902 +0600 +++ newurfaphp/URFAClient_Connection.php 2010-07-12 01:11:22.798994237 +0600 @@ -2,17 +2,20 @@ class URFAClient_Connection { private $socket = null; + private $admin = false; public $error = ''; // Для возврата ошибки - function __construct($address, $port, $login, $pass, $ssl = true) + function __construct($address, $port, $login, $pass, $ssl=true, $admin=false) { + + $this->admin=$admin; if ($address && $port && $login) { if (!$this->open($address, $port)) { $this->error = 'connect error'; return false; } - if (!$this->login($login, $pass, $ssl)) { + if (!$this->login($login, $pass, true)) { $this->error = 'login error'; } } @@ -20,7 +23,15 @@ function open($address, $port) { - $context = stream_context_create(array('ssl' => array('ciphers'=> "ADH-RC4-MD5",))); + if ($this->admin) { + $context = stream_context_create(); + stream_context_set_option($context, 'ssl', 'capture_peer_cert', true); + stream_context_set_option($context, 'ssl', 'local_cert', 'admin.crt'); + stream_context_set_option($context, 'ssl', 'passphrase', 'netup'); + } else { + $context = stream_context_create(array('ssl' => array('ciphers'=> "ADH-RC4-MD5",))); + } + $address = gethostbyname($address); $this->socket = stream_socket_client("tcp://$address:$port", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context); return !empty($this->socket); // Для возврата ошибки @@ -64,7 +75,7 @@ function ssl_connect($ssl) { -// stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT); + stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT); } @@ -93,8 +104,11 @@ function urfa_auth(&$packet, $uname, $upass, $ssl) { - if ($ssl == true) - $ssl = 2; + if ($this->admin) + $ssl = 4; + else + $ssl = 2; + $digest = $packet->attr[6]['data']; // print "Received ".bin2hex($digest)." digest\n"; $ctx = hash_init('md5'); @@ -118,6 +132,7 @@ * @return URFAClient_Packet */ // Старая версия (множественные вызовы urfa_get_data) +/* function urfa_get_data($data = false) { if (!$data) { @@ -136,7 +151,9 @@ } } } - /* Новая версия (единственный вызов urfa_get_data) +*/ +// Новая версия (единственный вызов urfa_get_data) + function urfa_get_data() { $packet = $this->getPacket(); $packet->clean(); @@ -151,7 +168,7 @@ return FALSE; return $packet; } - */ + function urfa_send_param(URFAClient_Packet $packet) { diff -Nur oldurfaphp/URFAClient.php newurfaphp/URFAClient.php --- oldurfaphp/URFAClient.php 2010-07-12 00:57:02.849872844 +0600 +++ newurfaphp/URFAClient.php 2010-07-12 01:16:54.565746125 +0600 @@ -14,11 +14,11 @@ protected $address; protected $port; // public $error = ''; - public function __construct($login, $pass, $address = "127.0.0.1", $port = "11758", $ssl = false) + public function __construct($login, $pass, $address = "127.0.0.1", $port = "11758", $ssl = true, $admin) { $this->address = $address; $this->port = $port; - $this->connection = new URFAClient_Connection($address, $port, $login, $pass, $ssl); + $this->connection = new URFAClient_Connection($address, $port, $login, $pass, $ssl, $admin); $this->error = $this->connection->error; } }