Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace FileTransfer;
- abstract class ConnectionProtocol
- {
- /*User login, String*/
- protected $user;
- /*User pass, String*/
- protected $pass;
- /*Hostname, String*/
- protected $host;
- /*SSH port, String or Number*/
- protected $port;
- /*current HostPath, String*/
- protected $connectionPath;
- /*current localPath, String*/
- protected $localPath;
- /*Connection, resource */
- protected $connection;
- /*CallsStack, Array */
- protected $log;
- /*LastResponse*/
- protected $response;
- protected $lastError;
- public function __construct( $user , $pwd, $host , $port, $localpath = __DIR__)
- {
- $this->user = $user;
- $this->pass = $pwd;
- $this->host = $host;
- $this->port = $port;
- $this->localPath = $localpath;
- $this->create();
- }
- abstract protected function create();
- public function __destruct( )
- {
- $this->close();
- }
- public function __toString()
- {
- return "<pre>".print_r($this->log, true)."</pre>";
- }
- public function setLocalDir($path)
- {
- if ( file_exists($path) && is_dir($path))
- {
- $this->localPath = $path;
- return true;
- }
- else
- {
- $this->setError("Dir not exist");
- return false;
- }
- }
- public function lastError()
- {
- return $this->lastError;
- }
- protected function setError($error)
- {
- $this->lastError = $error;
- }
- protected function addLog($str)
- {
- $this->log[] = $str;
- }
- protected function pathBuilder($path)
- {
- if(stripos('/', $path) === 0) return $path;
- else return $this->connectionPath.'/'.$path ;
- }
- }
- interface transport{
- public function create();
- public function close();
- public function cd($args);
- public function download($args);
- public function upload($args);
- public function exec($args);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement