New Last 10 Callers

This commit is contained in:
Andrew Pamment 2018-02-25 16:25:53 +10:00
parent ac4c525415
commit 70dcde1f75
12 changed files with 62 additions and 18 deletions

1
.gitignore vendored
View File

@ -80,3 +80,4 @@ core
docs/site
utils/reset_pass/reset_pass
.vscode
last10v2.dat

View File

@ -35,6 +35,10 @@ LINE: 280 NEW
OLDSTRING: (NONE)
NEWSTRING: "Read Now ? (Y / N): "
LINE: 5 MODIFIED
OLDSTRING: "\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d\e[0m\r\n"
NEWSTRING: "\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d \e[1;33m%c\e[0m\r\n"
Changes from v0.8-alpha -> v0.9-alpha
--------------------------------------------------------------
LINE: 255 NEW

Binary file not shown.

View File

@ -2,7 +2,7 @@
\r\n\r\nTimeout waiting for input..\r\n
\r\n\e[1;37mLast 10 callers:\r\n
\e[1;30m-------------------------------------------------------------------------------\r\n
\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d\e[0m\r\n
\e[1;37m%-16s \e[1;36m%-32s \e[1;32m%02d:%02d %02d-%02d-%02d \e[1;33m%c\e[0m\r\n
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
\e[1;37mPress any key to continue...\e[0m\r\n
\r\n\r\n\e[1;37mSystem Information\r\n

View File

@ -60,9 +60,13 @@ bbs_write_string("\r\n\r\n\027[1;37mLast 10 callers:\r\n");
bbs_write_string("\027[1;30m-------------------------------------------------------------------------------\r\n");
while (i < 10) do
user, location, ltime = bbs_read_last10(i);
user, location, ltime, calls = bbs_read_last10(i);
if (user ~= nil) then
bbs_write_string(string.format("\027[1;37m%-16s \027[1;36m%-32s \027[1;32m%s\r\n", user, location, os.date("%H:%M %d-%m-%y" ,ltime)));
if calls == 1 then
bbs_write_string(string.format("\027[1;37m%-16s \027[1;36m%-32s \027[1;32m%s \027[1;33mN\r\n", user, location, os.date("%H:%M %d-%m-%y" ,ltime)));
else
bbs_write_string(string.format("\027[1;37m%-16s \027[1;36m%-32s \027[1;32m%s\r\n", user, location, os.date("%H:%M %d-%m-%y" ,ltime)));
end
end
i = i + 1;

BIN
dist/www-bootstrap/static/newuser.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -341,6 +341,19 @@
max-width: 100%;
}
.last10-new {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
-webkit-box-flex: 0;
-ms-flex: 100%;
flex: 0 0 100%;
max-width: 100%;
}
#msgbody {
background-color: black;
color: gray;

View File

@ -331,9 +331,22 @@
padding-left: 15px;
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
-ms-flex: 0 0 23.333333%;
flex: 0 0 23.333333%;
max-width: 23.333333%;
}
.last10-new {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
-webkit-box-flex: 0;
-ms-flex: 0 0 10%;
flex: 0 0 10%;
max-width: 10%;
}
#msgbody {

View File

@ -672,7 +672,7 @@ void record_last10_callers(struct user_record *user) {
struct last10_callers callers[10];
int i,j;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
if (fptr != NULL) {
for (i=0;i<10;i++) {
@ -690,13 +690,13 @@ void record_last10_callers(struct user_record *user) {
strcpy(new_entry.name, user->loginname);
strcpy(new_entry.location, user->location);
new_entry.time = time(NULL);
new_entry.calls = user->timeson;
if (i == 10) {
j = 1;
} else {
j = 0;
}
fptr = fopen("last10.dat", "wb");
fptr = fopen("last10v2.dat", "wb");
for (;j<i;j++) {
fwrite(&callers[j], sizeof(struct last10_callers), 1, fptr);
}
@ -710,7 +710,7 @@ void display_last10_callers(struct user_record *user) {
int i,z;
struct tm l10_time;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
time_t l10_timet;
s_printf("\e[2J\e[1;1H");
@ -735,9 +735,9 @@ void display_last10_callers(struct user_record *user) {
l10_timet = callers[z].time;
localtime_r(&l10_timet, &l10_time);
if (conf.date_style == 1) {
s_printf(get_string(4), callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100);
s_printf(get_string(4), callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100, (callers[z].calls == 1 ? 'N' : ' '));
} else {
s_printf(get_string(4), 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);
s_printf(get_string(4), 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, (callers[z].calls == 1 ? 'N' : ' '));
}
}
s_printf(get_string(5));

View File

@ -43,6 +43,7 @@ struct last10_callers {
char name[17];
char location[33];
time_t time;
int calls;
}__attribute__((packed));
struct text_file {

View File

@ -87,7 +87,7 @@ int l_bbsReadLast10(lua_State *L) {
struct last10_callers l10;
FILE *fptr;
fptr = fopen("last10.dat", "rb");
fptr = fopen("last10v2.dat", "rb");
if (!fptr) {
return 0;
}
@ -100,8 +100,8 @@ int l_bbsReadLast10(lua_State *L) {
lua_pushstring(L, l10.name);
lua_pushstring(L, l10.location);
lua_pushnumber(L, l10.time);
return 3;
lua_pushnumber(L, l10.calls);
return 4;
}
int l_bbsGetEmailCount(lua_State *L) {

View File

@ -17,7 +17,7 @@ char *www_last10() {
int i,z;
struct tm l10_time;
FILE *fptr = fopen("last10.dat", "rb");
FILE *fptr = fopen("last10v2.dat", "rb");
if (fptr != NULL) {
@ -56,9 +56,17 @@ char *www_last10() {
for (z=0;z<i;z++) {
localtime_r(&callers[z].time, &l10_time);
if (conf.date_style == 1) {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100);
if (callers[z].calls == 1) {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div><div class=\"last10-new\"><img src=\"%sstatic/newuser.png\" /></div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100, conf.www_url);
} else {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", callers[z].name, callers[z].location, l10_time.tm_hour, l10_time.tm_min, l10_time.tm_mon + 1, l10_time.tm_mday, l10_time.tm_year - 100);
}
} else {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></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 (callers[z].calls == 1) {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div><div class=\"last10-new\"><img src=\"%sstatic/newuser.png\" /></div></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, conf.www_url);
} else {
sprintf(buffer, "<div class=\"last10-row\"><div class=\"last10-name\">%s</div><div class=\"last10-location\">%s</div><div class=\"last10-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></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;