0" ; $pageurl="products.php?1=1" ; $pagerewrite=""; $classid=getRequestInt("classid",$proot); $arr_url=split( ',' , $class[$classid]["url"] ); $var["str_url"]="{$cfg['lg']['home']}"; $var["str_url_2"]=$class[$arr_url[count($arr_url)-1]]["name"]; $var["title"] = $var["str_url_2"] . " - " . $var["title"]; $var["pagename"]="products.php"; $arr_son=array_filter(split( ',' , $class[$classid]["son"] ),callback_empty); for($index=0;$index

" . $class[$arr_url[$index]]["name"] . "

" ; } $arrQuery = split( '-' , getQuery("query") ); $sql_param["classid"] = getRequestInt("classid",$proot) ; $sql_param["disp"] = filterSQL(dataDefault($arrQuery[0],getRequest("disp"))) ; $sql_param["name"] = str_replace('-','|' , trim (dataDefault($arrQuery[1],getRequest("name")) ) ) ; $sql_param["name"] = str_replace('+',' ' , $sql_param["name"]) ; $sql_param["name"] = filterSQL(urldecode( $sql_param["name"] )) ; $sql_param["brandid"] = filterSQL(dataDefault($arrQuery[2],getRequest("brandid"))); $sql_param["pfrom"] = filterSQL(dataDefault($arrQuery[3],getRequest("pfrom"))); $sql_param["pto"] = filterSQL(dataDefault($arrQuery[4],getRequest("pto"))); $sql_param["p1"] = filterSQL(dataDefault($arrQuery[5],getRequest("p1"))); $sql_param["p2"] = filterSQL(dataDefault($arrQuery[6],getRequest("p2" ))); $sql_param["p3"] = filterSQL(dataDefault($arrQuery[7],getRequest("p3" ))); $sql_param["p4"] = filterSQL(dataDefault($arrQuery[8],getRequest("p4" ))); $sql_param["p5"] = filterSQL(dataDefault($arrQuery[9],getRequest("p5"))); $rewriteParam["pagesize"] = dataDefault($sql_param["p2"],$config[81] ) ; $rewriteParam["orderitem"] = dataDefault($sql_param["p3"],$classorderfield); $rewriteParam["orderby"] = dataDefault($sql_param["p4"],$classoderby) ; $rewriteParam["detail"] = dataDefault($sql_param["p5"],$classdetailmode); $template_file = 'lay_products' . $rewriteParam["detail"] . '.html'; if($sql_param["p1"] && $sql_param["name"]) { $condition .= " and name like '" . $sql_param["name"] . "%'" ; } if($classid!=$proot) { $p1=$sql_param["p1"]; if(empty($p1)) { $tree=get_id_tree($class,$classid); $condition .= " and classid in (" . $tree . ")" ; } else { $condition .= " and classid=" . $classid ; } } if($sql_param["disp"]) { $sql="select * from @@@productdisp where id=".$sql_param["disp"]; $rs=query($sql); if( BOF($rs) ) redirect(FOLDER."error.php?id=1"); $disp_rows = fetch($rs); $condition .= " and disp & " . $disp_rows["value"] . " = " . $disp_rows["value"] ; $var["str_url"]="{$cfg['lg']['home']} " . $cfg["split_uri"] . " Products " . $cfg["split_uri"] . " " . $disp_rows["name"] ; $var["str_url_2"] = $disp_rows["name"] ; $var["title"] = dataDefault($disp_rows["title"],$disp_rows["name"] . " - " . $config[63]); $var["keywords"] = dataDefault($disp_rows["keywords"],$disp_rows["name"] . " - " . $config[63]); $var["descript"] = dataDefault($disp_rows["descript"],$disp_rows["name"] . " - " . $config[63]); } $arrkeyword=array(); $arrreplace=array(); if($sql_param["name"]) { $arrkeyword = split(' ' , str_replace('|','-' , $sql_param["name"]) ); $var["search_keywords"] = stripslashes(str_replace('|','-' , $sql_param["name"])) ; $arrlikesql = array(); for($index=0;$index" ; //$arrppdsql[] = pow(2,count($arrkeyword)-$index) . "*(length(name)-length(replace(name,'{$arrkeyword[$index]}','')))" ; $arrppdsql[] = "(length(name)-length(replace(lower(name),'".strtolower($arrkeyword[$index])."','')))" ; } if( count($arrkeyword)>1 ) { $searchfield = ",(". join('+',$arrppdsql) .") as ppd"; $searchorderby = "ppd desc," ; } $condition .= " and ( (" . join(' or ' ,$arrstr ) . ") or itemno ='" . str_replace('|','-' , $sql_param["name"]) . "')" ; $pageurl .= "&name=" . $sql_param["name"] ; } if( $sql_param["brandid"] ) { $condition .= " and brandid=" . $sql_param["brandid"] ; $brandname=fetchValue("select name as v from @@@brandclass where id=" . $sql_param["brandid"] , "NULL"); $var["str_url"]="{$cfg['lg']['home']} " . $cfg["split_uri"] . " Products " . $cfg["split_uri"] . " " . $brandname; $var["str_url_2"]=$brandname; } if( $sql_param["pfrom"] ) { $condition .= " and price1>=" . $sql_param["pfrom"]; } if( $sql_param["pto"] ) { $condition .= " and price1<=" . $sql_param["pto"]; } //debug($condition); if(true && $sql_param["name"]) { $sql = "select count(classid) as t,classid from `@@@product` $condition group by classid order by t desc"; $rs = query($sql); $displayleve = $class[$classid]["level"] + 1 ; while($rows=fetch($rs)) { $arrtmp = split(',' , $class[$rows["classid"]]["url"] ); if( $displayleve>=count($arrtmp) ) continue; $tmpclassid = $arrtmp[$displayleve] ; $var["search_totalnum"] += $rows["t"] ; $var["rs_relate"][$tmpclassid]["name"] = $class[$tmpclassid]["name"] ; $var["rs_relate"][$tmpclassid]["t"] += $rows["t"] ; $var["rs_relate"][$tmpclassid]["rewrite"] = FOLDER . "products.php?classid={$tmpclassid}&name=" . urlencode($sql_param["name"]) ; } } //select product.id,sum(orderproduct.pnum) as total from product left join orderproduct on (orderproduct.pid=product.id) and 1=1 group by product.id order by total desc,id desc ; //debug($var["rs_relate"]); $pagenow=getQueryInt("page",1); if($pagenow==1 && $classid != $proot) { $var["statscript"][] = FOLDER."stat.php?action=stat&type=category&id=" . $classid; } $pagesize=dataDefault($rewriteParam["pagesize"],$config[81]); $var["pagesize"] = $pagesize; if( $rewriteParam["orderitem"]=="sale" ) { //$rs = query("select @@@product.*,sum(@@@orderproduct.pnum) as total from @@@product left join @@@orderproduct on (@@@orderproduct.pid=@@@product.id) where 1=1 and classid=521 group by @@@product.id order by total desc,id desc"); $joinsql = "left join @@@orderproduct on (@@@orderproduct.pid=@@@product.id)"; $rs=createSalePage("@@@product.*,sum(@@@orderproduct.pnum) as totalsale","@@@product",$joinsql,$condition," group by product.id order by totalsale desc,id desc" ,$pagesize,$pagenow,$pagetotal,$recordcount); } else { $rs=createPage("*".$searchfield,"@@@product",$condition," order by " . $searchorderby . dataDefault($rewriteParam["orderitem"],$config[160]) . " " . dataDefault($rewriteParam["orderby"],$config[161]) ,$pagesize,$pagenow,$pagetotal,$recordcount); } loadPage($pagenow,$pagetotal,$pagesize,$recordcount,$var); while($rows=fetch($rs)) { $rows["rewrite"] = getRewrite($rows["name"],$rows["id"],0,$cfg["rewrite"]); $rows["realpic"] = $config[61] . getImageURL($rows["pic"],1,"uploadImage/",$urltype); $rows["bigpic"] = $config[61] . getImageURL($rows["pic"],4,"uploadImage/",$urltype); $rows["largerpic"] = $config[61] . getImageURL($rows["pic"],7,"uploadImage/",$urltype); $rows["search_name"] = str_ireplace( $arrkeyword,$arrreplace,$rows["name"] ); //$rows["bigpic"]= $config[61] . getImageURL($rows["pic"],2,"uploadImage/",$urltype); $rows["pvalue"] =split( $cfg["split"] , $rows["pvalue"] ); $rows["price"]= $rows["price1"] * $discount * $rate; r2n( $rows["price"] ); if(!$rows["price2"] && ($config[300]!="")) eval("\$rows['price2']={$rows['price']} {$config[299]} {$config[300]};"); $rows["s_content"] = substr( strip_tags($rows["content"]) , 0 , 200 ) . "..."; $rows["pkey"] =split( $cfg["split"] , $rows["pkey"] ); $rows["pvalue"] =split( $cfg["split"] , $rows["pvalue"] ); $rows["ckey"] =split( $cfg["split"] , $rows["ckey"] ); $rows["cvalue"] =split( $cfg["split"] , $rows["cvalue"] ); $rows["ctype"] =split( $cfg["split"] , $rows["ctype"] ); $rows["totalsale"] = dataDefault($rows["totalsale"],0); $var["rs_p"][]=$rows; } free($rs); function getSwitchURL($index,$value) { global $rewriteParam; global $sql_param; $param[0] = $sql_param["disp"]; $param[1] = urlencode($sql_param["name"]) ; $param[2] = $sql_param["brandid"] ; $param[3] = $sql_param["pfrom"] ; $param[4] = $sql_param["pto"] ; $param[5] = $sql_param["p1"] ; $param[6] = $rewriteParam["pagesize"] ; $param[7] = $rewriteParam["orderitem"] ; $param[8] = $rewriteParam["orderby"] ; $param[9] = $rewriteParam["detail"] ; $param[10] = 1 ; $param[$index] = $value ; return join('-' , $param) . ".html"; } $tmprewrite = getRewritePre() . makeRewrite( $var["str_url_2"]) ; $str_switch = $tmprewrite . "-c$classid-" ; $var["rewriteurl"] = $tmprewrite . "-c$classid-" . $sql_param["disp"] . "-" . urlencode($sql_param["name"]) . "-" . $sql_param["brandid"] . "-" . $sql_param["pfrom"] . "-" . $sql_param["pto"] . "-" . $sql_param["p1"] . "-" . $rewriteParam["pagesize"] . "-" . $rewriteParam["orderitem"]. "-" . $rewriteParam["orderby"] . "-" . $rewriteParam["detail"]; if( !$sql_param["disp"] && !$sql_param["name"] && !$sql_param["brandid"] && !$sql_param["pfrom"] && !$sql_param["pto"] && !$sql_param["p1"] && !$sql_param["p2"] && !$sql_param["p3"] && !$sql_param["p4"] && !$sql_param["p5"] ) { $var["rewriteurl"] = $tmprewrite . "-c$classid" ; } if( $sql_param["disp"] && $sql_param["classid"]==$proot && !$sql_param["name"] && !$sql_param["brandid"] && !$sql_param["pfrom"] && !$sql_param["pto"] && !$sql_param["p1"] && !$sql_param["p2"] && !$sql_param["p3"] && !$sql_param["p4"] && !$sql_param["p5"] ) { $var["rewriteurl"] = getRewritePre() . makeRewrite( $var["str_url_2"]) . "-s" . $sql_param["disp"] ; } $mode = split (',' , $config[306] ); $var["mode"] = $mode; $var["rewrite"]=array(); for($index=0; $index