<?php
/* 
 * RSS
 */

header('Content-type: text/html; charset=utf-8');

include_once("../../inc_pathconfig.php");
include_once("../../inc_common.php");
config::setGlobalVars();

$res=new db_func();

$sitemap=null;
$sitemapPreRes=$res->showTabAsPage("c_get","name>'' AND str NOT LIKE '%&del%' OR name>'' AND str NOT LIKE '%&p%'","name","id",50000);
foreach($sitemapPreRes as $sitemapRes){
    if(!preg_match("[%]",$sitemapRes["name"])){
        if(!preg_match("[\.html]",$sitemapRes["name"])){
            preg_match_all("[/]",$sitemapRes["name"],$o);
            $c=count($o[0]);
            if($c<2){
                $c=1;
            }else{
                $c=round((1/$c+0.25),3);
            }
        }else{
            $c=0.5;
        }
        $name=preg_replace("[&]","&amp;",$sitemapRes["name"]);
        $sitemap.="
    <url>
        <loc>http://".PATHURL.$name."</loc>
        <priority>".$c."</priority>
        <changefreq>weekly</changefreq>
    </url>
";
    }
}

// Выводим фид

$str="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
    ".$sitemap."
</urlset>";

echo $str;

?>