<?php
/**
 * 热更新相关
 * Date: 2017/9/12 0012
 * Time: 19:39
 */
defined('BASEPATH') OR exit('No direct script access allowed');

class Hotupdate extends MY_Controller{

    public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form', 'url', 'cookie'));

        $this->env = get_cookie($this->_wenenv);
    }

    /**
     * 首页
     */
    public function index(){
        $this->load->view('hotupdate/index');
    }


    /**
     * 添加热更新
     */
    public function addhu(){
        if( $this->env == 1 ){
            $url = $this->config->item('officialBaseUrl').'/api/hotupdate.php';
        }else{
            $url = $this->config->item('localBaseUrl').'/api/hotupdate.php';
        }
        $data['url'] = $url;
        $this->load->view('hotupdate/addhu', $data);
    }


    /**
     * 上传操作
     */
    public function actionAddhu(){
        $post = $this->input->post();
        $file = $_FILES;
        var_dump($post);
        var_dump($file);

        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100';
        $config['max_width'] = '1024';
        $config['max_height'] = '768';

        $this->load->library('upload', $config);
        $this->upload->initialize($config);

        if ( ! $this->upload->do_upload('userfile'))
        {
            $error = array('error' => $this->upload->display_errors());
            print_r($error);
            exit;
        }
        else
        {
            $data = array('upload_data' => $this->upload->data());
            print_r($data);
            exit;
        }
        exit;
    }

}