<?php
include_once 'core/core.php';
include_once 'core/SiteMapGenerator.php';
$r = 'https://'.$real_name.'';
$SiteMap = new SiteMapGenerator($r); // Указываем адрес сайта
$SiteMap->addItemMap("/",$site->timeadd,1.0); // Добавляет главную страницу
foreach($list_app as $_k => $_v){
	$SiteMap->addItemMap($_k,$site->timeadd,0.9); 
}
$max = 2000;
$k_post = $db->Count("forum_topics","WHERE `sid` = '".$site->id."'");
$k_page = $core->k_page($k_post,$max);
$page = $core->page($k_page);
$start = $max*$page-$max;

$data = $db->Query("SELECT *, (SELECT COUNT(*) FROM `forum_message` WHERE `forum_topics`.`tid` = `forum_message`.`tid`) AS `ccc` FROM `forum_topics` WHERE `sid` = '".$site->id."' ORDER BY `lastUpdate` DESC LIMIT $start, $max"); 
while ($d = mysqli_fetch_assoc($data)){
	$SiteMap->addItemMap('/forum.lm?id='.$d["tid"].htmlspecialchars('&act=read'),$d["lastUpdate"]);
}

$max = 500;
$k_post = $db->Count("news","WHERE `sid` = '".$site->id."'");
$k_page = $core->k_page($k_post,$max);
$page = $core->page($k_page);
$start = $max*$page-$max;


$data = $db->Query("SELECT * FROM `news` WHERE `sid` = '".$site->id."' ORDER BY `nid` DESC LIMIT $start, $max");
while ($d = mysqli_fetch_assoc($data)){
	$SiteMap->addItemMap('/news.lm?id='.$d["nid"],$d["ntime"]);
}
$max = 2000;
$k_post = $db->Count("forum_topics","WHERE `sid` = '".$site->id."'");
$k_page = $core->k_page($k_post,$max);
$page = $core->page($k_page);
$start = $max*$page-$max;

$data = $db->Query("SELECT *, (SELECT COUNT(*) FROM `forum_message` WHERE `forum_topics`.`tid` = `forum_message`.`tid`) AS `ccc` FROM `forum_topics` WHERE `sid` = '".$site->id."' ORDER BY `lastUpdate` DESC LIMIT $start, $max"); 
while ($d = mysqli_fetch_assoc($data)){
	$SiteMap->addItemMap('/forum.lm?id='.$d["tid"].htmlspecialchars('&act=read'),$d["lastUpdate"]);
}

$SiteMap->ViewMap();