
<?php

class site{
	
	function download($file){
		
		$url = 'http://rep.zievo.com.br/multisite/sites/'.$file.'/files.zip';
		file_put_contents('sites/'.$file.'/files.zip', 
			file_get_contents($url)
		);
	
		return array(
			'success' => true,
			'message' => 'Download concluído'
		);
		
	}
	
	function unzip($src_file){
		
		$zip = new ZipArchive;
		if ($zip->open('sites/'.$src_file.'/files.zip') === TRUE) {
			$zip->extractTo('sites/'.$src_file.'/');
			$zip->close();
			
			unlink('sites/'.$src_file.'/files.zip');
			
			return array(
				'success' => true,
				'message' => 'Descompactado com sucesso'
			);
		} else {
			return array(
				'success' => false,
				'message' => 'Falha ao descompactar arquivo'
			);
		}
	}
	
}



?>