<?php
function company($ar)
{
	global $cache,$cachetime,$dpid,$dcid,$config,$db,$tpl;
	useCahe();
	$flag=md5(implode(",",$ar));
	$ar['temp']=empty($ar['temp'])?'user_default':$ar['temp'];
	$tmpdir=$config['webroot']."/templates/".$config['temp']."/label/".$ar['temp'].".htm";
	if(file_exists($tmpdir))
		$tpl->template_dir = $config['webroot']."/templates/".$config['temp']."/label/";
	else
		$tpl->template_dir = $config['webroot']."/templates/default/label/";
	if(!$tpl->is_cached($ar['temp'].".htm",$flag))
	{	
		$limit=$ar['limit'];
		$rec=$ar['rec'];
		$ifpay=$ar['ifpay'];
		$cid=$ar['catid'];
		
		$spointer=empty($ar['start_pointer'])?0:$ar['start_pointer'];
		if($dpid)
			$scl=" and province='$dpid' ";
		if($dcid)
			$scl=" and city='$dcid' ";
		if($rec)
			$scl.=" and statu='$rec'";
		if(!empty($cid))
			$scl.=" and catid like '%,$cid%'";
			
		if(!empty($ifpay))
			$scl.=" and ifpay='$ifpay' ";
		else
			$scl.=" and ifpay>1 ";
		$sql="SELECT * from ".COMPANY." WHERE company!='' $scl ORDER BY uptime DESC LIMIT $spointer,$limit";
		$db->query($sql);
		$user=$db->getRows();
		//==================================================
		$tpl->assign("config",$config);
		$tpl->assign("company",$user);
	}
	return $tpl->fetch($ar['temp'].'.htm',$flag);
}
?>