-
Notifications
You must be signed in to change notification settings - Fork 3
/
sitemap.php
56 lines (48 loc) · 1.69 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
<?php
header("Content-type:text/xml; charset=UTF-8");
error_reporting(E_ALL);
require_once 'data/connect_db.php';
require_once "data/dao/DaoRegions.php";
require_once "data/dao/DaoAreas.php";
require_once "data/dao/DaoPlacesV3.php";
$conn = mySqlConnect();
$dao = new DaoRegions($conn, "v3", "release");
$regions = $dao->getAllUrls();
$dao = new DaoAreas($conn, "v3", "release");
$areas = $dao->getAllUrls();
$dao = new DaoPlacesV3($conn, "v3", "release");
$places = $dao->getAllUrls();
$xml_string = '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://www.niceplaces.it/</loc>
<changefreq>monthly</changefreq>
</url>
<url>
<loc>https://www.niceplaces.it/en/</loc>
<changefreq>monthly</changefreq>
</url>';
for ($i = 0; $i < count($regions); $i++){
$lang = ($regions[$i][0] == "it") ? "" : "en/";
$xml_string = $xml_string . '<url>
<loc>https://www.niceplaces.it/' . $lang . $regions[$i][1] . '/</loc>
<changefreq>monthly</changefreq>
</url>';
}
for ($i = 0; $i < count($areas); $i++){
$lang = ($areas[$i][0] == "it") ? "" : "en/";
$xml_string = $xml_string . '<url>
<loc>https://www.niceplaces.it/' . $lang . $areas[$i][1] . '/</loc>
<changefreq>monthly</changefreq>
</url>';
}
for ($i = 0; $i < count($places); $i++){
$lang = ($places[$i][0] == "it") ? "" : "en/";
$xml_string = $xml_string . '<url>
<loc>https://www.niceplaces.it/' . $lang . $places[$i][1] . '/' . $places[$i][2] . '</loc>
<changefreq>monthly</changefreq>
</url>';
}
$xml_string = $xml_string . '</urlset>';
$xml = new SimpleXMLElement($xml_string);
$xml->asXML("sitemap.xml");