-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsitemap.xml
30 lines (23 loc) · 1.16 KB
/
sitemap.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
//
// Sitemap https://support.google.com/webmasters/answer/183668
// Sitemap stylesheet http://www.w3.org/TR/xslt-30/
// 50,000 URLs or maximum size of 10MB http://googlewebmastercentral.blogspot.com/2014/10/best-practices-for-xml-sitemaps-rssatom.html
//
include 'content/config.php';
include 'content/connect.php';
include 'content/cache.php'; cache::medb();
echo '<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="' . $scheme . '://' . $host . $path . '/sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">';
if ($stmt = $mysqli->prepare('SELECT url, GREATEST(modified, created) AS date FROM `' . table . '` ORDER BY `order` ASC')) {
$stmt->execute();
$stmt->bind_result($url, $date);
while ($stmt->fetch()) echo "\n <url>\n <loc>$scheme://$host$path" . (strlen($url) ? "/$url" : null) . "</loc>\n <lastmod>" . gmdate('c', strtotime($date)) . "</lastmod>\n </url>";
$stmt->free_result();
$stmt->close();
}
$mysqli->close();
echo "\n</urlset>";