<?php
!defined('A')&&die("<meta http-equiv='refresh' content=0;url='/'>");

$n=13;
$arr=explode(':',$_2=strtoupper(_2));
if(count($arr)<$n)$arr=explode(':',$_2='100-100000000:0.01-50:0:0:0:0:0:0:0:0:0:0:0:1');
$nm=array('jg','kl','xz','ys','jd','qg','pg','dc','yg','zs','dz','ns','ks','ye','f');
if(_2=='zs'){
	foreach($arr as $k=>$v){
		foreach(array_unique(explode($k>1?'+':'-',$v)) as $vv)eval("\$".$nm[$k]."[]='$vv';");
	}
	$arr=explode(':',_2);
	if(strlen(_3)<5)Js_to('错误！请输入完整号码。',Y);
	$tj="cert_no LIKE '%"._3."%'";
}else{
	foreach($arr as $k=>$v){
		foreach(array_unique(explode($k>1?'+':'-',$v)) as $vv)eval("\$".$nm[$k]."[]='$vv';");
	}
	if(count($jg)==1)$jg=array($jg[0],$jg[0]);
	elseif(count($jg)==0)$jg=array(100,100000000);
	$tj='world_price>='.intval($jg[0]/SP_2).' and world_price<='.intval($jg[1]/SP_2).' and '.(count($kl)<2?"carat='".$kl[0]."'":"carat>='".$kl[0]."' and carat<='".$kl[1]."'");
//收缩一格
foreach($nm as $k=>$v){
	if($k>1&&$k<$n){
		if(count($s=$$v)&&$s[0]){
			if($k=='2'){
				$ar=array();
				foreach($$v as $kk=>$vv){
					if($kk>11)continue;
					switch ($vv){
						case '1' :$ar[$kk]='ROUND';break;
						case '2' :$ar[$kk]='OVAL';break;
						case '3' :$ar[$kk]='CUSHION';break;
						case '4' :$ar[$kk]='PEAR';break;
						case '5' :$ar[$kk]='HEART';break;
						case '6' :$ar[$kk]='MARQUISE';break;
						case '7' :$ar[$kk]='PRINCESS';break;
						case '8' :$ar[$kk]='EMERALD';break;
						case '9' :$ar[$kk]='---';break;//暂时弃用
						case '10':$ar[$kk]='CUSHION';break;
						case '11':$ar[$kk]='CUSHION MBR';break;
						case '12':$ar[$kk]='---';break;//暂时弃用
						case '13':$ar[$kk]='---';break;//暂时弃用
					}
				}
				$tj.=" and shape in ('".implode("','",$ar)."')";
			}else{
				switch ($v){
					case 'ys':$tb='color';break;
					case 'jd':$tb='clarity';break;
					case 'qg':$tb='cut';break;
					case 'pg':$tb='polish';break;
					case 'dc':$tb='symmetry';break;
					case 'yg':$tb='fluorescence';break;
					case 'zs':$tb='cert_type';break;
					case 'dz':$tb='area';
						$area=array(1=>'现货',2=>'中国',3=>'海外',11=>'美国',12=>'印度',13=>'比利时',14=>'以色列',21=>'香港',22=>'深圳',23=>'上海',24=>'北京');
						$tjs=array();
						foreach($area as $a_k=>$a_v){
							if(in_array($a_k,$$v))$tjs[]=$tb." LIKE '".$a_v."'";
						}
						$tj.=' and ('.implode(' or ',$tjs).')';
					break;
					case 'ns': case 'ks':
						$tb=$v=='ns'?'cream':'brown';
						$nc=array(1=>"='N'",2=>"<>''",3=>"=''");
						$tjs=array();
						foreach($nc as $nck=>$ncv){
							if(in_array($nck,$$v))$tjs[]=$tb.$ncv;
						}
						$tj.=' and ('.implode(' or ',$tjs).')';
					break;
				}
				if($v!=='ns'&&$v!=='ks'&&$v!=='dz')
					$tj.=" and $tb in ('".implode("','",$s)."')";
}}}}}