<?php
class sitemapControl extends skymvc{
	function __construct(){
		parent::__construct();
		$this->loadModel(array("product"));
	}
	
	public function ondefault(){
		$this->smarty->display("sitemap/index.html");
	}
	
	public function onWrite(){
			set_time_limit(0);
			session_write_close();
			$data=$this->product->getAll("SELECT id,title,dateline FROM ".table('product')." WHERE status>0 AND status<90 ");
			$this->product->close();
			$xml='<?xml version="1.0" encoding="UTF-8"?>'."\n <urlset>\n";
			$str="";
			foreach($data as $v){
				 $xml.="<url>\n\r<loc>http://www.xingfunv.com/index/show/id-{$v['id']}.html</loc></url>\n\r"; 
				 $str.="http://www.xingfunv.com/index/show/id-{$v['id']}.html\r\n";
			}
			$xml.="</urlset>";
			file_put_contents("sitemap.txt",$str);
			file_put_contents("sitemap.xml",$xml);
			echo "生成成功";
		 
	}

}
?>