本文整理汇总了PHP中ftp_rmdir函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_rmdir函数的具体用法?PHP ftp_rmdir怎么用?PHP ftp_rmdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_rmdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean
/**
* @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: removeDirectoryJailed
/**
* {@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: mrmdir
function mrmdir($directory)
{
if (!$this->conn_id) {
return false;
}
return @ftp_rmdir($this->conn_id, $directory);
}
示例4: rmdir
public function rmdir($dir)
{
if (FALSE === ftp_rmdir($this->link, $dir)) {
$this->errormsg = "Can't remove this dir";
return FALSE;
}
return TRUE;
}
示例5: deleteFolder
public function deleteFolder(string $path) : bool
{
if (ftp_rmdir($this->connect, $path)) {
return true;
} else {
throw new FolderNotFoundException($path);
}
}
示例6: rmdir
/**
* 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: ftp_rmdirr
/**
* Recursively delete the files in a directory via FTP.
*
* @author Aidan Lister <aidan@php.net>
* @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: ftp_rdel
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: del
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: deleteDirUndFiles
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: mappa_torles
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: removeDir
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: deleteDirectory
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: ftp_rdel
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: rmAll
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
}