Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class FTPbackup {
- //Connection
- private $_conn_id, $_files, $_suffix, $_login;
- //Variables
- public $_path;
- private $_startlap, $_list, $_anzlist, $_i, $_split, $_itemname, $_endung, $_stos, $_nameer, $_counst;
- public function connectFTP($url="",$un="",$pw="",$port=21){
- $this->_files = array();
- $this->_conn_id = ftp_connect($url,$port);
- $this->_login = ftp_login($this->_conn_id, $un, $pw);
- if(!$conn_id){
- return "Couldn't connect to server.";
- }else if(!$login){
- return "Wrong Username/Password for server.";
- }else{
- return true;
- }
- }
- public function listDir($folder){
- $conn_id = $this->_conn_id;
- $suffix = $this->_suffix;
- $files = $this->_files;
- $list = ftp_rawlist($conn_id, $folder);
- $anzlist = count($list);
- $i = 0;
- while ($i < $anzlist){
- $split = preg_split("/[\s]+/", $list[$i], 9, PREG_SPLIT_NO_EMPTY);
- $itemname = $split[8];
- $endung = strtolower(substr(strrchr($itemname ,"."),1));
- $path = "$folder/$itemname";
- if (substr($list[$i],0,1) === "d" AND substr($itemname,0,1) != ".") {
- $stos = explode("/",$path);
- $counst = (count($stos)-1);
- $nameer = $stos[$counst];
- $this->_files = $files;
- $this->listDir($path);
- }else{
- if(substr($path,strlen($path)-1,strlen($path)) != "." ){
- array_push($files, $path);
- }
- }
- $i++;
- }
- return $files;
- }
- }
Add Comment
Please, Sign In to add comment