Advertisement
Guest User

Untitled

a guest
Jan 15th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class Ftp {
  2. private $host, $user, $pass, $port;
  3.  
  4. function __construct($host, $user, $pass, $port = null) {
  5. $this->host = $host;
  6. $this->user = $user;
  7. $this->pass = $pass;
  8. $this->port = $port;
  9. }
  10.  
  11. private function connectIfNeeded(){
  12. if($this->connection){ return; }
  13. $this->connection = ftp_connect(.........);
  14. }
  15.  
  16. function __destruct(){
  17. if($this->connection){
  18. ftp_close($this->connection);
  19. }
  20. }
  21. function getCWD(){
  22. $this->connectIfNeeded();
  23. // ...
  24. }
  25. function listFiles(){
  26. $this->connectIfNeeded();
  27. // ...
  28. }
  29. function getFile($file){
  30. $this->connectIfNeeded();
  31. // ...
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement