<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Packs extends CI_Controller {

	function __construct(){
		parent::__construct();
        	$this->load->helper('url');
                $this->load->library('session'); //加载session
		$this->load->model('CsdjDB');
		$this->load->model('CsdjAdmin');
		$this->load->model('CsdjSkins');
                $this->db->cache_off();
	        $this->CsdjAdmin->Admin_Login();
	}

	/**
	 * 扩展下载
	 */
	public function down()
	{
            $dir=$this->input->get_post('dir');
            $markid=$this->input->get_post('markid');
            $key=$this->input->get_post('key');
	    if (empty($key) || empty($dir) || empty($markid)) $this->CsdjAdmin->Admin_Url('<font color=red>抱歉，参数错误！</font>',site_url('admin/plugins/yun/'));

            $zip=CS_YPTURL.'index.php/packs/down/?code=gbk&key='.$key;
            $data = @ fopen($zip,"r");
            if($data=="10001" || $data=="10002" || $data=="10003"){
                   $this->CsdjAdmin->Admin_Url('<font color=red>抱歉，扩展附件下载失败！</font>',site_url('admin/plugins/yun/'));
            }else{
                 $filename=$dir.".zip";
		 Header("Content-type: application/octet-stream");
		 Header("Content-Disposition: attachment; filename=" . $filename);
		 while (!feof ($data)) {
			echo fread($data,1024);
		 }
		 fclose ($data);
            }

        }

}

