summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-16 21:22:58 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-16 21:22:58 +0800
commit5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b (patch)
tree433c1e503559c7b59edcbcb4e16679244ea26212
parent3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a (diff)
downloadpttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar.gz
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar.bz2
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar.lz
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar.xz
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.tar.zst
pttbbs-5b8ae2c4d6f73e6c762534586f8e86a0bc54de2b.zip
- bbs: allow local mail for web based tarqueue
- bbslua: unbind file api, add bbs.kball(), reduce kbhit min peek time - annouce: prevent deep directory crash - edit: syntax highlight update - pttbbs.conf: add ASKBOARD into default fav git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3838 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/announce.c13
-rw-r--r--mbbsd/bbs.c16
-rw-r--r--mbbsd/bbslua.c81
-rw-r--r--mbbsd/edit.c10
-rw-r--r--mbbsd/pmore.c8
-rw-r--r--sample/pttbbs.conf2
6 files changed, 96 insertions, 34 deletions
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 780525b8..0f4aecd6 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -399,6 +399,8 @@ a_newitem(menu_t * pm, int mode)
fileheader_t item;
strlcpy(fpath, pm->path, sizeof(fpath));
+ if (strlen(pm->path) + FNLEN*2 >= PATHLEN)
+ return;
switch (mode) {
case ADDITEM:
@@ -631,7 +633,7 @@ a_pastetagpost(menu_t * pm, int mode)
boardheader_t *bh = NULL;
int ans = 0, ent = 0, tagnum;
char title[TTLEN + 1] = "◇ ";
- char dirname[200], buf[200];
+ char dirname[PATHLEN], buf[PATHLEN];
if (TagBoard == 0){
sethomedir(dirname, cuser.userid);
@@ -1015,6 +1017,13 @@ a_menu(const char *maintitle, const char *path,
char fname[PATHLEN];
int ch, returnvalue = FULLUPDATE;
+ // prevent deep resursive directories
+ if (strlen(path) + FNLEN >= PATHLEN)
+ {
+ // it is not save to enter such directory.
+ return returnvalue;
+ }
+
if(trans_buffer)
trans_buffer[0] = '\0';
@@ -1135,7 +1144,7 @@ a_menu(const char *maintitle, const char *path,
# endif // GLOBAL_BBSMOVIE
if (vedit2(fname, NA, NULL, edflags) != -1) {
- char fpath[200];
+ char fpath[PATHLEN];
fileheader_t fhdr;
strlcpy(fpath, path, sizeof(fpath));
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index 5ad31a9f..662708e9 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -3296,6 +3296,19 @@ tar_addqueue(void)
pressanykey();
return FULLUPDATE;
}
+#ifdef TARQUEUE_SENDURL
+ move (3,0); outs("請輸入通知信箱 (預設為此 BBS 帳號信箱): ");
+ if (!getdata_str(4, 2, "",
+ email, sizeof(email), DOECHO, cuser.userid))
+ return FULLUPDATE;
+ if (strstr(email, "@") == NULL)
+ {
+ strcat(email, ".bbs@");
+ strcat(email, MYHOSTNAME);
+ }
+ move(4,0); clrtoeol();
+ outs(email);
+#else
if (!getdata(4, 0, "請輸入目的信箱:", email, sizeof(email), DOECHO))
return FULLUPDATE;
@@ -3306,6 +3319,7 @@ tar_addqueue(void)
pressanykey();
return FULLUPDATE;
}
+#endif
getdata(6, 0, "要備份看板內容嗎(Y/N)?[Y]", ans, sizeof(ans), LCECHO);
bakboard = (ans[0] == 'n' || ans[0] == 'N') ? 0 : 1;
getdata(7, 0, "要備份精華區內容嗎(Y/N)?[N]", ans, sizeof(ans), LCECHO);
@@ -3593,7 +3607,7 @@ int check_cooldown(boardheader_t *bp)
for(i=0; i<4; i++)
if(bp->nuser>limit[i*2] && posttimesof(usernum)>=limit[i*2+1])
{
- vmsgf("對不起,您的文章或推文太水囉! (限制 %d 分 %d 秒)",
+ vmsgf("對不起,您的文章或推文間隔太近囉! (限制 %d 分 %d 秒)",
diff/60, diff%60);
return 1;
}
diff --git a/mbbsd/bbslua.c b/mbbsd/bbslua.c
index 2da3e0b3..d22e0b4d 100644
--- a/mbbsd/bbslua.c
+++ b/mbbsd/bbslua.c
@@ -64,7 +64,7 @@
// CONST DEFINITION
//////////////////////////////////////////////////////////////////////////
-#define BBSLUA_INTERFACE_VER (0.117)
+#define BBSLUA_INTERFACE_VER (0.118)
#define BBSLUA_SIGNATURE "--#BBSLUA"
// BBS-Lua script format:
@@ -87,7 +87,7 @@
#define BLCONF_BREAK_KEY Ctrl('C')
#define BLCONF_EXEC_COUNT (5000)
#define BLCONF_PEEK_TIME (0.01)
-#define BLCONF_KBHIT_TMIN (0.05f)
+#define BLCONF_KBHIT_TMIN (BLCONF_PEEK_TIME)
#define BLCONF_KBHIT_TMAX (60*10)
#define BLCONF_SLEEP_TMIN (BLCONF_PEEK_TIME)
#define BLCONF_SLEEP_TMAX (BLCONF_KBHIT_TMAX)
@@ -127,7 +127,21 @@ bl_tv2double(const struct timeval *tv)
return d;
}
-void
+static int
+bl_peekbreak(float f)
+{
+ if (input_isfull())
+ drop_input();
+ if (peek_input(f, BLCONF_BREAK_KEY))
+ {
+ drop_input();
+ abortBBSLua = 1;
+ return 1;
+ }
+ return 0;
+}
+
+static void
bl_k2s(lua_State* L, int v)
{
if (v <= 0)
@@ -414,12 +428,8 @@ BLAPI_PROTO
bl_kbreset(lua_State *L)
{
// peek input queue first!
- if (peek_input(BLCONF_PEEK_TIME, BLCONF_BREAK_KEY))
- {
- drop_input();
- abortBBSLua = 1;
+ if (bl_peekbreak(BLCONF_PEEK_TIME))
return lua_yield(L, 0);
- }
drop_input();
return 0;
@@ -431,16 +441,15 @@ bl_sleep(lua_State *L)
int n = lua_gettop(L);
double us = 0, nus = 0;
+ // update screen first.
+ bl_refresh(L);
+
if (n > 0)
us = lua_tonumber(L, 1);
- if (us < BLCONF_SLEEP_TMIN)
- us = BLCONF_SLEEP_TMIN;
- if (us > BLCONF_SLEEP_TMAX)
- us = BLCONF_SLEEP_TMAX;
+ if (us < BLCONF_SLEEP_TMIN) us = BLCONF_SLEEP_TMIN;
+ if (us > BLCONF_SLEEP_TMAX) us = BLCONF_SLEEP_TMAX;
nus = us;
- refresh();
-
#ifdef _WIN32
Sleep(us * 1000);
@@ -455,7 +464,6 @@ bl_sleep(lua_State *L)
nus = bl_tv2double(&tp) + us;
bl_double2tv(nus, &tdest);
- // use peek_input
while ( (tp.tv_sec < tdest.tv_sec) ||
((tp.tv_sec == tdest.tv_sec) && (tp.tv_usec < tdest.tv_usec)))
{
@@ -463,12 +471,8 @@ bl_sleep(lua_State *L)
us = nus - bl_tv2double(&tp);
// check if input key is system break key.
- if (peek_input(us, BLCONF_BREAK_KEY))
- {
- drop_input();
- abortBBSLua = 1;
+ if (bl_peekbreak(us))
return lua_yield(L, 0);
- }
// check time
gettimeofday(&tp, NULL);
@@ -479,6 +483,34 @@ bl_sleep(lua_State *L)
return 0;
}
+BLAPI_PROTO
+bl_kball(lua_State *L)
+{
+ // first, sleep by given seconds
+ int r = 0, oldr = 0, i = 0;
+
+ r = bl_sleep(L);
+
+ if (abortBBSLua)
+ return r;
+
+ // next, collect all input and return.
+ if (num_in_buf() < 1)
+ return 0;
+
+ lua_newtable(L);
+ oldr = num_in_buf() +1;
+ i = 0;
+
+ while ((r = num_in_buf()) > 0 && oldr > r)
+ {
+ oldr = r;
+ bl_k2s(L, igetch());
+ i++;
+ }
+ return i;
+}
+
BLAPI_PROTO
bl_pause(lua_State* L)
@@ -649,6 +681,7 @@ static const struct luaL_reg lib_bbslua [] = {
{ "getstr", bl_getstr },
{ "kbhit", bl_kbhit },
{ "kbreset", bl_kbreset },
+ { "kball", bl_kball },
/* advanced output */
{ "rect", bl_rect },
/* BBS utilities */
@@ -749,6 +782,10 @@ bbsluaRegConst(lua_State *L, const char *globName)
// global
lua_pushcfunction(L, bl_print);
lua_setglobal(L, "print");
+
+ // unbind unsafe API
+ lua_pushnil(L); lua_setglobal(L, "dofile");
+ lua_pushnil(L); lua_setglobal(L, "loadfile");
}
static void
@@ -772,10 +809,8 @@ bbsluaHook(lua_State *L, lua_Debug* ar)
// refresh();
// check if input key is system break key.
- if (peek_input(BLCONF_PEEK_TIME, BLCONF_BREAK_KEY))
+ if (bl_peekbreak(BLCONF_PEEK_TIME))
{
- drop_input();
- abortBBSLua = 1;
lua_yield(L, 0);
return;
}
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 763b1b6a..60c719fc 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -2076,9 +2076,9 @@ static const char *luaString[] = {
static const char *luaBbs[] = {
"ANSI_COLOR", "ANSI_RESET", "ESC", "addstr", "clear", "clock",
- "clrtobot", "clrtoeol", "color", "ctime", "getch", "getdata",
- "getmaxyx", "getstr", "getyx", "interface", "kbhit", "kbreset", "move",
- "moverel", "now", "outs", "pause", "print", "rect", "refresh",
+ "clrtobot", "clrtoeol", "color", "ctime", "getch","getdata",
+ "getmaxyx", "getstr", "getyx", "interface", "kball", "kbhit", "kbreset",
+ "move", "moverel", "now", "outs", "pause", "print", "rect", "refresh",
"setattr", "sitename", "sleep", "strip_ansi", "time", "title", "userid",
NULL
};
@@ -2511,7 +2511,9 @@ detect_attr(const char *ps, size_t len)
if (!curr_buf->synparser)
{
curr_buf->synparser = 1;
- curr_buf->indent_mode = 1;
+ // if you need indent, toggle by hotkey.
+ // enabling indent by default may cause trouble to copy pasters
+ // curr_buf->indent_mode = 1;
}
}
#endif
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index 4f5af25b..00093410 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -14,10 +14,10 @@
*
* Copyright(c) 2005-2008 Hung-Te Lin <piaip@csie.ntu.edu.tw>
* All Rights Reserved.
- * You are free to use, modify, redistribute this program
- * in any non-commercial usage (including network service).
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * You are free to use, modify, redistribute this program in any
+ * non-commercial usage (including network service).
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
*
* MAJOR IMPROVEMENTS:
* - Clean source code, and more readable for mortal
diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf
index 917c35bc..502e1e87 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -51,6 +51,8 @@
#define GLOBAL_LAW BBSMNAME "Law"
/* 新手板(會自動進我的最愛) */
#define GLOBAL_NEWBIE BBSMNAME "NewHand"
+/* 找看板(會自動進我的最愛) */
+#define GLOBAL_ASKBOARD "AskBoard"
/* 外國板 */
#define GLOBAL_FOREIGN BBSMNAME "Foreign"