<?php
// 本类由系统自动生成，仅供测试用途
class CommonAction extends Action {
    public function header(){
		$this->display();
	}
	public function nav(){
		$this->display();
	}
	public function memberleft(){
		$this->display();
	}
	public function footer(){
		$this->display();
	}
	public function header1(){
		$this->display();
	}
	public function footer1(){
		$this->display();
	}
	public function _upload(){

        if(!empty($_FILES))
        {
            import("@.ORG.Util.Image");
            import("@.ORG.UploadFile");
            //导入上传类
            $upload = new UploadFile();
            //设置上传文件大小
            $upload->maxSize = 2097152;
            //设置上传文件类型
            $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
            //设置附件上传目录
            $y = date('Y',time());
            $m = date('m',time());
            $d = date('d',time());
            
            $dir='./Uploads/imgtemp';
            
            if (!is_dir($dir)) {
                mkdir($dir, 0777);
            }
            $dir.='/'.$y;
            if (!is_dir($dir)) {
                mkdir($dir, 0777);
            }
            $dir.='/'.$m;
            if (!is_dir($dir)) {
                mkdir($dir, 0777);
            }
            $dir.='/'.$d;
            if (!is_dir($dir)) {
                mkdir($dir, 0777);
            }
            $dir.='/';
            $upload->savePath =$dir;//'../Uploads/';
            
            // 设置引用图片类库包路径
            $upload->imageClassPath = '@.ORG.Util.Image';
            //设置需要生成缩略图，仅对图像文件有效
            //$upload->thumb = true;
            //设置需要生成缩略图的文件后缀
            //$upload->thumbPrefix = 'm_,s_';  //生产2张缩略图
            //设置缩略图最大宽度
            $upload->thumbMaxWidth = '46';
            //设置缩略图最大高度
            $upload->thumbMaxHeight = '46';
            //设置上传文件规则
            $upload->saveRule = uniqid;
            //删除原图
            $upload->thumbRemoveOrigin = TRUE;
            
            if (!$upload->upload()) {
                //捕获上传异常
                $strerror=$upload->getErrorMsg();
                if($strerror!="没有选择上传文件"){
                    $this->error($strerror);
                }
                
            } else {
                //取得成功上传的文件信息
                $uploadList = $upload->getUploadFileInfo();
                foreach ($uploadList as $key => $value) {
                    foreach ($_FILES as $key1 => $value1) {
                        if($value['name']===$value1['name']){

                            $_POST[$key1] = 'imgtemp/'.$y.'/'.$m.'/'.$d.'/'.$value['savename'];
                            
                        }
                    }
                    
                }

                
            }      
        }
    }
	protected function check_member(){
		$m_model = new AccountModel();
		$m_model->checklogin();
	}
}