<?php
include_once '../../mainfile.php' ;

require_once XOOPS_ROOT_PATH.'/class/template.php' ;

$sitemap_configs = @$xoopsModuleConfig ;
$sitemap_configs['alltime_guest'] = true ;


$myts =& MyTextSanitizer::getInstance() ;

$sitemap_configs['with_lastmod'] = true ;


//header( 'Content-Type:text/xml; charset=utf-8' ) ;

include_once XOOPS_ROOT_PATH.'/modules/sitemap/include/sitemap.php' ;
require_once XOOPS_ROOT_PATH.'/class/template.php';

if (function_exists('mb_http_output')) {
	mb_http_output('pass');
}
$xoopsTpl = new XoopsTpl();


// for All-time guest mode (backup uid & set as Guest)
//if( is_object( $xoopsUser ) && ! empty( $sitemap_configs['alltime_guest'] ) ) {
//	$backup_uid = $xoopsUser->getVar('uid') ;
//	$xoopsUser = '' ;
//	$xoopsUserIsAdmin = false ;
//	$xoopsTpl->assign(array('xoops_isuser' => false, 'xoops_userid' => 0, 'xoops_uname' => '', 'xoops_isadmin' => false));
//}

$sitemap = sitemap_show();

// for All-time guest mode (restore $xoopsUser*)
//if( ! empty( $backup_uid ) && ! empty( $sitemap_configs['alltime_guest'] ) ) {
//	$member_handler =& xoops_gethandler('member');
//	$xoopsUser =& $member_handler->getUser( $backup_uid ) ;
//	$xoopsUserIsAdmin = $xoopsUser->isAdmin();
//}



$xoopsTpl->assign('lastmod', gmdate( 'Y-m-d\TH:i:s\Z' ) ); // TODO
$xoopsTpl->assign('sitemap', $sitemap);
//$xoopsTpl->assign('msgs', $myts->displayTarea($msgs,1));
$xoopsTpl->assign('show_subcategoris', $sitemap_configs["show_subcategoris"]);

$xoopsTpl->assign('this', array(
	'mods' => $xoopsModule->getVar('dirname'),
	'name' => $xoopsModule->getVar('name')
));

$xoopsTpl->assign('channel_title', htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
$xoopsTpl->assign('channel_link', XOOPS_URL.'/');
$xoopsTpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES));
// $xoopsTpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
$xoopsTpl->assign('channel_lastbuild', date( 'r' ) ) ; // GIJ
$xoopsTpl->assign('channel_webmaster', $xoopsConfig['adminmail']);
$xoopsTpl->assign('channel_editor', $xoopsConfig['adminmail']);
$xoopsTpl->assign('channel_category', 'Site');
$xoopsTpl->assign('channel_generator', 'ImpressCMS');
$xoopsTpl->assign('channel_language', _LANGCODE);
$xoopsTpl->assign('image_url', XOOPS_URL.'/themes/impresscms/images/toplogo.png');

$dimention = getimagesize(XOOPS_ROOT_PATH.'/themes/impresscms/images/toplogo.png');
if (empty($dimention[0])) {
	$width = 88;
} else {
	$width = ($dimention[0] > 144) ? 144 : $dimention[0];
}
if (empty($dimention[1])) {
	$height = 31;
} else {
	$height = ($dimention[1] > 400) ? 400 : $dimention[1];
}
$xoopsTpl->assign('image_width', $width);
$xoopsTpl->assign('image_height', $height);


$today = date('Y-m-d') . "T" . date('H-i-s') . "Z";
$xoopsTpl->assign('today', $today);

if( is_object( @$xoopsLogger ) ) $xoopsLogger->activated = false ;

header ('Content-Type:text/xml; charset=utf-8');
$xoopsTpl->display( 'db:sitemap_xml_google.html' ) ;


?>
