destinationFile = $f; } function createFileSet() { $num = array_push($this->filesets, new FileSet()); return $this->filesets[$num-1]; } function main() { if ($this->destinationFile === null || empty($this->filesets)) { throw new BuildException("You must specify a file or fileset(s) for the task."); } // compile a list of all files to add to the file, both file attrib and fileset elements // can be used. $files = array(); if (!empty($this->filesets)) { $filenames = array(); foreach($this->filesets as $fs) { try { $ds = $fs->getDirectoryScanner($this->project); $filenames = $ds->getIncludedFiles(); // get included filenames $dir = $fs->getDir($this->project); foreach ($filenames as $fname) { $files[] = new PhingFile($dir, $fname); } } catch (BuildException $be) { $this->log($be->getMessage(), Project::MSG_WARN); } } } $objZip = new ZipArchive(); if ($objZip->open($this->destinationFile, ZIPARCHIVE::OVERWRITE) !== true) { throw new Exeption("Could not open " . $strResultingFile . " for writing!"); } $this->log("Creating ZIP archive of " . count($files) . " files..."); foreach($files as $file) { $this->log("Processing file " . $this->_cleanFileName($file) . " ..."); $contents = file_get_contents($file); $objZip->addFromString( $this->_cleanFileName($file), $contents ); } $objZip->close(); $this->log("Created ZIP archive " . $this->destinationFile . '.'); } /** * Cleanup a filename * * @param string $strFile Filename * @return string Filename */ protected function _cleanFileName($strFile) { $strFile = str_replace('../', '', $strFile); $strFile = str_replace('.\\build\\', '', $strFile); $strFile = str_replace('WINDOWS', '', $strFile); while (preg_match('/\/\//i', $strFile)) { $strFile = str_replace('//', '/', $strFile); } return $strFile; } } ]]> PHPExcel PHP Excel classes pear.pearplex.net Project providing a set of classes for the PHP programming language, which allow you to write to Excel 2007 files and read from Excel 2007 files. This package ONLY contains the class files, not the documentation and example code. Please refer to http://www.codeplex.com/PHPExcel for those files. LGPL data