diff --git a/STRINGS.CHANGES b/STRINGS.CHANGES
index 2201bb8..d4e306e 100644
--- a/STRINGS.CHANGES
+++ b/STRINGS.CHANGES
@@ -39,6 +39,31 @@ 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"
+LINE: 281 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\e[1;33mSystem Blog\e[0m\r\n"
+
+LINE: 282 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n"
+
+LINE: 283 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\e[0mNo Entries...\r\n"
+
+LINE: 284 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\e[1;37m%s (by \e[1;36m%s\e[1;37m)\r\n"
+
+LINE: 285 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\e[1;35m%d:%02d%s %s, %s %d %d\r\n"
+
+LINE: 286 NEW
+OLDSTRING: (NONE)
+NEWSTRING: "\r\n\r\n\e[1;37mEnter a title:\e[0m "
+
+
Changes from v0.8-alpha -> v0.9-alpha
--------------------------------------------------------------
LINE: 255 NEW
diff --git a/dist/ansis/bulletin1.ans b/dist/ansis/bulletin1.ans
index 8d24667..428d31d 100644
Binary files a/dist/ansis/bulletin1.ans and b/dist/ansis/bulletin1.ans differ
diff --git a/dist/magicka.strings b/dist/magicka.strings
index ed34b46..dbe6de5 100644
--- a/dist/magicka.strings
+++ b/dist/magicka.strings
@@ -278,3 +278,9 @@ File exists!\r\n
\e[1;32mConference: \e[1;37m%d. %s\e[0m\r\n
\e[1;32m Area: \e[1;37m%d. %s \e[1;33m(%d New Messages)\e[0m\r\n\r\n
Read Now ? (Y / N):
+\e[1;33mSystem Blog\e[0m\r\n
+\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
+\e[0mNo Entries...\r\n
+\e[1;37m%s (by \e[1;36m%s\e[1;37m)\r\n
+\e[1;35m%d:%02d%s %s, %s %d %d\r\n
+\r\n\r\n\e[1;37mEnter a title:\e[0m
diff --git a/dist/scripts/login_stanza.lua b/dist/scripts/login_stanza.lua
index 27dc33b..153cff8 100644
--- a/dist/scripts/login_stanza.lua
+++ b/dist/scripts/login_stanza.lua
@@ -30,6 +30,9 @@ while(true) do
i = i + 1;
end
+-- Display Blog
+bbs_display_blog();
+
-- Display Info
local bbsname;
local sysopname;
diff --git a/dist/www-bootstrap/header.tpl b/dist/www-bootstrap/header.tpl
index 7ef68c6..a3c86d4 100644
--- a/dist/www-bootstrap/header.tpl
+++ b/dist/www-bootstrap/header.tpl
@@ -65,6 +65,9 @@
Home
+
+ News
+
Last 10 Callers
diff --git a/dist/www-bootstrap/static/style-mobile.css b/dist/www-bootstrap/static/style-mobile.css
index 9795987..d7a6f6c 100644
--- a/dist/www-bootstrap/static/style-mobile.css
+++ b/dist/www-bootstrap/static/style-mobile.css
@@ -354,6 +354,24 @@
max-width: 100%;
}
+.blog-header {
+ border: 1px solid #666666;
+ background-color: #eee;
+ padding: 5px;
+}
+
+.blog-date {
+ font-size: small;
+}
+
+.blog-author {
+ font-size: small;
+}
+
+.blog-entry {
+ padding: 25px;
+}
+
#msgbody {
background-color: black;
color: gray;
diff --git a/dist/www-bootstrap/static/style.css b/dist/www-bootstrap/static/style.css
index c622ff8..367919b 100644
--- a/dist/www-bootstrap/static/style.css
+++ b/dist/www-bootstrap/static/style.css
@@ -288,6 +288,25 @@
background-color: #111111;
}
+.blog-header {
+ border: 1px solid #666666;
+ background-color: #eee;
+ padding: 5px;
+}
+
+.blog-date {
+ float: right;
+ font-size: small;
+}
+
+.blog-author {
+ font-size: small;
+}
+
+.blog-entry {
+ padding: 25px;
+}
+
.last10-row {
background-color: #eee;
display: -webkit-box;
diff --git a/docs/docs/guide/menus.md b/docs/docs/guide/menus.md
index d090772..2082444 100644
--- a/docs/docs/guide/menus.md
+++ b/docs/docs/guide/menus.md
@@ -131,3 +131,7 @@ Finally, an optional SECLEVEL command indicates the required security level for
**NLBROWSER** Browse the nodelist for the current conference.
**SENDFEEDBACK** Send feedback to the Sysop.
+
+**BLOGDISPLAY** Display the System Blog.
+
+**BLOGWRITE** Add an entry to the System Blog.
\ No newline at end of file
diff --git a/docs/docs/guide/scripting.md b/docs/docs/guide/scripting.md
index 2000a8f..a7a486e 100644
--- a/docs/docs/guide/scripting.md
+++ b/docs/docs/guide/scripting.md
@@ -113,3 +113,5 @@ Where data is the name of the lua script to call without the extension.
**bbs_data_path** Returns a path for script data storage. This is shared with all scripts, so make sure your filenames are unique.
**bbs_user_security** Returns the current user's security level.
+
+**bbs_display_blog** Display the System Blog.
diff --git a/seabattle.sh b/seabattle.sh
new file mode 100755
index 0000000..d55d103
--- /dev/null
+++ b/seabattle.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cd /home/andrew/Projects/seabattle
+./SeaBattle -D /home/andrew/MagickaBBS/node$1/dorinfo1.def
+
diff --git a/src/Makefile.freebsd b/src/Makefile.freebsd
index 412f879..c352d24 100644
--- a/src/Makefile.freebsd
+++ b/src/Makefile.freebsd
@@ -29,7 +29,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-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 bluewave.o hashmap/hashmap.o menus.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.freebsd.WWW b/src/Makefile.freebsd.WWW
index c4864e4..348ac29 100644
--- a/src/Makefile.freebsd.WWW
+++ b/src/Makefile.freebsd.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_blog.o www_files.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.linux b/src/Makefile.linux
index 45e93af..1cd1313 100644
--- a/src/Makefile.linux
+++ b/src/Makefile.linux
@@ -30,7 +30,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-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 bluewave.o hashmap/hashmap.o menus.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.linux.WWW b/src/Makefile.linux.WWW
index 4010a2a..ca047e0 100644
--- a/src/Makefile.linux.WWW
+++ b/src/Makefile.linux.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 www_blog.o www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.netbsd b/src/Makefile.netbsd
index 781b4d7..44b5d76 100644
--- a/src/Makefile.netbsd
+++ b/src/Makefile.netbsd
@@ -29,7 +29,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-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 bluewave.o hashmap/hashmap.o menus.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.netbsd.WWW b/src/Makefile.netbsd.WWW
index b681baf..d5affef 100644
--- a/src/Makefile.netbsd.WWW
+++ b/src/Makefile.netbsd.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.openbsd b/src/Makefile.openbsd
index bfcccd8..9c0fbb2 100644
--- a/src/Makefile.openbsd
+++ b/src/Makefile.openbsd
@@ -29,7 +29,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-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 bluewave.o hashmap/hashmap.o menus.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.openbsd.WWW b/src/Makefile.openbsd.WWW
index 2a1fb21..047118d 100644
--- a/src/Makefile.openbsd.WWW
+++ b/src/Makefile.openbsd.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o www_blog.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.osx b/src/Makefile.osx
index 0aa7f59..49f0fa0 100644
--- a/src/Makefile.osx
+++ b/src/Makefile.osx
@@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
JSMN = ../deps/jsmn/libjsmn.a
CDK = ../deps/cdk-5-20161210/libcdk.a
-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 bluewave.o hashmap/hashmap.o menus.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
diff --git a/src/Makefile.osx.WWW b/src/Makefile.osx.WWW
index a1a69df..0d58ee0 100644
--- a/src/Makefile.osx.WWW
+++ b/src/Makefile.osx.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 www_files.o www_blog.o bluewave.o hashmap/hashmap.o menus.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.sunos b/src/Makefile.sunos
index c0205a4..928b8c9 100644
--- a/src/Makefile.sunos
+++ b/src/Makefile.sunos
@@ -30,7 +30,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-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 bluewave.o hashmap/hashmap.o menus.o os/sunos.o nodelist.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 bluewave.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/Makefile.sunos.WWW b/src/Makefile.sunos.WWW
index 13fa7b5..486ff5e 100644
--- a/src/Makefile.sunos.WWW
+++ b/src/Makefile.sunos.WWW
@@ -34,7 +34,7 @@ $(CDK):
cd ../deps/cdk-5.0-20161210/ && ./configure
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
-OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www_files.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o
+OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o 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 bluewave.o www_files.o www_blog.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o blog.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
diff --git a/src/bbs.c b/src/bbs.c
index 587e27e..83d0ec0 100644
--- a/src/bbs.c
+++ b/src/bbs.c
@@ -1108,8 +1108,8 @@ tryagain:
// bulletins
display_bulletins();
- // external login cmd
-
+ blog_display();
+
// display info
display_info();
diff --git a/src/bbs.h b/src/bbs.h
index b9fbe8b..8f82707 100644
--- a/src/bbs.h
+++ b/src/bbs.h
@@ -243,6 +243,13 @@ struct msg_headers {
int msg_count;
};
+struct blog_entry_t {
+ char *subject;
+ char *author;
+ char *body;
+ time_t date;
+};
+
extern char *str_replace(const char *orig, const char *rep, const char *with);
extern int copy_file(char *src, char *dest);
extern int recursive_delete(const char *dir);
@@ -377,9 +384,15 @@ extern char *www_sanitize(char *inp);
extern char *www_files_display_listing(int dir, int sub);
extern char *www_files_areas();
extern char *www_files_get_from_area(int dir, int sub, char *file);
+extern char *www_blog();
#endif
extern int menu_system(char *menufile);
extern char *nl_get_bbsname(struct fido_addr *addr, char *domain);
extern void nl_browser();
+
+extern void blog_display();
+extern void blog_write();
+extern int blog_load(struct blog_entry_t ***entries);
+
#endif
diff --git a/src/blog.c b/src/blog.c
new file mode 100644
index 0000000..443b63e
--- /dev/null
+++ b/src/blog.c
@@ -0,0 +1,247 @@
+#include
+#include
+#include
+#include "bbs.h"
+
+extern struct bbs_config conf;
+extern struct user_record *gUser;
+
+int blog_load(struct blog_entry_t ***entries) {
+ int blog_entry_count = 0;
+ struct blog_entry_t **blog_entries;
+ char *sql = "SELECT author, title, body, date FROM blog ORDER BY date DESC";
+
+ char buffer[PATH_MAX];
+ int rc;
+ sqlite3 *db;
+ sqlite3_stmt *res;
+
+ snprintf(buffer, PATH_MAX, "%s/blog.sq3", conf.bbs_path);
+
+ rc = sqlite3_open(buffer, &db);
+
+ if (rc != SQLITE_OK) {
+ dolog("Cannot open database: %s", sqlite3_errmsg(db));
+ *entries = NULL;
+ return 0;
+ }
+ sqlite3_busy_timeout(db, 5000);
+ rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);
+
+ if (rc != SQLITE_OK) {
+ dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
+ sqlite3_close(db);
+ *entries = NULL;
+ return 0;
+ }
+ while (sqlite3_step(res) == SQLITE_ROW) {
+ if (blog_entry_count == 0) {
+ blog_entries = (struct blog_entry_t **)malloc(sizeof(struct blog_entry_t *));
+ } else {
+ blog_entries = (struct blog_entry_t **)realloc(blog_entries, sizeof(struct blog_entry_t *) * (blog_entry_count + 1));
+ }
+ blog_entries[blog_entry_count] = (struct blog_entry_t *)malloc(sizeof(struct blog_entry_t));
+
+ blog_entries[blog_entry_count]->author = strdup(sqlite3_column_text(res, 0));
+ blog_entries[blog_entry_count]->subject = strdup(sqlite3_column_text(res, 1));
+ blog_entries[blog_entry_count]->body = strdup(sqlite3_column_text(res, 2));
+ blog_entries[blog_entry_count]->date = sqlite3_column_int(res, 3);
+ blog_entry_count++;
+ }
+
+ sqlite3_finalize(res);
+ sqlite3_close(db);
+
+ *entries = blog_entries;
+ return blog_entry_count;
+}
+
+void blog_display() {
+
+ struct blog_entry_t **blog_entries;
+ int blog_entry_count = 0;
+
+ int i;
+ struct tm thetime;
+ char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"};
+ char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"};
+ char c;
+
+ int j;
+ int lines = 2;
+ s_printf("\e[2J\e[1;1H");
+ s_printf(get_string(280));
+ s_printf(get_string(281));
+
+ blog_entry_count = blog_load(&blog_entries);
+ if (blog_entry_count == 0) {
+ s_printf(get_string(282));
+ s_printf(get_string(6));
+ s_getchar();
+ return;
+ }
+
+ c = 'y';
+
+ for (i=0;idate, &thetime);
+
+ s_printf(get_string(283), blog_entries[i]->subject, blog_entries[i]->author);
+ lines++;
+ if (lines == 22 && tolower(c) != 'c') {
+ s_printf("\r\n");
+ s_printf(get_string(223));
+ c = s_getchar();
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n\r\n");
+ lines = 0;
+ }
+
+ s_printf(get_string(284), (thetime.tm_hour - 12 == 0 ? 12 : thetime.tm_hour - 12), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900);
+
+ lines++;
+ if (lines == 22 && tolower(c) != 'c') {
+ s_printf("\r\n");
+ s_printf(get_string(223));
+ c = s_getchar();
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n\r\n");
+ lines = 0;
+ }
+
+ s_printf("\r\n\e[0m");
+ lines++;
+ if (lines == 22 && tolower(c) != 'c') {
+ s_printf("\r\n");
+ s_printf(get_string(223));
+ c = s_getchar();
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n\r\n");
+ lines = 0;
+ }
+ for (j=0; jbody); j++) {
+ if (blog_entries[i]->body[j] == '\r') {
+ s_printf("\r\n");
+ lines++;
+ if (lines == 22 && tolower(c) != 'c') {
+ s_printf("\r\n");
+ s_printf(get_string(223));
+ c = s_getchar();
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n\r\n");
+ lines = 0;
+ }
+ } else {
+ s_printf("%c", blog_entries[i]->body[j]);
+ }
+ }
+
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n");
+ lines++;
+ if (lines == 22 && tolower(c) != 'c') {
+ s_printf("\r\n");
+ s_printf(get_string(223));
+ c = s_getchar();
+ if (tolower(c) == 'n') {
+ break;
+ }
+ s_printf("\r\n\r\n");
+ lines = 0;
+ }
+ }
+ for (i=0;isubject);
+ free(blog_entries[i]->author);
+ free(blog_entries[i]->body);
+ free(blog_entries[i]);
+ }
+
+ free(blog_entries);
+
+ s_printf(get_string(6));
+ s_getchar();
+
+}
+
+void blog_write() {
+ char *csql = "CREATE TABLE IF NOT EXISTS blog ("
+ "id INTEGER PRIMARY KEY,"
+ "author TEXT COLLATE NOCASE,"
+ "title TEXT,"
+ "body TEXT,"
+ "date INTEGER);";
+
+ char *isql = "INSERT INTO blog (author, title, body, date) VALUES(?, ?, ?, ?)";
+ int rc;
+ sqlite3 *db;
+ sqlite3_stmt *res;
+ char *blog_entry;
+ char buffer[PATH_MAX];
+ char *blog_subject;
+ char *err_msg = 0;
+
+ s_printf(get_string(285));
+ s_readstring(buffer, 64);
+ s_printf("\r\n");
+
+ blog_subject = strdup(buffer);
+
+ blog_entry = external_editor(gUser, "No-One", "No-One", NULL, 0, "No-One", "Blog Editor", 0, 1);
+
+ if (blog_entry != NULL) {
+ snprintf(buffer, PATH_MAX, "%s/blog.sq3", conf.bbs_path);
+ rc = sqlite3_open(buffer, &db);
+
+ if (rc != SQLITE_OK) {
+ dolog("Cannot open database: %s", sqlite3_errmsg(db));
+ free(blog_entry);
+ free(blog_subject);
+ return;
+ }
+ sqlite3_busy_timeout(db, 5000);
+ rc = sqlite3_exec(db, csql, 0, 0, &err_msg);
+ if (rc != SQLITE_OK ) {
+ dolog("SQL error: %s", err_msg);
+ sqlite3_free(err_msg);
+ sqlite3_close(db);
+ free(blog_entry);
+ free(blog_subject);
+ return;
+ }
+
+ rc = sqlite3_prepare_v2(db, isql, -1, &res, 0);
+
+ if (rc == SQLITE_OK) {
+ sqlite3_bind_text(res, 1, gUser->loginname, -1, 0);
+ sqlite3_bind_text(res, 2, blog_subject, -1, 0);
+ sqlite3_bind_text(res, 3, blog_entry, -1, 0);
+ sqlite3_bind_int(res, 4, time(NULL));
+ } else {
+ dolog("Failed to execute statement: %s", sqlite3_errmsg(db));
+ sqlite3_finalize(res);
+ sqlite3_close(db);
+ free(blog_entry);
+ free(blog_subject);
+ return;
+ }
+ sqlite3_step(res);
+
+ sqlite3_finalize(res);
+ sqlite3_close(db);
+ free(blog_entry);
+ free(blog_subject);
+ return;
+ }
+ free(blog_subject);
+}
\ No newline at end of file
diff --git a/src/lua_glue.c b/src/lua_glue.c
index 8808b31..8ead90b 100644
--- a/src/lua_glue.c
+++ b/src/lua_glue.c
@@ -21,6 +21,12 @@ int l_bbsWString(lua_State *L) {
return 0;
}
+int l_displayBlog(lua_State *L) {
+ blog_display();
+
+ return 0;
+}
+
int l_bbsRString(lua_State *L) {
char buffer[256];
int len = lua_tonumber(L, -1);
@@ -615,7 +621,9 @@ void lua_push_cfunctions(lua_State *L) {
lua_pushcfunction(L, l_userSecurity);
lua_setglobal(L, "bbs_user_security");
lua_pushcfunction(L, l_bbsPersonalMailScan);
- lua_setglobal(L, "bbs_personal_mail_scan");
+ lua_setglobal(L, "bbs_personal_mail_scan");
+ lua_pushcfunction(L, l_displayBlog);
+ lua_setglobal(L, "bbs_display_blog");
}
void do_lua_script(char *script) {
diff --git a/src/menus.c b/src/menus.c
index 72499c3..d66cfe5 100644
--- a/src/menus.c
+++ b/src/menus.c
@@ -57,6 +57,8 @@
#define MENU_GENWWWURLS 47
#define MENU_NLBROWSER 48
#define MENU_SENDFEEDBACK 49
+#define MENU_BLOGDISPLAY 50
+#define MENU_BLOGWRITE 51
extern struct bbs_config conf;
extern struct user_record *gUser;
@@ -225,6 +227,10 @@ int menu_system(char *menufile) {
menu[menu_items-1]->command = MENU_NLBROWSER;
} else if (strncasecmp(&buffer[8], "SENDFEEDBACK", 12) == 0) {
menu[menu_items-1]->command = MENU_SENDFEEDBACK;
+ } else if (strncasecmp(&buffer[8], "BLOGDISPLAY", 11) == 0) {
+ menu[menu_items-1]->command = MENU_BLOGDISPLAY;
+ } else if (strncasecmp(&buffer[8], "BLOGWRITE", 9) == 0) {
+ menu[menu_items-1]->command = MENU_BLOGWRITE;
}
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
menu[menu_items-1]->seclevel = atoi(&buffer[9]);
@@ -586,6 +592,12 @@ int menu_system(char *menufile) {
free(msg);
}
break;
+ case MENU_BLOGDISPLAY:
+ blog_display();
+ break;
+ case MENU_BLOGWRITE:
+ blog_write();
+ break;
default:
break;
}
diff --git a/src/www.c b/src/www.c
index 11b3763..4cbe0a2 100644
--- a/src/www.c
+++ b/src/www.c
@@ -576,6 +576,16 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
sprintf(whole_page, "%s%s%s", header, page, footer);
+ } else if (strcasecmp(url, "/blog") == 0 || strcasecmp(url, "/blog/") == 0) {
+ page = www_blog();
+ 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);
} else if (strcasecmp(url, "/email/") == 0 || strcasecmp(url, "/email") == 0) {
con_inf->user = www_auth_ok(connection, url_);
diff --git a/src/www_blog.c b/src/www_blog.c
new file mode 100644
index 0000000..e914ca3
--- /dev/null
+++ b/src/www_blog.c
@@ -0,0 +1,98 @@
+#if defined(ENABLE_WWW)
+
+#include
+#include
+#include
+#include "bbs.h"
+
+
+extern struct bbs_config conf;
+
+char *www_blog() {
+ char *page;
+ int max_len;
+ int len;
+ char buffer[4096];
+
+ struct blog_entry_t **blog_entries;
+ int blog_entry_count = 0;
+ int i, j;
+ struct tm thetime;
+
+ char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "???"};
+ char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "???"};
+
+ page = (char *)malloc(4096);
+ max_len = 4096;
+ len = 0;
+ memset(page, 0, 4096);
+
+ sprintf(buffer, "\n");
+ if (len + strlen(buffer) > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ strcat(page, buffer);
+ len += strlen(buffer);
+
+ blog_entry_count = blog_load(&blog_entries);
+
+ if (blog_entry_count == 0) {
+ sprintf(buffer, "No Entries
\n");
+ if (len + strlen(buffer) > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ strcat(page, buffer);
+ len += strlen(buffer);
+ } else {
+ for (i=0;idate, &thetime);
+ sprintf(buffer, "", blog_entries[i]->subject,(thetime.tm_hour - 12 == 0 ? 12 : thetime.tm_hour - 12), thetime.tm_min, (thetime.tm_hour >= 12 ? "pm" : "am"), days[thetime.tm_wday], months[thetime.tm_mon], thetime.tm_mday, thetime.tm_year + 1900, blog_entries[i]->author);
+ if (len + strlen(buffer) > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ strcat(page, buffer);
+ len += strlen(buffer);
+
+ sprintf(buffer, "");
+ if (len + strlen(buffer) > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ strcat(page, buffer);
+ len += strlen(buffer);
+
+ for (j=0;jbody);j++) {
+ if (blog_entries[i]->body[j] == '\r') {
+ sprintf(buffer, "
");
+ if (len + strlen(buffer) > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ strcat(page, buffer);
+ len += strlen(buffer);
+ } else {
+ if (len + 1 > max_len - 1) {
+ max_len += 4096;
+ page = (char *)realloc(page, max_len);
+ }
+ page[len++] = blog_entries[i]->body[j];
+ page[len] = '\0';
+ }
+ }
+ sprintf(buffer, "
");
+ 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
\ No newline at end of file