<?php

/*
 * Copyright (C) xgcms.com
 */

class rss extends base_model {
	
	function __construct(&$conf) {
		parent::__construct($conf);
	}
	public function sitemap(){
		
		$file=POST_PATH.'sitemap.xml';
		$i=false;
		if(is_file($file)){
			$update_time=filectime($file);
			$time=$_SERVER['time'];
			if(($time-$update_time)>3600){
				$i=true;
			}
		
		}else{
			$i=true;
			
		}
		if($i){
		        $app_url=$this->conf['app_url'];
				$list=$this->topic->index_fetch(array(),array('tid'=>-1),0,3000);
				$str='<?xml version="1.0" encoding="UTF-8"?>
							<urlset>';
	   
				foreach($list as $v){
				   $this->topic->format($v);
				   $str.=' <url>
					  <loc>'.$app_url.$v['url'].'</loc>
					  <lastmod>'.date('Y-m-d',$v['dateline']).'</lastmod>
					  <changefreq>always</changefreq>
					  <priority>1.0</priority>
					</url>';
				}
				$str.='
					   </urlset>';
				@file_put_contents($file,$str);		
		}
		
	}
	
	
}

?>