some more lua functionality
This commit is contained in:
parent
23f73405ae
commit
8935b660ec
2
dist/scripts/mainmenu.lua
vendored
2
dist/scripts/mainmenu.lua
vendored
@ -20,7 +20,7 @@ function menu()
|
|||||||
|
|
||||||
-- display tagline
|
-- display tagline
|
||||||
|
|
||||||
local tLines = readLines("scripts/taglines.txt");
|
local tLines = readLines(bbs_data_path() .. "taglines.txt");
|
||||||
|
|
||||||
local rand = math.random(#tLines);
|
local rand = math.random(#tLines);
|
||||||
|
|
||||||
|
20
src/bbs.c
20
src/bbs.c
@ -689,7 +689,7 @@ void automessage_display() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void runbbs_real(int socket, char *ip, int ssh) {
|
void runbbs_real(int socket, char *ip, int ssh) {
|
||||||
char buffer[1024];
|
char buffer[PATH_MAX];
|
||||||
char password[17];
|
char password[17];
|
||||||
|
|
||||||
struct stat s;
|
struct stat s;
|
||||||
@ -878,7 +878,7 @@ tryagain:
|
|||||||
user = gUser;
|
user = gUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, mynode);
|
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, mynode);
|
||||||
nodefile = fopen(buffer, "w");
|
nodefile = fopen(buffer, "w");
|
||||||
if (!nodefile) {
|
if (!nodefile) {
|
||||||
dolog("Error opening nodefile!");
|
dolog("Error opening nodefile!");
|
||||||
@ -889,15 +889,25 @@ tryagain:
|
|||||||
fputs(user->loginname, nodefile);
|
fputs(user->loginname, nodefile);
|
||||||
fclose(nodefile);
|
fclose(nodefile);
|
||||||
|
|
||||||
sprintf(buffer, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
snprintf(buffer, PATH_MAX, "%s/node%d/nodemsg.txt", conf.bbs_path, mynode);
|
||||||
|
|
||||||
if (stat(buffer, &s) == 0) {
|
if (stat(buffer, &s) == 0) {
|
||||||
unlink(buffer);
|
unlink(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(buffer, PATH_MAX, "%s/node%d/lua/", conf.bbs_path, mynode);
|
||||||
|
|
||||||
|
if (stat(buffer, &s) == 0) {
|
||||||
|
recursive_delete(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(ENABLE_WWW)
|
#if defined(ENABLE_WWW)
|
||||||
www_expire_old_links();
|
www_expire_old_links();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// do post-login
|
// do post-login
|
||||||
dolog("%s logged in, on node %d", user->loginname, mynode);
|
dolog("%s logged in, on node %d", user->loginname, mynode);
|
||||||
broadcast("%s logged in, on node %d", user->loginname, mynode);
|
broadcast("%s logged in, on node %d", user->loginname, mynode);
|
||||||
@ -918,7 +928,7 @@ tryagain:
|
|||||||
|
|
||||||
|
|
||||||
if (conf.script_path != NULL) {
|
if (conf.script_path != NULL) {
|
||||||
sprintf(buffer, "%s/login_stanza.lua", conf.script_path);
|
snprintf(buffer, PATH_MAX, "%s/login_stanza.lua", conf.script_path);
|
||||||
if (stat(buffer, &s) == 0) {
|
if (stat(buffer, &s) == 0) {
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
@ -980,7 +990,7 @@ void do_logout() {
|
|||||||
int do_internal_logout = 1;
|
int do_internal_logout = 1;
|
||||||
|
|
||||||
if (conf.script_path != NULL) {
|
if (conf.script_path != NULL) {
|
||||||
sprintf(buffer, "%s/logout_stanza.lua", conf.script_path);
|
snprintf(buffer, PATH_MAX, "%s/logout_stanza.lua", conf.script_path);
|
||||||
if (stat(buffer, &s) == 0) {
|
if (stat(buffer, &s) == 0) {
|
||||||
L = luaL_newstate();
|
L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
@ -336,6 +336,20 @@ int l_readMessage(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_dataPath(lua_State *L) {
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
struct stat s;
|
||||||
|
snprintf(buffer, PATH_MAX, "%s/data/", conf.script_path);
|
||||||
|
|
||||||
|
if (stat(buffer, &s) != 0) {
|
||||||
|
mkdir(buffer, 0755);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pushstring(L, buffer);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int l_tempPath(lua_State *L) {
|
int l_tempPath(lua_State *L) {
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
struct stat s;
|
struct stat s;
|
||||||
@ -350,6 +364,11 @@ int l_tempPath(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int l_userSecurity(lua_State *L) {
|
||||||
|
lua_pushnumber(L, gUser->sec_level);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int l_postMessage(lua_State *L) {
|
int l_postMessage(lua_State *L) {
|
||||||
int confr = lua_tointeger(L, 1);
|
int confr = lua_tointeger(L, 1);
|
||||||
int area = lua_tointeger(L, 2);
|
int area = lua_tointeger(L, 2);
|
||||||
@ -576,6 +595,10 @@ void lua_push_cfunctions(lua_State *L) {
|
|||||||
lua_setglobal(L, "bbs_temp_path");
|
lua_setglobal(L, "bbs_temp_path");
|
||||||
lua_pushcfunction(L, l_postMessage);
|
lua_pushcfunction(L, l_postMessage);
|
||||||
lua_setglobal(L, "bbs_post_message");
|
lua_setglobal(L, "bbs_post_message");
|
||||||
|
lua_pushcfunction(L, l_dataPath);
|
||||||
|
lua_setglobal(L, "bbs_data_path");
|
||||||
|
lua_pushcfunction(L, l_userSecurity);
|
||||||
|
lua_setglobal(L, "bbs_user_security");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_lua_script(char *script) {
|
void do_lua_script(char *script) {
|
||||||
|
Reference in New Issue
Block a user