-
Notifications
You must be signed in to change notification settings - Fork 0
/
sitemap.php
68 lines (52 loc) · 1.68 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
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors','On');
include_once "site.config.php";
include_once "class.MySQLDB.php";
include_once "class.SwishFormat.php";
include_once "class.SwishKatalogen.php";
$sf = new SwishFormat();
$db = new MySQLDB();
$ui = new SwishKatalogen();
$dbparam = $config["db"]["mysql"];
$db->connectDB(
$dbparam["hostname"],
$dbparam["port"],
$dbparam["username"],
$dbparam["password"],
$dbparam["database"]
);
/* Todays date */
$today = date("c");
$xml_template_string = "<?xml version='1.0' encoding='UTF-8'?><urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'></urlset>";
$xml = simplexml_load_string($xml_template_string);
/* Categories */
$cat_all = $db->getSitemapCategoriesAll();
foreach($cat_all as $cat) {
$sitemap_cat_url = $ui->getSitemapCatURL($cat['category']);
/* Append element */
$url = $xml->addChild('url');
$loc = $url->addChild('loc', $sitemap_cat_url);
$lastmod = $url->addChild('lastmod', $today);
}
/* Organisations */
$org_top = $db->getSitemapOrganisationsTop();
foreach($org_top as $org) {
$sitemap_org_url = $ui->getSitemapOrgURL($org["orgNumber"]);
/* Append element */
$url = $xml->addChild('url');
$loc = $url->addChild('loc', $sitemap_org_url);
$lastmod = $url->addChild('lastmod', $today);
}
/* Entries */
$entries_all = $db->getSitemapEntriesAll();
foreach($entries_all as $entry) {
$sitemap_entry_url = $ui->getSitemapEntryURL($entry['entry']);
/* Append element */
$url = $xml->addChild('url');
$loc = $url->addChild('loc', $sitemap_entry_url);
$lastmod = $url->addChild('lastmod', $today);
}
$response = $xml->asXML();
header("Content-Type: application/xml");
die($response);