Example #1
0
function wp_all_export_rmdir($dir)
{
    $scanned_files = @scandir($dir);
    if (!empty($scanned_files) and is_array($scanned_files)) {
        $files = array_diff($scanned_files, array('.', '..'));
        if (!empty($files)) {
            foreach ($files as $file) {
                is_dir("{$dir}/{$file}") ? wp_all_export_rmdir("{$dir}/{$file}") : @unlink("{$dir}/{$file}");
            }
        }
        return @rmdir($dir);
    }
}
 function wp_all_export_remove_source($file, $remove_dir = true)
 {
     @unlink($file);
     $path_parts = pathinfo($file);
     if (!empty($path_parts['dirname'])) {
         $path_all_parts = explode('/', $path_parts['dirname']);
         $dirname = array_pop($path_all_parts);
         if (wp_all_export_isValidMd5($dirname)) {
             if ($remove_dir) {
                 @unlink($path_parts['dirname'] . DIRECTORY_SEPARATOR . 'index.php');
             }
             if ($remove_dir or count(@scandir($path_parts['dirname'])) == 2) {
                 wp_all_export_rmdir($path_parts['dirname']);
             }
         }
     }
 }