www last 10 callers
This commit is contained in:
parent
4272f89b1a
commit
87d68d2981
@ -6,7 +6,7 @@ ZMODEM = Xmodem/libzmodem.a
|
|||||||
LUA = lua/liblua.a
|
LUA = lua/liblua.a
|
||||||
MICROHTTPD=-lmicrohttpd -lb64
|
MICROHTTPD=-lmicrohttpd -lb64
|
||||||
|
|
||||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o
|
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o
|
||||||
%.o: %.c $(DEPS)
|
%.o: %.c $(DEPS)
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ ZMODEM = Xmodem/libzmodem.a
|
|||||||
LUA = lua/liblua.a
|
LUA = lua/liblua.a
|
||||||
MICROHTTPD=-lmicrohttpd -lb64
|
MICROHTTPD=-lmicrohttpd -lb64
|
||||||
|
|
||||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o
|
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o
|
||||||
%.o: %.c $(DEPS)
|
%.o: %.c $(DEPS)
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c -o $@ $< $(CFLAGS)
|
||||||
|
|
||||||
|
1
bbs.h
1
bbs.h
@ -240,6 +240,7 @@ extern char *www_msgs_messagelist(struct user_record *user, int conference, int
|
|||||||
extern char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg);
|
extern char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg);
|
||||||
extern int www_send_msg(struct user_record *user, char *to, char *subj, int conference, int area, char *replyid, char *body);
|
extern int www_send_msg(struct user_record *user, char *to, char *subj, int conference, int area, char *replyid, char *body);
|
||||||
extern char *www_new_msg(struct user_record *user, int conference, int area);
|
extern char *www_new_msg(struct user_record *user, int conference, int area);
|
||||||
|
extern char *www_last10();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
www.c
10
www.c
@ -506,6 +506,16 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
|||||||
|
|
||||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
||||||
|
|
||||||
|
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||||
|
} else if (strcasecmp(url, "/last10/") == 0 || strcasecmp(url, "/last10") == 0) {
|
||||||
|
page = www_last10();
|
||||||
|
if (page == NULL) {
|
||||||
|
free(header);
|
||||||
|
free(footer);
|
||||||
|
return MHD_NO;
|
||||||
|
}
|
||||||
|
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
||||||
|
|
||||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||||
} else if (strcasecmp(url, "/email/") == 0 || strcasecmp(url, "/email") == 0) {
|
} else if (strcasecmp(url, "/email/") == 0 || strcasecmp(url, "/email") == 0) {
|
||||||
con_inf->user = www_auth_ok(connection, url_);
|
con_inf->user = www_auth_ok(connection, url_);
|
||||||
|
78
www_last10.c
Normal file
78
www_last10.c
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#if defined(ENABLE_WWW)
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "bbs.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern struct bbs_config conf;
|
||||||
|
|
||||||
|
char *www_last10() {
|
||||||
|
char *page;
|
||||||
|
int max_len;
|
||||||
|
int len;
|
||||||
|
char buffer[4096];
|
||||||
|
struct last10_callers callers[10];
|
||||||
|
|
||||||
|
int i,z;
|
||||||
|
struct tm l10_time;
|
||||||
|
FILE *fptr = fopen("last10.dat", "rb");
|
||||||
|
|
||||||
|
if (fptr != NULL) {
|
||||||
|
|
||||||
|
for (i=0;i<10;i++) {
|
||||||
|
if (fread(&callers[i], sizeof(struct last10_callers), 1, fptr) < 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fptr);
|
||||||
|
} else {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
page = (char *)malloc(4096);
|
||||||
|
max_len = 4096;
|
||||||
|
len = 0;
|
||||||
|
memset(page, 0, 4096);
|
||||||
|
|
||||||
|
sprintf(buffer, "<div class=\"content-header\"><h2>Last 10 Callers</h2></div>\n");
|
||||||
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
strcat(page, buffer);
|
||||||
|
len += strlen(buffer);
|
||||||
|
|
||||||
|
sprintf(buffer, "<div class=\"div-table\">\n");
|
||||||
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
strcat(page, buffer);
|
||||||
|
len += strlen(buffer);
|
||||||
|
|
||||||
|
for (z=0;z<i;z++) {
|
||||||
|
localtime_r(&callers[z].time, &l10_time);
|
||||||
|
sprintf(buffer, "<div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mday, l10_time.tm_mon + 1, l10_time.tm_year - 100);
|
||||||
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
strcat(page, buffer);
|
||||||
|
len += strlen(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buffer, "</div>\n");
|
||||||
|
if (len + strlen(buffer) > max_len - 1) {
|
||||||
|
max_len += 4096;
|
||||||
|
page = (char *)realloc(page, max_len);
|
||||||
|
}
|
||||||
|
strcat(page, buffer);
|
||||||
|
len += strlen(buffer);
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user