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

/**
 * to_xml.php
 * ----------
 * @version 5.4.0
 * @copyright 2002-2010 Melbis Company
 * @link http://www.melbis.com
 * @author Dmitriy Kasyanov
 **/

// Define script folder 
define('FOLDER', './');

 
// Require classes and includes
require_once('./admin/privat/privat.php');
require_once('./admin/includes/common.php');
require_once('./admin/class/show/class.XML.php');

// Start sessions
shop_session();

// Go!
main();


/**
 * Function main
 **/
function main()
{
	global $gData, $gOptions, $gTpl, $gStartPoint;

	// Get start point for time
	$gStartPoint = run_time(0);
	
	// Connect to Data 
	$gData = data_connect();	

	$prec = $gOptions['main_prec'];
	$url = rtrim($gOptions['attr_base_url'], '/');	
	
	// Start XML file
	$xml_file = './admin/tmp/'.md5(session_id()).'.xml';
	$xml = new XML(SHOP_CHARSET, $xml_file, 'UTF-8', false);
	$xml->StartTag('urlset', array('xmlns' 	=> 'http://www.google.com/schemas/sitemap/0.84'));
	
	// Home Page
	$xml->StartTag('url');
	$xml->PutTag('loc', array(), $url.'/');
	$xml->PutTag('lastmod', array(), gmdate("Y-m-d", strtotime($gOptions['main_update_time'])));
	$xml->PutTag('changefreq', array(), 'always');
	$xml->PutTag('priority', array(), '1.0');
	$xml->CloseTag('url');	
	
	// Request topic & goods
	$topic = $gData->GetCatForXML();
	$rows = $gData->GetNumRows($topic);
	if ( $rows == 0 )  exit;	
	for ( $n = 1; $n <= $rows; $n++ ) 
	{			
		$hash = $gData->FetchRow($topic);
		// Create Topic
		if ( $hash[5] == 2 ) 
		{
			$link = $hash[6];
		}
		else 
		{
			if ( strlen($hash[8]) == 0 )
			{
				$link = "dir.php?id=".$hash[0]; 
			}
			else 
			{
				$link = 'dir_'.urlencode($hash[8]).'.htm';
			}
		}
		$xml->StartTag('url');
		$xml->PutTag('loc', array(), $url.'/'.$link);
		//$xml->PutTag('lastmod', array(), gmdate("Y-m-d", strtotime($gOptions['main_update_time'])));
		//$xml->PutTag('changefreq', array(), 'weekly'); // always, hourly, daily, weekly, monthly, yearly, never
		$xml->PutTag('priority', array(), '0.8');
		$xml->CloseTag('url');

		// Create Goods
		$goods = $gData->GetGoodsForXML($hash[0]);
		$goods_rows = $gData->GetNumRows($goods);
		for ( $i = 1; $i <= $goods_rows; $i++ ) 
		{			
			$g_hash = $gData->FetchRow($goods);
			$link = ( strlen($g_hash[15]) > 0 ) ? 'goods_'.urlencode($g_hash[15]).'.htm' : 'goods.php?id='.$g_hash[0];
		
			$xml->StartTag('url');
			$xml->PutTag('loc', array(), $url.'/'.$link);
			//$xml->PutTag('lastmod', array(), gmdate("Y-m-d", strtotime($gOptions['main_update_time'])));
			//$xml->PutTag('changefreq', array(), 'monthly'); // always, hourly, daily, weekly, monthly, yearly, never
			$xml->PutTag('priority', array(), '0.7');
			$xml->CloseTag('url');
		}
	}

	
	$xml->CloseTag('urlset');
	$xml->Free();
	
	header('Content-type: text/xml; charset=UTF-8');
	echo implode('',file($xml_file));
	@unlink($xml_file);
	
}
?>