<?php
include('header.php');
$all = $mysqli->query("SELECT published,deleted FROM media WHERE published='1' AND deleted='0'");
$media = $all->num_rows;
if ($media > 0) {
?>
<div class="page-header page-heading">
<h1><i class="fa fa-sitemap"></i> Sitemaps</h1>
</div>
<table class="table">
<thead>
<tr>
<th>Sitemap</th>
</tr>
</thead>
<tbody>
<?php 
if (isset($options['general_category_sitemap']) AND $options['general_category_sitemap'] == 1) {
$categories = $mysqli->query("SELECT id FROM categories");
$categories_number = $categories->num_rows;
if ($categories_number > 0) {
$categories_sitemap_link = $options['general_siteurl'].'/categories-sitemap.xml';
$categories_sitemap = str_replace(':/','://',str_replace('//','/',($categories_sitemap_link)));
?>
<tr><td><a href="<?php echo $categories_sitemap; ?>" target="_BLANK"><?php echo $categories_sitemap; ?></a></td></tr>
<?php	
}
}
if (isset($options['general_lists_sitemap']) AND $options['general_lists_sitemap'] == 1) {
$lists = $mysqli->query("SELECT id FROM lists WHERE privacy='0'");
$lists_number = $lists->num_rows;
if ($lists_number > 0) {
$lists_sitemap_link = $options['general_siteurl'].'/lists-sitemap.xml';
$lists_sitemap = str_replace(':/','://',str_replace('//','/',($lists_sitemap_link)));
?>
<tr><td><a href="<?php echo $lists_sitemap; ?>" target="_BLANK"><?php echo $lists_sitemap; ?></a></td></tr>
<?php	
}
}
if (isset($options['general_sitemap_items'])) {
$number = $options['general_sitemap_items'];	
} else {
$number = 1000;	
}
$sitemaps = ceil($media/$number);
for($c=0;$c<$sitemaps;$c++) {
	$n = $c+1;
$sitemap_link = $options['general_siteurl'].'/sitemap-'.$n.'.xml';
$sitemap = str_replace(':/','://',str_replace('//','/',($sitemap_link)));
?>
<tr><td><a href="<?php echo $sitemap; ?>" target="_BLANK"><?php echo $sitemap; ?></a></td></tr>
<?php
}
}
?>
</tbody>
</table>
<?php
include('footer.php');
?>