From 02f46793878c5d3186282adcce0f0a7bb855ca39 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 7 Feb 2018 20:38:25 +1000 Subject: [PATCH] Send feedback menu option --- dist/ansis/logoff.ans | Bin 599 -> 710 bytes dist/ansis/mainmenu.ans | Bin 1348 -> 1404 bytes dist/menus/logoff.mnu | 3 ++ dist/menus/main.mnu | 3 ++ docs/docs/guide/menus.md | 4 +- src/bbs.h | 1 + src/email.c | 110 +++++++++++++++++++++------------------ src/menus.c | 14 +++++ 8 files changed, 82 insertions(+), 53 deletions(-) diff --git a/dist/ansis/logoff.ans b/dist/ansis/logoff.ans index 68bb9bf70497f1ad86241efac14a6713701192a8..5570abd14cf2cd0f9116cb42940b75fc07c06eb5 100644 GIT binary patch literal 710 zcmb`E&q@O^5XQG2SN7!1T*iBm>>qcLJ=M}m!4_euP;y#rM36M%u1Md{x5&W0ij%CC z+ARgeFT;>Y^8GR-Oz=G6d7P=hXCfOi5$18M(2$S`u9%1}+tpMV06=u9-AccA>?$^G zpe0%3hGqzdW)F>khK3E7s6ZP8>OdNUXqsI}gU}$|Ovyo9@kOLY0GNmq_3=wtSE?-c zkUj8sn!Hd8I?vU)6HPOI@-|M*f{sjZ6LTK9c^R@6fri-y{(|2aOVz~ zkd8KU1~Kp4hoCz!jX-U;f%@*;hH9Hwp(+A05Ga2C_MJPo@599Rwz7c4C;KoOKp1U| YdXwKVZsNSg$iTqJ7{I_ac_ou90M_|Bm;e9( diff --git a/dist/ansis/mainmenu.ans b/dist/ansis/mainmenu.ans index dabf0cf097cda9f18cb92a77b72395210b7c13d3..8d0f1a46bdd4aeae71d8a88f8c9bd31c0bfa8ba0 100644 GIT binary patch delta 74 zcmX@Y^@nSN0gHunv_Yloginname, -1, 0); + sqlite3_bind_text(res, 2, recipient, -1, 0); + sqlite3_bind_text(res, 3, subject, -1, 0); + sqlite3_bind_text(res, 4, msg, -1, 0); + sqlite3_bind_int(res, 5, time(NULL)); + } else { + dolog("Failed to execute statement: %s", sqlite3_errmsg(db)); + sqlite3_finalize(res); + sqlite3_close(db); + return; + } + sqlite3_step(res); + + sqlite3_finalize(res); + sqlite3_close(db); +} + +void send_email(struct user_record *user) { + char buffer[26]; + + char *recipient; + char *subject; + char *msg; + s_printf(get_string(54)); s_readstring(buffer, 16); @@ -62,48 +109,7 @@ void send_email(struct user_record *user) { msg = external_editor(user, user->loginname, recipient, NULL, 0, NULL, subject, 1, 0); if (msg != NULL) { - sprintf(buffer, "%s/email.sq3", conf.bbs_path); - - rc = sqlite3_open(buffer, &db); - - if (rc != SQLITE_OK) { - dolog("Cannot open database: %s", sqlite3_errmsg(db)); - sqlite3_close(db); - - exit(1); - } - 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); - - return; - } - - rc = sqlite3_prepare_v2(db, isql, -1, &res, 0); - - if (rc == SQLITE_OK) { - sqlite3_bind_text(res, 1, user->loginname, -1, 0); - sqlite3_bind_text(res, 2, recipient, -1, 0); - sqlite3_bind_text(res, 3, subject, -1, 0); - sqlite3_bind_text(res, 4, msg, -1, 0); - sqlite3_bind_int(res, 5, time(NULL)); - } else { - dolog("Failed to execute statement: %s", sqlite3_errmsg(db)); - sqlite3_finalize(res); - sqlite3_close(db); - s_printf("\r\nNo such email\r\n"); - return; - } - sqlite3_step(res); - - sqlite3_finalize(res); - sqlite3_close(db); + commit_email(recipient, subject, msg); free(msg); } free(subject); diff --git a/src/menus.c b/src/menus.c index f2ba1d9..68dc8c6 100644 --- a/src/menus.c +++ b/src/menus.c @@ -56,6 +56,7 @@ #define MENU_DISPTXTFILEPAUSE 46 #define MENU_GENWWWURLS 47 #define MENU_NLBROWSER 48 +#define MENU_SENDFEEDBACK 49 extern struct bbs_config conf; extern struct user_record *gUser; @@ -87,6 +88,7 @@ int menu_system(char *menufile) { char c; int clearscreen = 0; char confirm; + char *msg; dolog("%s is loading menu: %s", gUser->loginname, menufile); @@ -221,6 +223,8 @@ int menu_system(char *menufile) { menu[menu_items-1]->command = MENU_GENWWWURLS; } else if (strncasecmp(&buffer[8], "NLBROWSER", 9) == 0) { 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, "SECLEVEL", 8) == 0) { menu[menu_items-1]->seclevel = atoi(&buffer[9]); @@ -564,6 +568,16 @@ int menu_system(char *menufile) { case MENU_NLBROWSER: nl_browser(); break; + case MENU_SENDFEEDBACK: + if (check_user(conf.sysop_name)) { + break; + } + msg = external_editor(gUser, conf.sysop_name, gUser->loginname, NULL, 0, NULL, "Feedback", 1, 0); + if (msg != NULL) { + commit_email(conf.sysop_name, "Feedback", msg); + free(msg); + } + break; default: break; }