04.07.2012, 09:25
(
Последний раз редактировалось next-studio|TheKiller; 04.07.2012 в 09:30.
Причина: Fixed a failing return @ __construct function
)
Hello all!
Well, during the last days i've been doing a small php socket connection for the remote server.(failled all times e.e)
And i am having a few problems with it.
I can connect into the ssh port, but i get "SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze1 Protocol mismatch."
And the code, which i've been doing is:
I'm not experienced with class's, so sorry if it's badly coded...
Well, during the last days i've been doing a small php socket connection for the remote server.(failled all times e.e)
And i am having a few problems with it.
I can connect into the ssh port, but i get "SSH-2.0-OpenSSH_5.5p1 Debian-6+squeeze1 Protocol mismatch."
And the code, which i've been doing is:
PHP код:
<?php
class servermanagement
{
private $socket = null;
private $server = null;
private $port = null;
private $user = null;
private $pass = null;
private $exec = "";
public function __construct($server, $port)
{
$this->server = $server;
$this->port = $port;
$this->socket = fsockopen("tcp://".$this->server, $this->port, $errno, $errstr, 2);
socket_set_timeout($this->socket, 2);
return;
}
public function LoginOnTheServer($user, $pass)
{
$this->user = $user;
$this->pass = $pass;
if($this->socket)
{
fwrite($this->socket, $this->user."\n", 100);
sleep(5);
fwrite($this->socket, $this->pass."\n", 100);
}
return;
}
public function GetServerUptime()
{
if($this->socket)
{
fwrite($this->socket, "uptime\n", 8);
}
$data = fread($this->socket, 4096);
return $data;
}
public function CloseConnectionWithTheServer()
{
fwrite($this->socket, "exit\n", 6);
fclose($this->socket);
return;
}
}
?>