2 * XML sitemap generator
4 * Copyright (c) 2010-2021 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
20 * XML sitemap generator -- go through the message list for a BBS room
22 void sitemap_do_bbs(void) {
25 SharedMessageStatus Stat;
26 message_summary *Msg = NULL;
28 memset(&Stat, 0, sizeof Stat);
29 Stat.maxload = INT_MAX;
30 Stat.lowest_found = (-1);
31 Stat.highest_found = (-1);
32 num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
33 if (num_msgs < 1) return;
35 for (i=0; i<num_msgs; i+=20) {
36 Msg = GetMessagePtrAt(i, WC->summ);
38 wc_printf("<url><loc>%s/readfwd", ChrPtr(site_prefix));
40 urlescputs(ChrPtr(WC->CurRoom.name));
41 wc_printf("?start_reading_at=%ld", Msg->msgnum);
42 wc_printf("</loc></url>\r\n");
49 * XML sitemap generator -- go through the message list for a wiki room
51 void sitemap_do_wiki(void) {
54 SharedMessageStatus Stat;
55 message_summary *Msg = NULL;
58 memset(&Stat, 0, sizeof Stat);
59 Stat.maxload = INT_MAX;
60 Stat.lowest_found = (-1);
61 Stat.highest_found = (-1);
62 num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
63 if (num_msgs < 1) return;
65 for (i=0; i<num_msgs; ++i) {
66 Msg = GetMessagePtrAt(i, WC->summ);
69 serv_printf("MSG0 %ld|3", Msg->msgnum);
70 serv_getln(buf, sizeof buf);
71 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
72 if ( (!strncasecmp(buf, "exti=", 5))
73 && (!bmstrcasestr(buf, "_HISTORY_"))
75 wc_printf("<url><loc>%s/wiki", ChrPtr(site_prefix));
77 urlescputs(ChrPtr(WC->CurRoom.name));
78 wc_printf("?page=%s", &buf[5]);
79 wc_printf("</loc></url>\r\n");
87 struct sitemap_room_list {
88 struct sitemap_room_list *next;
95 * Load the room list for the sitemap
97 struct sitemap_room_list *sitemap_load_roomlist(void) {
99 char roomname_plain[SIZ];
100 struct sitemap_room_list *roomlist = NULL;
103 serv_getln(buf, sizeof buf);
104 if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
105 struct sitemap_room_list *ptr = malloc(sizeof(struct sitemap_room_list));
106 extract_token(roomname_plain, buf, 0, '|', sizeof roomname_plain);
107 ptr->roomname = NewStrBufPlain(roomname_plain, -1);
108 ptr->defview = extract_int(buf, 6);
109 ptr->next = roomlist;
116 extern void sitemap_do_blog(void);
119 * Entry point for RSS feed generator
122 struct sitemap_room_list *roomlist = NULL;
123 output_headers(0, 0, 0, 0, 1, 0);
124 hprintf("Content-type: text/xml\r\n");
126 "Server: %s / %s\r\n"
127 "Connection: close\r\n"
129 PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
133 wc_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
134 wc_printf("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n");
136 roomlist = sitemap_load_roomlist();
138 while (roomlist != NULL)
140 struct sitemap_room_list *ptr;
142 gotoroom(roomlist->roomname);
144 /* Output the messages in this room only if it's a room type we can make sense of */
145 switch(roomlist->defview) {
160 roomlist = roomlist->next;
161 FreeStrBuf(&ptr->roomname);
165 wc_printf("</urlset>\r\n");
174 WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
175 WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);