HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/bb.cwoyt.com/Application/Home/Controller/IndexController.class.php
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 赛脑 <2233759493@qq.com> <http://www.sn.com>
// +----------------------------------------------------------------------

namespace Home\Controller;
use COM\Page;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {
	
	
	//系统首页
    public function index(){
		
		to_url();
		$domain = M('config')->where('id = 101')->getField('value');
		if($domain == 1){
			$banner = M('banner')->where('status = 1')->order('sort asc,bid desc')->select();
			$list = M('product')->where('status = 1 and good = 1')->order('sort asc,proid desc')->select();
			$value = M('config')->where('id = 88')->getField('value');
			$phone = M('config')->where('id = 104')->getField('value');
			$language = M('config')->where('id = 97')->getField('value');
			$this->assign('_list', $list);
			$this->assign('banner', $banner);
			$this->assign('value', $value);
			$this->assign('phone', $phone);
			$this->assign('language', $language);
			$this->display();
		}else{
			$url = $_SERVER['HTTP_HOST'];
			$zdomain = M('config')->where('id = 102')->getField('value');
			if($url == $zdomain){
				$banner = M('banner')->where('status = 1')->order('sort asc,bid desc')->select();
				$list = M('product')->where('status = 1')->order('sort asc,proid desc')->select();
				$value = M('config')->where('id = 88')->getField('value');
				$language = M('config')->where('id = 97')->getField('value');
				$this->assign('_list', $list);
				$this->assign('banner', $banner);
				$this->assign('value', $value);
				$this->assign('language', $language);
				$this->display();
			}else{
				$proid = M('domain')->where('domain = "'.$url.'"')->getField('proid');
				$this->info($proid);
			}
			
		}
		
    }
	

	public function lists(){
		$cid = I('get.cid');
		$class = M('class')->where('status = 1')->order('sort asc,cid desc')->select();
		$phone = M('config')->where('id = 104')->getField('value');
		if($cid){
			$where['cid'] = array('like','%'.$cid.'%');
		}
		$where['status'] = array('eq',1);
		$list = M('product')->where($where)->order('sort asc,proid desc')->select();
		$value = M('config')->where('id = 88')->getField('value');
		
		$this->assign('value', $value);
		$this->assign('cid', $cid);
		$this->assign('list', $list);
		$this->assign('class', $class);
		$this->assign('phone', $phone);
		if(is_mobile()){
			$this->display();
		}else{
			$this->display('pc-lists');
		}
		
	}
	


	public function search(){
		
		$q = I('get.q');
		$where['title'] = array('like','%'.$q.'%');
		$where['status'] = array('eq',1);
		$where['good'] = array('eq',1);
		$list = M('product')->where($where)->order('sort asc,proid desc')->select();
		$value = M('config')->where('id = 88')->getField('value');
		$this->assign('value', $value);
		$this->assign('q', $q);
		$this->assign('_list', $list);
		$this->display();
	}
	
	public function iframe(){
		$proid = I('get.proid');
		$gzid = I('get.gzid',22);
		$uid = I('get.uid',1);
		$this->info($proid,$gzid,$uid,true);
	}
	
	
	public function info($proid,$gzid = '',$uid = '',$iframe = false){
		to_url();
		cookie('num',null);
		$proid = $proid?$proid:I('get.proid');
		$gzid = $gzid?$gzid:I('get.gzid',22);
		$uid = $uid?$uid:I('get.uid',1);
		
		$t = time();
		$start_time = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));  //当天开始时间
		$end_time = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t)); //当天结束时间
		$GetIpLookup = $_SERVER["REMOTE_ADDR"];
		$GetIpLookup['province'] = '未知地区';
		$GetIpLookup['city'] = '未知地区';
		
		//统计数据初始化
		$t1 = array(
			'proid' => $proid,
			'uid' => $uid,
			'gzid' => $gzid,
			'province' => $GetIpLookup['province'],
			'city' => $GetIpLookup['city'],
			'ip' => $GetIpLookup['ip'],
			'browse_num' => 1,
			'addtime' => $t,
		);
		
		//统计时间段,类型-2
		$setime['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
		$setime['type'] = array('eq',2);
		$setime['uid'] = array('eq',$uid);
		
		$setime = M('statistical')->where($setime)->find();
		if($setime){
			M('statistical')->where('sid = '.$setime['sid'])->setInc('browse_num',1);
		}else{
			$t1['type'] = 2;
			M('statistical')->add($t1);
		}
		
		//统计产品,类型-4
		$por['proid'] = array('eq',$proid);
		$por['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
		$por['type'] = array('eq',4);
		$por['uid'] = array('eq',$uid);
		
		$por = M('statistical')->where($por)->find();
		if($por){
			M('statistical')->where('sid = '.$por['sid'])->setInc('browse_num',1);
		}else{
			$t1['type'] = 4;
			M('statistical')->add($t1);
		}
		
		//统计地区,类型-5
		$addr['province'] = array('eq',$GetIpLookup['province']);
		$addr['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
		$addr['type'] = array('eq',5);
		$addr['uid'] = array('eq',$uid);
		
		$addr = M('statistical')->where($addr)->find();
		if($addr){
			M('statistical')->where('sid = '.$addr['sid'])->setInc('browse_num',1);
		}else{
			$t1['type'] = 5;
			M('statistical')->add($t1);
		}
		
		//统计来源,类型-6
		$gz['gzid'] = array('eq',$gzid);
		$gz['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
		$gz['type'] = array('eq',6);
		$gz['uid'] = array('eq',$uid);
		
		$gz = M('statistical')->where($gz)->find();
		if($gz){
			M('statistical')->where('sid = '.$gz['sid'])->setInc('browse_num',1);
		}else{
			$t1['type'] = 6;
			M('statistical')->add($t1);
		}
		
		//统计用户,类型-7
		$user['uid'] = array('eq',$uid);
		$user['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
		$user['type'] = array('eq',7);
		$user['uid'] = array('eq',$uid);
		
		$user = M('statistical')->where($user)->find();
		if($user){
			M('statistical')->where('sid = '.$user['sid'])->setInc('browse_num',1);
		}else{
			$t1['type'] = 7;
			M('statistical')->add($t1);
		}
		
		$info = M('product')->where('proid = '.$proid)->find();
		$info['content'] = M('product_data')->where('proid = '.$proid)->getField('content');
		
		preg_match_all('/{video@\d+@}/',$info['content'],$video_arr);
		if(count($video_arr[0])){
			foreach($video_arr[0] as $k=>$v){
				
				$varr = str2arr($v,'@');
				$gkkarr[] = $v;
				$kkvarr[] = M('video')->where('vid = '.$varr[1])->getField('content');
			}
			$info['content'] = str_replace($gkkarr,$kkvarr,$info['content']);
		}
		
		$temp = M('template')->where('tid = '.$info['template'])->find();
		$norms_pro = M('product_norms')->where('proid = '.$proid.' and type = 1')->order('def asc')->select();
		$norms_size = M('product_norms')->where('proid = '.$proid.' and type = 2')->order('def asc')->select();
		$norms_color = M('product_norms')->where('proid = '.$proid.' and type = 3')->order('def asc')->select();
		$temp['options'] = unserialize($temp['options']);
		$temp['pay_type'] = unserialize($temp['pay_type']);
		$info['images'] = explode(',',$info['images']);
		$info['review'] = explode("\r\n",trim($info['review']));
		foreach($info['review'] as $k=>$v){
			$info['review'][$k] = explode("|",$v);
		}
		$info['preferential'] = $info['oldprice']-$info['price'];
		$options = '';
		foreach($temp['options'] as $k=>$v){
			$options .= "'".$v."',";
		}
		$options = substr($options,0,-1);
		$pay = array();
		foreach($temp['pay_type'] as $k=>$v){
			if($v['status'] == 0){
				unset($temp['pay_type'][$k]);
			}else{
				$pay[$v['sort']] = $k;
			}
		}
		ksort($pay);
		$pay = array_merge($pay);
		$arr = array();
		$arr = cookie('num');
		$arr[$norms_pro[0]['nid']] = $norms_pro[0]['number'];
		cookie('num',$arr,600);
	

		//最新下单
		if($temp['order_type'] == 1){
			$orderhtml = explode("\r\n",trim($temp['order_content']));
			foreach($orderhtml as $k=>$v){
				$orderhtml[$k] = str_replace("{time}",date('Y-m-d'),$v);
			}
		}else{
			$NewWhere['proid'] = array('eq',$proid);
			$NewWhere['status'] = array('eq',1);
			$NewArr = M('order')->where($NewWhere)->limit(30)->select();
			
			$orderhtml = array();
			foreach($NewArr as $kn=>$vn){
				$NewArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
				$NewArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
				$NewArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
				foreach($NewArr[$kn] as $k=>$v){
					$NewArrkarr[] = "{".$k."}";
					$NewArrvarr[] = $v;
				}
				$orderhtml[] = str_replace($NewArrkarr,$NewArrvarr,$temp['order_content']);
				unset($NewArrkarr);
				unset($NewArrvarr);
			}
		}
		
		
		//发货信息
		if($temp['delivery_type'] == 1){
			$html = explode("\r\n",trim($temp['delivery_content']));
			foreach($html as $k=>$v){
				$html[$k] = str_replace("{time}",date('Y-m-d'),$v);
			}
		}else{
			$DelWhere['proid'] = array('eq',$proid);
			$DelWhere['status'] = array('eq',3);
			$DelArr = M('order')->where($DelWhere)->limit(30)->select();
		
			$html = array();
			foreach($DelArr as $kn=>$vn){
				$DelArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
				$DelArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
				$DelArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
				foreach($DelArr[$kn] as $k=>$v){
					$DelArrkarr[] = "{".$k."}";
					$DelArrvarr[] = $v;
				}
				$html[] = str_replace($DelArrkarr,$DelArrvarr,$temp['delivery_content']);
				unset($DelArrkarr);
				unset($DelArrvarr);
			}
			
		}
		
		
		if($info['time_status'] == 0){
			$endtime = $info['endtime']-time();
			if($info['time_type'] == 2){
				if($endtime < 0){
					$endtime = M('product')->where('proid = '.$proid)->save(array('endtime' => time()+$info['time_sum']));
					$this->redirect('Home/index/info?proid='.$proid.'&gzid='.I('get.gzid'));
				}
			}
		}
		
		if($info['parameter']){
			$parameter = explode("\r\n",trim($info['parameter']));
			foreach($parameter as $k=>$v){
				$parameter[$k] = explode(":",$v);
			}
		}
		
		if($info['status'] == 1){
			if($info['time_status'] == 0){
				if($info['time_type'] == 1){
					if(($info['starttime'] < time()) && ($info['endtime'] > time())){
						$temphtml = 1;
					}
				}else{
					$temphtml = 1;
				}	
			}else{
				$temphtml = 1;
			}			
		}
		
		$audit = M('audit')->where('id = '.$proid)->find();
		$temp['nav_temp'] = explode(',',$temp['nav_temp']);
		$temp['nav_count'] = count($temp['nav_temp']);
	//	p($temp);
		$language = M('config')->where('id = 97')->getField('value');
		$statistical = M('config')->where('id = 99')->getField('value');
		$value = M('config')->where('id = 88')->getField('value');
		$cookie = M('config')->where('id = 105')->getField('value');
		
		if($info['copyright']){
			$copyright = $info['copyright'];
		}else{
			$copyright = C('WEB_SITE_ICP');
		}
		
		$WX_APPID = M('config')->where('id = 53')->getField('value');
		$WX_APPSECRET = M('config')->where('id = 54')->getField('value');
// 		require 'Jssdk.php';
// 		$jssdk = new \Jssdk($WX_APPID, $WX_APPSECRET);
// 		$signPackage = $jssdk->GetSignPackage();
		
		$url =  _SERVER_NAME_.$_SERVER['REQUEST_URI'];
		
		$this->assign('copyright', $copyright);
		$this->assign('cookie', $cookie);
		$this->assign('url', $url);
		$this->assign('audit', $audit);
		$this->assign('statistical', $statistical);
// 		$this->assign('signPackage', $signPackage);
		$this->assign('root', __ROOT__);
		$this->assign('value', $value);
		$this->assign('language', $language);
		$this->assign('parameter', $parameter);
		$this->assign('endtime', $endtime);
		$this->assign('html', $html);
		$this->assign('orderhtml', $orderhtml);
		$this->assign('options', $options);
		$this->assign('pay', $pay);
		$this->assign('info', $info);
		$this->assign('temp', $temp);
		$this->assign('norms_pro', $norms_pro);
		$this->assign('norms_size', $norms_size);
		$this->assign('norms_color', $norms_color);
		$this->assign('proid', $proid);
		$this->assign('gzid', $gzid);
		$this->assign('uid', $uid);
		$this->assign('temphtml', $temphtml);
		
		if($iframe){
			$StyleArr = str2arr($info['style'],'-');
			if($StyleArr[0] == 'xinfo'){
				$this->display('iframe-info');
			}else{
				$this->display('iframe-'.$info['style']);
			}
			
			
		}else{
			$this->assign('iframe','style');
			$this->display($info['style']);
		}
		
	}
	
	public function order_cookie(){
		
		if(IS_POST){
			cookie('order',null);
		
			if(I('post.pro_class') == 3 || I('post.pro_class') == 4){
				$title = implode(',',I('post.pro'));
				$nid = implode(',',I('post.nid'));
				
				foreach(I('post.nid') as $k=>$v){
					$total += M('product_norms')->where('nid = '.$v)->getField('price')*I('post.num');
				}
			}else{
				$title = I('post.title');
				$nid = I('post.nid');
				$total = M('product_norms')->where('nid = '.$nid)->getField('price')*I('post.num');
			}
			
			$data = array(
				'proid' => I('post.proid'),
				'nid' => $nid,
				'title' => $title,
				'total' => $total,
				'gzid' => I('post.gzid'),
				'num' => I('post.num'),
				'size' => I('post.size'),
				'color' => I('post.color'),
				'tid' => I('post.tid'),
				'uid' => I('post.uid'),
			);
		//	p($data);exit;
			cookie('order',$data,6000);
			$this->success('',U('confirm'));
		}
		
	}
	
	
	public function confirm(){
		
		if(IS_POST){
			
		}else{
			
			$order = cookie('order');
			$post_order = U('post_order');
			
			if(!$order){
				$cookieNum = cookie('cookieNum');
				$cookieNumFile = './log/cookie/'.$cookieNum.'.cookie';
				$cookieNumFileContents = file_get_contents($cookieNumFile);
				if($cookieNumFileContents){
					$Carcookie = unserialize($cookieNumFileContents);
				}
				foreach($Carcookie as $k=>$v){
					$total += $v['price'] * $v['num'];
				}
				$order = reset($Carcookie);
				
			}
			
			
			$info = M('product')->where('proid = '.$order['proid'])->find();
			$temp = M('template')->where('tid = '.$info['template'])->find();
			$temp['options'] = unserialize($temp['options']);
			$temp['pay_type'] = unserialize($temp['pay_type']);
			$options = '';
			foreach($temp['options'] as $k=>$v){
				$options .= "'".$v."',";
			}
			$options = substr($options,0,-1);
			$pay = array();
			foreach($temp['pay_type'] as $k=>$v){
				if($v['status'] == 0){
					unset($temp['pay_type'][$k]);
				}else{
					$pay[$v['sort']] = $k;
				}
			}
			ksort($pay);
			$pay = array_merge($pay);
			if($total){
				$order['total'] = round($total,2);
				$post_order = U('Carorder/carCookiePost');
			}
	
			$this->assign('post_order', $post_order);
			$this->assign('order', $order);
			$this->assign('total', $total);
			$this->assign('options', $options);
			$this->assign('info', $info);
			$this->assign('temp', $temp);
			$this->assign('pay', $pay);
			$this->display();
			
		}
		
	}
	
	public function Carcookie(){
		
		if(IS_POST){
			cookie('order',null);
			$cookieNum = cookie('cookieNum');
			if(!$cookieNum){
				$cookieNum = date('YmdHis').'-'.rand(1000,9999);
			}
			$cookieNumFile = './log/cookie/'.$cookieNum.'.cookie';
			$cookieNumFileContents = file_get_contents($cookieNumFile);
			
			if($cookieNumFileContents){
				$Car = unserialize($cookieNumFileContents);
			}
			
			$proid = I('post.proid');
			$nid = I('post.nid')?I('post.nid'):0;
			$sid = I('post.sid')?I('post.sid'):0;
			$cid = I('post.cid')?I('post.cid'):0;
			
			$tit = M('product')->where('proid = '.$proid)->getField('title');
			$thumb = M('product_norms')->where('nid = '.$nid)->getField('thumb');
			if(!$thumb){
				$thumb = M('product')->where('proid = '.$proid)->getField('thumb');
			}
			
			$Car[$proid.'-'.$nid.'-'.$sid.'-'.$cid] = array(
				'proid' => $proid,
				'tit' => $tit,
				'thumb' => $thumb,
				'title' => I('post.title'),
				'size' => I('post.size'),
				'color' => I('post.color'),
				'num' => I('post.num'),
				'price' => round(I('post.price'),2),
				'total' => round(I('post.total'),2),
				'totals' => round(I('post.totals'),2),
				'number' => I('post.number'),
				'uid' => I('post.uid'),
				'gzid' => I('post.gzid'),
				'tid' => I('post.tid'),
				'pro_class' => I('post.pro_class'),
				'paytype' => I('post.paytype'),
				'nid' => $nid,
				'sid' => $sid,
				'cid' => $cid,
			);
			$Car = serialize($Car);
			
			$file = fopen($cookieNumFile,"w+");
			fwrite($file,$Car);
			fclose($file);
			cookie('cookieNum',$cookieNum,6000);
			$this->success('添加购物车成功!');
			
		}
		
	}
	
	
	
	public function Carorder(){
		
		$cookieNum = cookie('cookieNum');
		$cookieNumFile = './log/cookie/'.$cookieNum.'.cookie';
		$Carcookie = file_get_contents($cookieNumFile);
		
		$Carcookie = unserialize($Carcookie);
		foreach($Carcookie as $k=>$v){
			$total += $v['price'] * $v['num'];
		}
	
		$this->assign('Carcookie', $Carcookie);
		$this->assign('total', $total);
		$this->display();
		
	}
	
	public function carorder_post(){
		
		if(IS_POST){
			$cookieNum = cookie('cookieNum');
			$cookieNumFile = './log/cookie/'.$cookieNum.'.cookie';
			$Carcookie = file_get_contents($cookieNumFile);
			$Carcookie = unserialize($Carcookie);
			if(I('post.type') == 1){
				$Carcookie[I('post.id')]['num'] = I('post.num');
			}else{
				unset($Carcookie[I('post.id')]);
			}
			$Carcookie = serialize($Carcookie);
			$file = fopen($cookieNumFile,"w+");
			fwrite($file,$Carcookie);
			fclose($file);
			
		}
	}
	
	
	
	
	public function post_order(){
		if(IS_POST){
			
			if(I('post.smstype') == 1){
				if(I('post.sms')){
					if(I('post.sms') != cookie('sms')){
						$arr = array(
							'status' => 4,
							'title' => '验证码不正确!',
						);
						echo json_encode($arr);exit;
					}
				}else{
					$arr = array(
						'status' => 4,
						'title' => '验证码不正确!',
					);
					echo json_encode($arr);exit;
				}
				
			}
			
			$ordernum = rand(10,99);
			$total = '';
			$order = cookie('order');
			if(!$order){
				
				if(I('post.pro_class') == 3 || I('post.pro_class') == 4){
					$title = implode(',',I('post.pro'));
					$nid = implode(',',I('post.nid'));
					
					foreach(I('post.nid') as $k=>$v){
						$total += M('product_norms')->where('nid = '.$v)->getField('price')*I('post.num');
					}
				}else{
					$title = I('post.title');
					$nid = I('post.nid');
					$total = M('product_norms')->where('nid = '.$nid)->getField('price')*I('post.num');
				}
			}else{
				$title = $order['title'];
				$nid = $order['nid'];
				$total = $order['total'];
			}
			
			$GetIpLookup = $_SERVER["REMOTE_ADDR"];
			$GetIpLookup['province'] = '未知地区';
			$GetIpLookup['city'] ='未知地区';
			$data = array(
				'name' => I('post.name'),
				'phone' => trim(I('post.phone')),
				'province' => I('post.province'),
				'city' => I('post.city'),
				'area' => I('post.area'),
				'address' => htmlspecialchars(I('post.address')),
				'ipprovince' => $GetIpLookup['province'],
				'ipcity' => $GetIpLookup['city'],
				'ip' => $_SERVER["REMOTE_ADDR"],
				'status' => 1,
				'addtime' => NOW_TIME,
				'message' => htmlspecialchars(I('post.message')),
				'proid' => I('post.proid'),
				'nid' => $nid,
				'title' =>$title,
				'ordernum' => date('YmdHis',NOW_TIME).$ordernum,
				'paytype' => I('post.paytype'),
				'total' => $total,
				'gzid' => I('post.gzid'),
				'num' => I('post.num'),
				'sex' => I('post.sex'),
				'age' => I('post.age'),
				'height' => I('post.height'),
				'weight' => I('post.weight'),
				'idnumber' => I('post.idnumber'),
				'tel' => I('post.tel'),
				'code' => I('post.code'),
				'qq' => I('post.qq'),
				'wechat' => I('post.wechat'),
				'email' => I('post.email'),
				// 'size' => I('post.size'),
				// 'color' => I('post.color'),
				'size' => json_encode(I('post.size'),JSON_UNESCAPED_UNICODE),
				'color' => json_encode(I('post.color'),JSON_UNESCAPED_UNICODE),
				'tid' => I('post.tid'),
				'iframe' => I('post.iframe'),
				'uid' => I('post.uid'),
				'cichun' => I('post.cichun'),
				'yanse' => I('post.yanse'),
				'orderway' => is_mobile()?1:0,
			);
			
			$t = time();
			$start_time = mktime(0,0,0,date("m",$t),date("d",$t),date("Y",$t));  //当天开始时间
			$end_time = mktime(23,59,59,date("m",$t),date("d",$t),date("Y",$t)); //当天结束时间
		
			//统计数据初始化
			$t1 = array(
				'proid' => $data['proid'],
				'uid' => $data['uid'],
				'gzid' => $data['gzid'],
				'province' => $GetIpLookup['province'],
				'city' => $GetIpLookup['city'],
				'ip' => $GetIpLookup['ip'],
				'browse_num' => 1,
				'addtime' => $t,
				'pay' => $data['paytype'],
			);
			
			//统计时间段,类型-2
			$paytype['pay'] = array('eq',$data['paytype']);
			$paytype['addtime'] = array(array('gt',$start_time),array('lt',$end_time));
			$paytype['type'] = array('eq',3);
			$paytype['uid'] = array('eq',$uid);
			
			$paytype = M('statistical')->where($paytype)->find();
			if($paytype){
				M('statistical')->where('sid = '.$paytype['sid'])->setInc('browse_num',1);
			}else{
				$t1['type'] = 3;
				M('statistical')->add($t1);
			}
			
			$var = M('config')->where('id = 95')->getField('value');
			if($var == 1){
				$stime = strtotime(date('Ymd')); 
				$etime = strtotime(date('Ymd'))+86400;
				$map['addtime'] = array(array('gt',$stime),array('lt',$etime));
				$map['phone'] = array('eq',$data['phone']);
				$map['proid'] = array('eq',$data['proid']);
				$count = M('order')->where($map)->count();
				$char = M('config')->where('id = 96')->getField('value');
				if($count >= $char){
					$arr = array(
						'status' => 4,
						'title' => '下单过于频繁!',
					);
					echo json_encode($arr);exit;
				}
				
				$where['addtime'] = array(array('gt',$stime),array('lt',$etime));
				$where['ip'] = array('eq',$data['ip']);
				$where['proid'] = array('eq',$data['proid']);
				$wcount = M('order')->where($where)->count();
				
				if($wcount >= $char){
					$arr = array(
						'status' => 4,
						'title' => '下单过于频繁!',
					);
					echo json_encode($arr);exit;
				}
				
			}
			
			
			M('order')->add($data);
			M('product')->where('proid = '.$data['proid'])->setInc('number',1);
			
			if($data['paytype'] == 'huodao'){
				$return = $this->houdao_order_return($data);
			}else if($data['paytype'] == 'wechat'){
				$return = $this->wechat_order_return($data);
			}else if($data['paytype'] == 'alipay'){
				$return = $this->alipay_order_return($data);
			}else if($data['paytype'] == 'alipaycode'){
				$return = $this->alipaycode_order_return($data);
			}else if($data['paytype'] == 'wechatcode'){
				$return = $this->alipaycode_order_return($data);
			}else if($data['paytype'] == 'ty'){
				$return = $this->houdao_order_return($data);
			}else if($data['paytype'] == 'bty'){
				$return = $this->houdao_order_return($data);
			}else{
				$return = $this->houdao_order_return($data);
			}
			echo $return;exit;
		}
		
	}
	
	public function houdao_order_return($data){
		
		
		$nidarr = explode(',',$data['nid']);
		foreach($nidarr as $k=>$v){
			M('product_norms')->where('nid = '.$v)->setDec('number',$data['num']);
		}
		
		$temp = M('template')->where('tid = '.$data['tid'])->field('pay_type,alert,alert_type,alert_href,alert_content')->find();
		$order = M('order')->where('ordernum = '.$data['ordernum'])->getField('total');
		$temp['pay_type'] = unserialize($temp['pay_type']);
		$total = $temp['pay_type']['huodao']['discount']*$order;
		M('order')->where('ordernum = '.$data['ordernum'])->save(array('total' => $total));
		
		$email_value = M('config')->where('id = 64')->getField('value');
		if($email_value == 1){
			
			$info['temp'] = M('template')->where('tid = '.$data['tid'])->field('size_title,color_title')->find();
			if($data['color']){
				$color = $info['temp']['color_title'].' :'.$data['color'];
			}
			if($data['size']){
				$size = $info['temp']['size_title'].' :'.$data['size'];
			}
			
			$pay = require './Application/Common/Conf/pay.php';
			$html = M('config')->where('id = 103')->getField('value');
			
			$data['time'] = date('Y-m-d H:i',$data['addtime']);
			$data['paytype'] = $pay[$data['paytype']];
			foreach($data as $k=>$v){
				$datakarr[] = "{".$k."}";
				$datavarr[] = $v;
			}
			$data_html = str_replace($datakarr,$datavarr,$html);
			
			$email_title = M('config')->where('id = 70')->getField('value');
			$email = M('config')->where('id = 60')->getField('value');
			
			send_email($email,$email_title,$data_html);
		}
		
		$status = M('config')->where('id = 71')->getField('value');
		if($status == 1){
			$dx = M('config')->where('id = 78')->getField('value');
			$dx_arr = unserialize($dx);
			if(in_array('gk',$dx_arr)){
				$gk = M('config')->where('id = 76')->getField('value');
				$order_gk = M('order')->where('ordernum = '.$data['ordernum'])->find();
				$order_gk['time'] = date('Y-m-d H:i',$order_gk['addtime']);
				$gk_html  = '';
				foreach($order_gk as $k=>$v){
					$gkkarr[] = "{".$k."}";
					$kkvarr[] = $v;
				}
				$gk_html = str_replace($gkkarr,$kkvarr,$gk);
				sms($data['phone'],$gk_html);
			}
			
			if(in_array('sj',$dx_arr)){
				$sj = M('config')->where('id = 77')->getField('value');
				$order_sj = M('order')->where('ordernum = '.$data['ordernum'])->find();
				$order_sj['time'] = date('Y-m-d H:i',$order_sj['addtime']);
				$sj_html  = '';
				foreach($order_sj as $k=>$v){
					$sjkarr[] = "{".$k."}";
					$sjvarr[] = $v;
				}
				$sj_html = str_replace($sjkarr,$sjvarr,$sj);
				$sj_phone = M('config')->where('id = 82')->getField('value');
				
				sms($sj_phone,$sj_html);
			}
		
		}
		
		if($temp['alert'] == 0){
			if($temp['alert_type'] == 1){
				$arr = array(
					'status' => 1,
					'url' => $temp['alert_href'],
					'ordernum' => $data['ordernum'],
				);
			}else if($temp['alert_type'] == 2){
				$html = '';
				foreach($data as $k=>$v){
					$karr[] = "{".$k."}";
					$varr[] = $v;
				}
				$html = str_replace($karr,$varr,$temp['alert_content']);
				$arr = array(
					'status' => 2,
					'title' => $html,
					'ordernum' => $data['ordernum'],
				);
			}
		}else{
			$arr = array(
				'status' => 3,
				'url' => U('order?ordernum='.$data['ordernum']),
				'ordernum' => $data['ordernum'],
			);
			
		}
		
		return json_encode($arr);exit;
	}
	
	
	public function wechat_order_return($data){
		
		$temp = M('template')->where('tid = '.$data['tid'])->field('pay_type')->find();
		$order = M('order')->where('ordernum = '.$data['ordernum'])->getField('total');
		$temp['pay_type'] = unserialize($temp['pay_type']);
		
		if($temp['pay_type']['wechat']['discount'] != '1'){
			if($order > '0.01'){
				$total = round($temp['pay_type']['wechat']['discount']*$order,2);
			}else{
				$total = $order;
			}
		}else{
			$total = $order;
		}
		
		M('order')->where('ordernum = '.$data['ordernum'])->save(array('total' => $total));
		
		if(is_weixin()){
			$url = U('Home/Wxpay/index?ordernum='.$data['ordernum']);
		}else{
			
			if(is_mobile()){
				$url = U('Home/Wxpay/Wxh5pay?ordernum='.$data['ordernum']);
			}else{
				$url = U('Home/Wxpay/native?ordernum='.$data['ordernum']);
			}
			
		}
		
		
		$arr = array(
			'status' => 5,
			'title' => '提交订单成功,即将跳转到支付页面...',
			'url' => $url,
			'ordernum' => $data['ordernum'],
		);
		return json_encode($arr);exit;
	}
	
	public function alipay_order_return($data){
		
		$temp = M('template')->where('tid = '.$data['tid'])->field('pay_type')->find();
		$order = M('order')->where('ordernum = '.$data['ordernum'])->getField('total');
		$temp['pay_type'] = unserialize($temp['pay_type']);
		
		if($temp['pay_type']['alipay']['discount'] != '1'){
			if($order > '0.01'){
				$total = round($temp['pay_type']['alipay']['discount']*$order,2);
			}else{
				$total = $order;
			}
		}else{
			$total = $order;
		}
		
		
		M('order')->where('ordernum = '.$data['ordernum'])->save(array('total' => $total));
		
		$url = U('Home/Alipay/index?ordernum='.$data['ordernum']);
		$arr = array(
			'status' => 5,
			'title' => '提交订单成功,即将跳转到支付页面...',
			'url' => $url,
			'ordernum' => $data['ordernum'],
		);
		return json_encode($arr);exit;
	}
	
	public function alipaycode_order_return($data){
		
		
		$nidarr = explode(',',$data['nid']);
		foreach($nidarr as $k=>$v){
			M('product_norms')->where('nid = '.$v)->setDec('number',$data['num']);
		}
		
		$temp = M('template')->where('tid = '.$data['tid'])->field('pay_type,alert,alert_type,alert_href,alert_content')->find();
		$order = M('order')->where('ordernum = '.$data['ordernum'])->getField('total');
		$temp['pay_type'] = unserialize($temp['pay_type']);
		
		if($temp['pay_type'][$data['paytype']]['discount'] != '1'){
			if($order > '0.01'){
				$total = round($temp['pay_type'][$data['paytype']]['discount']*$order,2);
			}else{
				$total = $order;
			}
		}else{
			$total = $order;
		}
		
		
		M('order')->where('ordernum = '.$data['ordernum'])->save(array('total' => $total));
		
		$email_value = M('config')->where('id = 64')->getField('value');
		if($email_value == 1){
			
			$info['temp'] = M('template')->where('tid = '.$data['tid'])->field('size_title,color_title')->find();
			if($data['color']){
				$color = $info['temp']['color_title'].' :'.$data['color'];
			}
			if($data['size']){
				$size = $info['temp']['size_title'].' :'.$data['size'];
			}
			
			$pay = require './Application/Common/Conf/pay.php';
			$html = M('config')->where('id = 103')->getField('value');
			
			$data['time'] = date('Y-m-d H:i',$data['addtime']);
			$data['paytype'] = $pay[$data['paytype']];
			foreach($data as $k=>$v){
				$datakarr[] = "{".$k."}";
				$datavarr[] = $v;
			}
			$data_html = str_replace($datakarr,$datavarr,$html);
			
			$email_title = M('config')->where('id = 70')->getField('value');
			$email = M('config')->where('id = 60')->getField('value');
			
			send_email($email,$email_title,$data_html);
		}
		
		$status = M('config')->where('id = 71')->getField('value');
		if($status == 1){
			$dx = M('config')->where('id = 78')->getField('value');
			$dx_arr = unserialize($dx);
			if(in_array('gk',$dx_arr)){
				$gk = M('config')->where('id = 76')->getField('value');
				$order_gk = M('order')->where('ordernum = '.$data['ordernum'])->find();
				$order_gk['time'] = date('Y-m-d H:i',$order_gk['addtime']);
				$gk_html  = '';
				foreach($order_gk as $k=>$v){
					$gkkarr[] = "{".$k."}";
					$kkvarr[] = $v;
				}
				$gk_html = str_replace($gkkarr,$kkvarr,$gk);
				sms($data['phone'],$gk_html);
			}
			
			if(in_array('sj',$dx_arr)){
				$sj = M('config')->where('id = 77')->getField('value');
				$order_sj = M('order')->where('ordernum = '.$data['ordernum'])->find();
				$order_sj['time'] = date('Y-m-d H:i',$order_sj['addtime']);
				$sj_html  = '';
				foreach($order_sj as $k=>$v){
					$sjkarr[] = "{".$k."}";
					$sjvarr[] = $v;
				}
				$sj_html = str_replace($sjkarr,$sjvarr,$sj);
				$sj_phone = M('config')->where('id = 82')->getField('value');
				
				sms($sj_phone,$sj_html);
			}
		
		}
		
		$url = U('Home/Order/index?ordernum='.$data['ordernum']);
		$arr = array(
			'status' => 5,
			'title' => '提交订单成功,即将跳转到支付页面...',
			'url' => $url,
			'ordernum' => $data['ordernum'],
		);
		return json_encode($arr);exit;
	}
	
	
	public function json_num_min($nid,$num){
		$nid = I('post.nid');
		$num = I('post.num');
		$arr = array();
		$arr = cookie('num');
		if(in_array($num,$arr)){
			unset($arr[$nid]);
		}else{
			$arr[$nid] = $num;
		}
		cookie('num',$arr,600);
		$min = min($arr);
		echo $min;exit;
	}
	
	public function sms(){
		$sms = M('config')->where('id = 80')->getField('value');
		if($sms == 1){
			$phone = I('post.phone');
			$smscon = M('config')->where('id = 81')->getField('value');
			
			$sms = rand(1000,9999);
			cookie('sms',$sms,600);
			$content = str_replace('{sms}',$sms,$smscon);
			echo sms($phone,$content);exit;
		}else{
			echo 1;exit;
		}
		
	}
	
	
	public function order(){
		
		$pay = require './Application/Common/Conf/pay.php';
		$ordernum = I('get.ordernum');
		$info = M('order')->where('ordernum = "'.$ordernum.'"')->find();
		$temp = M('template')->where('tid = '.$info['tid'])->field('options,size_title,color_title')->find();
		$options = unserialize($temp['options']);
		$info['title'] = explode(',',$info['title']);
		
		$currency = M('product')->where('proid = "'.$info['proid'].'"')->getField('currency');
		$value = M('config')->where('id = 88')->getField('value');
		$language = M('config')->where('id = 97')->getField('value');
		
		$this->assign('language', $language);
		$this->assign('options', $options);
		$this->assign('info', $info);
		$this->assign('temp', $temp);
		$this->assign('value', $value);
		$this->assign('pay', $pay);
		$this->assign('currency', $currency);
		$this->display();
	}
	
	public function get_phone(){
		
		$phone = I('get.phone');
		$proid = I('get.proid');
		$list = M('order')->where('phone = "'.$phone.'" and proid = '.$proid)->order('addtime desc')->select();
		if(!$list){
			$this->error('暂无你要搜索的订单!');
		}else{
			$this->success('',U('phone?phone='.$phone.'&proid='.$proid));
		}
		
	}
	
	
	public function phone(){
		$phone = I('get.phone');
		$proid = I('get.proid');
		$list = M('order')->where('phone = "'.$phone.'" and proid = '.$proid)->order('addtime desc')->select();
		if(!$list){
			$this->error('暂无你要搜索的订单!');exit;
		}
		foreach($list as $k=>$v){
		//	$list[$k]['options'] = unserialize(M('template')->where('tid = '.$v['tid'])->getField('options'));
			$list[$k]['temp'] = M('template')->where('tid = '.$v['tid'])->field('options,size_title,color_title')->find();
			$list[$k]['options'] = unserialize($list[$k]['temp']['options']);
			$list[$k]['title'] = explode(',',$v['title']);
			$list[$k]['currency'] = M('product')->where('proid = "'.$v['proid'].'"')->getField('currency');
		}
	//	p($list);
		$value = M('config')->where('id = 88')->getField('value');
		$ems = M('config')->where('id = 92')->getField('value');
		$language = M('config')->where('id = 97')->getField('value');
		$status = require './Application/Common/Conf/status.php';
		$allems = require './Application/Common/Conf/allems.php';
		$pay = require './Application/Common/Conf/pay.php';
		
		$this->assign('status', $status);
		$this->assign('pay', $pay);
		$this->assign('allems', $allems);
		$this->assign('language', $language);
		$this->assign('value', $value);
		$this->assign('ems', $ems);
		$this->assign('list', $list);
		$this->assign('proid', $proid);
		$this->display();
	}
	
	public function explain(){
		
		$orderid = I('post.orderid');
		$explain = I('post.explain');
		
		M('order')->save(array('orderid' => $orderid,'explain' => $explain));
		$this->success('提交成功!');
		
	}
	
	
	
	
	public function ems(){
		
		$ordernum = I('get.ordernum');
		$proid = I('get.proid');
		$info = M('order')->where('ordernum = "'.$ordernum.'"')->find();
		$pro = M('product')->where('proid = "'.$info['proid'].'"')->find();
		
		$order = getOrderTracesByJson($info['exp_com'],$info['exp_num']);
		
		$temp = M('template')->where('tid = '.$info['tid'])->field('options,size_title,color_title')->find();
		
		
		$ems = require './Application/Common/Conf/ems.php';
		$language = M('config')->where('id = 97')->getField('value');
	
		$count = count($order['Traces'])-1;
		$this->assign('temp', $temp);
		$this->assign('count', $count);
		$this->assign('language', $language);
		$this->assign('order', $order);
		$this->assign('ems', $ems);
		$this->assign('info', $info);
		$this->assign('proid', $proid);
		$this->assign('pro', $pro);
		$this->display();
	}
	
	public function post_cartadd(){
		cookie('bw_cart',null);
		$cart = cookie('bw_cart');
		$cart = json_decode($cart,true);
		$cart[I('post.proid').'-'.I('post.nid',0).'-'.I('post.sid',0).'-'.I('post.cid',0)] = array(
			'gzid' => I('post.gzid'),
			'tid' => I('post.tid'),
			'proid' => I('post.proid'),
			'nid' => I('post.nid'),
			'sid' => I('post.sid'),
			'cid' => I('post.cid'),
			'num' => I('post.num'),
			'title' => I('post.title'),
			'size' => I('post.size'),
			'color' => I('post.color'),
			'gzid' => I('post.gzid'),
			'pro_class' => I('post.pro_class'),
			'totals' => I('post.totals'),
			'total' => I('post.total'),
			'price' => I('post.price'),
			'number' => I('post.number'),
		);
		
		//p($cart);
		$data = json_encode($cart);
		cookie('bw_cart',$data,3600);
		echo $data;
	}
	
	
	public function message(){
		
		$proid = I('get.proid');
		$cart = cookie('bw_cart');
		$cart = json_decode($cart,true);
		sort($cart);
		
		$info = M('product')->where('proid = '.$proid)->find();
		$temp = M('template')->where('tid = '.$info['template'])->find();
		$temp['options'] = unserialize($temp['options']);
		$temp['pay_type'] = unserialize($temp['pay_type']);
		$options = '';
		foreach($temp['options'] as $k=>$v){
			$options .= "'".$v."',";
		}
		$options = substr($options,0,-1);
		
		$pay = array();
		foreach($temp['pay_type'] as $k=>$v){
			if($v['status'] == 0){
				unset($temp['pay_type'][$k]);
			}else{
				$pay[$v['sort']] = $k;
			}
		}
		ksort($pay);
		$pay = array_merge($pay);
	
		$this->assign('info', $info);
		$this->assign('proid', $proid);
		$this->assign('temp', $temp);
		$this->assign('options', $options);
		$this->assign('pay', $pay);
		$this->assign('cart', $cart);
		$this->meta_title = '提交信息';
		$this->display();
	}
	
	
	public function contact(){
		
		$contact = M('config')->where('id = 42')->getField('value');
		$this->assign('contact', $contact);
		$this->meta_title = '联系我们';
		$this->display();
	}
	
	public function about(){
		
		$contact = M('config')->where('id = 43')->getField('value');
		$this->assign('contact', $contact);
		$this->meta_title = '关于我们';
		$this->display();
	}
	
	
	public function html(){
		
		$p = I('get.p')?I('get.p'):1;
		
		if($p == 1){
			delDirAndFile('html');
			if(!file_exists('./html')){
				mkdir('./html');
			}
		}
		$ps = $p+1;
		$count = M('product')->count();
		$cp = 5;
		$countp = intval($count/$cp);
		
		$page = new Page($count,$cp);
		
		$list = M('product')->field('proid,style')->order('proid desc')->limit($page->firstRow.','.$page->listRows)->select();
		
		foreach($list as $kp=>$vp){
			
			cookie('num',null);
			$proid = $vp['proid'];
			$info = M('product')->where('proid = '.$proid)->find();
			$info['content'] = M('product_data')->where('proid = '.$proid)->getField('content');
			
			preg_match_all('/{video@\d+@}/',$info['content'],$video_arr);
			if(count($video_arr[0])){
				foreach($video_arr[0] as $k=>$v){
					
					$varr = str2arr($v,'@');
					$gkkarr[] = $v;
					$kkvarr[] = M('video')->where('vid = '.$varr[1])->getField('content');
				}
				$info['content'] = str_replace($gkkarr,$kkvarr,$info['content']);
			}
			
			
			$temp = M('template')->where('tid = '.$info['template'])->find();
			$norms_pro = M('product_norms')->where('proid = '.$proid.' and type = 1')->order('def asc')->select();
			$norms_size = M('product_norms')->where('proid = '.$proid.' and type = 2')->order('def asc')->select();
			$norms_color = M('product_norms')->where('proid = '.$proid.' and type = 3')->order('def asc')->select();
			$temp['options'] = unserialize($temp['options']);
			$temp['pay_type'] = unserialize($temp['pay_type']);
			$info['images'] = explode(',',$info['images']);
			$info['review'] = explode("\r\n",trim($info['review']));
			foreach($info['review'] as $k=>$v){
				$info['review'][$k] = explode("|",$v);
			}
			$info['preferential'] = $info['oldprice']-$info['price'];
			$options = '';
			foreach($temp['options'] as $k=>$v){
				$options .= "'".$v."',";
			}
			$options = substr($options,0,-1);
			
			$pay = array();
			foreach($temp['pay_type'] as $k=>$v){
				if($v['status'] == 0){
					unset($temp['pay_type'][$k]);
				}else{
					$pay[$v['sort']] = $k;
				}
			}
			ksort($pay);
			$pay = array_merge($pay);
			$arr = array();
			$arr = cookie('num');
			$arr[$norms_pro[0]['nid']] = $norms_pro[0]['number'];
			cookie('num',$arr,600);
			//p($temp);

			
			//最新下单
			if($temp['order_type'] == 1){
				$orderhtml = explode("\r\n",trim($temp['order_content']));
				foreach($orderhtml as $k=>$v){
					$orderhtml[$k] = str_replace("{time}",date('Y-m-d'),$v);
				}
			}else{
				$NewWhere['proid'] = array('eq',$proid);
				$NewWhere['status'] = array('eq',1);
				$NewArr = M('order')->where($NewWhere)->limit(30)->select();
				
				$orderhtml = array();
				foreach($NewArr as $kn=>$vn){
					$NewArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
					$NewArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
					$NewArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
					foreach($NewArr[$kn] as $k=>$v){
						$NewArrkarr[] = "{".$k."}";
						$NewArrvarr[] = $v;
					}
					$orderhtml[] = str_replace($NewArrkarr,$NewArrvarr,$temp['order_content']);
					unset($NewArrkarr);
					unset($NewArrvarr);
				}
			}
			
			
			//发货信息
			if($temp['delivery_type'] == 1){
				$html = explode("\r\n",trim($temp['delivery_content']));
				foreach($html as $k=>$v){
					$html[$k] = str_replace("{time}",date('Y-m-d'),$v);
				}
			}else{
				$DelWhere['proid'] = array('eq',$proid);
				$DelWhere['status'] = array('eq',3);
				$DelArr = M('order')->where($DelWhere)->limit(30)->select();
			
				$html = array();
				foreach($DelArr as $kn=>$vn){
					$DelArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
					$DelArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
					$DelArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
					foreach($DelArr[$kn] as $k=>$v){
						$DelArrkarr[] = "{".$k."}";
						$DelArrvarr[] = $v;
					}
					$html[] = str_replace($DelArrkarr,$DelArrvarr,$temp['delivery_content']);
					unset($DelArrkarr);
					unset($DelArrvarr);
				}
				
			}
			
			if($info['time_status'] == 0){
				if($info['time_type'] == 2){
					$endtime = $info['time_sum'];
				}else{
					$endtime = $info['endtime']-time();
				}
			}
			
			if($info['parameter']){
				$parameter = explode("\r\n",trim($info['parameter']));
				foreach($parameter as $k=>$v){
					$parameter[$k] = explode(":",$v);
				}
			}
			
			if($info['status'] == 1){
				if($info['time_status'] == 0){
					if($info['time_type'] == 1){
						if(($info['starttime'] < time()) && ($info['endtime'] > time())){
							$temphtml = 1;
						}
					}else{
						$temphtml = 1;
					}	
				}else{
					$temphtml = 1;
				}			
			}
			$audit = M('audit')->where('id = '.$proid)->find();
			$temp['nav_temp'] = explode(',',$temp['nav_temp']);
			$temp['nav_count'] = count($temp['nav_temp']);
			$language = M('config')->where('id = 97')->getField('value');
			$statistical = M('config')->where('id = 99')->getField('value');
			$cookie = M('config')->where('id = 105')->getField('value');
			if($info['copyright']){
				$copyright = $info['copyright'];
			}else{
				$copyright = C('WEB_SITE_ICP');
			}
			/*
			$WX_APPID = M('config')->where('id = 53')->getField('value');
			$WX_APPSECRET = M('config')->where('id = 54')->getField('value');
			require 'Jssdk.php';
			$jssdk = new \Jssdk($WX_APPID, $WX_APPSECRET);
			$signPackage = $jssdk->GetSignPackage();
			$this->assign('signPackage', $signPackage);
			*/
			
			$value = M('config')->where('id = 88')->getField('value');
			$this->assign('cookie', $cookie);
			$this->assign('copyright', $copyright);
			$this->assign('audit', $audit);
			$this->assign('value', $value);
			$this->assign('statistical', $statistical);
			$this->assign('root', __ROOT__);
			$this->assign('language', $language);
			$this->assign('parameter', $parameter);
			$this->assign('endtime', $endtime);
			$this->assign('html', $html);
			$this->assign('orderhtml', $orderhtml);
			$this->assign('options', $options);
			$this->assign('pay', $pay);
			$this->assign('info', $info);
			$this->assign('temp', $temp);
			$this->assign('norms_pro', $norms_pro);
			$this->assign('norms_size', $norms_size);
			$this->assign('norms_color', $norms_color);
			$this->assign('proid', $proid);
			$this->assign('temphtml', $temphtml);
			$this->assign('iframe','style');
			
			
			$gzname = M('gzname')->select();
			$member = M('member')->field('uid')->select();
			foreach($gzname as $gzv){
				if(!file_exists('./html/'.$proid)){
					mkdir('./html/'.$proid);
				}
				$this->assign('gzid', $gzv['gzid']);
				foreach($member as $mv){
					$this->assign('uid', $mv['uid']);
					$this->buildHtml($gzv['gzid'].'-'.$mv['uid'],'./html/'.$proid.'/',"Index:".$vp['style']);
				}
			}
			
			foreach($member as $mv){
				$this->assign('uid', $mv['uid']);
				$this->assign('gzid', 22);
				$this->buildHtml($proid.'-'.$mv['uid'],'./html/',"Index:".$vp['style']);
			}
		}
		
		if(($countp+2) > $ps){
			$this->redirect('html?p='.$ps);
		}
		
	}
	
	
	public function htmlpro(){
		
		cookie('num',null);
		$proid = I('get.proid');
		$info = M('product')->where('proid = '.$proid)->find();
		$info['content'] = M('product_data')->where('proid = '.$proid)->getField('content');
		
		preg_match_all('/{video@\d+@}/',$info['content'],$video_arr);
		if(count($video_arr[0])){
			foreach($video_arr[0] as $k=>$v){
				
				$varr = str2arr($v,'@');
				$gkkarr[] = $v;
				$kkvarr[] = M('video')->where('vid = '.$varr[1])->getField('content');
			}
			$info['content'] = str_replace($gkkarr,$kkvarr,$info['content']);
		}
		
		
		$temp = M('template')->where('tid = '.$info['template'])->find();
		$norms_pro = M('product_norms')->where('proid = '.$proid.' and type = 1')->order('def asc')->select();
		$norms_size = M('product_norms')->where('proid = '.$proid.' and type = 2')->order('def asc')->select();
		$norms_color = M('product_norms')->where('proid = '.$proid.' and type = 3')->order('def asc')->select();
		$temp['options'] = unserialize($temp['options']);
		$temp['pay_type'] = unserialize($temp['pay_type']);
		$info['images'] = explode(',',$info['images']);
		$info['review'] = explode("\r\n",trim($info['review']));
		foreach($info['review'] as $k=>$v){
			$info['review'][$k] = explode("|",$v);
		}
		$info['preferential'] = $info['oldprice']-$info['price'];
		$options = '';
		foreach($temp['options'] as $k=>$v){
			$options .= "'".$v."',";
		}
		$options = substr($options,0,-1);
		
		$pay = array();
		foreach($temp['pay_type'] as $k=>$v){
			if($v['status'] == 0){
				unset($temp['pay_type'][$k]);
			}else{
				$pay[$v['sort']] = $k;
			}
		}
		ksort($pay);
		$pay = array_merge($pay);
		$arr = array();
		$arr = cookie('num');
		$arr[$norms_pro[0]['nid']] = $norms_pro[0]['number'];
		cookie('num',$arr,600);
		//p($temp);

		
		//最新下单
		if($temp['order_type'] == 1){
			$orderhtml = explode("\r\n",trim($temp['order_content']));
			foreach($orderhtml as $k=>$v){
				$orderhtml[$k] = str_replace("{time}",date('Y-m-d'),$v);
			}
		}else{
			$NewWhere['proid'] = array('eq',$proid);
			$NewWhere['status'] = array('eq',1);
			$NewArr = M('order')->where($NewWhere)->limit(30)->select();
			
			$orderhtml = array();
			foreach($NewArr as $kn=>$vn){
				$NewArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
				$NewArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
				$NewArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
				foreach($NewArr[$kn] as $k=>$v){
					$NewArrkarr[] = "{".$k."}";
					$NewArrvarr[] = $v;
				}
				$orderhtml[] = str_replace($NewArrkarr,$NewArrvarr,$temp['order_content']);
				unset($NewArrkarr);
				unset($NewArrvarr);
			}
		}
		
		
		//发货信息
		if($temp['delivery_type'] == 1){
			$html = explode("\r\n",trim($temp['delivery_content']));
			foreach($html as $k=>$v){
				$html[$k] = str_replace("{time}",date('Y-m-d'),$v);
			}
		}else{
			$DelWhere['proid'] = array('eq',$proid);
			$DelWhere['status'] = array('eq',3);
			$DelArr = M('order')->where($DelWhere)->limit(30)->select();
		
			$html = array();
			foreach($DelArr as $kn=>$vn){
				$DelArr[$kn]['time'] = date('Y-m-d',$vn['addtime']);
				$DelArr[$kn]['phone'] = substr($vn['phone'],0,3).'****'.substr($vn['phone'],-4);
				$DelArr[$kn]['name'] = mb_substr($vn['name'],0,1,'utf-8').'**';
				foreach($DelArr[$kn] as $k=>$v){
					$DelArrkarr[] = "{".$k."}";
					$DelArrvarr[] = $v;
				}
				$html[] = str_replace($DelArrkarr,$DelArrvarr,$temp['delivery_content']);
				unset($DelArrkarr);
				unset($DelArrvarr);
			}
			
		}
		
		if($info['time_status'] == 0){
			if($info['time_type'] == 2){
				$endtime = $info['time_sum'];
			}else{
				$endtime = $info['endtime']-time();
			}
		}
		
		if($info['parameter']){
			$parameter = explode("\r\n",trim($info['parameter']));
			foreach($parameter as $k=>$v){
				$parameter[$k] = explode(":",$v);
			}
		}
		
		if($info['status'] == 1){
			if($info['time_status'] == 0){
				if($info['time_type'] == 1){
					if(($info['starttime'] < time()) && ($info['endtime'] > time())){
						$temphtml = 1;
					}
				}else{
					$temphtml = 1;
				}	
			}else{
				$temphtml = 1;
			}			
		}
		$audit = M('audit')->where('id = '.$proid)->find();
		$temp['nav_temp'] = explode(',',$temp['nav_temp']);
		$temp['nav_count'] = count($temp['nav_temp']);
		$language = M('config')->where('id = 97')->getField('value');
		$statistical = M('config')->where('id = 99')->getField('value');
		$cookie = M('config')->where('id = 105')->getField('value');
		if($info['copyright']){
			$copyright = $info['copyright'];
		}else{
			$copyright = C('WEB_SITE_ICP');
		}
		/*
		$WX_APPID = M('config')->where('id = 53')->getField('value');
		$WX_APPSECRET = M('config')->where('id = 54')->getField('value');
		require 'Jssdk.php';
		$jssdk = new \Jssdk($WX_APPID, $WX_APPSECRET);
		$signPackage = $jssdk->GetSignPackage();
		$this->assign('signPackage', $signPackage);
		*/
		
		$value = M('config')->where('id = 88')->getField('value');
		$this->assign('cookie', $cookie);
		$this->assign('copyright', $copyright);
		$this->assign('audit', $audit);
		$this->assign('value', $value);
		$this->assign('statistical', $statistical);
		$this->assign('root', __ROOT__);
		$this->assign('language', $language);
		$this->assign('parameter', $parameter);
		$this->assign('endtime', $endtime);
		$this->assign('html', $html);
		$this->assign('orderhtml', $orderhtml);
		$this->assign('options', $options);
		$this->assign('pay', $pay);
		$this->assign('info', $info);
		$this->assign('temp', $temp);
		$this->assign('norms_pro', $norms_pro);
		$this->assign('norms_size', $norms_size);
		$this->assign('norms_color', $norms_color);
		$this->assign('proid', $proid);
		$this->assign('temphtml', $temphtml);
		$this->assign('iframe','style');
		
		
		$gzname = M('gzname')->select();
		$member = M('member')->field('uid')->select();
		foreach($gzname as $gzv){
			if(!file_exists('./html/'.$proid)){
				mkdir('./html/'.$proid);
			}
			$this->assign('gzid', $gzv['gzid']);
			foreach($member as $mv){
				$this->assign('uid', $mv['uid']);
				$this->buildHtml($gzv['gzid'].'-'.$mv['uid'],'./html/'.$proid.'/',"Index:".$info['style']);
			}
		}
		
		foreach($member as $mv){
			$this->assign('uid', $mv['uid']);
			$this->assign('gzid', 22);
			$this->buildHtml($proid.'-'.$mv['uid'],'./html/',"Index:".$info['style']);
		}
		
		
		
	}
	

    public function upload(){
    	if(IS_POST){
            //又拍云
            // $config = array(
            //     'host'     => 'http://v0.api.upyun.com', //又拍云服务器
            //     'username' => 'zuojiazi', //又拍云用户
            //     'password' => 'thinkphp2013', //又拍云密码
            //     'bucket'   => 'thinkphp-static', //空间名称
            // );
            // $upload = new \COM\Upload(array('rootPath' => 'image/'), 'Upyun', $config);
            //百度云存储
            $config = array(
                'AccessKey'  =>'3321f2709bffb9b7af32982b1bb3179f',
                'SecretKey'  =>'67485cd6f033ffaa0c4872c9936f8207',
                'bucket'     =>'test-upload',
                'size'      =>'104857600'
            );
    		$upload = new \COM\Upload(array('rootPath' => './Uploads/bcs'), 'Bcs', $config);
    		$info   = $upload->upload($_FILES);
    	} else {
    		$this->display();
    	}
    }

    public function upyun(){
        $policydoc = array(
            "bucket"             => "thinkphp-static", /// 空间名
            "expiration"         => NOW_TIME + 600, /// 该次授权过期时间
            "save-key"            => "/{year}/{mon}/{random}{.suffix}",
            "allow-file-type"      => "jpg,jpeg,gif,png", /// 仅允许上传图片
            "content-length-range" => "0,102400", /// 文件在 100K 以下
        );

        $policy = base64_encode(json_encode($policydoc));
        $sign = md5($policy.'&'.'56YE3Ne//xc+JQLEAlhQvLjLALM=');

        $this->assign('policy', $policy);
        $this->assign('sign', $sign);
        $this->display();
    }

    public function test(){
        $table = new \OT\DataDictionary;
        echo "<pre>".PHP_EOL;
        $out = $table->generateAll();
        echo "</pre>";
        // print_r($out);
    }

}
?>