public static function CleanCache(){
		static $clean = false;


		if( $clean || empty(Less_Cache::$cache_dir) ){
			return;
		}

		$clean = true;

		// only remove files with extensions created by less.php
		// css files removed based on the list files
		$remove_types = array('lesscache'=>1,'list'=>1,'less'=>1,'map'=>1);

		$files = scandir(Less_Cache::$cache_dir);
		if( !$files ){
			return;
		}

		$check_time = time() - self::$gc_lifetime;
		foreach($files as $file){


			// don't delete if the file wasn't created with less.php
			if( strpos($file,Less_Cache::$prefix) !== 0 ){
				continue;
			}

			$parts = explode('.',$file);
			$type = array_pop($parts);


			if( !isset($remove_types[$type]) ){
				continue;
			}

			$full_path = Less_Cache::$cache_dir . $file;
			$mtime = filemtime($full_path);

			// don't delete if it's a relatively new file
			if( $mtime > $check_time ){
				continue;
			}


			// delete the list file and associated css file
			if( $type === 'list' ){
				self::ListFiles($full_path, $list, $css_file_name);
				if( $css_file_name ){
					$css_file = Less_Cache::$cache_dir . $css_file_name;
					if( file_exists($css_file) ){
						unlink($css_file);
					}
				}
			}

			unlink($full_path);
		}


	}
public static function CleanCache(){
		static $clean = false;


		if( $clean || empty(Less_Cache::$cache_dir) ){
			return;
		}

		$clean = true;

		// only remove files with extensions created by less.php
		// css files removed based on the list files
		$remove_types = array('lesscache'=>1,'list'=>1,'less'=>1,'map'=>1);

		$files = scandir(Less_Cache::$cache_dir);
		if( !$files ){
			return;
		}

		$check_time = time() - self::$gc_lifetime;
		foreach($files as $file){


			// don't delete if the file wasn't created with less.php
			if( strpos($file,Less_Cache::$prefix) !== 0 ){
				continue;
			}

			$parts = explode('.',$file);
			$type = array_pop($parts);


			if( !isset($remove_types[$type]) ){
				continue;
			}

			$full_path = Less_Cache::$cache_dir . $file;
			$mtime = filemtime($full_path);

			// don't delete if it's a relatively new file
			if( $mtime > $check_time ){
				continue;
			}


			// delete the list file and associated css file
			if( $type === 'list' ){
				self::ListFiles($full_path, $list, $css_file_name);
				if( $css_file_name ){
					$css_file = Less_Cache::$cache_dir . $css_file_name;
					if( file_exists($css_file) ){
						unlink($css_file);
					}
				}
			}

			unlink($full_path);
		}


	}
public static function CleanCache ( ) { static $ clean = false ; if ( $ clean || empty ( Less_Cache :: $ cache_dir ) ) { return ; } $ clean = true ; // only remove files with extensions created by less.php // css files removed based on the list files $ remove_types = array ( 'lesscache' => 1 , 'list' => 1 , 'less' => 1 , 'map' => 1 ) ; $ files = scandir ( Less_Cache :: $ cache_dir ) ; if ( ! $ files ) { return ; } $ check_time = time ( ) - self :: $ gc_lifetime ; foreach ( $ files as $ file ) { // don't delete if the file wasn't created with less.php if ( strpos ( $ file , Less_Cache :: $ prefix ) !== 0 ) { continue ; } $ parts = explode ( '.' , $ file ) ; $ type = array_pop ( $ parts ) ; if ( ! isset ( $ remove_types [ $ type ] ) ) { continue ; } $ full_path = Less_Cache :: $ cache_dir . $ file ; $ mtime = filemtime ( $ full_path ) ; // don't delete if it's a relatively new file if ( $ mtime > $ check_time ) { continue ; } // delete the list file and associated css file if ( $ type === 'list' ) { self :: ListFiles ( $ full_path , $ list , $ css_file_name ) ; if ( $ css_file_name ) { $ css_file = Less_Cache :: $ cache_dir . $ css_file_name ; if ( file_exists ( $ css_file ) ) { unlink ( $ css_file ) ; } } } unlink ( $ full_path ) ; } }
Delete unused less.php files
Delete unused less . php files