<?php
require_once ("../config/config.php");
require_once ("../includes/mysqlwrapper.php");
header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://'.$config['host']['name'].'/</loc>
      <priority>1.0</priority>
      <changefreq>always</changefreq>
   </url>';
  $areas=sql('Select * from page_areas where up=0 and hide=0 order by pos asc, name asc',1);
  while($it=mysqli_fetch_array($areas))
  {
    if($it['page']!=1)
    {
    echo '
   <url>
      <loc>http://'.$config['host']['name'].'/'.($it['lang']!='ru'?$it['lang'].'/':'').$it['name'].'/</loc>
      <priority>0.8</priority>
   </url>';
    }
    $subareas=sql('Select * from page_areas where up='.$it['id'].' and hide=0 order by name',1);
    while($sit=mysqli_fetch_array($subareas))
    {
      if($it['page']!=1)
      {
    echo '
   <url>
      <loc>http://'.$config['host']['name'].'/'.($sit['lang']!='ru'?$sit['lang'].'/':'').$sit['name'].'/</loc>
      <priority>0.6</priority>
   </url>';
      }
    }
  }
  $news=sql('Select * from news where hide=0 order by id asc',1);
  while($it=mysqli_fetch_array($news))
  {
    echo '
   <url>
      <loc>http://'.$config['host']['name'].'/news/'.($it['alias']!=''?$it['alias']:$it['id']).'/</loc>
      <priority>0.6</priority>
   </url>';
  }
  $news=sql('Select * from materials where hide=0 order by id asc',1);
  while($it=mysqli_fetch_array($news))
  {
    echo '
   <url>
      <loc>http://'.$config['host']['name'].'/'.$it['type'].'/'.($it['alias']!=''?$it['alias']:$it['id']).'/</loc>
      <priority>0.6</priority>
   </url>';
  }
  $members=sql('Select * from members where hide=0 order by id asc',1);
  while($it=mysqli_fetch_array($members))
  {
    echo '
   <url>
      <loc>http://'.$config['host']['name'].'/members/'.($it['alias']!=''?$it['alias']:$it['id']).'/</loc>
      <priority>0.6</priority>
   </url>';
  }
  echo '
</urlset>';
?>

