Guest User

Untitled

a guest
Nov 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?
  2. class FTPbackup {
  3. //Connection
  4. private $_conn_id, $_files, $_suffix, $_login;
  5.  
  6. //Variables
  7. public $_path;
  8. private $_startlap, $_list, $_anzlist, $_i, $_split, $_itemname, $_endung, $_stos, $_nameer, $_counst;
  9.  
  10. public function connectFTP($url="",$un="",$pw="",$port=21){
  11. $this->_files = array();
  12. $this->_conn_id = ftp_connect($url,$port);
  13. $this->_login = ftp_login($this->_conn_id, $un, $pw);
  14. if(!$conn_id){
  15. return "Couldn't connect to server.";
  16. }else if(!$login){
  17. return "Wrong Username/Password for server.";
  18. }else{
  19. return true;
  20. }
  21. }
  22.  
  23. public function listDir($folder){
  24. $conn_id = $this->_conn_id;
  25. $suffix = $this->_suffix;
  26. $files = $this->_files;
  27. $list = ftp_rawlist($conn_id, $folder);
  28. $anzlist = count($list);
  29. $i = 0;
  30. while ($i < $anzlist){
  31. $split = preg_split("/[\s]+/", $list[$i], 9, PREG_SPLIT_NO_EMPTY);
  32. $itemname = $split[8];
  33. $endung = strtolower(substr(strrchr($itemname ,"."),1));
  34. $path = "$folder/$itemname";
  35. if (substr($list[$i],0,1) === "d" AND substr($itemname,0,1) != ".") {
  36. $stos = explode("/",$path);
  37. $counst = (count($stos)-1);
  38. $nameer = $stos[$counst];
  39. $this->_files = $files;
  40. $this->listDir($path);
  41. }else{
  42. if(substr($path,strlen($path)-1,strlen($path)) != "." ){
  43. array_push($files, $path);
  44. }
  45. }
  46. $i++;
  47. }
  48. return $files;
  49. }
  50. }
Add Comment
Please, Sign In to add comment