-
Notifications
You must be signed in to change notification settings - Fork 5
/
sitemap.php
144 lines (114 loc) · 4.58 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
chdir(__DIR__);
require_once 'api/Turbo.php';
$turbo = new Turbo();
header('Content-type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
$languages = $turbo->languages->languages();
$langLink = '';
if (!empty($languages)) {
$firstLang = reset($languages);
if (isset($_GET['lang_label'])) {
$language = $turbo->languages->languages(['id' => $turbo->languages->langId()]);
} else {
$turbo->languages->setLangId($firstLang->id);
}
if (!empty($language) && is_object($language) && $language->id != $firstLang->id) {
$langLink = $language->label . '/';
}
}
$url = $turbo->config->root_url . '/' . $langLink;
$lastmod = date('Y-m-d');
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>$lastmod</lastmod>\n";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
foreach ($turbo->pages->getPages() as $page) {
if ($page->visible && $page->url && $page->url != '404') {
$url = $turbo->config->root_url . '/' . $langLink . esc($page->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
if ($page->url == 'blog') {
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($turbo->settings->lastModifyPosts)) . "</lastmod>";
} elseif ($page->url == 'faq') {
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($turbo->settings->lastModifyFAQ)) . "</lastmod>";
} elseif ($page->url == 'reviews') {
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($turbo->settings->lastModifyReviews)) . "</lastmod>";
} elseif ($page->url == 'brands') {
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($turbo->settings->lastModifyBrands)) . "</lastmod>";
} else {
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($page->last_modified)) . "</lastmod>";
}
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
}
foreach ($turbo->blog->getPosts(['visible' => 1]) as $post) {
$url = $turbo->config->root_url . '/' . $langLink . 'blog/' . esc($post->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($post->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
foreach ($turbo->articlesCategories->getArticlesCategories() as $category) {
if ($category->visible) {
$url = $turbo->config->root_url . '/' . $langLink . 'articles/' . esc($category->url);
echo "\t<url>" . "\n";
echo "\t\t<loc>$url</loc>" . "\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($category->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
}
$turbo->db->query("SELECT url, last_modified FROM __articles WHERE visible=1");
foreach ($turbo->db->results() as $article) {
$url = $turbo->config->root_url . '/' . $langLink . 'article/' . esc($article->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($article->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
foreach ($turbo->categories->getCategories() as $category) {
if (isset($category->visible) && $category->visible) {
$url = $turbo->config->root_url . '/' . $langLink . 'catalog/' . esc($category->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($category->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
}
foreach ($turbo->brands->getBrands() as $brand) {
$url = $turbo->config->root_url . '/' . $langLink . 'brands/' . esc($brand->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($brand->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>daily</changefreq>\n";
echo "\t\t<priority>1.0</priority>\n";
echo "\t</url>\n";
}
$turbo->db->query("SELECT url, last_modified FROM __products WHERE visible=1");
foreach ($turbo->db->results() as $product) {
$url = $turbo->config->root_url . '/' . $langLink . 'products/' . esc($product->url);
echo "\t<url>\n";
echo "\t\t<loc>$url</loc>\n";
echo "\t\t<lastmod>" . date('Y-m-d', strtotime($product->last_modified)) . "</lastmod>";
echo "\t\t<changefreq>weekly</changefreq>\n";
echo "\t\t<priority>0.5</priority>\n";
echo "\t</url>\n";
}
echo '</urlset>' . "\n";
function esc($s)
{
return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
}