Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $ftp_server="nuftp.com";
- $ftp_user="ftptest@nuftp.com";
- $ftp_pass="TiN40L?dK9et";
- $remotepath="/virtdocs";
- $localpath="E:/Program Files/EasyPHP 3.0/www/tasks/ftp/virtdocs";
- $ftp_conn=ftp_connect($ftp_server);
- if(ftp_login($ftp_conn,$ftp_user,$ftp_pass))
- {
- mkdir($localpath);
- ftp_chdir($ftp_conn,$remotepath);
- downloadDir($remotepath);
- }
- function downloadDir($path)
- {
- $items=ftp_nlist($GLOBALS['ftp_conn'],$path);
- $rawlist=ftp_rawlist($GLOBALS['ftp_conn'],$path);
- $merge=array_merge($items,$rawlist);
- $i=-1;
- foreach($items as $item)
- {
- $i++;
- if(strpos($item,".")===0 && (strrpos($item,".")===1 || strlen($item)==1))
- {
- //echo $item;
- continue;
- }
- echo "<br>".$rawlist[$i];
- $fullpath=$path."/".$item;
- //echo "<br>".$fullpath;
- $currentlocalpath=str_replace($GLOBALS['remotepath'],$GLOBALS['localpath'],$fullpath);
- //echo "<br>".$fullpath."<br>".$currentlocalpath;
- if(strpos($rawlist[$i],"d")===0)
- {
- mkdir($currentlocalpath);
- //echo "<br>Dir ".$currentlocalpath;
- chdir($currentlocalpath);
- ftp_chdir($GLOBALS['ftp_conn'],$fullpath);
- downloadDir($fullpath);
- ftp_cdup($GLOBALS['ftp_conn']);
- //chroot($GLOBALS['localpath']);
- }
- if(strpos($rawlist[$i],"-")===0)
- {
- if(ftp_get($GLOBALS['ftp_conn'],$currentlocalpath,$fullpath,FTP_ASCII))
- echo "<br>File ".$currentlocalpath;
- }
- }
- }
- ftp_close($ftp_conn);
- ?>
Add Comment
Please, Sign In to add comment