-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsitemap.php
55 lines (41 loc) · 1.21 KB
/
sitemap.php
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/*
* This file is part of http://github.com/adamdburton/pointshop-documentation
*
* (c) Adam Burton <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if(!file_exists('./vendor/autoload.php'))
{
die('Run composer install!');
}
DEFINE('PS_DOCS', true);
require './vendor/autoload.php';
require './utils.php';
date_default_timezone_set('Europe/London');
$config = json_decode(file_get_contents('config.json'), true);
$tree = buildTree();
function treeToXML($tree)
{
global $config;
$xml = '';
foreach($tree as $tree_page)
{
$xml .= '<url>' . "\n";
$xml .= '<loc>http://' . $config['domain'] . $tree_page['full_uri'] . '</loc>' . "\n";
$xml .= '<lastmod>' . date(DATE_W3C, filemtime($tree_page['file'])) . '</lastmod>' . "\n";
$xml .= '</url>' . "\n";
if(count($tree_page['children']))
{
$xml .= treeToXML($tree_page['children'], $xml);
}
}
return $xml;
}
$sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$sitemap .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
$sitemap .= treeToXML($tree) . "\n";
$sitemap .= '</urlset>';
echo $sitemap;