-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap-list-jsonld.xml
executable file
·43 lines (38 loc) · 1.71 KB
/
sitemap-list-jsonld.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
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
//declare content type before any text is sent to browser
header('Content-type: text/xml');
//make XML declaration
echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<?php $indexFile = '/usr/local/apache2/htdocs/linked-people/index.html'; ?>
<loc><?php echo 'https://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/index.html'; ?></loc>
<lastmod><?php echo date("Y-m-d\TH:i:sP", filemtime($indexFile)); ?></lastmod>
<changefreq>monthly</changefreq>
<priority>1.0</priority>
</url>
<?php
//pass database parameters and connect to database
include_once './meta/assets/database-params.inc';
// retrieve items from database
$query = "SELECT person_id,updated FROM linked_people.person GROUP BY person_id ORDER BY person_id ASC";
$getRecords = $connectLibstaff->query($query);
if (!$getRecords) { die('<p>Error retrieving items from database!</p>'); }
// store items in array, strip out html tags, generate valid date stamp
while ($row = $getRecords->fetch_object()) {
$person_id = $row->person_id;
$dateW3C = new DateTime($row->updated);
$updated = $dateW3C->format('Y-m-d\TH:i:sP');
// output to client
?>
<url>
<loc><?php echo 'https://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']); ?>/about.json?id=<?php echo $person_id; ?></loc>
<lastmod><?php echo $updated; ?></lastmod>
<changefreq>monthly</changefreq>
<priority>0.9</priority>
</url>
<?php
}
?>
</urlset>