commit 54744852ba85714403491e5d973d7c8a675be117 parent 71a9f02d0afcdb35d5130825f8828e557d6f233f Author: dankert <devnull@localhost> Date: Tue, 28 Dec 2004 23:55:21 +0100 Methode clean() zum Loeschen ueberzaehliger Dateien im Zielordner Diffstat:
serviceClasses/Publish.class.php | | | 43 | ++++++++++++++++++++++++++++++++++++++++++- |
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/serviceClasses/Publish.class.php b/serviceClasses/Publish.class.php @@ -120,7 +120,48 @@ class Publish { $this->ftp->close(); } - } + } + + + function clean() + { + if ( !empty($this->local_destdir) ) + $this->cleanFolder($this->local_destdir); + } + + + function cleanFolder( $folderName ) + { + $dh = opendir( $folderName ); + + while( $file = readdir($dh) ) + { + if ( $file != '.' && $file != '..') + { + $fullpath = $folderName.'/'.$file; + + // Wenn eine Datei beschreibbar und entsprechend alt + // ist, dann entfernen + if ( is_file($fullpath) && + is_writable($fullpath) && + filemtime($fullpath) < START_TIME ) + unlink($fullpath); + + if ( is_file($fullpath) && + is_writable($fullpath) && + filemtime($fullpath) < START_TIME ) + echo( $fullpath ).'<br/>'; + + // Bei Ordnern rekursiv absteigen + if ( is_dir( $fullpath) ) + { + $this->cleanFolder($fullpath); + @rmdir($fullpath); + } + } + } + } + } ?> \ No newline at end of file