<?php
function cache_new(){
	global $db,$Blog;	
	$sql = "select * from $Blog->table order by ID desc limit 0,6";
	$t = $db->query($sql);
	$str0 = $str1 = $str2 = $str3 = "<ul>";
	$file0 = S_ROOT."blog/caching/new0.txt";
	$file1 = S_ROOT."blog/caching/new1.txt";
	$file2 = S_ROOT."blog/caching/new2.txt";
	$file3 = S_ROOT."blog/caching/new3.txt";
	while($i=$db->fetch($t)){
		$subject0 = $i["subject0"]; 
		$subject1 = $i["subject1"];if($subject1=="") $subject1 = $subject0;
		$subject2 = $i["subject2"];if($subject2=="") $subject2 = $subject0;
		$subject3 = $i["subject3"];if($subject3=="") $subject3 = $subject0;
		$str0 .= "<li><a href=\"/news_0-".$i["catID"]."_".$i["ID"].".html\">".$subject0."</a></li>";
		$str1 .= "<li><a href=\"/news_1-".$i["catID"]."_".$i["ID"].".html\">".$subject1."</a></li>";
		$str2 .= "<li><a href=\"/news_2-".$i["catID"]."_".$i["ID"].".html\">".$subject2."</a></li>";
		$str3 .= "<li><a href=\"/news_3-".$i["catID"]."_".$i["ID"].".html\">".$subject3."</a></li>";
	}
	$str0 .= "</ul>";
	$str1 .= "</ul>";
	$str2 .= "</ul>";
	$str3 .= "</ul>";
	$fp = fopen($file0,"w");
	fputs($fp, $str0);
	
	$fp = fopen($file1,"w");
	fputs($fp, $str1);
	
	$fp = fopen($file2,"w");
	fputs($fp, $str2);
	
	$fp = fopen($file3,"w");
	fputs($fp, $str3);
			
	fclose($fp);
}
function cache_new_home(){
	global $db,$Blog;	
	$sql = "select * from $Blog->table order by ID desc limit 0,5";
	$t = $db->query($sql);
	$str0 = $str1 = $str2 = $str3 = "<ul>";
	$file0 = S_ROOT."blog/caching/new_home0.txt";
	$file1 = S_ROOT."blog/caching/new_home1.txt";
	$file2 = S_ROOT."blog/caching/new_home2.txt";
	$file3 = S_ROOT."blog/caching/new_home3.txt";
	while($i=$db->fetch($t)){
		$subject0 = $i["subject0"]; 
		$subject1 = $i["subject1"];if($subject1=="") $subject1 = $subject0;
		$subject2 = $i["subject2"];if($subject2=="") $subject2 = $subject0;
		$subject3 = $i["subject3"];if($subject3=="") $subject3 = $subject0;
		$str0 .= "<li><a href=\"/news_0-".$i["catID"]."_".$i["ID"].".html\">".$subject0." <span>(".substr(date_mysql_au($i["postDate"]),0,5).")</span></a></li>";
		$str1 .= "<li><a href=\"/news_1-".$i["catID"]."_".$i["ID"].".html\">".$subject1." <span>(".substr(date_mysql_au($i["postDate"]),0,5).")</span></a></li>";
		$str2 .= "<li><a href=\"/news_2-".$i["catID"]."_".$i["ID"].".html\">".$subject2." <span>(".substr(date_mysql_au($i["postDate"]),0,5).")</span></a></li>";
		$str3 .= "<li><a href=\"/news_3-".$i["catID"]."_".$i["ID"].".html\">".$subject3." <span>(".substr(date_mysql_au($i["postDate"]),0,5).")</span></a></li>";
	}
	$str0 .= "</ul>";
	$str1 .= "</ul>";
	$str2 .= "</ul>";
	$str3 .= "</ul>";
	$fp = fopen($file0,"w");
	fputs($fp, $str0);
	
	$fp = fopen($file1,"w");
	fputs($fp, $str1);
	
	$fp = fopen($file2,"w");
	fputs($fp, $str2);
	
	$fp = fopen($file3,"w");
	fputs($fp, $str3);
			
	fclose($fp);
}
?>