forked from laukstein/ajax-seo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.xml
46 lines (36 loc) · 1.75 KB
/
sitemap.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
44
45
46
<?php
// --------------------------------------------------
// Creating Sitemaps in Google Webmaster Tools http://support.google.com/webmasters/bin/answer.py?hl=en&answer=183668
// --------------------------------------------------
include 'content/config.php'; // Configuration
include 'content/connect.php'; // Connect to MySQL
header('Content-Type: application/xml');
// HTTP header caching
// --------------------------------------------------
$tablemod = mysql_query("SELECT CONCAT(DATE_FORMAT(MAX(GREATEST(updated, created)), '%a, %d %b %Y %T '), @@global.time_zone) AS date FROM `" . table . "`");
while ($row = @mysql_fetch_array($tablemod, MYSQL_ASSOC)) {
function cache(&$gmtime) {
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmtime) {
http_response_code(304);
exit;
}
}
header('Last-Modified: ' . $gmtime);
}
cache($row['date']);
}
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.sitemaps.org/schemas/sitemap-image/1.1"
xmlns:video="http://www.sitemaps.org/schemas/sitemap-video/1.1">
';
$result = mysql_query("SELECT url, CONCAT(DATE_FORMAT(GREATEST(updated, created), '%Y-%m-%dT%H:%i:%s'), @@global.time_zone) AS date FROM `" . table . "` ORDER BY array ASC");
while ($row = @mysql_fetch_array($result, MYSQL_ASSOC)) {
$row[] = array(
'row' => array_map('htmlspecialchars', $row)
);
echo " <url>\n <loc>http://{$_SERVER['SERVER_NAME']}$path{$row['url']}</loc>\n <lastmod>{$row['date']}</lastmod>\n </url>";
}
mysql_close($con);
echo "\n</urlset>";