-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.php
46 lines (46 loc) · 1.4 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
<?php
header('Content-Type: application/xml');
$headVariables = $config = array();
include (__DIR__.'/config.default.php');
if (file_exists(__DIR__.'/config.php')) {
include (__DIR__.'/config.php');
}
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
$dp = opendir(dirname(__FILE__).'/content/');
$tplList = array();
$tpl_name="";
while ($fn = readdir($dp)) {
if (preg_match('/\.php$/', $fn)) {
$pageName = basename($fn, '.php');
$baseFile = dirname(__FILE__).'/content/'.$pageName;
$contentFile = $baseFile.'.php';
} elseif (preg_match ('/\.txt$/', $fn)) {
$pageName = basename($fn, '.txt');
$baseFile = dirname(__FILE__).'/content/'.$pageName;
$contentFile = $baseFile.'.txt';
} else {
continue;
}
$metaFile = $baseFile.'.meta.php';
$siteMaps['priority']=0.5;
$siteMaps['changefreq']='weekly';
if (file_exists($metaFile)) {
include($metaFile);
$lastModified = max (filemtime($metaFile), filemtime($contentFile));
} else {
$lastModified = filemtime($contentFile);
}
$siteMaps['lastmod'] = date('c', $lastModified);
?>
<url>
<loc>http://<?php echo $_SERVER['HTTP_HOST']?>/<?php echo htmlspecialchars($pageName);?></loc>
<priority><?php echo $siteMaps['priority'];?></priority>
<changefreq><?php echo $siteMaps['changefreq']; ?></changefreq>
<lastmod><?php echo $siteMaps['lastmod']; ?></lastmod>
</url>
<?php
}
?>
</urlset>