Location: PHPKode > projects > chillyCMS > chillyCMS/core/zipper.class.php
<?php
//#################################################################################################
//	Zipper class
//#################################################################################################
//	chillyCMS - Content Management System
//	Copyright (C) 2008
//	Stefanie Wiegand <hide@address.com> & Johannes Cox <hide@address.com>
//	
//	This program is licensed under the GPL 3.0 license. For more information see LICENSE.txt.
//#################################################################################################
defined('DOIT') or die('Restricted access');

//If ZipArchive is missing, replace it
if (!class_exists('ZipArchive')) {
	echo "Class ZipArchive not found"; 
} 

class Zipper extends ZipArchive {
	public function addDir($path,$newname) {
		$newname=cut_doubledots($newname);
		$path=cut_doubledots($path);
		$nodes = glob($path."/"."*");
		$error=false;
		if (!empty($nodes)) {
			foreach ($nodes as $node) {
				//exclude temporary files
				if (substr($node,-1)!="~") {
					$newnode=substr($node,strlen($path)+1);
					$newnode=$newname."/".$newnode;
					if (is_dir($node)) {
						if ($this->addEmptyDir($newnode)) {
							//echo "added $newnode<br>";
							if (!$this->addDir($node,$newnode)) { $error=true; break; }
						} else {
							$error=true;
						}
					} else if (is_file($node)) {
						if ($this->addFile($node,$newnode)) {
							//echo "added $newnode<br>";
						}
					}
				}
			}
		}
		if (!$error) { return true; } else { return false; }
	}
}
?>
Return current item: chillyCMS