Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.32.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : file-system.php
<?php

/**
 * @todo: move all mkdir calls here.
 *
 * Class Brizy_FileSystem
 */
class Brizy_Admin_FileSystem {

	/**
	 * @param $pageUploadPath
	 */
	static public function deleteAllDirectories( $pageUploadPath ) {
		try {
			$dIterator = new DirectoryIterator( $pageUploadPath );
			foreach ( $dIterator as $entry ) {
				if ( ! $entry->isDot() && $entry->isDir() ) {
					$subDirIterator = new RecursiveDirectoryIterator( $entry->getRealPath(), RecursiveDirectoryIterator::SKIP_DOTS );
					$files          = new RecursiveIteratorIterator( $subDirIterator, RecursiveIteratorIterator::CHILD_FIRST );
					foreach ( $files as $file ) {
						if ( ! $file->isDir() ) {
							@unlink( $file->getRealPath() );
						}
					}

					self::deleteFilesAndDirectory( $entry->getRealPath() );
				}
			}
		} catch ( Exception $e ) {
			return false;
		}
	}


	/**
	 * @param $pageUploadPath
	 */
	static public function deleteFilesAndDirectory( $pageUploadPath ) {
		try {
			$dIterator = new DirectoryIterator( $pageUploadPath );
			foreach ( $dIterator as $entry ) {
				if ( $entry->isDot() ) {
					continue;
				}

				if ( $entry->isDir() ) {
					$subDirIterator = new RecursiveDirectoryIterator( $entry->getRealPath(), RecursiveDirectoryIterator::SKIP_DOTS );
					$files          = new RecursiveIteratorIterator( $subDirIterator, RecursiveIteratorIterator::CHILD_FIRST );
					foreach ( $files as $file ) {
						if ( ! $file->isDir() ) {
							@unlink( $file->getRealPath() );
						}
					}

					@rmdir( $entry->getRealPath() );
				} else {
					@unlink( $entry->getRealPath() );
				}
			}

			@rmdir( $pageUploadPath );
		} catch ( Exception $e ) {
			return false;
		}

	}
}
© 2025 XylotrechusZ