コード例 #1
2
 /**
  * @param string $file
  */
 private function clean($file)
 {
     if (ftp_size($this->connection, $file) == -1) {
         $result = ftp_nlist($this->connection, $file);
         foreach ($result as $childFile) {
             $this->clean($childFile);
         }
         ftp_rmdir($this->connection, $file);
     } else {
         ftp_delete($this->connection, $file);
     }
 }
コード例 #2
0
ファイル: FTPExtension.php プロジェクト: aWEBoLabs/taxi
 /**
  * {@inheritdoc}
  */
 protected function removeDirectoryJailed($directory)
 {
     $pwd = ftp_pwd($this->connection);
     if (!ftp_chdir($this->connection, $directory)) {
         throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory));
     }
     $list = @ftp_nlist($this->connection, '.');
     if (!$list) {
         $list = array();
     }
     foreach ($list as $item) {
         if ($item == '.' || $item == '..') {
             continue;
         }
         if (@ftp_chdir($this->connection, $item)) {
             ftp_cdup($this->connection);
             $this->removeDirectory(ftp_pwd($this->connection) . '/' . $item);
         } else {
             $this->removeFile(ftp_pwd($this->connection) . '/' . $item);
         }
     }
     ftp_chdir($this->connection, $pwd);
     if (!ftp_rmdir($this->connection, $directory)) {
         throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory));
     }
 }
コード例 #3
0
ファイル: ftp.fun.php プロジェクト: polarlight1989/08cms
 function mrmdir($directory)
 {
     if (!$this->conn_id) {
         return false;
     }
     return @ftp_rmdir($this->conn_id, $directory);
 }
コード例 #4
0
ファイル: ftp.class.php プロジェクト: knowsee/uoke_framework
 public function rmdir($dir)
 {
     if (FALSE === ftp_rmdir($this->link, $dir)) {
         $this->errormsg = "Can't remove this dir";
         return FALSE;
     }
     return TRUE;
 }
コード例 #5
0
ファイル: Forge.php プロジェクト: znframework/znframework
 public function deleteFolder(string $path) : bool
 {
     if (ftp_rmdir($this->connect, $path)) {
         return true;
     } else {
         throw new FolderNotFoundException($path);
     }
 }
コード例 #6
0
ファイル: Ftp.php プロジェクト: rajarshc/Rooja
 /**
  * Updates Varien's method that accepts the $recursive param but doesn't do anything
  * with it. This new method calls rmdirRecursive() if $recursive is true.
  *
  * @param string $dir
  * @param bool $recursive
  * @return boolean
  */
 public function rmdir($dir, $recursive = false)
 {
     if ($recursive) {
         return $this->rmdirRecursive($dir);
     } else {
         return @ftp_rmdir($this->_conn, $dir);
     }
 }
コード例 #7
0
/**
 * Recursively delete the files in a directory via FTP.
 *
 * @author      Aidan Lister <*****@*****.**>
 * @version     1.0.0
 * @link        http://aidanlister.com/2004/04/recursively-deleting-directories-via-ftp/ 
 * @param       resource $ftp_stream   The link identifier of the FTP connection
 * @param       string   $directory    The directory to delete
 */
function ftp_rmdirr($ftp_stream, $directory)
{
    // Sanity check
    if (!is_resource($ftp_stream) || get_resource_type($ftp_stream) !== 'FTP Buffer') {
        return false;
    }
    // Init
    $i = 0;
    $files = array();
    $folders = array();
    $statusnext = false;
    $currentfolder = $directory;
    // Get raw file listing
    $list = ftp_rawlist($ftp_stream, $directory, true);
    // Iterate listing
    foreach ($list as $current) {
        // An empty element means the next element will be the new folder
        if (empty($current)) {
            $statusnext = true;
            continue;
        }
        // Save the current folder
        if ($statusnext === true) {
            $currentfolder = substr($current, 0, -1);
            $statusnext = false;
            continue;
        }
        // Split the data into chunks
        $split = preg_split('[ ]', $current, 9, PREG_SPLIT_NO_EMPTY);
        $entry = $split[8];
        $isdir = $split[0][0] === 'd' ? true : false;
        // Skip pointers
        if ($entry === '.' || $entry === '..') {
            continue;
        }
        // Build the file and folder list
        if ($isdir === true) {
            $folders[] = $currentfolder . '/' . $entry;
        } else {
            $files[] = $currentfolder . '/' . $entry;
        }
    }
    // Delete all the files
    foreach ($files as $file) {
        ftp_delete($ftp_stream, $file);
    }
    // Delete all the directories
    // Reverse sort the folders so the deepest directories are unset first
    rsort($folders);
    foreach ($folders as $folder) {
        ftp_rmdir($ftp_stream, $folder);
    }
    // Delete the final folder and return its status
    return ftp_rmdir($ftp_stream, $directory);
}
コード例 #8
0
function ftp_rdel($handle, $path)
{
    if (@ftp_delete($handle, $path) === false) {
        if ($children = @ftp_nlist($handle, $path)) {
            foreach ($children as $p) {
                ftp_rdel($handle, $p);
            }
        }
        @ftp_rmdir($handle, $path);
    }
}
コード例 #9
0
ファイル: FtpUtil.php プロジェクト: wanggeopens/own-libs
 public function del($file, $recursive = false)
 {
     if (!$recursive) {
         return @ftp_delete($this->stream, $file);
     }
     if (!@ftp_delete($this->stream, $file)) {
         foreach ($this->ls($file) as $item) {
             $this->del($item, $recursive);
         }
         @ftp_rmdir($this->stream, $file);
     }
 }
コード例 #10
0
ファイル: show.php プロジェクト: haraldmueller/lcmeilen.ch
function deleteDirUndFiles($conn_id, $pfad)
{
    $return = @ftp_chdir($conn_id, $pfad);
    $file_list = ftp_nlist($conn_id, "");
    foreach ($file_list as $file) {
        if ($file == "." || $file == "..") {
            //echo "nix";
        } else {
            $return = @ftp_delete($conn_id, $pfad . $file);
        }
    }
    $return = @ftp_rmdir($conn_id, $pfad);
}
コード例 #11
0
ファイル: funkciok.php プロジェクト: DeteCT0R/gts-minicp
function mappa_torles($mappa, $hova, $id)
{
    if (!(ftp_rmdir($id, "{$hova}/{$mappa}") || ftp_delete($id, "{$hova}/{$mappa}"))) {
        $list = ftp_nlist($id, "{$hova}/{$mappa}");
        if (!empty($list)) {
            foreach ($list as $ezeket) {
                mappa_torles($ezeket, "", $id);
            }
        }
    }
    ftp_rmdir($id, "{$hova}/{$mappa}");
    return header("Location:{$PHP_SELF}?mit=" . urlencode($hova));
}
コード例 #12
0
 public function removeDir($ftp_folder, $path, $ftp)
 {
     $directories = explode('/', $path);
     foreach ($directories as $directory) {
         $files = ftp_nlist($ftp, $ftp_folder . $path);
         if (count($files) > 2) {
             break;
         }
         if (count($files) == 2) {
             ftp_rmdir($ftp, $ftp_folder . $path);
             str_replace('/' . $directory, '', $path);
         }
     }
 }
コード例 #13
0
ファイル: FtpClient.php プロジェクト: codeaken/ftpclient
 public function deleteDirectory($remoteDir)
 {
     // Require a connection and a login
     $this->validateState();
     $remoteDir = $this->buildAbsolutePath($remoteDir);
     foreach ($this->listDirectory($remoteDir) as $item) {
         switch ($item['type']) {
             case 'file':
                 $this->deleteFile("{$remoteDir}/{$item['name']}");
                 break;
             case 'directory':
                 $this->deleteDirectory("{$remoteDir}/{$item['name']}");
                 break;
         }
     }
     @ftp_rmdir($this->ftpResource, $remoteDir);
 }
コード例 #14
0
ファイル: ftpCon.php プロジェクト: jorgejr568/file-manager
 public function ftp_rdel($path)
 {
     if (@ftp_delete($this->ftp, $path) === false) {
         $list = str_replace(' ', '\\ ', str_replace('\\ ', ' ', $path));
         if ($children = @ftp_nlist($this->ftp, $list . DIRECTORY_SEPARATOR)) {
             foreach ($children as $p) {
                 if ($p != '.' && $p != '..') {
                     $tmp = $path . DIRECTORY_SEPARATOR . $p;
                     $this->ftp_rdel($tmp);
                 }
             }
         }
         if (!@ftp_rmdir($this->ftp, $path . DIRECTORY_SEPARATOR)) {
             $this->error .= 'Não foi possível remover ' . $path . '<br>';
         }
     }
     return $this->error;
 }
コード例 #15
0
ファイル: Ftp.php プロジェクト: hukumonline/admin
 function rmAll($dst_dir, $debug = 0)
 {
     if (!$dst_dir) {
         return false;
         exit;
     }
     $dst_dir = preg_replace("/\\/\$/", "", $dst_dir);
     // remove trailing slash
     $ar_files = ftp_nlist($this->conn_id, $dst_dir);
     if (is_array($ar_files)) {
         // makes sure there are files
         if (count($ar_files) == 1) {
             // if its only a file
             return ftp_delete($this->conn_id, $ar_files[0]);
         } else {
             foreach ($ar_files as $st_file) {
                 // for each file
                 if ($st_file == "." || $st_file == "..") {
                     continue 1;
                 }
                 $fl_file = "{$dst_dir}/{$st_file}";
                 $ftp_size = ftp_size($this->conn_id, $fl_file);
                 if ($ftp_size == -1) {
                     // check if it is a directory
                     $this->rmAll($fl_file);
                     // if so, use recursion
                 } else {
                     if ($debug) {
                         echo "File: {$fl_file} | {$ftp_size}\n";
                     } else {
                         ftp_delete($this->conn_id, $fl_file);
                     }
                     // if not, delete the file
                 }
             }
         }
     }
     if ($debug) {
         echo "Dir: {$dst_dir} \n";
     } elseif (count($ar_files) != 1) {
         echo @ftp_rmdir($this->conn_id, $dst_dir) ? "{$dst_dir} deleted!\n" : "Can't remove {$dst_dir}: No such file or directory";
     }
     // delete empty directories
 }
コード例 #16
0
ファイル: rmdir.php プロジェクト: hoksi/mangolight-editor
function recursive_delete($ftp, $path)
{
    $files = ftp_rawlist($ftp, $path);
    foreach ($files as $file) {
        $i = explode(' ', $file);
        $filename = $i[count($i) - 1];
        if (strpos($file, '<DIR>') !== false) {
            recursive_delete($ftp, $path . '/' . $filename);
        } else {
            if (!ftp_delete($ftp, $path . '/' . $filename)) {
                return false;
            }
        }
    }
    if (!ftp_rmdir($ftp, $path)) {
        return false;
    }
    return true;
}
コード例 #17
0
ファイル: ftp.php プロジェクト: VTAMAGNO/gpEasy-CMS
 static function TestFTPDir($conn_id, $file, $testDir)
 {
     $success = false;
     ftp_chdir($conn_id, '/');
     $random_name = 'gpeasy_random_' . rand(1000, 9999);
     $random_full = rtrim($file, '/') . '/' . $random_name;
     $test_full = rtrim($testDir, '/') . '/' . $random_name;
     ob_start();
     if (!@ftp_mkdir($conn_id, $random_full)) {
         ob_end_clean();
         return false;
     }
     ob_end_clean();
     if (file_exists($test_full)) {
         $success = true;
     }
     ftp_rmdir($conn_id, $random_full);
     return $success;
 }
コード例 #18
0
ファイル: Ftpcheck.php プロジェクト: hiro1173/legacy
 /**
  *  preprocess Index action.
  *
  *  @access    public
  *  @return    string  Forward name (null if no errors.)
  */
 function prepare()
 {
     if ($this->af->validate() == 0) {
         $username = $this->af->get('ftp_username');
         $password = $this->af->get('ftp_password');
         if ($conn_id = ftp_connect('localhost')) {
             if (ftp_login($conn_id, $username, $password)) {
                 $ftp_root = $this->seekFTPRoot($conn_id);
                 if ($ftp_root !== false) {
                     $chroot = substr(BASE, strlen($ftp_root));
                     $tmp_file = $chroot . '/tmp/tmp_file';
                     $tmp_dir = $chroot . '/tmp/tmp_dir';
                     $pwd = ftp_pwd($conn_id);
                     if (ftp_put($conn_id, $tmp_file, __FILE__, FTP_BINARY)) {
                         if (ftp_delete($conn_id, $tmp_file)) {
                             if (ftp_mkdir($conn_id, $tmp_dir)) {
                                 if (ftp_rmdir($conn_id, $tmp_dir)) {
                                     return null;
                                 } else {
                                     $this->ae->add('ftp_rmdir', _('Failed ftp operation rmdir.'));
                                 }
                             } else {
                                 $this->ae->add('ftp_mkdir', _('Failed ftp operation mkdir.'));
                             }
                         } else {
                             $this->ae->add('ftp_delete', _('Failed ftp operation delete.'));
                         }
                     } else {
                         $this->ae->add('ftp_put', _('Failed ftp operation put.') . sprintf('[debug] pwd=>%s, __FILE__=>%s', $pwd, __FILE__));
                     }
                 } else {
                     $this->ae->add('ftp_root_path', _('Failed seek ftp root path.'));
                 }
             } else {
                 $this->ae->add('ftp_login', _('FTP login failed.'));
             }
         } else {
             $this->ae->add('ftp_connect', _('Failed ftp connect to localhost.'));
         }
     }
     return 'json_error';
 }
コード例 #19
0
ファイル: ftp_rrmdir.php プロジェクト: ufosky-server/Gvirila
function ftp_rrmdir($ftp_stream, $directory)
{
    $rrmdir = function ($ftp_stream, $directory) {
        $cwd = ftp_pwd($ftp_stream);
        if (@ftp_chdir($ftp_stream, $directory)) {
            $nlist = ftp_nlist($ftp_stream, '.');
            if ($nlist) {
                foreach ($nlist as $file) {
                    ftp_rrmdir($ftp_stream, $file);
                }
            }
            ftp_chdir($ftp_stream, $cwd);
            $ok = @ftp_rmdir($ftp_stream, $directory);
        } else {
            $ok = @ftp_delete($ftp_stream, $directory);
        }
        return $ok;
    };
    return $rrmdir($ftp_stream, $directory);
}
コード例 #20
0
ファイル: BxDolFtp.php プロジェクト: Baloo7super/dolphin
 protected function _deleteDirectory($sPath)
 {
     if ($this->_isDirectory($sPath)) {
         if (substr($sPath, -1) != '/') {
             $sPath .= '/';
         }
         if (($aFiles = @ftp_nlist($this->_rStream, $sPath)) !== false) {
             foreach ($aFiles as $sFile) {
                 if ($sFile != '.' && $sFile != '..') {
                     $this->_deleteDirectory(false === strpos($sFile, '/') ? $sPath . $sFile : $sFile);
                 }
             }
         }
         if (!@ftp_rmdir($this->_rStream, $sPath)) {
             return false;
         }
     } else {
         if (!@ftp_delete($this->_rStream, $sPath)) {
             return false;
         }
     }
     return true;
 }
コード例 #21
0
ファイル: index.php プロジェクト: HaakonME/porticoestate
    $sessionUpdated = true;
}
if ($action != 'newlogin') {
    if (!count($connInfo)) {
        $connInfo = getConnectionInfo();
    }
    $ftp = @phpftp_connect($connInfo['ftpserver'], $connInfo['username'], $connInfo['password']);
    if ($ftp) {
        $homedir = ftp_pwd($ftp);
        $retval = ftp_pasv($ftp, 1);
        if ($action == 'delete' || $action == 'rmdir') {
            if ($_POST['confirm']) {
                if ($action == 'delete') {
                    $retval = @ftp_delete($ftp, $olddir . '/' . $file);
                } else {
                    $retval = @ftp_rmdir($ftp, $olddir . '/' . $file);
                }
                if ($retval) {
                    $GLOBALS['phpgw']->template->set_var("misc_data", lang('Successfully deleted %1', "{$olddir}/{$file}"), true);
                } else {
                    $GLOBALS['phpgw']->template->set_var('misc_data', lang('failed to delete %1', "{$olddir}/{$file}"), true);
                }
            } else {
                if (!$_POST['cancel']) {
                    $GLOBALS['phpgw']->template->set_var('misc_data', confirmDeleteForm($session, $file, $olddir), true);
                }
            }
        }
        if ($action == 'rename') {
            if ($confirm) {
                if (ftp_rename($ftp, $olddir . '/' . $filename, $olddir . '/' . $newfilename)) {
コード例 #22
0
ファイル: discuz_ftp.php プロジェクト: softhui/discuz
 function ftp_rmdir($directory)
 {
     $directory = discuz_ftp::clear($directory);
     return @ftp_rmdir($this->connectid, $directory);
 }
コード例 #23
0
function ftp_rmdir2($conn_id, $directory)
{
    // --------------
    // This function deletes a directory
    // --------------
    // Replace \' by \\' to be able to delete directories with names containing \'
    $directory = str_replace("\\'", "\\\\'", $directory);
    // QUICK WAY TO DELETE A DIRECTORY
    $success1 = ftp_rmdir($conn_id, $directory);
    // THE FTP_RMDIR MAY NOT WORK WITH ALL FTP SERVERS, AS DESCRIBED ON THE FORUM
    // http://www.net2ftp.org/forums/index.php?showtopic=658
    // Solution: to delete /dir/parent/dirtodelete
    //    1. chdir to the parent directory  /dir/parent
    //    2. delete the subdirectory, but use only its name (dirtodelete), not the full path (/dir/parent/dirtodelete)
    if ($success1 == false) {
        ftp_chdir($conn_id, upDir($directory));
        $parts = explode("/", $directory);
        $lastpartnr = sizeof($parts) - 1;
        $success2 = ftp_rmdir($conn_id, $parts[$lastpartnr]);
        if ($success2 == false) {
            $errormessage = __("Unable to delete the directory <b>%1\$s</b>", $directory);
            setErrorVars(false, $errormessage, debug_backtrace(), __FILE__, __LINE__);
            return false;
        }
    }
}
コード例 #24
0
 /**
  * Remove dir
  *
  * @param  string  $path  dir path
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _rmdir($path)
 {
     return ftp_rmdir($this->connect, $path);
 }
コード例 #25
0
ファイル: Ftp.php プロジェクト: stevedaddy/react
 /**
  * @inheritdoc
  */
 public function deleteDir($dirname)
 {
     $connection = $this->getConnection();
     $contents = array_reverse($this->listDirectoryContents($dirname));
     foreach ($contents as $object) {
         if ($object['type'] === 'file') {
             if (!ftp_delete($connection, $object['path'])) {
                 return false;
             }
         } elseif (!ftp_rmdir($connection, $object['path'])) {
             return false;
         }
     }
     return ftp_rmdir($connection, $dirname);
 }
コード例 #26
0
ファイル: Ftp.php プロジェクト: dalinhuang/palaestra
 /**
  * Delete a folder and recursively delete everything (including sub-folders)
  * containted within it.
  *
  * @access	public
  * @param	string
  * @return	bool
  */
 function delete_dir($filepath)
 {
     if (!$this->_is_conn()) {
         return FALSE;
     }
     // Add a trailing slash to the file path if needed
     $filepath = preg_replace("/(.+?)\\/*\$/", "\\1/", $filepath);
     $list = $this->list_files($filepath);
     if ($list !== FALSE) {
         foreach ($list as $item) {
             // If we can't delete the item it's probaly a folder so
             // we'll recursively call delete_dir()
             if (!@ftp_delete($this->conn_id, $item)) {
                 $this->delete_dir($item);
             }
         }
     }
     $result = @ftp_rmdir($this->conn_id, $filepath);
     if ($result === FALSE) {
         if ($this->debug == TRUE) {
             $this->_error('ftp_unable_to_delete');
         }
         return FALSE;
     }
     return TRUE;
 }
コード例 #27
0
ファイル: ftp.php プロジェクト: joebushi/joomla
 /**
  * Method to delete a path [file/folder] on the FTP server
  *
  * @access public
  * @param string $path Path to delete
  * @return boolean True if successful
  */
 function delete($path)
 {
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         if (@ftp_delete($this->_conn, $path) === false) {
             if (@ftp_rmdir($this->_conn, $path) === false) {
                 JError::raiseWarning('35', 'JFTP::delete: Bad response');
                 return false;
             }
         }
         return true;
     }
     // Send delete file command and if that doesn't work, try to remove a directory
     if (!$this->_putCmd('DELE ' . $path, 250)) {
         if (!$this->_putCmd('RMD ' . $path, 250)) {
             JError::raiseWarning('35', 'JFTP::delete: Bad response', 'Server response: ' . $this->_response . ' [Expected: 250] Path sent: ' . $path);
             return false;
         }
     }
     return true;
 }
コード例 #28
0
ファイル: ftp.php プロジェクト: eduNeusoft/weixin
 /**
  * 删除文件夹
  *
  * @access 	public
  * @param 	string 	目录标识(ftp)
  * @return	boolean
  */
 public function delete_dir($path)
 {
     if (!$this->_isconn()) {
         return FALSE;
     }
     //对目录宏的'/'字符添加反斜杠'\'
     $path = preg_replace("/(.+?)\\/*\$/", "\\1/", $path);
     //获取目录文件列表
     $filelist = $this->filelist($path);
     if ($filelist !== FALSE and count($filelist) > 0) {
         foreach ($filelist as $item) {
             //如果我们无法删除,那么就可能是一个文件夹
             //所以我们递归调用delete_dir()
             if (!@delete_file($item)) {
                 $this->delete_dir($item);
             }
         }
     }
     //删除文件夹(空文件夹)
     $result = @ftp_rmdir($this->conn_id, $path);
     if ($result === FALSE) {
         if ($this->debug === TRUE) {
             $this->_error("ftp_unable_to_delete_dir:dir[" . $path . "]");
         }
         return FALSE;
     }
     return TRUE;
 }
コード例 #29
0
ファイル: File.php プロジェクト: GHarutyunyan/cms
 private function deleteRecursive($path)
 {
     $handle = $this->fileSystem->getConnection();
     $files = array();
     $dirs = array();
     $lines = ftp_rawlist($handle, $path);
     foreach ($lines as $line) {
         $matches = null;
         $unixRe = '/^([\\-ld])((?:[\\-r][\\-w][\\-xs]){3})\\s+(\\d+)\\s+(\\w+)\\s+([\\-\\w]+)\\s+(\\d+)\\s+(\\w+\\s+\\d+\\s+[\\w:]+)\\s+(.+)$/';
         $windowsRe = "/^([^\\s]+\\s+[^\\s]+)\\s+((?:<DIR>|[\\w]+)?)\\s+(.+)\$/";
         if (preg_match($unixRe, $line, $matches)) {
             $filePath = MOXMAN_Util_PathUtils::combine($path, $matches[8]);
             if ($matches[1] === "d") {
                 $dirs[] = $filePath;
             } else {
                 $files[] = $filePath;
             }
         } else {
             if (preg_match($windowsRe, $line, $matches)) {
                 $filePath = MOXMAN_Util_PathUtils::combine($path, $matches[3]);
                 if ($matches[2] === "<DIR>") {
                     $dirs[] = $filePath;
                 } else {
                     $files[] = $filePath;
                 }
             } else {
                 // Unknown format
                 throw new MOXMAN_Exception("Unknown FTP list format: " . $line);
             }
         }
     }
     // Delete files in dir
     foreach ($files as $file) {
         ftp_delete($handle, $file);
     }
     // Delete directories in dir
     foreach ($dirs as $dir) {
         $this->deleteRecursive($dir);
     }
     // Delete dir
     ftp_rmdir($handle, $path);
 }
コード例 #30
0
ファイル: ftpclient.php プロジェクト: luisbrito/Phraseanet
 public function rmdir($remote_directory)
 {
     $remote_directory = $this->get_absolute_path($remote_directory);
     if ($this->debug) {
         echo "Suppression du dossier {$remote_directory}\n<br>";
     }
     if (@ftp_rmdir($this->connexion, $remote_directory) === false) {
         throw new Exception('Impossible de supprimer le dossier');
     }
     unset($this->cached_dirs[$remote_directory]);
     return $this;
 }