EGOCMS  24.0
EGOTEC Content-Managament-System
Ego_FTP.php
gehe zur Dokumentation dieser Datei
1 <?php
14 class Ego_FTP {
20  const DEFAULT_PORT = 21;
21 
27  private $host;
28 
34  private $port;
35 
41  private $ftp;
42 
49  public function __construct($host, $port = self::DEFAULT_PORT) {
50  $this->host = $host;
51  $this->port = (int) $port;
52  }
53 
57  public function __destruct() {
58  $this->close();
59  }
60 
69  public function connect($username = '', $password = '', $ssl = false) {
70  if ($ssl) {
71  $this->ftp = @ftp_ssl_connect($this->host, $this->port);
72  } else {
73  $this->ftp = @ftp_connect($this->host, $this->port);
74  }
75 
76  if (!empty($username)) {
77  // Direkt anmelden
78  if (!@ftp_login($this->ftp, $username, $password)) {
79  return false;
80  }
81  }
82  @ftp_pasv($this->ftp, true); // Immer im Passivmodus
83  return true;
84  }
85 
91  public function close() {
92  if ($this->ftp) {
93  @ftp_close($this->ftp);
94  $this->ftp = null;
95  }
96  }
97 
104  public function mkdir($directory) {
105  return @ftp_mkdir($this->ftp, $directory);
106  }
107 
114  public function chdir($dir) {
115  return @ftp_chdir($this->ftp, $dir);
116  }
117 
126  public function put($remote_file, $local_file, $mode = FTP_ASCII) {
127  return @ftp_put($this->ftp, $remote_file, $local_file, $mode);
128  }
129 
138  public function get($local_file, $remote_file, $mode = FTP_ASCII) {
139  return @ftp_get($this->ftp, $local_file, $remote_file, $mode);
140  }
141 
148  public function delete($path) {
149  return @ftp_delete($this->ftp, $path);
150  }
151 
159  public function rename($oldname, $newname) {
160  return @ftp_rename($this->ftp, $oldname, $newname);
161  }
162 
170  public function chmod($mode, $filename) {
171  return @ftp_chmod($this->ftp, $mode, $filename);
172  }
173 
180  public function size($remote_file) {
181  return @ftp_size($this->ftp, $remote_file);
182  }
183 }
184 ?>
connect($username='', $password='', $ssl=false)
Definition: Ego_FTP.php:69
chdir($dir)
Definition: Ego_FTP.php:114
__destruct()
Definition: Ego_FTP.php:57
size($remote_file)
Definition: Ego_FTP.php:180
rename($oldname, $newname)
Definition: Ego_FTP.php:159
chmod($mode, $filename)
Definition: Ego_FTP.php:170
close()
Definition: Ego_FTP.php:91
put($remote_file, $local_file, $mode=FTP_ASCII)
Definition: Ego_FTP.php:126
__construct($host, $port=self::DEFAULT_PORT)
Definition: Ego_FTP.php:49
const DEFAULT_PORT
Definition: Ego_FTP.php:20
mkdir($directory)
Definition: Ego_FTP.php:104