Сервер: Centos 5.5 c установленным openssh-server и LAMP сервером не каких модов на пхп больше не ставил... и не знаю что делать код вроде правильный написал по идеи все должно работать.. но увы папку не создает.. такое чувство что чего то в пхп не хватает... можите подсказать что делать????
либо я не понял как правильно пользоваться данным классом:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- class ssh
- {
- private $host; // Host of serverr
- private $port; // Port of server
- private $user; // User fpr server
- private $pass; // Password for server
- private $connection = false; // Connection resourse
- private $error = false; // Last error
- private $result = ""; // Result of command executing
- private $timeOut = 10; // Time out of command executing
- public function __construct($host, $user, $pass, $port = 22){
- $this->host = $host;
- $this->user = $user;
- $this->pass = $pass;
- $this->port = $port;
- if($host == sshData::$host && $user == sshData::$user){
- $this->connection = sshData::$connect;
- $result = true;
- }else{
- sshData::$host = $host;
- sshData::$user = $user;
- $result = $this->connect();
- sshData::$connect = $this->connection;
- }
- return $result;
- }
- // Execute some command
- /*
- $steam = ssh2_exec($this->connection,$command); return true;
- $timeStart = time();
- $this->result = "";
- stream_set_blocking($stream,$true);
- while(strlen($this->result) == 0){
- $this->result .= fread($stream,4096);
- if(strlen($this->result) > 0)return true;
- elseif((time() - $timeStart) > $this->timeOut){
- $this->error = "Warning: Timeout of command executing has been reached";
- return false;
- }
- }
- //
- $r = rand(0,100000);
- $fi = @file_get_contents("data/data1");
- $f = @fopen("data/data1","w");
- @fwrite($f,$fi.$command."; echo \"{__EXECUTING_FINISHED__".$r."}\"".";\n");
- @fclose($f);
- */
- $this->error = "Warning: Unable to execute command";
- return false;
- }else{
- $this->result = "";
- while(true){
- return true;
- $this->error = "Warning: Timeout of command executing has been reached";
- return false;
- }
- }
- }
- }
- // Return last result
- public function result(){
- return $this->result;
- }
- // Return last error
- public function error(){
- return $this->error;
- }
- // Sending file to server
- public function f2s($localePath,$serverPath){
- }
- // Getting file from server
- public function s2f($serverPath,$localePath){
- }
- // Connect to the server
- private function connect(){
- $this->error = "Fatal error: SSH lib doesn't exist";
- return false;
- }else{
- if(!$this->connection){
- $this->error = "Fatal error: Unable to establish connection";
- return false;
- }else{
- $this->error = "Fatal error: Unable to authenticate";
- return false;
- }else return true;
- }
- }
- }
- }
- class sshData
- {
- static $user;
- static $host;
- static $connect;
- }
- ?>