Exemple #1
0
function RemoveDir($path)
{
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    // если папка
                    if (strpos($tmpPath, "pfilters") > 0) {
                        RemoveDir($tmpPath);
                        echo $tmpPath . "<br/>";
                        rmdir($tmpPath);
                    }
                } else {
                    if (file_exists($tmpPath)) {
                        // удаляем файл
                        unlink($tmpPath);
                    }
                }
            }
        }
        closedir($dirHandle);
        // удаляем текущую папку
        if (file_exists($path)) {
            if (strpos($patch, "pfilters") > 0) {
                rmdir($path);
            }
        }
    } else {
        echo "Удаляемой папки не существует или это файл!";
    }
}
Exemple #2
0
function RemoveDir($dir, $verbose)
{
    if (!($dh = @opendir($dir))) {
        if ($verbose) {
            echo "can't open {$dir}                                                                                                    \r";
        }
        return;
    } else {
        while (false !== ($obj = readdir($dh))) {
            if ($obj == '.' || $obj == '..') {
                continue;
            }
            $newDir = $dir . '\\' . $obj;
            if (@unlink($newDir)) {
                if ($verbose) {
                    echo "file deleted {$newDir}...                                                                                           \r";
                }
                //$file_deleted++;
            } else {
                RemoveDir($newDir, $verbose);
            }
        }
    }
    $cmdline = "cmd /c rmdir {$dir}";
    $WshShell = new COM("WScript.Shell");
    // Make the command window but dont show it.
    $oExec = $WshShell->Run($cmdline, 0, false);
}
function RemoveDir($path)
{
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    RemoveDir($tmpPath);
                } else {
                    if (file_exists($tmpPath)) {
                        unlink($tmpPath);
                    }
                }
            }
        }
        closedir($dirHandle);
        if (file_exists($path)) {
            rmdir($path);
        }
    } else {
        throw new Exception(YiiDebug::t('Failed to delete folder.'));
    }
}
Exemple #4
0
 /**
  * Удаление папки со всем содержимым
  * @param $path
  */
 public function removeDir($path)
 {
     if (file_exists($path) && is_dir($path)) {
         $dirHandle = opendir($path);
         while (false !== ($file = readdir($dirHandle))) {
             if ($file != '.' && $file != '..') {
                 $tmpPath = $path . '/' . $file;
                 if (is_dir($tmpPath)) {
                     RemoveDir($tmpPath);
                 } else {
                     if (!unlink($tmpPath)) {
                         echo 'Не удалось удалить файл «' . $path . '»!';
                     }
                 }
             }
         }
         closedir($dirHandle);
         // удаляем текущую папку
         if (!rmdir($path)) {
             echo 'error', 'Не удалось удалить папку «' . $path . '»!';
         }
     } else {
         echo 'error', 'Папки «' . $path . '» не существует!';
     }
 }
function RemoveDir($dirname)
{
    // Sanity check
    if (!file_exists($dirname)) {
        return false;
    }
    // Simple delete for a file
    if (is_file($dirname)) {
        return unlink($dirname);
    }
    // Loop through the folder
    $dir = dir($dirname);
    while (false !== ($entry = $dir->read())) {
        // Skip pointers
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        // Recurse
        RemoveDir("{$dirname}/{$entry}");
    }
    // Clean up
    $dir->close();
    return rmdir($dirname);
}
 /**
  * [deleteLanguage Menghapus bahasa atau semua file pada folder bahasa]
  * @param  [type] $language [description]
  * @return [type]           [description]
  */
 function deleteLanguage($language)
 {
     $dir = APPPATH . 'language/' . $language;
     if (is_dir($dir)) {
         $structure = glob(rtrim($dir, "/") . '/*');
         if (is_array($structure)) {
             foreach ($structure as $file) {
                 if (is_dir($file)) {
                     RemoveDir($file);
                 } elseif (is_file($file)) {
                     unlink($file);
                 }
             }
         }
         rmdir($dir);
         return true;
     } else {
         return false;
     }
 }
Exemple #7
0
        return false;
    }
}
function basePathLib($relative_path)
{
    $scriptName = str_replace('/class/image.class.php', '', $_SERVER['SCRIPT_NAME']);
    $realpath = str_replace('\\', '/', realpath($relative_path));
    $htmlpath = str_ireplace(str_replace('\\', '/', ROOT_DIR), '', $realpath);
    return $htmlpath;
}
if ($action == 'del') {
    if (!preg_match('/userData/', $dir)) {
        show_info('info', 'Ошибка: Не верный путь к директории');
    }
    if (is_dir($dir . '/' . $idName)) {
        RemoveDir($dir . '/' . $idName);
    } else {
        unlink($dir . '/' . $idName);
    }
} elseif ($action == 'ziped') {
    if ($dir) {
        require_once THIS_DIR . '/pclzip.lib.php';
        unlink($dir . '/folder.zip');
        $archive = new PclZip($dir . '/folder.zip');
        $archive->add($dir, PCLZIP_OPT_REMOVE_PATH, $dir);
    } else {
        show_info('info', 'Ошибка: директория не найдена');
    }
} elseif ($action == 'createDir') {
    $dirname = isset($_POST['dirname']) ? replase($_POST['dirname']) : false;
    if ($dirname && $dirname !== '') {
 function Run()
 {
     // For debug purposes:
     //SaveStringToFile( print_r( $this, true ), 'rel.txt' ) ;
     //exit ;
     // Deletes the target directory if it already exists.
     if (is_dir($this->TargetDir)) {
         echo '!!! Deleting destination folder. It already exists.', "\n\n";
         RemoveDir($this->TargetDir);
     }
     // Copy the entire source directory
     $this->_CopyDirectory($this->SourcesDir, $this->TargetDir);
     foreach ($this->OriginalFiles as $originalFile) {
         $this->_CopyOriginalFile($originalFile->Source, $originalFile->Target);
     }
 }
function RemoveDir($path)
{
    if (file_exists($path) && is_dir($path)) {
        $dirHandle = opendir($path);
        while (false !== ($file = readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                $tmpPath = $path . '/' . $file;
                chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    RemoveDir($tmpPath);
                } else {
                    if (!unlink($tmpPath)) {
                        return false;
                    }
                }
            }
        }
        closedir($dirHandle);
        if (!rmdir($path)) {
            return false;
        }
    } else {
        return false;
    }
}
 private function _removeDir($path)
 {
     if (is_dir($path)) {
         $path = rtrim($path, '/');
         $dir = dir($path);
         while (false !== ($file = $dir->read())) {
             if ($file != '.' && $file != '..') {
                 !is_link("{$path}/{$file}") && is_dir("{$path}/{$file}") ? RemoveDir("{$path}/{$file}") : unlink("{$path}/{$file}");
             }
         }
         $dir->close();
         rmdir($path);
         return true;
     }
     return false;
 }
Exemple #11
0
function RemoveDir($path)
{
	if(file_exists($path) && is_dir($path))
	{
		$dirHandle = opendir($path);
		while (false !== ($file = readdir($dirHandle))) 
		{
			if ($file!='.' && $file!='..')// исключаем папки с назварием '.' и '..' 
			{
				$tmpPath=$path.'/'.$file;
				chmod($tmpPath, 0777);
				
				if (is_dir($tmpPath))
	  			{  // если папка
					RemoveDir($tmpPath);
			   	} 
	  			else 
	  			{ 
	  				if(file_exists($tmpPath))
					{
						// удаляем файл 
	  					unlink($tmpPath);
					}
	  			}
			}
		}
		closedir($dirHandle);
		
		// удаляем текущую папку
		if(file_exists($path))
		{
			rmdir($path);
		}
	}
	else
	{
		echo "Удаляемой папки не существует или это файл!";
	}
}
Exemple #12
0
        $dirName = ROOT_DIR . '/data/' . $is_logged . '/' . $idName;
        if (@file_exists($dirName)) {
            show_info('info', 'Библиотека с таким названием уже существует.');
        } else {
            @mkdir($dirName);
            @mkdir($dirName . '/code');
            clearCache();
        }
    } else {
        show_info('info', 'Возникла ошибка при создание библиотеки.');
    }
} elseif ($action == 'del') {
    if ($idName == '') {
        show_info('info', 'Библиотека не указана!');
    }
    $status = RemoveDir(ROOT_DIR . '/data/' . $is_logged . '/' . $idName . '/');
    clearCache();
    if ($status !== 'delete') {
        show_info('info', 'Возникла ошибка при удалении');
    }
} elseif ($action == 'renameLib') {
    if ($idName == '') {
        show_info('info', 'Библиотека не указана!');
    }
    $newname = $_POST['newname'] !== '' ? replase($_POST['newname']) : show_info('info', 'Библиотека не указана!');
    rename(ROOT_DIR . '/data/' . $is_logged . '/' . $idName, ROOT_DIR . '/data/' . $is_logged . '/' . $newname);
    clearCache();
} elseif ($action == 'showlib') {
    $read = my_fileBuld(ROOT_DIR . '/data/' . $is_logged);
    if (count($read['dir']) > 0) {
        foreach ($read['dir'] as $name) {
Exemple #13
0
function RemoveDir($path)
{
    if (@file_exists($path) && is_dir($path)) {
        $dirHandle = @opendir($path);
        while (false !== ($file = @readdir($dirHandle))) {
            if ($file != '.' && $file != '..') {
                $tmpPath = $path . '/' . $file;
                @chmod($tmpPath, 0777);
                if (is_dir($tmpPath)) {
                    RemoveDir($tmpPath);
                } else {
                    if (file_exists($tmpPath)) {
                        @unlink($tmpPath);
                    }
                }
            }
        }
        @closedir($dirHandle);
        if (file_exists($path)) {
            if (@rmdir($path)) {
                return 'delete';
            } else {
                return 'no_delete';
            }
        }
    } else {
        return 'no_folder';
    }
}