00001
00002
00003
00009 #include "webcit.h"
00010
00014 void output_date(void) {
00015 struct tm tm;
00016 time_t now;
00017 char buf[128];
00018
00019 time(&now);
00020 localtime_r(&now, &tm);
00021
00022 wc_strftime(buf, 32, "%A, %x", &tm);
00023 wprintf("%s", buf);
00024 }
00025
00026
00027
00028
00032 void dummy_section(void) {
00033 svprintf("BOXTITLE", WCS_STRING, "(dummy section)");
00034 do_template("beginbox");
00035 wprintf(_("(nothing)"));
00036 do_template("endbox");
00037 }
00038
00039
00043 void new_messages_section(void) {
00044 char buf[SIZ];
00045 char room[SIZ];
00046 int i;
00047 int number_of_rooms_to_check;
00048 char *rooms_to_check = "Mail|Lobby";
00049
00050
00051 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
00052 if (number_of_rooms_to_check == 0) return;
00053
00054 wprintf("<table border=0 width=100%%>\n");
00055 for (i=0; i<number_of_rooms_to_check; ++i) {
00056 extract_token(room, rooms_to_check, i, '|', sizeof room);
00057
00058 serv_printf("GOTO %s", room);
00059 serv_getln(buf, sizeof buf);
00060 if (buf[0] == '2') {
00061 extract_token(room, &buf[4], 0, '|', sizeof room);
00062 wprintf("<tr><td><a href=\"dotgoto?room=");
00063 urlescputs(room);
00064 wprintf("\">");
00065 escputs(room);
00066 wprintf("</a></td><td>%d/%d</td></tr>\n",
00067 extract_int(&buf[4], 1),
00068 extract_int(&buf[4], 2)
00069 );
00070 }
00071 }
00072 wprintf("</table>\n");
00073
00074 }
00075
00076
00080 void wholist_section(void) {
00081 char buf[SIZ];
00082 char user[SIZ];
00083
00084 serv_puts("RWHO");
00085 serv_getln(buf, sizeof buf);
00086 if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00087 extract_token(user, buf, 1, '|', sizeof user);
00088 wprintf("<li><a href=\"showuser?who=");
00089 urlescputs(user);
00090 wprintf("\">");
00091 escputs(user);
00092 wprintf("</a></li>");
00093 }
00094 }
00095
00096
00100 void tasks_section(void) {
00101 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
00102 int num_msgs = 0;
00103 int i;
00104 #endif
00105
00106 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
00107 gotoroom("_TASKS_");
00108 if (WC->wc_view != VIEW_TASKS) {
00109 num_msgs = 0;
00110 }
00111 else {
00112 num_msgs = load_msg_ptrs("MSGS ALL", 0);
00113 }
00114
00115 if (num_msgs < 1) {
00116 wprintf("<i>");
00117 wprintf(_("(None)"));
00118 wprintf("</i><br />\n");
00119 }
00120 else {
00121 for (i=0; i<num_msgs; ++i) {
00122 display_task(WC->msgarr[i]);
00123 }
00124 }
00125
00126 calendar_summary_view();
00127
00128 #else
00129 wprintf("<i>");
00130 wprintf(_("(This server does not support task lists)"));
00131 wprintf("</i>\n");
00132 #endif
00133 }
00134
00135
00139 void calendar_section(void) {
00140 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
00141 int num_msgs = 0;
00142 int i;
00143 #endif
00144
00145 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
00146 gotoroom("_CALENDAR_");
00147 if ( (WC->wc_view != VIEW_CALENDAR) && (WC->wc_view != VIEW_CALBRIEF) ) {
00148 num_msgs = 0;
00149 }
00150 else {
00151 num_msgs = load_msg_ptrs("MSGS ALL", 0);
00152 }
00153
00154 if (num_msgs < 1) {
00155 wprintf("<i>");
00156 wprintf(_("(Nothing)"));
00157 wprintf("</i><br />\n");
00158 }
00159 else {
00160 for (i=0; i<num_msgs; ++i) {
00161 display_calendar(WC->msgarr[i]);
00162 }
00163 calendar_summary_view();
00164 }
00165
00166 #else
00167 wprintf("<i>");
00168 wprintf(_("(This server does not support calendars)"));
00169 wprintf("</i>\n");
00170 #endif
00171 }
00172
00176 void server_info_section(void) {
00177 char message[512];
00178
00179 snprintf(message, sizeof message,
00180 _("You are connected to %s, running %s with %s, and located in %s. Your system administrator is %s."),
00181 serv_info.serv_humannode,
00182 serv_info.serv_software,
00183 SERVER,
00184 serv_info.serv_bbs_city,
00185 serv_info.serv_sysadm);
00186 escputs(message);
00187 }
00188
00195 void summary_inner_div(void) {
00204 wprintf("<div class=\"fix_scrollbar_bug\">"
00205 "<table border=0 width=100%%><tr valign=top>");
00206
00210 wprintf("<td width=33%%>");
00211 wprintf("<div class=\"box\">");
00212 wprintf("<div class=\"boxlabel\">");
00213 wprintf(_("Messages"));
00214 wprintf("</div><div class=\"boxcontent\">");
00215 wprintf("<div id=\"msg_inner\">");
00216 new_messages_section();
00217 wprintf("</div></div></div>");
00218 wprintf("</td>");
00219
00223 wprintf("<td width=33%%>");
00224 wprintf("<div class=\"box\">");
00225 wprintf("<div class=\"boxlabel\">");
00226 wprintf(_("Tasks"));
00227 wprintf("</div><div class=\"boxcontent\">");
00228 wprintf("<div id=\"tasks_inner\">");
00229 tasks_section();
00230 wprintf("</div></div></div>");
00231 wprintf("</td>");
00232
00236 wprintf("<td width=33%%>");
00237 wprintf("<div class=\"box\">");
00238 wprintf("<div class=\"boxlabel\">");
00239 wprintf(_("Today on your calendar"));
00240 wprintf("</div><div class=\"boxcontent\">");
00241 wprintf("<div id=\"calendar_inner\">");
00242 calendar_section();
00243 wprintf("</div></div></div>");
00244 wprintf("</td>");
00245
00246 wprintf("</tr><tr valign=top>");
00247 wprintf("<td colspan=3><br/></td>");
00248 wprintf("</tr><tr valign=top>");
00249
00253 wprintf("<td colspan=2>");
00254 wprintf("<div class=\"box\">");
00255 wprintf("<div class=\"boxlabel\">");
00256 wprintf(_("Who's online now"));
00257 wprintf("</div><div class=\"boxcontent\">");
00258 wprintf("<div id=\"who_inner\">");
00259 who_inner_div();
00260 wprintf("</div></div></div>");
00261 wprintf("</td>");
00262
00266 wprintf("<td width=33%%>");
00267 wprintf("<div class=\"box\">");
00268 wprintf("<div class=\"boxlabel\">");
00269 wprintf(_("About this server"));
00270 wprintf("</div><div class=\"boxcontent\">");
00271 wprintf("<div id=\"info_inner\">");
00272 server_info_section();
00273 wprintf("</div></div></div>");
00274 wprintf("</td>");
00275
00276
00280 wprintf("</tr></table>");
00281 }
00282
00283
00287 void summary(void) {
00288 char title[256];
00289
00290 output_headers(1, 1, 2, 0, 0, 0);
00291 wprintf("<div id=\"banner\">\n");
00292 wprintf("<div class=\"service_banner\">\n");
00293 wprintf("<img src=\"static/summscreen_48x.gif\">");
00294 wprintf("<h1>");
00295 snprintf(title, sizeof title, _("Summary page for %s"), WC->wc_fullname);
00296 escputs(title);
00297 wprintf("</h1><h2>\n");
00298 output_date();
00299 wprintf("</h2></div>");
00300 wprintf("<ul><li class=\"start_page\">");
00301 offer_start_page();
00302 wprintf("</li></ul>");
00303 wprintf("</div>");
00304
00310 wprintf("<div id=\"content\">\n");
00311 summary_inner_div();
00312 wprintf("</div>\n");
00313
00314 wprintf(
00315 "<script type=\"text/javascript\"> "
00316 " new Ajax.PeriodicalUpdater('msg_inner', 'new_messages_html', "
00317 " { method: 'get', frequency: 60 } ); "
00318 " new Ajax.PeriodicalUpdater('tasks_inner', 'tasks_inner_html', "
00319 " { method: 'get', frequency: 120 } ); "
00320 " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html', "
00321 " { method: 'get', frequency: 90 } ); "
00322 " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html', "
00323 " { method: 'get', frequency: 30 } ); "
00324 "</script> \n"
00325 );
00326
00327 wDumpContent(1);
00328 }
00329
00330