Browse Source

Sitemaps generator

pecesama 17 years ago
parent
commit
8e12d24bc6
1 changed files with 68 additions and 0 deletions
  1. 68 0
      sitemap.php

+ 68 - 0
sitemap.php View File

1
+<?php
2
+if(!defined('entry')) define('entry',true);
3
+/* ===========================
4
+
5
+  gelato CMS - A PHP based tumblelog CMS
6
+  development version
7
+  http://www.gelatocms.com/
8
+
9
+  gelato CMS is a free software licensed under the GPL 2.0
10
+  Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
11
+
12
+  =========================== */
13
+?>
14
+<?php
15
+	// Code modified from the one at http://paste.ubuntu-nl.org/44548/
16
+	header("Content-type: text/xml; charset=utf-8");	
17
+
18
+	require(dirname(__FILE__)."/config.php");
19
+	include("classes/configuration.class.php");
20
+	include("classes/gelato.class.php");
21
+	$tumble = new gelato();
22
+	$conf = new configuration();	
23
+	$isFeed = true;
24
+	
25
+	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
26
+	
27
+	$rs = $tumble->getPosts(1);	
28
+?>
29
+<!-- generator="gelato CMS" -->
30
+
31
+<urlset 
32
+		xmlns="http://www.google.com/schemas/sitemap/0.84"
33
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
+        xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84
35
+        	http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
36
+	
37
+	<url>
38
+		<loc><?php echo $conf->urlGelato;?></loc>
39
+        <priority>0.9</priority>		
40
+<?php
41
+		if ($tumble->contarRegistros()>0) {
42
+			$register = mysql_fetch_array($rs);
43
+			$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
44
+			echo "<lastmod>".$formatedDate."</lastmod>";
45
+		}
46
+?>
47
+		<changefreq>hourly</changefreq>        
48
+	</url>
49
+
50
+
51
+<?php	
52
+	$rs = $tumble->getPosts($tumble->getPostsNumber());
53
+	if ($tumble->contarRegistros()>0) {
54
+		while($register = mysql_fetch_array($rs)) {
55
+			$url = htmlspecialchars($conf->urlGelato."/index.php?post=".$register["id_post"]);
56
+			$formatedDate = gmdate("Y-m-d", strtotime($register["date"]));
57
+?>
58
+	<url>
59
+		<loc><?php echo $url;?></loc>
60
+        <priority>0.7</priority>
61
+		<lastmod><?php echo $formatedDate;?></lastmod>
62
+        <changefreq>daily</changefreq>        
63
+	</url>
64
+<?php
65
+		}
66
+	}
67
+?>
68
+</urlset>