<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Utility extends CI_Controller {
	public function __construct(){
		parent::__construct();
		if($this->session->userdata('is_logged_in')==FALSE){
			redirect('login');
		}
	}

	function index(){
		show_404();
	}

	function zipping(){
		$this->load->library('zip');
		$this->load->library('my_zip');
		$path = getcwd().'/resources/tmp/';
		$destination_path = getcwd().'/zip/zipku.zip';
		if (file_exists($destination_path)) {
			unlink($destination_path);
		}
		/*
		$this->zip->read_dir($path); 
		if ( !is_dir ( getcwd().'/zip' ) ){
			@mkdir(getcwd().'/zip',0750,true);
		}
		$this->zip->archive($destination_path);
		$this->zip->clear_data(); 
		*/
		$folder_in_zip = "/";
		$this->my_zip->get_files_from_folder($path, $folder_in_zip);
		$this->my_zip->archive($destination_path);
		echo "Files in <strong>".$path."</strong> are zipped to <strong>".$destination_path."</strong>";
	}
}