예제 #1
0
 function import_action(){
 	$this->_view_table = '';
 	if(front::post('submit')){
 		if($_FILES['excelFile']['tmp_name']){
 			$upload=new upload();
 			$upload->dir='attachment';
 			if (!$_FILES['excelFile']['name'] ||!preg_match('/\.xls$/i',$_FILES['excelFile']['name'])){
 				alerterror('请选择Excel2003文件');
 			}
 			$name = $upload->run($_FILES['excelFile']);
 			$reader = PHPExcel_IOFactory::createReader('Excel5');
 			$PHPExcel = $reader->load($name);
 			$sheet = $PHPExcel->getSheet(0);
 			$highestRow = $sheet->getHighestRow();
 			$highestColumm = $sheet->getHighestColumn();
 			$i = 0;
 			for ($row = 2; $row <= $highestRow; $row++){
 				if($sheet->getCell('A'.$row)->getValue()){
 					$data['catid'] = $sheet->getCell('A'.$row)->getValue();
 					$data['typeid'] = intval($sheet->getCell('B'.$row)->getValue());
 					$data['spid'] = intval($sheet->getCell('C'.$row)->getValue());
 					$data['title'] = $sheet->getCell('D'.$row)->getValue();
 					$data['content'] = $sheet->getCell('E'.$row)->getValue();
 					$data['tag'] = $sheet->getCell('F'.$row)->getValue();
 					$data['adddate'] = $sheet->getCell('G'.$row)->getValue();
 					if($data['adddate'] == ''){
 						$data['adddate'] = date('Y-m-d H:i:s');
 					}
 					$data['author'] = $sheet->getCell('H'.$row)->getValue();
 					$data['attr3'] = $sheet->getCell('I'.$row)->getValue();
 					$data['checked'] = intval($sheet->getCell('J'.$row)->getValue());
 					$data['attr2'] = $sheet->getCell('K'.$row)->getValue();
 					$data['thumb'] = $sheet->getCell('L'.$row)->getValue();
 					$data['pics'] = serialize(explode('|',$sheet->getCell('M'.$row)->getValue()));
 					$data['userid'] = $this->view->user['userid'];
 					$this->_table->rec_insert($data);
 					$i++;
 				}
 			}
 			front::flash("{$this->tname}导入{$i}条数据成功!");
 		}else{
 			alerterror('请选择要导入的Excel2003文件');
 		}
 	}
 }
예제 #2
0
    function uploadimage_action() {
        $res=array();
        $uploads=array();
        if (is_array($_FILES)) {
            $upload=new upload();
            $upload->dir='images';
            $upload->max_size=config::get('upload_max_filesize')*1024*1024;
            $attachment=new attachment();
            $_file_type=str_replace(',','|',config::get('upload_filetype'));
            foreach ($_FILES as $name=>$file) {
                $res[$name]['size']=ceil($file['size'] / 1024);
                if ($file['size'] >$upload->max_size) {
                    $res[$name]['code']="alert('附件超过上限(".ceil($upload->max_size / 1024)."K)!');";
                    break;
                }
                if (!front::checkstr(file_get_contents($file['tmp_name']))) {
                    $res[$name]['code']=lang('上传失败!附件没有通过验证!');
                    break;
                }
                if (!$file['name'] ||!preg_match('/\.('.$_file_type.')$/',$file['name']))
                    continue;
                $uploads[$name]=$upload->run($file);
                if (!$uploads[$name]) {
                    $res[$name]['code']="alert('".lang('附件保存失败!')."');";
                    break;
                }
                $res[$name]['name']=$uploads[$name];
                $res[$name]['type']=$file['type'];
                $rname=preg_replace('%(.*)[\\\\\/](.*)_\d+(\.[a-z]+)$%i','$2$3',$uploads[$name]);
                $res[$name]['code']="
                document.form1.attachment_id.value=data[key].id;
                if(!document.form1.attachment_intro.value) {
                document.form1.attachment_intro.value='$rname';
                }
                get('attachment_path').innerHTML=data[key].name;
                get('file_info').innerHTML='附件已保存!大小为:'+data[key].size+'K ';
                        ";
                if(substr(config::get('base_url'),-1,1) != '/'){
                	$ex = '/';
                }
                $str = config::get('base_url').$ex.$uploads[$name];
				echo $str;
                return;
            }
        }
        echo json::encode($res);
    }
예제 #3
0
 function swfsave_action(){
     if (is_array($_FILES['Filedata'])) {
         $upload = new upload();
         $upload->dir = 'images';
         $upload->max_size = 2048000;
         $attachment = new attachment();
         $_file_type = str_replace(',','|',config::get('upload_filetype'));
         $file = $_FILES['Filedata'];
         $file['name'] = strtolower($file['name']);
         if ($file['size'] > $upload->max_size) {
             echo "附件超过上限(".ceil($upload->max_size / 1024)."K)!');";
             exit;
         }
         if (!front::checkstr(file_get_contents($file['tmp_name']))) {
             echo '上传失败!请将图片保存为WEB格式!';
             exit;
         }
         if (!$file['name'] || !preg_match('/\.('.$_file_type.')$/',$file['name'])){
             echo '上传失败!不允许的文件类型!';
             exit;
         }
         $filename = $upload->run($file);
         if(config::get('watermark_open')) {
             include_once ROOT.'/lib/plugins/watermark.php';
             imageWaterMark($filename,config::get('watermark_pos'),config::get('watermark_path'),null,5,"#FF0000",config::get('watermark_ts'),config::get('watermark_qs'));
         }
         if (!$filename) {
             echo "附件保存失败!";
             exit;
         }
         echo 'ok_'.$filename;
         exit;
     }else{
         exit('请添加文件');
     }
 }
예제 #4
0
파일: index.php 프로젝트: GHubgenius/qbbj
 //	}
 /*文件上传处理程序*/
 $file = $_FILES['fileField'];
 $attachurl = '';
 if ($file['size'] > 0) {
     $fileArr['file'] = $file['tmp_name'];
     $fileArr['name'] = $file['name'];
     $fileArr['size'] = $file['size'];
     $fileArr['type'] = $file['type'];
     $file_name = 'f' . mt_rand(100, 999) . strtotime(date('Y-m-d H:i:s', time())) . strtolower(strrchr($file['name'], "."));
     $filetypes = explode(' ', $webdb[upfileType]);
     $savepath = "../upload_files/guestbook/";
     $maxsize = 0;
     $overwrite = 0;
     $upload = new upload($fileArr, $file_name, $savepath, $filetypes, $overwrite, $maxsize);
     if (!$upload->run()) {
         showerr($upload->errmsg());
     }
     $attachurl = "guestbook/" . $file_name;
 }
 $db->query("INSERT INTO `{$_pre}content` ( `ico` , `email` , `oicq` , `weburl` , `blogurl` , `uid` , `username` , `ip` , `content` , `yz` , `posttime` , `list`, `fid`, `mobphone`, `companyname`, `truename`, `phone`, `deadline`, `attach1`, `attach2`, `attach3`, `attachurl`, `ofid`, `aid` , `goods_num`, `goods_spe`, `goods_remark`)\n\tVALUES (\n\t'{$face}','{$postdb['email']}','{$postdb['oicq']}','{$postdb['weburl']}','{$postdb['blogurl']}','{$lfjuid}','{$postdb['username']}','{$onlineip}','{$postdb['content']}','{$yz}','{$timestamp}','{$timestamp}','{$fid}','{$postdb['mobphone']}','{$postdb['companyname']}','{$postdb['truename']}','{$postdb['phone']}','{$postdb['deadline']}','{$postdb['attach1']}','{$postdb['attach2']}','{$postdb['attach3']}','{$attachurl}','{$postdb['ofid']}','{$postdb['aid']}','{$postdb['goods_num']}','{$postdb['goods_spe']}','{$postdb['goods_remark']}')\n\t");
 /*发送邮件程序*/
 require_once 'phpmailer/class.phpmailer.php';
 $content .= "公司名称:" . $postdb[companyname] . "<br>联系人:" . $postdb[truename] . "<br>电子邮件:" . $postdb[email] . "<br>联系电话:" . $postdb[phone] . "<br>交货期:" . $postdb[deadline] . "<br>commodity code:" . $postdb[goods_sn] . "<br>name of commodity:" . $postdb[title] . "<br>number:" . $postdb[goods_num] . "<br>specification:" . $postdb[goods_spe] . "<br>remarks:" . $postdb[goods_remark] . "<br>询价中需要说明的要求1:" . $postdb[attach1] . "<br>询价中需要说明的要求2:" . $postdb[attach2] . "<br>询价中需要说明的要求3:" . $postdb[attach3];
 $content = iconv('GBK', 'UTF-8', $content);
 send_email($content);
 $rurl = "?fid={$fid}";
 if ($postdb[ofid]) {
     $rurl .= "&ofid={$ofid}";
 }
 if ($postdb[aid]) {