<?
defined('ROOT_PHPLEFT') or exit('phpleft: Not page');
/*
	phpleftDms Copyright (c) 2011 phpleft.COM
	ÉÌÒµÊÚÈ¨£ºQQ45150208
	
*/
class allcache{
	
	function moduleid_cache($moduleid){
		global $PL_CFG,$db,$query;
		$query=$db->query("Select * from ".$PL_CFG['tb_pre']."setting where item ='$moduleid'");
         while($rs=$db->fetch_array($query)){
	      $do[$rs['item_name']] = $rs['item_value'];
	
}
       $file = "set-".$moduleid.".php";
       $path = PL_ROOT.$PL_CFG['cache']."/";

	return cache_write($file, $do, $path);
	}
function menu_cache($st){
		global $PL_CFG,$db,$query;
		$menu = sql_cache("table=menu&cache=id&order=inlist asc,id asc");
		$file = "menu.php";
        $path = PL_ROOT.$PL_CFG['cache']."/";
		if ($st=='1'){
        cache_write($file, $menu, $path);
		foreach($menu as $i=>$m){
			$file_m = "moduleid-".$m[id].".php";
			cache_write($file_m, $m, $path);
			}
		}else if ($st=='2'){
			foreach($menu as $i=>$m){
				allcache::moduleid_cache($m[id]);
			}
			allcache::moduleid_cache('member');
		    $sett = sql_cache("table=member_group");
            $files = "set-group.php";
            $pathcaches = PL_ROOT.$PL_CFG['cache']."/";
            cache_write($files, $sett, $pathcaches);
		}else if ($st=='3'){
			foreach($menu as $i=>$m){
				$files = "catid_".$m[id].".php";
				$menusp = sql_cache("table=sort&cache=id&where=module=".$m[id]."&order=keylist asc,id asc");
                cache_write($files, $menusp, $path);
			}
			
			
		}else if ($st=='4'){
			foreach($menu as $i=>$m){
            $file = 'table_'.$m[id].'.inc.php';
			$tablem=sql_cache("table=table&where=module='".modname($m[id])."' and moduleid='".$m[id]."'&order=keylist asc");
           cache_write($file, $tablem, $path);
			}
			$file = 'table_member.inc.php';
			$tablem=sql_cache("table=table&where=module='member' and moduleid='member'&order=keylist asc");
            cache_write($file, $tablem, $path);
		}else if ($st=='5'){
			foreach($menu as $i=>$m){
				if($m[path]<>''){
       $db->query("update ".$PL_CFG['tb_pre']."menu set linkurl = '".$PL_CFG[url].$m[path]."/' where id=".$m[id]);	
	   $menu = sql_cache("table=menu&cache=id&order=inlist asc,id asc");
           cache_write($file, $menu, $path);
				}
			}
		}
	return true;	
}
	
	

	
	
	
	
	
	
	
	
	
	
	
}





?>