2 * XML sitemap generator
4 * Copyright (c) 2010 by the citadel.org team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
26 * XML sitemap generator -- go through the message list
28 void sitemap_do_messages(void) {
32 SharedMessageStatus Stat;
33 message_summary *Msg = NULL;
35 memset(&Stat, 0, sizeof Stat);
36 Stat.maxload = INT_MAX;
37 Stat.lowest_found = (-1);
38 Stat.highest_found = (-1);
39 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
40 if (num_msgs < 1) return;
42 for (i=0; i<num_msgs; i+=20) {
43 Msg = GetMessagePtrAt(i, WCC->summ);
45 wc_printf("<url><loc>%s/readfwd", ChrPtr(site_prefix));
46 wc_printf("?gotofirst=");
47 urlescputs(ChrPtr(WC->CurRoom.name));
48 wc_printf("?start_reading_at=%ld", Msg->msgnum);
49 wc_printf("</loc></url>\r\n");
56 * Entry point for RSS feed generator
60 output_headers(0, 0, 0, 0, 1, 0);
61 hprintf("Content-type: text/xml\r\n");
64 "Connection: close\r\n"
66 PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
70 wc_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
71 wc_printf("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n");
73 HashList *roomlist = GetRoomListHashLKRA(NULL, NULL);
74 HashPos *it = GetNewHashPos(roomlist, 0);
79 while (GetNextHashPos(roomlist, it, &HKlen, &HashKey, (void *)&room))
81 /* Output the messages in this room only if it's a message board */
82 if (room->defview == VIEW_BBS)
85 sitemap_do_messages();
90 /* DeleteHash(&roomlist); This will be freed when the session closes */
92 wc_printf("</urlset>\r\n");
101 WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
102 WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);