commit
904efbac5a
3
.gitignore
vendored
3
.gitignore
vendored
@ -80,3 +80,6 @@ core
|
||||
docs/site
|
||||
utils/reset_pass/reset_pass
|
||||
.vscode
|
||||
last10v2.dat
|
||||
utils/filecenter/filecenter
|
||||
utils/dosbox_shim/shim
|
||||
|
8
.gitlab-ci.yml
Normal file
8
.gitlab-ci.yml
Normal file
@ -0,0 +1,8 @@
|
||||
image: gcc
|
||||
|
||||
before_script:
|
||||
- apt-get update -qq && apt-get install -y -qq build-essential libsqlite3-dev libreadline-dev git libssh-dev libssl1.0-dev libncurses5-dev libmicrohttpd-dev libdbd-sqlite3-perl sed
|
||||
|
||||
magicka:
|
||||
script:
|
||||
- make www
|
@ -4,6 +4,88 @@ If you are using your own custom strings file, you will need
|
||||
to add / modify the new string on the line specified. Be sure
|
||||
to remove the start and end quotation marks.
|
||||
|
||||
Changes from v0.9-alpha -> v0.10-alpha
|
||||
--------------------------------------------------------------
|
||||
|
||||
LINE: 275 NEW
|
||||
OLDSTRING: (NONE)
|
||||
NEWSTRING: "\r\n\e[1;31mError executing archiver.\r\n\e[0m"
|
||||
|
||||
LINE: 276 NEW
|
||||
OLDSTRING: (NONE)
|
||||
NEWSTRING: "\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m"
|
||||
|
||||
LINE: 204 MODIFIED
|
||||
OLDSTRING: "\e[1;31mUser not found! Assuming new user...\e[0m\r\n\r\n"
|
||||
NEWSTRING: "\r\n\e[1;31mUser not found!\e[0m\r\n\r\n"
|
||||
|
||||
LINE: 277 NEW
|
||||
OLDSTRING: (NONE)
|
||||
NEWSTRING: "\r\nScan for new personal mail? (Y/N/S): "
|
||||
|
||||
LINE: 278 NEW
|
||||
OLDSTRING: (NONE)
|
||||
NEWSTRING: "\e[1;32mConference: \e[1;37m%d. %s\e[0m\r\n"
|
||||
|
||||
LINE: 279 NEW
|
||||
OLDSTRING: (NONE)
|
||||
NEWSTRING: "\e[1;32m Area: \e[1;37m%d. %s \e[1;33m(%d New Messages)\e[0m\r\n\r\n"
|
||||
|
||||
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"
|
||||
|
||||
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 "
|
||||
|
||||
LINE 128 MODIFIED
|
||||
OLDSTRING: "\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
NEWSTRING: "\e[1;30m[\e[1;34m%5d\e[1;30m]\e[1;32m*\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
|
||||
LINE 129 MODIFIED
|
||||
OLDSTRING: "\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
NEWSTRING: "\e[1;30m[\e[1;34m%5d\e[1;30m] \e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
|
||||
LINE 189 MODIFIED
|
||||
OLDSTRING: "\e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
NEWSTRING: "\e[1;30m[\e[1;34;44m%5d\e[1;30;40m]\e[1;32m*\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
|
||||
LINE 190 MODIFIED
|
||||
OLDSTRING: "\e[1;30m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
NEWSTRING: "\e[1;30m[\e[1;34;44m%5d\e[1;30;40m] \e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n"
|
||||
|
||||
LINE 115 MODIFIED
|
||||
OLDSTRING: "\r\n\r\nReplying to: %s\r\n"
|
||||
NEWSTRING: "\r\n\r\n\e[1;32m To: \e[0m"
|
||||
|
||||
LINE 116 MODIFIED
|
||||
OLDSTRING: "Change Subject? (Y/N) "
|
||||
NEWSTRING: "\r\n\e[1;32mSubject: \e[0m"
|
||||
|
||||
Changes from v0.8-alpha -> v0.9-alpha
|
||||
--------------------------------------------------------------
|
||||
|
2
deps/aha/aha.c
vendored
2
deps/aha/aha.c
vendored
@ -572,6 +572,6 @@ char * aha(char *input)
|
||||
//Footer
|
||||
if ((fc!=-1) || (bc!=-1) || (ul!=0) || (bo!=0) || (bl!=0))
|
||||
append_output(&output, "</span>\n", &size, &outat);
|
||||
|
||||
free(unmangle_out);
|
||||
return output;
|
||||
}
|
||||
|
2
deps/lua/Makefile
vendored
2
deps/lua/Makefile
vendored
@ -49,7 +49,7 @@ ALL_A= $(LUA_A)
|
||||
# Targets start here.
|
||||
default: $(PLAT)
|
||||
|
||||
all: $(ALL_T)
|
||||
all: $(ALL_A)
|
||||
|
||||
o: $(ALL_O)
|
||||
|
||||
|
BIN
dist/ansis/bulletin1.ans
vendored
BIN
dist/ansis/bulletin1.ans
vendored
Binary file not shown.
BIN
dist/ansis/mainmenu.ans
vendored
BIN
dist/ansis/mainmenu.ans
vendored
Binary file not shown.
1
dist/config/bbs.ini
vendored
1
dist/config/bbs.ini
vendored
@ -14,6 +14,7 @@ External Editor stdio = true
|
||||
External Editor Codepage = CP437
|
||||
Automessage Write Level = 10
|
||||
Fork = false
|
||||
Run As User = USERNAME
|
||||
Enable WWW = false
|
||||
WWW Port = 8080
|
||||
WWW URL = http://127.0.0.1:8080/
|
||||
|
1
dist/config/filesgen.ini
vendored
1
dist/config/filesgen.ini
vendored
@ -1,5 +1,6 @@
|
||||
[main]
|
||||
Visible Sec Level = 10
|
||||
Visible on Web = false
|
||||
|
||||
[Misc]
|
||||
Database = files_misc
|
||||
|
28
dist/magicka.strings
vendored
28
dist/magicka.strings
vendored
@ -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
|
||||
@ -112,8 +112,8 @@ Quoting Cancelled\r\n
|
||||
\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
|
||||
\r\n\e[1;37mPress \e[1;36mR \e[1;37mto reply, \e[1;36mQ \e[1;37mto quit, \e[1;36mB \e[1;37mto go Back, \e[1;36mSPACE \e[1;37mfor Next Mesage...
|
||||
\r\nSorry, you are not allowed to post in this area\r\n
|
||||
\r\n\r\nReplying to: %s\r\n
|
||||
Change Subject? (Y/N)
|
||||
\r\n\r\n\e[1;32m To: \e[0m
|
||||
\r\n\e[1;32mSubject: \e[0m
|
||||
\r\nNew subject:
|
||||
\r\nOk, not changing the subject line...
|
||||
\r\n\r\nNo more messages\r\n
|
||||
@ -125,8 +125,8 @@ Read message [1-%d] or N for New:
|
||||
\r\nMailing to @%d\r\n
|
||||
Start at message [1-%d] or N for New?
|
||||
\e[2J\e[1;1H\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m
|
||||
\e[1;30m[\e[1;34m%4d\e[1;30m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34m%4d\e[1;30m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34m%5d\e[1;30m]\e[1;32m*\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34m%5d\e[1;30m] \e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
(#) Read Message # (Q) Quit (ENTER) Continue\r\n
|
||||
\r\nThere is no mail in this area\r\n
|
||||
\r\n\r\nMail Conferences:\r\n\r\n
|
||||
@ -186,8 +186,8 @@ Is this Correct? (Y/N)
|
||||
\e[1;37mPress any key to continue...\e[0m
|
||||
\e[24;1H\e[1;32mUp / Down \e[1;37mto Scroll, \e[1;32mLeft / Right \e[1;37mChange Message, \e[1;32mR \e[1;37mReply, \e[1;32mQ \e[1;37mQuit\e[K\e[0m
|
||||
\e[23;1H\e[1;30m-------------------------------------------------------------------------------\e[0m\r\n
|
||||
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m] \e[1;37m%-25.25s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34;44m%5d\e[1;30;40m]\e[1;32m*\e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[1;30m[\e[1;34;44m%5d\e[1;30;40m] \e[1;37m%-24.24s \e[1;32m%-15.15s \e[1;33m%-15.15s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
\e[24;1H\e[1;37;44mUp/Down to Scroll, Enter to read, Q to quit\e[K\e[0m
|
||||
\e[24;1H\e[1;32mUp / Down \e[1;37mto Scroll, \e[1;32mLeft / Right \e[1;37mto Change Message, \e[1;32mR \e[1;37mreply, \e[1;32mD \e[1;37mDelete, \e[1;32mQ \e[1;37mquit\e[K\e[0m
|
||||
\e[1;30m[\e[1;34;44m%4d\e[1;30;40m]\e[1;32m*\e[1;37m%-39.39s \e[1;32m%-16.16s \e[1;35m%02d:%02d %02d-%02d-%02d\e[K\e[0m\r\n
|
||||
@ -201,7 +201,7 @@ Is this Correct? (Y/N)
|
||||
\r\nPlease enter a description:\r\n
|
||||
...Found!\r\n\r\n
|
||||
\e[1;32mUpload Successful!\e[0m\r\n
|
||||
\e[1;31mUser not found! Assuming new user...\e[0m\r\n\r\n
|
||||
\r\n\e[1;31mUser not found!\e[0m\r\n\r\n
|
||||
\e[1;32mSuccesfully processed \e[1;37m%d \e[1;32mmessages!\r\n\e[0m
|
||||
\e[0;36mA. \e[1;37mDefault Archiver (\e[1;33m%s\e[1;37m)\r\n
|
||||
\r\n\e[1;32mSelect an archiver...\e[0m\r\n\r\n
|
||||
@ -272,3 +272,15 @@ File exists!\r\n
|
||||
\e[24;1H\e[1;37;44mUp / Down to Select, A to Add, D to Delete, Q to Quit\e[K
|
||||
\e[8;28H\e[1;31;40mNo BBSes in the list!
|
||||
\e[10;22H\e[1;37mPress \e[1;33mA \e[1;37m to Add yours or \e[1;33mQ \e[1;37mto Quit\e[0m
|
||||
\r\n\e[1;31mError executing archiver.\r\n\e[0m
|
||||
\r\n\r\n\e[1;37m(\e[1;32mV\e[1;37m)iew or \e[1;37m(\e[1;32mU\e[1;37m)pdate Automessage or \e[1;37m(\e[1;31mQ\e[1;37m)uit: \e[0m
|
||||
\r\nScan for new personal mail? (Y/N/S):
|
||||
\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
|
||||
|
2
dist/menus/main.mnu
vendored
2
dist/menus/main.mnu
vendored
@ -2,7 +2,7 @@ LUASCRIPT mainmenu
|
||||
ANSIFILE mainmenu
|
||||
|
||||
HOTKEY O
|
||||
COMMAND AUTOMESSAGE_WRITE
|
||||
COMMAND AUTOMESSAGE
|
||||
|
||||
HOTKEY A
|
||||
COMMAND TEXTFILES
|
||||
|
11
dist/scripts/login_stanza.lua
vendored
11
dist/scripts/login_stanza.lua
vendored
@ -30,6 +30,9 @@ while(true) do
|
||||
i = i + 1;
|
||||
end
|
||||
|
||||
-- Display Blog
|
||||
bbs_display_blog();
|
||||
|
||||
-- Display Info
|
||||
local bbsname;
|
||||
local sysopname;
|
||||
@ -60,10 +63,14 @@ 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
|
||||
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;
|
||||
end
|
||||
@ -83,6 +90,8 @@ end
|
||||
|
||||
bbs_mail_scan();
|
||||
|
||||
bbs_personal_mail_scan();
|
||||
|
||||
bbs_file_scan();
|
||||
|
||||
-- Display Auto Message
|
||||
|
6
dist/www-bootstrap/header.tpl
vendored
6
dist/www-bootstrap/header.tpl
vendored
@ -65,6 +65,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@@WWW_URL@@">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@@WWW_URL@@blog/">News</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@@WWW_URL@@last10/">Last 10 Callers</a>
|
||||
</li>
|
||||
@ -74,6 +77,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@@WWW_URL@@msgs/">Conferences</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="@@WWW_URL@@files/areas/">File Areas</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
BIN
dist/www-bootstrap/static/newuser.png
vendored
Normal file
BIN
dist/www-bootstrap/static/newuser.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
67
dist/www-bootstrap/static/style-mobile.css
vendored
67
dist/www-bootstrap/static/style-mobile.css
vendored
@ -341,6 +341,37 @@
|
||||
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%;
|
||||
}
|
||||
|
||||
.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;
|
||||
@ -364,3 +395,39 @@ textarea {
|
||||
max-width: 100%;
|
||||
overflow-x: none;
|
||||
}
|
||||
|
||||
.filedesc {
|
||||
background-color: black;
|
||||
color: gray;
|
||||
font-family: 'pxplus_ibm_vga8regular';
|
||||
line-height: 1;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
thead {
|
||||
color: #eee;
|
||||
background-color: #666666;
|
||||
}
|
||||
|
||||
thead th:nth-child(1) {
|
||||
width: 5%;
|
||||
}
|
||||
|
||||
thead th:nth-child(2) {
|
||||
width: 5%;
|
||||
}
|
||||
|
||||
thead th:nth-child(3) {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
vertical-align: top;
|
||||
padding: 20px;
|
||||
border-top: 1px solid #666;
|
||||
}
|
74
dist/www-bootstrap/static/style.css
vendored
74
dist/www-bootstrap/static/style.css
vendored
@ -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;
|
||||
@ -331,9 +350,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 {
|
||||
@ -343,3 +375,39 @@
|
||||
line-height: 1;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.filedesc {
|
||||
background-color: black;
|
||||
color: gray;
|
||||
font-family: 'pxplus_ibm_vga8regular';
|
||||
line-height: 1;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
thead {
|
||||
color: #eee;
|
||||
background-color: #666666;
|
||||
}
|
||||
|
||||
thead th:nth-child(1) {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
thead th:nth-child(2) {
|
||||
width: 10%;
|
||||
}
|
||||
|
||||
thead th:nth-child(3) {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
vertical-align: top;
|
||||
padding: 20px;
|
||||
border-top: 1px solid #666;
|
||||
}
|
@ -38,47 +38,54 @@ These commands will compile and install DosBox into /usr/local/bin.
|
||||
|
||||
## Create Configuration File
|
||||
|
||||
Next you will need to create a config file which enables the serial port for socket inheritance, and also mounts drives so that DosBox can access both your doors and your BBS drop files.
|
||||
Next you will need to create a config file which enables the serial port, and also mounts drives so that DosBox can access both your doors and your BBS drop files.
|
||||
|
||||
An example setup is here: [dosbox.conf](https://gist.github.com/apamment/98e42db83c452105b3e21a8bc062c5c3)
|
||||
An example setup is here: [dosbox.conf](https://gist.github.com/apamment/2e5b00eda2f304f2bc7d298a0487bd9b)
|
||||
|
||||
In this example, drive C: is the location where my doors are stored, dropfiles will be copied to the door directory.
|
||||
|
||||
Be sure to change the port for each door. In this example the port is 9999.
|
||||
|
||||
## Create Shell Script to Invoke DosBox
|
||||
|
||||
The shell script you need will vary from system to system, but basically, you want to:
|
||||
|
||||
* ensure no one else is using the door before you start it
|
||||
* Copy the dropfile to the door directory
|
||||
* make DosBox not use an X11 window,
|
||||
* ensure that the dropfiles have DOS line endings
|
||||
* launch DosBox with the command to start the batch file in the next section.
|
||||
|
||||
Here is an example script I use for Freshwater Fishing:
|
||||
|
||||
#!/bin/bash
|
||||
export SDL_VIDEODRIVER="dummy"
|
||||
NODE=$1
|
||||
SOCKET=$2
|
||||
NODE=$2
|
||||
PORT=$1
|
||||
|
||||
trap '' 2
|
||||
|
||||
if [ ! -e /home/pi/MagickaBBS/doors/ffs.inuse ]; then
|
||||
touch /home/pi/MagickaBBS/doors/ffs.inuse
|
||||
cp /home/pi/MagickaBBS/node${NODE}/door.sys /home/pi/MagickaBBS/doors/ffs/
|
||||
/usr/local/bin/dosbox -socket $SOCKET -c "C:\ffs\ffs.bat ${NODE}" -conf /home/pi/MagickaBBS/doors/dosbox.conf
|
||||
rm /home/pi/MagickaBBS/doors/ffs.inuse
|
||||
fi
|
||||
/usr/local/bin/dosbox -c "C:\ffs\ffs.bat ${NODE}" -conf /home/pi/MagickaBBS/doors/dosbox-ffs.conf > /dev/null 2>&1
|
||||
|
||||
trap 2
|
||||
|
||||
|
||||
This will just dump the user back to the BBS if the door is in use. You could get fancy and use the 'inuse' door I created which will display an in-use message and then quit ([INUSE Door](https://github.com/apamment/inuse)), but that is outside the scope of this document.
|
||||
|
||||
You will also need to make the bash script executable:
|
||||
|
||||
chmod +x ffs.sh
|
||||
|
||||
## Create Shell Script to Invoke the DosBox Shim
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -e /home/pi/MagickaBBS/doors/ffs.inuse ]; then
|
||||
touch /home/pi/MagickaBBS/doors/ffs.inuse
|
||||
/home/pi/MagickaBBS/utils/dosbox_shim/shim 9999 $NODE /home/andrew/MagickaBBS/doors/ffs.sh
|
||||
rm /home/pi/MagickaBBS/doors/ffs.inuse
|
||||
fi
|
||||
|
||||
This will just dump the user back to the BBS if the door is in use. You could get fancy and use the 'inuse' door I created which will display an in-use message and then quit ([INUSE Door](https://github.com/apamment/inuse)), but that is outside the scope of this document.
|
||||
|
||||
Again be sure to change the port to match the dosbox config for this door.
|
||||
|
||||
## Create Batch File to Start Door
|
||||
|
||||
Please note, you will need to setup your doors using DosBox in the normal fashion, either you set them up on a machine where you have a monitor attached and transfer the files over, or you run DosBox directly from your PI with either remote X11 or a local monitor.
|
||||
@ -101,13 +108,13 @@ This loads BNU, then launches the door with the drop file.
|
||||
|
||||
## Setup BBS
|
||||
|
||||
Finally, you will want to setup your BBS to call the script you made in Step 6. You also need to pass the node number and socket handle.
|
||||
Finally, you will want to setup your BBS to call the dosbox shim script.
|
||||
|
||||
In doors.ini, something like
|
||||
|
||||
[Freshwater Fishing]
|
||||
command = /home/pi/MagickaBBS/doors/ffs.sh
|
||||
stdio = false
|
||||
command = /home/pi/MagickaBBS/doors/ffs-shim.sh
|
||||
stdio = true
|
||||
codepage = CP437
|
||||
|
||||
Then, add a command to your doors menu:
|
||||
|
@ -6,6 +6,7 @@ File directories and subdirectories are similar to message conferences and areas
|
||||
|
||||
[main]
|
||||
Visible Sec Level = 10
|
||||
Visible On Web = false
|
||||
|
||||
[Area One]
|
||||
Database = area_one
|
||||
@ -19,7 +20,11 @@ File directories and subdirectories are similar to message conferences and areas
|
||||
Upload Sec Level = 99
|
||||
Upload Path = /path/to/MagickaBBS/files/area_two
|
||||
|
||||
In the main section there is just one variable that applies to the whole directory, **Visible Sec Level** is the security level required to view the directory.
|
||||
In the main section variables apply to the whole directory,
|
||||
|
||||
**Visible Sec Level** is the security level required to view the directory.
|
||||
|
||||
**Visible On Web** is either true or false if you want it visible and the files downloadable via the website.
|
||||
|
||||
The section name for the sub-directory is the name of the sub directory.
|
||||
|
||||
@ -33,9 +38,10 @@ The section name for the sub-directory is the name of the sub directory.
|
||||
|
||||
## Uploading Files
|
||||
|
||||
When a user (or the sysop) uploads a file, they are not *approved* by default, so they will not be shown in the listings. To approve uploaded files, the sysop should run the fileapprove utility on the database.
|
||||
When a user (or the sysop) uploads a file, they are not *approved* by default, so they will not be shown in the listings. To approve uploaded files, the sysop should run the filecenter utility on the database.
|
||||
|
||||
./utils/fileapprove/fileapprove -d database.sq3
|
||||
cd utils/filecenter
|
||||
./filecenter -c ../../config/bbs.ini
|
||||
|
||||
This will list all the files in the database, and allow the sysop to toggle the approved status, or remove the file entirely.
|
||||
|
||||
|
@ -18,6 +18,7 @@ This is the main bbs INI file and contains the following sections
|
||||
* **External Editor Codepage** The codepage the external editor uses (CP437 for magiedit) (Only required if External Editor CMD is set)
|
||||
* **Automessage Write Level** The security level a user needs to change the automessage (Required)
|
||||
* **Fork** True if you want the BBS to run in daemon mode false if not. (Required)
|
||||
* **Run as User** Which user to run at if invoked as root. (Required if running as root)
|
||||
* **Enable WWW** True to enable the WWW server, false if not. (Required)
|
||||
* **WWW Port** Port to listen for HTTP connections (Required if WWW is enabled)
|
||||
* **WWW URL** Public facing url of the BBS (Required if WWW is enabled)
|
||||
|
@ -24,10 +24,12 @@ should work on debian and debian derivatives.
|
||||
|
||||
## Install Magicka
|
||||
|
||||
Clone the repo
|
||||
Clone the repo and checkout the branch you want, eg. v0.9-patch.
|
||||
|
||||
git clone https://github.com/MagickaBBS/MagickaBBS
|
||||
|
||||
git checkout v0.9-patch
|
||||
|
||||
Build the BBS
|
||||
|
||||
make www
|
||||
|
@ -32,6 +32,17 @@ Next is a DATA command, this specifies the DATA associated with the COMMAND comm
|
||||
|
||||
Finally, an optional SECLEVEL command indicates the required security level for a user to be able to trigger a command.
|
||||
|
||||
## Chaining Commands
|
||||
|
||||
As of v0.10 commands can be chained one after the other under a single hotkey. For example, a menu that would display a text file then run a door might look like this:
|
||||
|
||||
HOTKEY A
|
||||
COMMAND DISPLAYTEXTFILE
|
||||
DATA sometextfile
|
||||
COMMAND RUNDOOR
|
||||
DATA door to run
|
||||
SECLEVEL 10
|
||||
|
||||
## List of COMMANDs
|
||||
|
||||
**SUBMENU** loads a new menu. DATA is the name of the submenu
|
||||
@ -118,7 +129,7 @@ Finally, an optional SECLEVEL command indicates the required security level for
|
||||
|
||||
**FILESCAN** Scan for new files.
|
||||
|
||||
**FULLMAILSCAN** Scan for new messages and display them.
|
||||
**FULLMAILSCAN** Scan for new messages and display them. Optional DATA PERSONAL for personal mail scan.
|
||||
|
||||
**FILESEARCH** Search for a file.
|
||||
|
||||
@ -131,3 +142,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.
|
@ -96,6 +96,8 @@ Where data is the name of the lua script to call without the extension.
|
||||
|
||||
**bbs_full_mail_scan** Performs a full mail scan (like a mail scan but also displays new messages)
|
||||
|
||||
**bbs_personal_mail_scan** Performs a full mail scan (like a full mail scan but only displays personal messages)
|
||||
|
||||
**bbs_get_userhandle** Returns the logged in user's handle
|
||||
|
||||
**bbs_message_found** Takes three numbers, the conference, area and the message number, returns one number, 1 if found, 0 if not.
|
||||
@ -111,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.
|
||||
|
@ -18,7 +18,7 @@ Assuming you've installed Magicka BBS from via git rather than use a ZIP file or
|
||||
make cleanwww
|
||||
make www
|
||||
|
||||
Where branch is the branch you're updating to, for example v0.9-alpha.
|
||||
Where branch is the branch you're updating to, for example v0.9-patch.
|
||||
|
||||
## Step 3. Update Scripts
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
. . . .__ .__ __.
|
||||
|\/| _. _ * _.;_/ _. [__)[__)(__
|
||||
| |(_](_]|(_.| \(_] [__)[__).__) v0.9a
|
||||
| |(_](_]|(_.| \(_] [__)[__).__) v0.10a
|
||||
-------._|----------------------------------
|
||||
Magicka BBS is a Free BBS System for Linux,
|
||||
macOS, FreeBSD, NetBSD, OpenIndiana,
|
||||
|
2
setup.sh
2
setup.sh
@ -69,9 +69,11 @@ else
|
||||
SED=sed
|
||||
fi
|
||||
|
||||
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/bbs.ini
|
||||
$SED -i "s/BBS Name = Magicka BBS/BBS Name = ${bbsname}/g" config/bbs.ini
|
||||
$SED -i "s/Sysop Name = sysop/Sysop Name = ${handle}/g" config/bbs.ini
|
||||
$SED -i "s/USERNAME/${USERNAME}/g" config/bbs.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/localmail.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/filesgen.ini
|
||||
$SED -i "s@/home/andrew/MagickaBBS@${PWD}@g" config/happynet.ini
|
||||
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -51,8 +51,11 @@ magichat: $(JSMN)
|
||||
mgpost: $(JAMLIB)
|
||||
cd ../utils/mgpost && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -74,6 +77,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile freebsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -80,6 +83,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -75,6 +78,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile linux MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -80,6 +83,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -51,8 +51,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -74,6 +77,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -80,6 +83,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -51,8 +51,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -74,7 +77,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile bsd MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -80,7 +83,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -8,9 +8,9 @@ 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
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
|
||||
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -75,6 +78,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile macosx MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE)
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -79,6 +82,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter dosbox_shim magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -52,8 +52,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -75,6 +78,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
@ -10,7 +10,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd reset_pass
|
||||
all: magicka magimail magiedit ticproc mgpost magichat filecenter magiftpd reset_pass
|
||||
|
||||
${LUA}:
|
||||
cd ../deps/lua && $(MAKE) -f Makefile solaris MAKEFLAGS=
|
||||
@ -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)
|
||||
|
||||
@ -56,8 +56,11 @@ mgpost: $(JAMLIB)
|
||||
magichat: $(JSMN)
|
||||
cd ../utils/magichat && $(MAKE) -f Makefile.sunos
|
||||
|
||||
fileapprove: $(CDK)
|
||||
cd ../utils/fileapprove && $(MAKE)
|
||||
filecenter: $(CDK)
|
||||
cd ../utils/filecenter && $(MAKE)
|
||||
|
||||
dosbox_shim:
|
||||
cd ../utils/dosbox_shim && $(MAKE)
|
||||
|
||||
magiftpd:
|
||||
cd ../utils/magiftpd && $(MAKE)
|
||||
@ -80,6 +83,7 @@ clean:
|
||||
cd ../utils/mgpost && $(MAKE) clean
|
||||
cd ../utils/magichat && $(MAKE) clean
|
||||
cd ../deps/cdk-5.0-20161210 && $(MAKE) clean
|
||||
cd ../utils/fileapprove && $(MAKE) clean
|
||||
cd ../utils/filecenter && $(MAKE) clean
|
||||
cd ../utils/magiftpd && $(MAKE) clean
|
||||
cd ../utils/reset_pass && $(MAKE) clean
|
||||
cd ../utils/dosbox_shim && $(MAKE) clean
|
||||
|
254
src/bbs.c
254
src/bbs.c
@ -256,12 +256,18 @@ void s_putchar(char c) {
|
||||
size_t inc;
|
||||
size_t ouc;
|
||||
size_t sz;
|
||||
int ret;
|
||||
|
||||
if (!should_convert_utf8()) {
|
||||
if (sshBBS) {
|
||||
putchar(c);
|
||||
} else {
|
||||
write(gSocket, &c, 1);
|
||||
ret = send(gSocket, &c, 1, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ic = iconv_open("UTF-8", "CP437");
|
||||
@ -277,7 +283,12 @@ void s_putchar(char c) {
|
||||
if (sshBBS) {
|
||||
fprintf(stdout, "%s", ptr1);
|
||||
} else {
|
||||
write(gSocket, ptr1, outbuf - ptr1);
|
||||
ret = send(gSocket, ptr1, outbuf - ptr1, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
iconv_close(ic);
|
||||
free(ptr1);
|
||||
@ -294,11 +305,17 @@ void s_putstring(char *c) {
|
||||
size_t sz;
|
||||
char *ptr1;
|
||||
char *ptr2;
|
||||
int ret;
|
||||
if (!should_convert_utf8()) {
|
||||
if (sshBBS) {
|
||||
fprintf(stdout, "%s", c);
|
||||
} else {
|
||||
write(gSocket, c, strlen(c));
|
||||
ret = send(gSocket, c, strlen(c), 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ic = iconv_open("UTF-8", "CP437");
|
||||
@ -313,7 +330,12 @@ void s_putstring(char *c) {
|
||||
if (sshBBS) {
|
||||
fprintf(stdout, "%s", ptr1);
|
||||
} else {
|
||||
write(gSocket, ptr1, outbuf - ptr1);
|
||||
ret = send(gSocket, ptr1, outbuf - ptr1, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
iconv_close(ic);
|
||||
free(ptr1);
|
||||
@ -395,22 +417,25 @@ char s_getchar() {
|
||||
char iac_binary_do[] = {IAC, IAC_DO, IAC_TRANSMIT_BINARY, '\0'};
|
||||
char iac_binary_wont[] = {IAC, IAC_WONT, IAC_TRANSMIT_BINARY, '\0'};
|
||||
char iac_binary_dont[] = {IAC, IAC_DONT, IAC_TRANSMIT_BINARY, '\0'};
|
||||
|
||||
int ret;
|
||||
do {
|
||||
|
||||
if (sshBBS) {
|
||||
c = getchar();
|
||||
} else {
|
||||
do {
|
||||
len = read(gSocket, &c, 1);
|
||||
|
||||
if (len == 0) {
|
||||
} while (len == -1 && errno == EINTR);
|
||||
if (len <= 0) {
|
||||
disconnect("Socket Closed");
|
||||
}
|
||||
}
|
||||
|
||||
if (!sshBBS) {
|
||||
while (c == IAC) {
|
||||
do {
|
||||
len = read(gSocket, &c, 1);
|
||||
} while (len == -1 && errno == EINTR);
|
||||
if (len == 0) {
|
||||
disconnect("Socket Closed");
|
||||
} else if (c == IAC) {
|
||||
@ -418,8 +443,10 @@ char s_getchar() {
|
||||
return c;
|
||||
}
|
||||
if (c == IAC_WILL || c == IAC_WONT || c == IAC_DO || c == IAC_DONT) {
|
||||
len = read(gSocket, &d, 1);
|
||||
if (len == 0) {
|
||||
do {
|
||||
len = read(gSocket, &c, 1);
|
||||
} while (len == -1 && errno == EINTR);
|
||||
if (len <= 0) {
|
||||
disconnect("Socket Closed");
|
||||
}
|
||||
|
||||
@ -428,7 +455,12 @@ char s_getchar() {
|
||||
if (d == 0) {
|
||||
if (telnet_bin_mode != 1) {
|
||||
telnet_bin_mode = 1;
|
||||
write(gSocket, iac_binary_do, 3);
|
||||
ret = send(gSocket, iac_binary_do, 3, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -436,7 +468,12 @@ char s_getchar() {
|
||||
if (d == 0) {
|
||||
if (telnet_bin_mode != 0) {
|
||||
telnet_bin_mode = 0;
|
||||
write(gSocket, iac_binary_dont, 3);
|
||||
ret = send(gSocket, iac_binary_dont, 3, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -444,7 +481,13 @@ char s_getchar() {
|
||||
if (d == 0) {
|
||||
if (telnet_bin_mode != 1) {
|
||||
telnet_bin_mode = 1;
|
||||
write(gSocket, iac_binary_will, 3);
|
||||
ret = send(gSocket, iac_binary_will, 3, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -452,22 +495,31 @@ char s_getchar() {
|
||||
if (d == 0) {
|
||||
if (telnet_bin_mode != 0) {
|
||||
telnet_bin_mode = 0;
|
||||
write(gSocket, iac_binary_wont, 3);
|
||||
ret = send(gSocket, iac_binary_wont, 3, 0);
|
||||
if (ret == -1) {
|
||||
if (errno == ECONNRESET) {
|
||||
disconnect("Disconnected");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (c == 250) {
|
||||
do {
|
||||
do {
|
||||
len = read(gSocket, &c, 1);
|
||||
if (len == 0) {
|
||||
} while (len == -1 && errno == EINTR);
|
||||
if (len <= 0) {
|
||||
disconnect("Socket Closed");
|
||||
}
|
||||
} while(c != 240);
|
||||
}
|
||||
|
||||
do {
|
||||
len = read(gSocket, &c, 1);
|
||||
if (len == 0) {
|
||||
} while (len == -1 && errno == EINTR);
|
||||
if (len <= 0) {
|
||||
disconnect("Socket Closed");
|
||||
}
|
||||
}
|
||||
@ -485,6 +537,49 @@ char s_getc() {
|
||||
return (char)c;
|
||||
}
|
||||
|
||||
void s_readstring_inject(char *buffer, int max, char *inject) {
|
||||
int i;
|
||||
char c;
|
||||
|
||||
memset(buffer, 0, max);
|
||||
|
||||
if (strlen(inject) > max) {
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(buffer, inject);
|
||||
|
||||
s_printf("%s", inject);
|
||||
|
||||
for (i=strlen(buffer);i<max;i++) {
|
||||
c = s_getchar();
|
||||
|
||||
if ((c == '\b' || c == 127) && i > 0) {
|
||||
buffer[i-1] = '\0';
|
||||
i -= 2;
|
||||
s_printf("\e[D \e[D");
|
||||
continue;
|
||||
} else if (c == '\b' || c == 127) {
|
||||
i -= 1;
|
||||
continue;
|
||||
} else if (c == 27) {
|
||||
c = s_getchar();
|
||||
if (c == 91) {
|
||||
c = s_getchar();
|
||||
}
|
||||
i -= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c == '\n' || c == '\r') {
|
||||
return;
|
||||
}
|
||||
s_putchar(c);
|
||||
buffer[i] = c;
|
||||
buffer[i+1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void s_readstring(char *buffer, int max) {
|
||||
int i;
|
||||
char c;
|
||||
@ -577,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++) {
|
||||
@ -595,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);
|
||||
}
|
||||
@ -615,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");
|
||||
@ -640,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));
|
||||
@ -668,7 +763,7 @@ void display_info() {
|
||||
s_getc();
|
||||
}
|
||||
|
||||
void automessage_write(struct user_record *user) {
|
||||
void automessage_write() {
|
||||
FILE *fptr;
|
||||
char automsg[450];
|
||||
char buffer[76];
|
||||
@ -679,11 +774,11 @@ void automessage_write(struct user_record *user) {
|
||||
memset(automsg, 0, 450);
|
||||
memset(buffer, 0, 76);
|
||||
|
||||
if (user->sec_level >= conf.automsgwritelvl) {
|
||||
if (gUser->sec_level >= conf.automsgwritelvl) {
|
||||
timen = time(NULL);
|
||||
localtime_r(&timen, &timenow);
|
||||
|
||||
sprintf(automsg, get_string(15), user->loginname, asctime(&timenow));
|
||||
sprintf(automsg, get_string(15), gUser->loginname, asctime(&timenow));
|
||||
|
||||
automsg[strlen(automsg) - 1] = '\r';
|
||||
automsg[strlen(automsg)] = '\n';
|
||||
@ -733,6 +828,24 @@ void automessage_display() {
|
||||
s_getc();
|
||||
}
|
||||
|
||||
void automessage() {
|
||||
char c;
|
||||
s_printf(get_string(275));
|
||||
c = s_getchar();
|
||||
s_printf("\r\n");
|
||||
switch(tolower(c)) {
|
||||
case 'v':
|
||||
automessage_display();
|
||||
break;
|
||||
case 'u':
|
||||
automessage_write();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void runbbs_real(int socket, char *ip, int ssh) {
|
||||
char buffer[PATH_MAX];
|
||||
char password[17];
|
||||
@ -754,25 +867,27 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
||||
int do_internal_login = 0;
|
||||
int usernotfound;
|
||||
int tries;
|
||||
int fno;
|
||||
|
||||
atexit(exit_bbs);
|
||||
|
||||
ipaddress = ip;
|
||||
usertimeout = 10;
|
||||
timeoutpaused = 0;
|
||||
|
||||
if (!ssh) {
|
||||
gUser = NULL;
|
||||
sshBBS = 0;
|
||||
if (write(socket, iac_echo, 3) != 3) {
|
||||
dolog("Failed to send iac_echo");
|
||||
exit(0);
|
||||
}
|
||||
if (write(socket, iac_sga, 3) != 3) {
|
||||
dolog("Failed to send iac_sga");
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
sshBBS = 1;
|
||||
}
|
||||
|
||||
memset (&sa, 0, sizeof (sa));
|
||||
sa.sa_handler = &timer_handler;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigaction (SIGALRM, &sa, 0);
|
||||
|
||||
itime.it_interval.tv_sec = 60;
|
||||
itime.it_interval.tv_usec = 0;
|
||||
itime.it_value.tv_sec = 60;
|
||||
itime.it_value.tv_usec = 0;
|
||||
|
||||
setitimer (ITIMER_REAL, &itime, 0);
|
||||
|
||||
ipaddress = ip;
|
||||
|
||||
st.sa_handler = sigterm_handler2;
|
||||
sigemptyset(&st.sa_mask);
|
||||
@ -781,26 +896,45 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
||||
dolog("Failed to setup sigterm handler.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (sigaction(SIGPIPE, &st, NULL) == -1) {
|
||||
dolog("Failed to setup sigpipe handler.");
|
||||
exit(1);
|
||||
}
|
||||
gSocket = socket;
|
||||
|
||||
|
||||
if (!ssh) {
|
||||
gUser = NULL;
|
||||
sshBBS = 0;
|
||||
if (send(socket, iac_echo, 3, 0) != 3) {
|
||||
dolog("Failed to send iac_echo");
|
||||
exit(0);
|
||||
}
|
||||
if (send(socket, iac_sga, 3, 0) != 3) {
|
||||
dolog("Failed to send iac_sga");
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
sshBBS = 1;
|
||||
}
|
||||
|
||||
s_printf("Magicka BBS v%d.%d (%s), Loading...\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_STR);
|
||||
|
||||
// find out which node we are
|
||||
for (i=1;i<=conf.nodes;i++) {
|
||||
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i);
|
||||
|
||||
if (stat(buffer, &s) != 0) {
|
||||
mynode = i;
|
||||
nodefile = fopen(buffer, "w");
|
||||
if (!nodefile) {
|
||||
fno = open(buffer, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
if (fno == -1) {
|
||||
dolog("Error opening nodefile!");
|
||||
close(socket);
|
||||
exit(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
fputs("UNKNOWN", nodefile);
|
||||
fclose(nodefile);
|
||||
write(fno, "UNKNOWN", 7);
|
||||
|
||||
close(fno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -815,24 +949,10 @@ void runbbs_real(int socket, char *ip, int ssh) {
|
||||
|
||||
dolog("Incoming %s connection on node %d", (ssh ? "SSH" : "Telnet"), mynode);
|
||||
|
||||
usertimeout = 10;
|
||||
timeoutpaused = 0;
|
||||
tries = 0;
|
||||
|
||||
memset (&sa, 0, sizeof (sa));
|
||||
sa.sa_handler = &timer_handler;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigaction (SIGALRM, &sa, 0);
|
||||
|
||||
itime.it_interval.tv_sec = 60;
|
||||
itime.it_interval.tv_usec = 0;
|
||||
itime.it_value.tv_sec = 60;
|
||||
itime.it_value.tv_usec = 0;
|
||||
|
||||
setitimer (ITIMER_REAL, &itime, 0);
|
||||
|
||||
s_displayansi("issue");
|
||||
|
||||
tries = 0;
|
||||
|
||||
if (!ssh) {
|
||||
tryagain:
|
||||
s_printf(get_string(19));
|
||||
@ -845,8 +965,8 @@ tryagain:
|
||||
if (strcasecmp(buffer, "new") == 0) {
|
||||
usernotfound = 1;
|
||||
} else if (check_user(buffer)) {
|
||||
usernotfound = 1;
|
||||
s_printf(get_string(203));
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
if (usernotfound) {
|
||||
@ -871,7 +991,7 @@ tryagain:
|
||||
gUser = user;
|
||||
|
||||
for (i=1;i<=conf.nodes;i++) {
|
||||
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i);
|
||||
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, i);
|
||||
if (stat(buffer, &s) == 0) {
|
||||
nodefile = fopen(buffer, "r");
|
||||
if (!nodefile) {
|
||||
@ -895,7 +1015,7 @@ tryagain:
|
||||
s_printf(get_string(24), gUser->loginname);
|
||||
s_getc();
|
||||
for (i=1;i<=conf.nodes;i++) {
|
||||
sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, i);
|
||||
snprintf(buffer, PATH_MAX, "%s/nodeinuse.%d", conf.bbs_path, i);
|
||||
if (stat(buffer, &s) == 0) {
|
||||
nodefile = fopen(buffer, "r");
|
||||
if (!nodefile) {
|
||||
@ -988,7 +1108,7 @@ tryagain:
|
||||
// bulletins
|
||||
display_bulletins();
|
||||
|
||||
// external login cmd
|
||||
blog_display();
|
||||
|
||||
// display info
|
||||
display_info();
|
||||
@ -1022,7 +1142,7 @@ tryagain:
|
||||
}
|
||||
|
||||
void do_logout() {
|
||||
char buffer[256];
|
||||
char buffer[PATH_MAX];
|
||||
struct stat s;
|
||||
lua_State *L;
|
||||
int ret = 0;
|
||||
|
30
src/bbs.h
30
src/bbs.h
@ -12,7 +12,7 @@
|
||||
#include "jamlib/jam.h"
|
||||
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 9
|
||||
#define VERSION_MINOR 10
|
||||
#define VERSION_STR "alpha"
|
||||
|
||||
#define NETWORK_FIDO 1
|
||||
@ -43,6 +43,7 @@ struct last10_callers {
|
||||
char name[17];
|
||||
char location[33];
|
||||
time_t time;
|
||||
int calls;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct text_file {
|
||||
@ -93,6 +94,7 @@ struct file_directory {
|
||||
char *name;
|
||||
char *path;
|
||||
int sec_level;
|
||||
int display_on_web;
|
||||
int file_sub_count;
|
||||
struct file_sub **file_subs;
|
||||
};
|
||||
@ -124,6 +126,8 @@ struct ip_address_guard {
|
||||
};
|
||||
|
||||
struct bbs_config {
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
int codepage;
|
||||
int ipv6;
|
||||
char *bbs_name;
|
||||
@ -239,11 +243,19 @@ 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);
|
||||
extern void automessage_write(struct user_record *user);
|
||||
extern void automessage_write();
|
||||
extern void automessage_display();
|
||||
extern void automessage();
|
||||
extern void dolog(char *fmt, ...);
|
||||
extern void dolog_www(char *ipaddr, char *fmt, ...);
|
||||
extern void runbbs_ssh(char *ipaddress);
|
||||
@ -258,6 +270,7 @@ extern void s_displayansi(char *file);
|
||||
extern char s_getchar();
|
||||
extern void s_readpass(char *buffer, int max);
|
||||
extern void s_readstring(char *buffer, int max);
|
||||
extern void s_readstring_inject(char *buffer, int max, char *inject);
|
||||
extern char s_getc();
|
||||
extern void disconnect(char *calledby);
|
||||
extern void display_info();
|
||||
@ -282,7 +295,7 @@ extern void display_textfiles();
|
||||
extern time_t utc_to_local(time_t utc);
|
||||
extern s_JamBase *open_jam_base(char *path);
|
||||
extern void free_message_headers(struct msg_headers *msghs);
|
||||
extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user);
|
||||
extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user, int personal);
|
||||
extern void mail_scan(struct user_record *user);
|
||||
extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email, int sig);
|
||||
extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email, int sig);
|
||||
@ -302,6 +315,7 @@ extern void msg_conf_sub_bases();
|
||||
extern void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno);
|
||||
extern void msgbase_reset_all_pointers(int readm);
|
||||
extern void full_mail_scan(struct user_record *user);
|
||||
extern void full_mail_scan_personal(struct user_record *user);
|
||||
extern int read_new_msgs(struct user_record *user, struct msg_headers *msghs);
|
||||
extern int new_messages(struct user_record *user, int conference, int area);
|
||||
|
||||
@ -366,9 +380,19 @@ extern char *www_last10();
|
||||
extern void www_expire_old_links();
|
||||
extern char *www_create_link(int dir, int sub, int fid);
|
||||
extern char *www_decode_hash(char *hash);
|
||||
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
|
||||
|
256
src/blog.c
Normal file
256
src/blog.c
Normal file
@ -0,0 +1,256 @@
|
||||
#include <sqlite3.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#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 hour;
|
||||
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;i<blog_entry_count;i++) {
|
||||
localtime_r(&blog_entries[i]->date, &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;
|
||||
}
|
||||
if (thetime.tm_hour >= 12) {
|
||||
hour = thetime.tm_hour - 12;
|
||||
} else {
|
||||
hour = thetime.tm_hour;
|
||||
}
|
||||
s_printf(get_string(284), (hour == 0 ? 12 : hour), 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; j<strlen(blog_entries[i]->body); 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;i<blog_entry_count;i++) {
|
||||
free(blog_entries[i]->subject);
|
||||
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");
|
||||
|
||||
if (strlen(buffer) == 0) {
|
||||
s_printf(get_string(39));
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
@ -134,7 +134,7 @@ int bwave_scan_email(int areano, int totmsgs, FILE *fti_file, FILE *mix_file, FI
|
||||
}
|
||||
|
||||
int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file, FILE *mix_file, FILE *dat_file, int *last_ptr) {
|
||||
struct msg_headers *msghs = read_message_headers(confr, area, gUser);
|
||||
struct msg_headers *msghs = read_message_headers(confr, area, gUser, 0);
|
||||
int all_unread = 1;
|
||||
s_JamBase *jb;
|
||||
s_JamLastRead jlr;
|
||||
@ -282,6 +282,7 @@ int bwave_scan_area(int confr, int area, int areano, int totmsgs, FILE *fti_file
|
||||
fwrite(&mix, sizeof(MIX_REC), 1, mix_file);
|
||||
//}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
free_message_headers(msghs);
|
||||
return totmsgs;
|
||||
}
|
||||
@ -313,6 +314,7 @@ void bwave_create_packet() {
|
||||
FILE *inf_file;
|
||||
int tot_areas = 0;
|
||||
int totmsgs = 0;
|
||||
int ret;
|
||||
|
||||
for (i=0;i<conf.mail_conference_count;i++) {
|
||||
for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) {
|
||||
@ -528,7 +530,8 @@ void bwave_create_packet() {
|
||||
dup2(bbs_stderr, STDERR_FILENO);
|
||||
dup2(bbs_stdin, STDIN_FILENO);
|
||||
}
|
||||
system(buffer);
|
||||
|
||||
ret = system(buffer);
|
||||
|
||||
if (sshBBS) {
|
||||
|
||||
@ -541,8 +544,11 @@ void bwave_create_packet() {
|
||||
close(sterr);
|
||||
}
|
||||
|
||||
|
||||
if (ret != -1 && ret >> 8 != 127) {
|
||||
do_download(gUser, archive);
|
||||
} else {
|
||||
s_printf(get_string(274));
|
||||
}
|
||||
|
||||
snprintf(buffer, 1024, "%s/node%d/bwave", conf.bbs_path, mynode);
|
||||
recursive_delete(buffer);
|
||||
@ -707,6 +713,7 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
} else {
|
||||
dolog("Failed to lock msg base!");
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -716,12 +723,14 @@ int bwave_add_message(int confr, int area, unsigned int dwritten, char *to, char
|
||||
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return -1;
|
||||
} else {
|
||||
JAM_UnlockMB(jb);
|
||||
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ void chat_system(struct user_record *user) {
|
||||
}
|
||||
memset(inputbuffer, 0, 256);
|
||||
inputbuffer_at = 0;
|
||||
} else if (c != '\n') {
|
||||
} else if (c != '\n' && c != '\0') {
|
||||
if (c == '\b' || c == 127) {
|
||||
if (inputbuffer_at > 0) {
|
||||
inputbuffer_at--;
|
||||
@ -454,6 +454,7 @@ void chat_system(struct user_record *user) {
|
||||
message[y+1] = '\0';
|
||||
y++;
|
||||
} else {
|
||||
|
||||
y = 0;
|
||||
// json parse
|
||||
jsmn_init(&parser);
|
||||
|
@ -846,11 +846,11 @@ void download_zmodem(struct user_record *user, char *filename) {
|
||||
break ;
|
||||
|
||||
case ZmErrCantOpen:
|
||||
dolog("cannot open file \"%s\": %s\n", filename, strerror(errno)) ;
|
||||
dolog("cannot open file \"%s\": %s", filename, strerror(errno)) ;
|
||||
return;
|
||||
|
||||
case ZmFileTooLong:
|
||||
dolog("filename \"%s\" too long, skipping...\n", filename) ;
|
||||
dolog("filename \"%s\" too long, skipping...", filename) ;
|
||||
return;
|
||||
|
||||
case ZmDone:
|
||||
|
@ -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);
|
||||
@ -87,7 +93,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 +106,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) {
|
||||
@ -115,6 +121,11 @@ int l_bbsFullMailScan(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_bbsPersonalMailScan(lua_State *L) {
|
||||
full_mail_scan_personal(gUser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_bbsMailScan(lua_State *L) {
|
||||
mail_scan(gUser);
|
||||
return 0;
|
||||
@ -203,21 +214,22 @@ int l_messageFound(lua_State *L) {
|
||||
z = JAM_ReadMsgHeader(jb, id, &jmh, &jsp);
|
||||
|
||||
if (z != 0) {
|
||||
dolog("Failed to read msg header: %d Erro %d", z, JAM_Errno(jb));
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
lua_pushnumber(L, 0);
|
||||
return 1;
|
||||
}
|
||||
if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
lua_pushnumber(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
|
||||
free(jb);
|
||||
lua_pushnumber(L, 1);
|
||||
return 1;
|
||||
}
|
||||
@ -247,9 +259,11 @@ int l_readMessageHdr(lua_State *L) {
|
||||
if (z != 0) {
|
||||
dolog("Failed to read msg header: %d Erro %d", z, JAM_Errno(jb));
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
} else if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
} else {
|
||||
for (z=0;z<jsp->NumFields;z++) {
|
||||
if (jsp->Fields[z]->LoID == JAMSFLD_SUBJECT) {
|
||||
@ -271,6 +285,7 @@ int l_readMessageHdr(lua_State *L) {
|
||||
}
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
if (subject == NULL) {
|
||||
subject = strdup("(No Subject)");
|
||||
@ -318,9 +333,11 @@ int l_readMessage(lua_State *L) {
|
||||
if (z != 0) {
|
||||
dolog("Failed to read msg header: %d Erro %d", z, JAM_Errno(jb));
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
body = strdup("No Message");
|
||||
} else if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
body = strdup("No Message");
|
||||
} else {
|
||||
body = (char *)malloc(jmh.TxtLen + 1);
|
||||
@ -328,6 +345,7 @@ int l_readMessage(lua_State *L) {
|
||||
body[jmh.TxtLen] = '\0';
|
||||
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
lua_pushstring(L, body);
|
||||
|
||||
@ -468,6 +486,7 @@ int l_postMessage(lua_State *L) {
|
||||
} else if (conf.mail_conferences[confr]->mail_areas[area]->type == TYPE_NETMAIL_AREA) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -480,6 +499,7 @@ int l_postMessage(lua_State *L) {
|
||||
} else {
|
||||
dolog("Failed to lock msg base!");
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -533,6 +553,7 @@ int l_postMessage(lua_State *L) {
|
||||
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
free(msg);
|
||||
|
||||
@ -599,6 +620,10 @@ void lua_push_cfunctions(lua_State *L) {
|
||||
lua_setglobal(L, "bbs_data_path");
|
||||
lua_pushcfunction(L, l_userSecurity);
|
||||
lua_setglobal(L, "bbs_user_security");
|
||||
lua_pushcfunction(L, l_bbsPersonalMailScan);
|
||||
lua_setglobal(L, "bbs_personal_mail_scan");
|
||||
lua_pushcfunction(L, l_displayBlog);
|
||||
lua_setglobal(L, "bbs_display_blog");
|
||||
}
|
||||
|
||||
void do_lua_script(char *script) {
|
||||
|
201
src/mail_menu.c
201
src/mail_menu.c
@ -128,6 +128,7 @@ void free_message_headers(struct msg_headers *msghs) {
|
||||
if (msghs->msgs[i]->replyid != NULL) {
|
||||
free(msghs->msgs[i]->replyid);
|
||||
}
|
||||
free(msghs->msgs[i]);
|
||||
}
|
||||
if (msghs->msg_count > 0) {
|
||||
free(msghs->msgs);
|
||||
@ -145,7 +146,7 @@ int msg_is_to(struct user_record *user, char *addressed_to, char *address, int t
|
||||
} else {
|
||||
myname = strdup(user->loginname);
|
||||
}
|
||||
if (type == NETWORK_FIDO) {
|
||||
if (type == NETWORK_FIDO && address != NULL) {
|
||||
if (strcasecmp(myname, addressed_to) == 0) {
|
||||
dest = parse_fido_addr(address);
|
||||
if (conf.mail_conferences[msgconf]->fidoaddr->zone == dest->zone &&
|
||||
@ -205,7 +206,7 @@ int msg_is_from(struct user_record *user, char *addressed_from, char *address, i
|
||||
}
|
||||
}
|
||||
|
||||
struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user) {
|
||||
struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user, int personal) {
|
||||
s_JamBase *jb;
|
||||
s_JamBaseHeader jbh;
|
||||
s_JamMsgHeader jmh;
|
||||
@ -313,6 +314,36 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
||||
!msg_is_to(user, jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, !conf.mail_conferences[msgconf]->realnames, msgconf) &&
|
||||
!msg_is_from(user, jamm->from, jamm->oaddress, conf.mail_conferences[msgconf]->nettype, !conf.mail_conferences[msgconf]->realnames, msgconf)) {
|
||||
|
||||
if (jamm->subject != NULL) {
|
||||
free(jamm->subject);
|
||||
}
|
||||
if (jamm->from != NULL) {
|
||||
free(jamm->from);
|
||||
}
|
||||
if (jamm->to != NULL) {
|
||||
free(jamm->to);
|
||||
}
|
||||
if (jamm->oaddress != NULL) {
|
||||
free(jamm->oaddress);
|
||||
}
|
||||
if (jamm->daddress != NULL) {
|
||||
free(jamm->daddress);
|
||||
}
|
||||
if (jamm->msgid != NULL) {
|
||||
free(jamm->msgid);
|
||||
}
|
||||
if (jamm->replyid != NULL) {
|
||||
free(jamm->replyid);
|
||||
}
|
||||
free(jamm->msg_h);
|
||||
free(jamm);
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
} else if (personal) {
|
||||
if (!msg_is_to(user, jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, conf.mail_conferences[msgconf]->realnames, msgconf) &&
|
||||
!msg_is_to(user, jamm->to, jamm->daddress, conf.mail_conferences[msgconf]->nettype, !conf.mail_conferences[msgconf]->realnames, msgconf)) {
|
||||
|
||||
if (jamm->subject != NULL) {
|
||||
free(jamm->subject);
|
||||
}
|
||||
@ -354,9 +385,11 @@ struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_r
|
||||
|
||||
} else {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return msghs;
|
||||
}
|
||||
|
||||
@ -588,9 +621,9 @@ char *editor(struct user_record *user, char *quote, int quotelen, char *from, in
|
||||
s_printf(get_string(87));
|
||||
|
||||
while(!doquit) {
|
||||
s_printf(get_string(88), lines, next_line_buffer);
|
||||
s_printf(get_string(88), lines, "");
|
||||
strcpy(linebuffer, next_line_buffer);
|
||||
s_readstring(&linebuffer[strlen(next_line_buffer)], 70 - strlen(next_line_buffer));
|
||||
s_readstring_inject(linebuffer, 70, next_line_buffer);
|
||||
memset(next_line_buffer, 0, 70);
|
||||
|
||||
if (strlen(linebuffer) == 70 && linebuffer[69] != ' ') {
|
||||
@ -1652,6 +1685,8 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
|
||||
if (tolower(c) == 'r') {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
jb = NULL;
|
||||
if (user->sec_level < conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->write_sec_level) {
|
||||
s_printf(get_string(113));
|
||||
} else {
|
||||
@ -1665,23 +1700,14 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
subject = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(subject, buffer);
|
||||
|
||||
s_printf(get_string(114), subject);
|
||||
s_printf(get_string(114));
|
||||
s_readstring_inject(buffer, 32, msghs->msgs[mailno]->from);
|
||||
to = strdup(buffer);
|
||||
s_printf(get_string(115));
|
||||
|
||||
c = s_getc();
|
||||
|
||||
if (tolower(c) == 'y') {
|
||||
s_printf(get_string(116));
|
||||
s_readstring(buffer, 25);
|
||||
|
||||
if (strlen(buffer) == 0) {
|
||||
s_printf(get_string(117));
|
||||
} else {
|
||||
s_readstring_inject(buffer, 64, subject);
|
||||
free(subject);
|
||||
subject = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(subject, buffer);
|
||||
}
|
||||
}
|
||||
subject = strdup(buffer);
|
||||
|
||||
s_printf("\r\n");
|
||||
|
||||
if (msghs->msgs[mailno]->from != NULL) {
|
||||
@ -1695,11 +1721,9 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
sprintf(from, "%s %s", user->firstname, user->lastname);
|
||||
}
|
||||
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->type == TYPE_NEWSGROUP_AREA) {
|
||||
free(to);
|
||||
to = (char *)malloc(4);
|
||||
strcpy(to, "ALL");
|
||||
} else {
|
||||
to = (char *)malloc(strlen(buffer) + 1);
|
||||
strcpy(to, buffer);
|
||||
}
|
||||
replybody = external_editor(user, to, from, body, z2, msghs->msgs[mailno]->from, subject, 0, 0);
|
||||
if (replybody != NULL) {
|
||||
@ -1942,6 +1966,11 @@ int read_message(struct user_record *user, struct msg_headers *msghs, int mailno
|
||||
msg_line_count = 0;
|
||||
}
|
||||
|
||||
if (jb != NULL) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
|
||||
if (doquit == 2) {
|
||||
return 1;
|
||||
}
|
||||
@ -1970,18 +1999,25 @@ int read_new_msgs(struct user_record *user, struct msg_headers *msghs) {
|
||||
jlr.LastReadMsg = 0;
|
||||
jlr.HighReadMsg = 0;
|
||||
all_unread = 1;
|
||||
} else if (jlr.LastReadMsg == 0 && jlr.HighReadMsg == 0) {
|
||||
}
|
||||
if (jlr.LastReadMsg == 0 && jlr.HighReadMsg == 0) {
|
||||
all_unread = 1;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
if (all_unread == 0) {
|
||||
k = jlr.HighReadMsg;
|
||||
for (i=0;i<msghs->msg_count;i++) {
|
||||
if (msghs->msgs[i]->msg_h->MsgNum == k) {
|
||||
i+=2;
|
||||
break;
|
||||
}
|
||||
if (msghs->msgs[i]->msg_h->MsgNum > k) {
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 2;
|
||||
|
||||
} else {
|
||||
i = 1;
|
||||
}
|
||||
@ -2007,7 +2043,7 @@ void read_mail(struct user_record *user) {
|
||||
|
||||
s_printf("\r\n");
|
||||
// list mail in message base
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
|
||||
if (msghs != NULL && msghs->msg_count > 0) {
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
@ -2023,6 +2059,7 @@ void read_mail(struct user_record *user) {
|
||||
all_unread = 1;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
s_printf(get_string(120), msghs->msg_count);
|
||||
|
||||
s_readstring(buffer, 6);
|
||||
@ -2080,7 +2117,7 @@ void post_message(struct user_record *user) {
|
||||
sprintf(buffer, "ALL");
|
||||
} else {
|
||||
s_printf(get_string(54));
|
||||
s_readstring(buffer, 16);
|
||||
s_readstring(buffer, 32);
|
||||
}
|
||||
if (strlen(buffer) == 0) {
|
||||
strcpy(buffer, "ALL");
|
||||
@ -2287,6 +2324,7 @@ void post_message(struct user_record *user) {
|
||||
}
|
||||
if (z != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2311,6 +2349,7 @@ void post_message(struct user_record *user) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
free(msg);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
free(to);
|
||||
free(subject);
|
||||
@ -2333,7 +2372,7 @@ void list_messages(struct user_record *user) {
|
||||
|
||||
s_printf("\r\n");
|
||||
// list mail in message base
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
|
||||
if (msghs != NULL && msghs->msg_count > 0) {
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
@ -2349,6 +2388,7 @@ void list_messages(struct user_record *user) {
|
||||
all_unread = 1;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
s_printf(get_string(125), msghs->msg_count);
|
||||
|
||||
s_readstring(buffer, 6);
|
||||
@ -2561,7 +2601,7 @@ void list_messages(struct user_record *user) {
|
||||
redraw = 1;
|
||||
read_message(user, msghs, i - 1, 0);
|
||||
free_message_headers(msghs);
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user);
|
||||
msghs = read_message_headers(user->cur_mail_conf, user->cur_mail_area, user, 0);
|
||||
jb = open_jam_base(conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
if (!jb) {
|
||||
dolog("Error opening JAM base.. %s", conf.mail_conferences[user->cur_mail_conf]->mail_areas[user->cur_mail_area]->path);
|
||||
@ -2577,6 +2617,7 @@ void list_messages(struct user_record *user) {
|
||||
all_unread = 1;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2949,7 +2990,7 @@ void prev_mail_area(struct user_record *user) {
|
||||
|
||||
|
||||
|
||||
void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
void do_mail_scan(struct user_record *user, int oldscan, int personal) {
|
||||
s_JamBase *jb;
|
||||
s_JamBaseHeader jbh;
|
||||
s_JamLastRead jlr;
|
||||
@ -2961,7 +3002,15 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
int orig_conf;
|
||||
int orig_area;
|
||||
int res = 0;
|
||||
char ch;
|
||||
int unread_count;
|
||||
int k;
|
||||
|
||||
if (personal) {
|
||||
s_printf(get_string(276));
|
||||
} else {
|
||||
s_printf(get_string(139));
|
||||
}
|
||||
c = s_getc();
|
||||
|
||||
if (tolower(c) == 'y' || tolower(c) == 's') {
|
||||
@ -2969,13 +3018,16 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
if (conf.mail_conferences[i]->sec_level > user->sec_level) {
|
||||
continue;
|
||||
}
|
||||
if (oldscan) {
|
||||
s_printf(get_string(140), i, conf.mail_conferences[i]->name);
|
||||
|
||||
lines+=2;
|
||||
if (lines == 22) {
|
||||
s_printf(get_string(6));
|
||||
s_getc();
|
||||
lines = 0;
|
||||
}
|
||||
}
|
||||
for (j=0;j<conf.mail_conferences[i]->mail_area_count;j++) {
|
||||
if (conf.mail_conferences[i]->mail_areas[j]->read_sec_level > user->sec_level) {
|
||||
continue;
|
||||
@ -2993,16 +3045,18 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
|
||||
if (JAM_ReadMBHeader(jb, &jbh) != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
||||
if (jbh.ActiveMsgs == 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
continue;
|
||||
}
|
||||
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
|
||||
msghs = read_message_headers(i, j, user);
|
||||
msghs = read_message_headers(i, j, user, personal);
|
||||
if (msghs != NULL) {
|
||||
if (msghs->msg_count > 0) {
|
||||
if (oldscan) {
|
||||
@ -3014,6 +3068,14 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
lines = 0;
|
||||
}
|
||||
} else {
|
||||
s_printf("\e[2J\e[1;1H");
|
||||
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
|
||||
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count);
|
||||
s_printf(get_string(279));
|
||||
|
||||
ch = s_getchar();
|
||||
s_printf("\r\n");
|
||||
if (tolower(ch) == 'y') {
|
||||
orig_conf = user->cur_mail_conf;
|
||||
orig_area = user->cur_mail_area;
|
||||
|
||||
@ -3026,6 +3088,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
user->cur_mail_area = orig_area;
|
||||
}
|
||||
}
|
||||
}
|
||||
free_message_headers(msghs);
|
||||
}
|
||||
} else {
|
||||
@ -3038,9 +3101,18 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
lines = 0;
|
||||
}
|
||||
} else {
|
||||
msghs = read_message_headers(i, j, user);
|
||||
msghs = read_message_headers(i, j, user, personal);
|
||||
if (msghs != NULL) {
|
||||
|
||||
if (msghs->msg_count > 0) {
|
||||
s_printf("\e[2J\e[1;1H");
|
||||
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
|
||||
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msg_count);
|
||||
s_printf(get_string(279));
|
||||
|
||||
ch = s_getchar();
|
||||
s_printf("\r\n");
|
||||
if (tolower(ch) == 'y') {
|
||||
orig_conf = user->cur_mail_conf;
|
||||
orig_area = user->cur_mail_area;
|
||||
|
||||
@ -3052,19 +3124,31 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
user->cur_mail_conf = orig_conf;
|
||||
user->cur_mail_area = orig_area;
|
||||
}
|
||||
}
|
||||
free_message_headers(msghs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (jlr.HighReadMsg < jbh.ActiveMsgs) {
|
||||
|
||||
|
||||
|
||||
if (conf.mail_conferences[i]->mail_areas[j]->type == TYPE_NETMAIL_AREA) {
|
||||
msghs = read_message_headers(i, j, user);
|
||||
msghs = read_message_headers(i, j, user, personal);
|
||||
if (msghs != NULL) {
|
||||
if (msghs->msg_count > 0) {
|
||||
if (msghs->msgs[msghs->msg_count-1]->msg_no > jlr.HighReadMsg) {
|
||||
unread_count = 0;
|
||||
|
||||
for (k=msghs->msg_count-1;k>=0;k--) {
|
||||
if (msghs->msgs[k]->msg_no < jlr.HighReadMsg) {
|
||||
break;
|
||||
}
|
||||
unread_count++;
|
||||
}
|
||||
if (unread_count > 0) {
|
||||
if (oldscan) {
|
||||
s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, msghs->msgs[msghs->msg_count-1]->msg_h->MsgNum - jlr.HighReadMsg);
|
||||
s_printf(get_string(141), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
|
||||
lines++;
|
||||
if (lines == 22) {
|
||||
s_printf(get_string(6));
|
||||
@ -3072,6 +3156,14 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
lines = 0;
|
||||
}
|
||||
} else {
|
||||
s_printf("\e[2J\e[1;1H");
|
||||
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
|
||||
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
|
||||
s_printf(get_string(279));
|
||||
|
||||
ch = s_getchar();
|
||||
s_printf("\r\n");
|
||||
if (tolower(ch) == 'y') {
|
||||
orig_conf = user->cur_mail_conf;
|
||||
orig_area = user->cur_mail_area;
|
||||
|
||||
@ -3085,6 +3177,7 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
free_message_headers(msghs);
|
||||
}
|
||||
} else {
|
||||
@ -3097,9 +3190,26 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
lines = 0;
|
||||
}
|
||||
} else {
|
||||
msghs = read_message_headers(i, j, user);
|
||||
msghs = read_message_headers(i, j, user, personal);
|
||||
if (msghs != NULL) {
|
||||
if (msghs->msg_count > 0) {
|
||||
unread_count = 0;
|
||||
|
||||
for (k=msghs->msg_count-1;k>=0;k--) {
|
||||
if (msghs->msgs[k]->msg_no < jlr.HighReadMsg) {
|
||||
break;
|
||||
}
|
||||
unread_count++;
|
||||
}
|
||||
if (unread_count > 0) {
|
||||
s_printf("\e[2J\e[1;1H");
|
||||
s_printf(get_string(277), i, conf.mail_conferences[i]->name);
|
||||
s_printf(get_string(278), j, conf.mail_conferences[i]->mail_areas[j]->name, unread_count);
|
||||
s_printf(get_string(279));
|
||||
|
||||
ch = s_getchar();
|
||||
s_printf("\r\n");
|
||||
if (tolower(ch) == 'y') {
|
||||
orig_conf = user->cur_mail_conf;
|
||||
orig_area = user->cur_mail_area;
|
||||
|
||||
@ -3111,16 +3221,20 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
user->cur_mail_conf = orig_conf;
|
||||
user->cur_mail_area = orig_area;
|
||||
}
|
||||
}
|
||||
}
|
||||
free_message_headers(msghs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
if (res) {
|
||||
break;
|
||||
}
|
||||
@ -3135,12 +3249,16 @@ void do_mail_scan(struct user_record *user, int oldscan) {
|
||||
}
|
||||
}
|
||||
|
||||
void full_mail_scan_personal(struct user_record *user) {
|
||||
do_mail_scan(user, 0, 1);
|
||||
}
|
||||
|
||||
void full_mail_scan(struct user_record *user) {
|
||||
do_mail_scan(user, 0);
|
||||
do_mail_scan(user, 0, 0);
|
||||
}
|
||||
|
||||
void mail_scan(struct user_record *user) {
|
||||
do_mail_scan(user, 1);
|
||||
do_mail_scan(user, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -3257,6 +3375,7 @@ void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno) {
|
||||
|
||||
if (JAM_ReadMBHeader(jb, &jbh) != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3301,6 +3420,7 @@ void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno) {
|
||||
JAM_WriteLastRead(jb, gUser->id, &jlr);
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
}
|
||||
|
||||
void msgbase_reset_all_pointers(int readm) {
|
||||
@ -3326,15 +3446,17 @@ int new_messages(struct user_record *user, int conference, int area) {
|
||||
}
|
||||
if (JAM_ReadMBHeader(jb, &jbh) != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
||||
if (jbh.ActiveMsgs == 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) {
|
||||
msghs = read_message_headers(conference, area, user);
|
||||
msghs = read_message_headers(conference, area, user, 0);
|
||||
if (msghs != NULL) {
|
||||
if (msghs->msg_count > 0) {
|
||||
count = msghs->msg_count;
|
||||
@ -3347,7 +3469,7 @@ int new_messages(struct user_record *user, int conference, int area) {
|
||||
} else {
|
||||
if (jlr.HighReadMsg < jbh.ActiveMsgs) {
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_NETMAIL_AREA) {
|
||||
msghs = read_message_headers(conference, area, user);
|
||||
msghs = read_message_headers(conference, area, user, 0);
|
||||
if (msghs != NULL) {
|
||||
if (msghs->msg_count > 0) {
|
||||
if (msghs->msgs[msghs->msg_count-1]->msg_h->MsgNum > jlr.HighReadMsg) {
|
||||
@ -3362,5 +3484,6 @@ int new_messages(struct user_record *user, int conference, int area) {
|
||||
}
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return count;
|
||||
}
|
||||
|
77
src/main.c
77
src/main.c
@ -5,6 +5,7 @@
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/stat.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -40,6 +41,7 @@ extern struct user_record *gUser;
|
||||
int ssh_pid = -1;
|
||||
int bbs_pid = 0;
|
||||
int server_socket = -1;
|
||||
int ipv6_pid = -1;
|
||||
|
||||
int bbs_stdin;
|
||||
int bbs_stdout;
|
||||
@ -62,6 +64,9 @@ void sigterm_handler(int s)
|
||||
MHD_stop_daemon(www_daemon);
|
||||
}
|
||||
#endif
|
||||
if (ipv6_pid != -1) {
|
||||
kill(ipv6_pid, SIGTERM);
|
||||
}
|
||||
remove(conf.pid_file);
|
||||
exit(0);
|
||||
}
|
||||
@ -255,6 +260,12 @@ static int file_sub_handler(void* user, const char* section, const char* name,
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
if (strcasecmp(name, "visible sec level") == 0) {
|
||||
fd->sec_level = atoi(value);
|
||||
} else if (strcasecmp(name, "visible on web") == 0) {
|
||||
if (strcasecmp(value, "true") == 0) {
|
||||
fd->display_on_web = 1;
|
||||
} else {
|
||||
fd->display_on_web = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// check if it's partially filled in
|
||||
@ -401,6 +412,7 @@ static int handler(void* user, const char* section, const char* name,
|
||||
const char* value)
|
||||
{
|
||||
struct bbs_config *conf = (struct bbs_config *)user;
|
||||
struct passwd *pwd;
|
||||
|
||||
if (strcasecmp(section, "main") == 0) {
|
||||
if (strcasecmp(name, "bbs name") == 0) {
|
||||
@ -515,6 +527,12 @@ static int handler(void* user, const char* section, const char* name,
|
||||
} else {
|
||||
conf->date_style = 0;
|
||||
}
|
||||
} else if (strcasecmp(name, "run as user") == 0) {
|
||||
pwd = getpwnam(value);
|
||||
if (pwd != NULL) {
|
||||
conf->uid = pwd->pw_uid;
|
||||
conf->gid = pwd->pw_gid;
|
||||
}
|
||||
}
|
||||
} else if (strcasecmp(section, "paths") == 0){
|
||||
if (strcasecmp(name, "ansi path") == 0) {
|
||||
@ -566,6 +584,7 @@ static int handler(void* user, const char* section, const char* name,
|
||||
conf->file_directories[conf->file_directory_count]->name = strdup(name);
|
||||
conf->file_directories[conf->file_directory_count]->path = strdup(value);
|
||||
conf->file_directories[conf->file_directory_count]->file_sub_count = 0;
|
||||
conf->file_directories[conf->file_directory_count]->display_on_web = 0;
|
||||
conf->file_directory_count++;
|
||||
} else if (strcasecmp(section, "text files") == 0) {
|
||||
if (conf->text_file_count == 0) {
|
||||
@ -788,6 +807,14 @@ void serverssh(int port, int ipv6) {
|
||||
c = sizeof(struct sockaddr_in);
|
||||
}
|
||||
|
||||
if (conf.uid != getuid()) {
|
||||
if (setgid(conf.gid) != 0 || setuid(conf.uid) != 0) {
|
||||
perror("SetUID Failed: ");
|
||||
remove(conf.pid_file);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
listen(ssh_sock, 3);
|
||||
|
||||
while ((csock = accept(ssh_sock, (struct sockaddr *)client_p, (socklen_t *)&c))) {
|
||||
@ -1063,6 +1090,7 @@ void server(int port, int ipv6) {
|
||||
ssh_pid = fork();
|
||||
|
||||
if (ssh_pid == 0) {
|
||||
ipv6_pid = -1;
|
||||
ssh_pid = -1;
|
||||
serverssh(conf.ssh_port, ipv6);
|
||||
exit(0);
|
||||
@ -1072,20 +1100,6 @@ void server(int port, int ipv6) {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_WWW)
|
||||
if (conf.www_server && conf.www_path != NULL && conf.www_url != NULL) {
|
||||
if (!conf.fork) {
|
||||
printf(" - HTTP Starting on Port %d (IPv%d)\n", conf.www_port, (ipv6 ? 6 : 4));
|
||||
}
|
||||
www_init();
|
||||
if (ipv6) {
|
||||
www_daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION|MHD_USE_IPv6, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_URI_LOG_CALLBACK, &www_logger, NULL, MHD_OPTION_END);
|
||||
} else {
|
||||
www_daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_URI_LOG_CALLBACK, &www_logger, NULL, MHD_OPTION_END);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ipv6) {
|
||||
server_socket = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
} else {
|
||||
@ -1145,6 +1159,28 @@ void server(int port, int ipv6) {
|
||||
client_p = &client4;
|
||||
}
|
||||
|
||||
if (conf.uid != getuid()) {
|
||||
if (setgid(conf.gid) != 0 || setuid(conf.uid) != 0) {
|
||||
perror("SetUID Failed: ");
|
||||
remove(conf.pid_file);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(ENABLE_WWW)
|
||||
if (conf.www_server && conf.www_path != NULL && conf.www_url != NULL) {
|
||||
if (!conf.fork) {
|
||||
printf(" - HTTP Starting on Port %d (IPv%d)\n", conf.www_port, (ipv6 ? 6 : 4));
|
||||
}
|
||||
www_init();
|
||||
if (ipv6) {
|
||||
www_daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION|MHD_USE_IPv6, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_URI_LOG_CALLBACK, &www_logger, NULL, MHD_OPTION_END);
|
||||
} else {
|
||||
www_daemon = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION, conf.www_port, NULL, NULL, &www_handler, NULL, MHD_OPTION_NOTIFY_COMPLETED, &www_request_completed, NULL, MHD_OPTION_URI_LOG_CALLBACK, &www_logger, NULL, MHD_OPTION_END);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
listen(server_socket, 3);
|
||||
|
||||
|
||||
@ -1222,7 +1258,7 @@ void server(int port, int ipv6) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
int main_pid, ipv6_pid;
|
||||
int main_pid;
|
||||
FILE *fptr;
|
||||
struct stat s;
|
||||
char buffer[1024];
|
||||
@ -1262,7 +1298,8 @@ int main(int argc, char **argv) {
|
||||
conf.codepage = 0;
|
||||
conf.date_style = 0;
|
||||
conf.ipv6 = 0;
|
||||
|
||||
conf.uid = getuid();
|
||||
conf.gid = getgid();
|
||||
// Load BBS data
|
||||
if (ini_parse(argv[1], handler, &conf) <0) {
|
||||
fprintf(stderr, "Unable to load configuration ini (%s)!\n", argv[1]);
|
||||
@ -1329,6 +1366,12 @@ int main(int argc, char **argv) {
|
||||
exit(-1);
|
||||
} else
|
||||
if (main_pid > 0) {
|
||||
if (conf.uid != getuid()) {
|
||||
if (setgid(conf.gid) != 0 || setuid(conf.uid) != 0) {
|
||||
perror("Setuid Error: ");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
fptr = fopen(conf.pid_file, "w");
|
||||
if (!fptr) {
|
||||
fprintf(stderr, "Unable to open pid file for writing.\n");
|
||||
@ -1351,6 +1394,7 @@ int main(int argc, char **argv) {
|
||||
} else if (ipv6_pid > 0) {
|
||||
server(conf.telnet_port, 0);
|
||||
} else {
|
||||
ipv6_pid = -1;
|
||||
server(conf.telnet_port, 1);
|
||||
}
|
||||
} else {
|
||||
@ -1375,6 +1419,7 @@ int main(int argc, char **argv) {
|
||||
} else if (ipv6_pid > 0) {
|
||||
server(conf.telnet_port, 0);
|
||||
} else {
|
||||
ipv6_pid = -1;
|
||||
server(conf.telnet_port, 1);
|
||||
}
|
||||
} else {
|
||||
|
212
src/menus.c
212
src/menus.c
@ -11,7 +11,7 @@
|
||||
#define MENU_SUBMENU 1
|
||||
#define MENU_LOGOFF 2
|
||||
#define MENU_PREVMENU 3
|
||||
#define MENU_AUTOMESSAGEWRITE 4
|
||||
#define MENU_AUTOMESSAGE 4
|
||||
#define MENU_TEXTFILES 5
|
||||
#define MENU_CHATSYSTEM 6
|
||||
#define MENU_BBSLIST 7
|
||||
@ -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;
|
||||
@ -64,8 +66,9 @@ extern int mynode;
|
||||
|
||||
struct menu_item {
|
||||
char hotkey;
|
||||
int command;
|
||||
char *data;
|
||||
int *command;
|
||||
char **data;
|
||||
int command_count;
|
||||
int seclevel;
|
||||
};
|
||||
|
||||
@ -80,6 +83,7 @@ int menu_system(char *menufile) {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
int m;
|
||||
struct stat s;
|
||||
char *lRet;
|
||||
lua_State *L;
|
||||
@ -123,113 +127,131 @@ int menu_system(char *menufile) {
|
||||
}
|
||||
menu[menu_items-1] = (struct menu_item *)malloc(sizeof(struct menu_item));
|
||||
menu[menu_items-1]->hotkey = buffer[7];
|
||||
menu[menu_items-1]->command = 0;
|
||||
menu[menu_items-1]->command = NULL;
|
||||
menu[menu_items-1]->data = NULL;
|
||||
menu[menu_items-1]->command_count = 0;
|
||||
menu[menu_items-1]->seclevel = 0;
|
||||
} else if (strncasecmp(buffer, "COMMAND", 7) == 0 && menu_items > 0) {
|
||||
if (menu[menu_items-1]->command_count == 0) {
|
||||
menu[menu_items-1]->command = (int *)malloc(sizeof(int));
|
||||
menu[menu_items-1]->data = (char **)malloc(sizeof(char *));
|
||||
} else {
|
||||
menu[menu_items-1]->command = (int *)realloc(menu[menu_items-1]->command, sizeof(int) * (menu[menu_items-1]->command_count + 1));
|
||||
menu[menu_items-1]->data = (char **)realloc(menu[menu_items-1]->data, sizeof(char *) * (menu[menu_items-1]->command_count + 1));
|
||||
}
|
||||
menu[menu_items-1]->command_count++;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = 0;
|
||||
menu[menu_items-1]->data[menu[menu_items -1]->command_count - 1] = NULL;
|
||||
if (strncasecmp(&buffer[8], "SUBMENU", 7) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SUBMENU;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SUBMENU;
|
||||
} else if (strncasecmp(&buffer[8], "LOGOFF", 6) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LOGOFF;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LOGOFF;
|
||||
} else if (strncasecmp(&buffer[8], "PREVMENU", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_PREVMENU;
|
||||
} else if (strncasecmp(&buffer[8], "AUTOMESSAGE_WRITE", 17) == 0) {
|
||||
menu[menu_items-1]->command = MENU_AUTOMESSAGEWRITE;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_PREVMENU;
|
||||
} else if (strncasecmp(&buffer[8], "AUTOMESSAGE", 11) == 0) {
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_AUTOMESSAGE;
|
||||
} else if (strncasecmp(&buffer[8], "TEXTFILES", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_TEXTFILES;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_TEXTFILES;
|
||||
} else if (strncasecmp(&buffer[8], "CHATSYSTEM", 10) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CHATSYSTEM;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CHATSYSTEM;
|
||||
} else if (strncasecmp(&buffer[8], "BBSLIST", 7) == 0) {
|
||||
menu[menu_items-1]->command = MENU_BBSLIST;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BBSLIST;
|
||||
} else if (strncasecmp(&buffer[8], "LISTUSERS", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LISTUSERS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LISTUSERS;
|
||||
} else if (strncasecmp(&buffer[8], "BULLETINS", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_BULLETINS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BULLETINS;
|
||||
} else if (strncasecmp(&buffer[8], "LAST10CALLERS", 13) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LAST10;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LAST10;
|
||||
} else if (strncasecmp(&buffer[8], "SETTINGS", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SETTINGS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SETTINGS;
|
||||
} else if (strncasecmp(&buffer[8], "RUNDOOR", 7) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DOOR;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_DOOR;
|
||||
} else if (strncasecmp(&buffer[8], "MAILSCAN", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_MAILSCAN;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_MAILSCAN;
|
||||
} else if (strncasecmp(&buffer[8], "READMAIL", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_READMAIL;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_READMAIL;
|
||||
} else if (strncasecmp(&buffer[8], "POSTMESSAGE", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_POSTMESSAGE;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_POSTMESSAGE;
|
||||
} else if (strncasecmp(&buffer[8], "CHOOSEMAILCONF", 14) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CHOOSEMAILCONF;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CHOOSEMAILCONF;
|
||||
} else if (strncasecmp(&buffer[8], "CHOOSEMAILAREA", 14) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CHOOSEMAILAREA;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CHOOSEMAILAREA;
|
||||
} else if (strncasecmp(&buffer[8], "SENDEMAIL", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SENDEMAIL;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SENDEMAIL;
|
||||
} else if (strncasecmp(&buffer[8], "LISTEMAIL", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LISTEMAIL;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LISTEMAIL;
|
||||
} else if (strncasecmp(&buffer[8], "NEXTMAILCONF", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_NEXTMAILCONF;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_NEXTMAILCONF;
|
||||
} else if (strncasecmp(&buffer[8], "PREVMAILCONF", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_PREVMAILCONF;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_PREVMAILCONF;
|
||||
} else if (strncasecmp(&buffer[8], "NEXTMAILAREA", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_NEXTMAILAREA;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_NEXTMAILAREA;
|
||||
} else if (strncasecmp(&buffer[8], "PREVMAILAREA", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_PREVMAILAREA;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_PREVMAILAREA;
|
||||
} else if (strncasecmp(&buffer[8], "BLUEWAVEDOWNLOAD", 16) == 0) {
|
||||
menu[menu_items-1]->command = MENU_BLUEWAVEDOWN;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BLUEWAVEDOWN;
|
||||
} else if (strncasecmp(&buffer[8], "BLUEWAVEUPLOAD", 14) == 0) {
|
||||
menu[menu_items-1]->command = MENU_BLUEWAVEUP;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BLUEWAVEUP;
|
||||
} else if (strncasecmp(&buffer[8], "CHOOSEFILEDIR", 13) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CHOOSEFILEDIR;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CHOOSEFILEDIR;
|
||||
} else if (strncasecmp(&buffer[8], "CHOOSEFILESUB", 13) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CHOOSEFILESUB;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CHOOSEFILESUB;
|
||||
} else if (strncasecmp(&buffer[8], "LISTFILES", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LISTFILES;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LISTFILES;
|
||||
} else if (strncasecmp(&buffer[8], "UPLOAD", 6) == 0) {
|
||||
menu[menu_items-1]->command = MENU_UPLOAD;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_UPLOAD;
|
||||
} else if (strncasecmp(&buffer[8], "DOWNLOAD", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DOWNLOAD;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_DOWNLOAD;
|
||||
} else if (strncasecmp(&buffer[8], "CLEARTAGGED", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_CLEARTAGGEDFILES;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_CLEARTAGGEDFILES;
|
||||
} else if (strncasecmp(&buffer[8], "NEXTFILEDIR", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_NEXTFILEDIR;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_NEXTFILEDIR;
|
||||
} else if (strncasecmp(&buffer[8], "PREVFILEDIR", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_PREVFILEDIR;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_PREVFILEDIR;
|
||||
} else if (strncasecmp(&buffer[8], "NEXTFILESUB", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_NEXTFILESUB;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_NEXTFILESUB;
|
||||
} else if (strncasecmp(&buffer[8], "PREVFILESUB", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_PREVFILESUB;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_PREVFILESUB;
|
||||
} else if (strncasecmp(&buffer[8], "LISTMESSAGES", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_LISTMESSAGES;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_LISTMESSAGES;
|
||||
} else if (strncasecmp(&buffer[8], "DOSCRIPT", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DOSCRIPT;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_DOSCRIPT;
|
||||
} else if (strncasecmp(&buffer[8], "SENDNODEMSG", 11) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SENDNODEMSG;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SENDNODEMSG;
|
||||
} else if (strncasecmp(&buffer[8], "SUBUNSUBCONF", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SUBUNSUBCONF;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SUBUNSUBCONF;
|
||||
} else if (strncasecmp(&buffer[8], "RESETMSGPTRS", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_RESETPOINTERS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_RESETPOINTERS;
|
||||
} else if (strncasecmp(&buffer[8], "RESETALLMSGPTRS", 15) == 0) {
|
||||
menu[menu_items-1]->command = MENU_RESETALLPOINTERS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_RESETALLPOINTERS;
|
||||
} else if (strncasecmp(&buffer[8], "FILESCAN", 8) == 0) {
|
||||
menu[menu_items-1]->command = MENU_FILESCAN;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_FILESCAN;
|
||||
} else if (strncasecmp(&buffer[8], "FULLMAILSCAN", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_FULLMAILSCAN;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_FULLMAILSCAN;
|
||||
} else if (strncasecmp(&buffer[8], "FILESEARCH", 10) == 0) {
|
||||
menu[menu_items-1]->command = MENU_FILESEARCH;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_FILESEARCH;
|
||||
} else if (strncasecmp(&buffer[8], "DISPLAYTXTFILE", 14) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DISPTXTFILE;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_DISPTXTFILE;
|
||||
} else if (strncasecmp(&buffer[8], "DISPLAYTXTPAUSE", 15) == 0) {
|
||||
menu[menu_items-1]->command = MENU_DISPTXTFILEPAUSE;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_DISPTXTFILEPAUSE;
|
||||
} else if (strncasecmp(&buffer[8], "GENWWWURLS", 10) == 0) {
|
||||
menu[menu_items-1]->command = MENU_GENWWWURLS;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_GENWWWURLS;
|
||||
} else if (strncasecmp(&buffer[8], "NLBROWSER", 9) == 0) {
|
||||
menu[menu_items-1]->command = MENU_NLBROWSER;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_NLBROWSER;
|
||||
} else if (strncasecmp(&buffer[8], "SENDFEEDBACK", 12) == 0) {
|
||||
menu[menu_items-1]->command = MENU_SENDFEEDBACK;
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_SENDFEEDBACK;
|
||||
} else if (strncasecmp(&buffer[8], "BLOGDISPLAY", 11) == 0) {
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BLOGDISPLAY;
|
||||
} else if (strncasecmp(&buffer[8], "BLOGWRITE", 9) == 0) {
|
||||
menu[menu_items-1]->command[menu[menu_items -1]->command_count - 1] = MENU_BLOGWRITE;
|
||||
}
|
||||
} else if (strncasecmp(buffer, "SECLEVEL", 8) == 0) {
|
||||
menu[menu_items-1]->seclevel = atoi(&buffer[9]);
|
||||
} else if (strncasecmp(buffer, "DATA", 4) == 0) {
|
||||
menu[menu_items-1]->data = strdup(&buffer[5]);
|
||||
if (menu[menu_items-1]->data[menu[menu_items -1]->command_count - 1] != NULL) {
|
||||
free(menu[menu_items-1]->data[menu[menu_items -1]->command_count - 1]);
|
||||
}
|
||||
menu[menu_items-1]->data[menu[menu_items -1]->command_count - 1] = strdup(&buffer[5]);
|
||||
} else if (strncasecmp(buffer, "LUASCRIPT", 9) == 0) {
|
||||
if (lua_script != NULL) {
|
||||
free(lua_script);
|
||||
@ -328,9 +350,10 @@ int menu_system(char *menufile) {
|
||||
for (i=0;i<menu_items;i++) {
|
||||
if (tolower(menu[i]->hotkey) == tolower(c)) {
|
||||
if (menu[i]->seclevel <= gUser->sec_level) {
|
||||
switch(menu[i]->command) {
|
||||
for (j=0; j<menu[i]->command_count;j++) {
|
||||
switch(menu[i]->command[j]) {
|
||||
case MENU_SUBMENU:
|
||||
doquit = menu_system(menu[i]->data);
|
||||
doquit = menu_system(menu[i]->data[j]);
|
||||
if (doquit == 1) {
|
||||
// free menus
|
||||
if (do_lua_menu) {
|
||||
@ -343,9 +366,13 @@ int menu_system(char *menufile) {
|
||||
free(ansi_file);
|
||||
}
|
||||
for (i=0;i<menu_items;i++) {
|
||||
if (menu[i]->data != NULL) {
|
||||
free(menu[i]->data);
|
||||
for (j=0;j<menu[i]->command_count;j++) {
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
free(menu[i]->data[j]);
|
||||
}
|
||||
}
|
||||
free(menu[i]->data);
|
||||
free(menu[i]->command);
|
||||
free(menu[i]);
|
||||
}
|
||||
free(menu);
|
||||
@ -363,9 +390,13 @@ int menu_system(char *menufile) {
|
||||
free(ansi_file);
|
||||
}
|
||||
for (i=0;i<menu_items;i++) {
|
||||
if (menu[i]->data != NULL) {
|
||||
free(menu[i]->data);
|
||||
for (j=0;j<menu[i]->command_count;j++) {
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
free(menu[i]->data[j]);
|
||||
}
|
||||
}
|
||||
free(menu[i]->data);
|
||||
free(menu[i]->command);
|
||||
free(menu[i]);
|
||||
}
|
||||
free(menu);
|
||||
@ -381,15 +412,19 @@ int menu_system(char *menufile) {
|
||||
free(ansi_file);
|
||||
}
|
||||
for (i=0;i<menu_items;i++) {
|
||||
if (menu[i]->data != NULL) {
|
||||
free(menu[i]->data);
|
||||
for (j=0;j<menu[i]->command_count;j++) {
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
free(menu[i]->data[j]);
|
||||
}
|
||||
}
|
||||
free(menu[i]->data);
|
||||
free(menu[i]->command);
|
||||
free(menu[i]);
|
||||
}
|
||||
free(menu);
|
||||
return 0;
|
||||
case MENU_AUTOMESSAGEWRITE:
|
||||
automessage_write(gUser);
|
||||
case MENU_AUTOMESSAGE:
|
||||
automessage();
|
||||
break;
|
||||
case MENU_TEXTFILES:
|
||||
display_textfiles();
|
||||
@ -414,11 +449,11 @@ int menu_system(char *menufile) {
|
||||
break;
|
||||
case MENU_DOOR:
|
||||
{
|
||||
for (j=0;j<conf.door_count;j++) {
|
||||
if (strcasecmp(menu[i]->data, conf.doors[j]->name) == 0) {
|
||||
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
|
||||
rundoor(gUser, conf.doors[j]->command, conf.doors[j]->stdio, conf.doors[j]->codepage);
|
||||
dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[j]->name, mynode);
|
||||
for (m=0;m<conf.door_count;m++) {
|
||||
if (strcasecmp(menu[i]->data[j], conf.doors[m]->name) == 0) {
|
||||
dolog("%s launched door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
||||
rundoor(gUser, conf.doors[m]->command, conf.doors[m]->stdio, conf.doors[m]->codepage);
|
||||
dolog("%s returned from door %s, on node %d", gUser->loginname, conf.doors[m]->name, mynode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -501,7 +536,7 @@ int menu_system(char *menufile) {
|
||||
list_messages(gUser);
|
||||
break;
|
||||
case MENU_DOSCRIPT:
|
||||
do_lua_script(menu[i]->data);
|
||||
do_lua_script(menu[i]->data[j]);
|
||||
break;
|
||||
case MENU_SENDNODEMSG:
|
||||
send_node_msg();
|
||||
@ -514,10 +549,10 @@ int menu_system(char *menufile) {
|
||||
s_readstring(buffer, 10);
|
||||
if (tolower(buffer[0]) == 'r') {
|
||||
k = -1;
|
||||
j = 1;
|
||||
m = 1;
|
||||
} else if (tolower(buffer[0]) == 'u') {
|
||||
k = -1;
|
||||
j = 0;
|
||||
m = 0;
|
||||
} else if (buffer[0] < '0' || buffer[0] > '9') {
|
||||
s_printf(get_string(39));
|
||||
break;
|
||||
@ -525,39 +560,47 @@ int menu_system(char *menufile) {
|
||||
k = atoi(buffer) - 1;
|
||||
}
|
||||
|
||||
msgbase_reset_pointers(gUser->cur_mail_conf, gUser->cur_mail_area, j, k);
|
||||
msgbase_reset_pointers(gUser->cur_mail_conf, gUser->cur_mail_area, m, k);
|
||||
|
||||
break;
|
||||
case MENU_RESETALLPOINTERS:
|
||||
s_printf(get_string(230));
|
||||
confirm = s_getc();
|
||||
if (confirm == 'r' || confirm == 'R') {
|
||||
j = 1;
|
||||
m = 1;
|
||||
} else if (confirm == 'u' || confirm == 'U') {
|
||||
j = 0;
|
||||
m = 0;
|
||||
} else {
|
||||
s_printf(get_string(39));
|
||||
break;
|
||||
}
|
||||
msgbase_reset_all_pointers(j);
|
||||
msgbase_reset_all_pointers(m);
|
||||
break;
|
||||
case MENU_FILESCAN:
|
||||
file_scan();
|
||||
break;
|
||||
case MENU_FULLMAILSCAN:
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
if (strcasecmp(menu[i]->data[j], "PERSONAL") == 0) {
|
||||
full_mail_scan_personal(gUser);
|
||||
} else {
|
||||
full_mail_scan(gUser);
|
||||
}
|
||||
} else {
|
||||
full_mail_scan(gUser);
|
||||
}
|
||||
break;
|
||||
case MENU_FILESEARCH:
|
||||
file_search();
|
||||
break;
|
||||
case MENU_DISPTXTFILE:
|
||||
if (menu[i]->data != NULL) {
|
||||
s_displayansi_pause(menu[i]->data, 0);
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
s_displayansi_pause(menu[i]->data[j], 0);
|
||||
}
|
||||
break;
|
||||
case MENU_DISPTXTFILEPAUSE:
|
||||
if (menu[i]->data != NULL) {
|
||||
s_displayansi_pause(menu[i]->data, 1);
|
||||
if (menu[i]->data[j] != NULL) {
|
||||
s_displayansi_pause(menu[i]->data[j], 1);
|
||||
}
|
||||
s_printf(get_string(6));
|
||||
s_getc();
|
||||
@ -578,9 +621,16 @@ int menu_system(char *menufile) {
|
||||
free(msg);
|
||||
}
|
||||
break;
|
||||
case MENU_BLOGDISPLAY:
|
||||
blog_display();
|
||||
break;
|
||||
case MENU_BLOGWRITE:
|
||||
blog_write();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ char **strings;
|
||||
int string_count;
|
||||
|
||||
void chomp(char *string) {
|
||||
while ((string[strlen(string)-1] == '\r' || string[strlen(string)-1] == '\n') && strlen(string)) {
|
||||
while (strlen(string) && (string[strlen(string)-1] == '\r' || string[strlen(string)-1] == '\n')) {
|
||||
string[strlen(string)-1] = '\0';
|
||||
}
|
||||
}
|
||||
|
14
src/users.c
14
src/users.c
@ -76,7 +76,7 @@ static int secLevel(void* user, const char* section, const char* name,
|
||||
}
|
||||
|
||||
int save_user(struct user_record *user) {
|
||||
char buffer[256];
|
||||
char buffer[PATH_MAX];
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
@ -84,7 +84,7 @@ int save_user(struct user_record *user) {
|
||||
char *update_sql = "UPDATE users SET password=?, salt=?, firstname=?,"
|
||||
"lastname=?, email=?, location=?, sec_level=?, last_on=?, time_left=?, cur_mail_conf=?, cur_mail_area=?, cur_file_dir=?, cur_file_sub=?, times_on=?, bwavepktno=?, archiver=?, protocol=?,nodemsgs=?,codepage=?,exteditor=?,bwavestyle=?,signature=?,autosig=? where loginname LIKE ?";
|
||||
|
||||
sprintf(buffer, "%s/users.sq3", conf.bbs_path);
|
||||
snprintf(buffer, PATH_MAX, "%s/users.sq3", conf.bbs_path);
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
@ -128,13 +128,13 @@ int save_user(struct user_record *user) {
|
||||
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
|
||||
if (rc != SQLITE_DONE) {
|
||||
|
||||
sqlite3_finalize(res);
|
||||
dolog("execution failed: %s", sqlite3_errmsg(db));
|
||||
sqlite3_close(db);
|
||||
exit(1);
|
||||
}
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return 1;
|
||||
|
||||
@ -583,7 +583,7 @@ int check_user(char *loginname) {
|
||||
}
|
||||
|
||||
struct user_record *new_user() {
|
||||
char buffer[256];
|
||||
char buffer[PATH_MAX];
|
||||
struct user_record *user;
|
||||
int done = 0;
|
||||
char c;
|
||||
@ -603,7 +603,7 @@ struct user_record *new_user() {
|
||||
s_printf(get_string(166));
|
||||
s_readstring(buffer, 16);
|
||||
s_printf("\r\n");
|
||||
if (strlen(buffer) < 3) {
|
||||
if (strlen(buffer) < 2) {
|
||||
s_printf(get_string(167));
|
||||
continue;
|
||||
}
|
||||
@ -753,7 +753,7 @@ struct user_record *new_user() {
|
||||
user->sec_level = conf.newuserlvl;
|
||||
user->bwavepktno = 0;
|
||||
user->sec_info = (struct sec_level_t *)malloc(sizeof(struct sec_level_t));
|
||||
sprintf(buffer, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||
snprintf(buffer, PATH_MAX, "%s/config/s%d.ini", conf.bbs_path, user->sec_level);
|
||||
|
||||
if (ini_parse(buffer, secLevel, user->sec_info) <0) {
|
||||
dolog("Unable to load sec Level ini (%s)!", buffer);
|
||||
|
121
src/www.c
121
src/www.c
@ -420,6 +420,9 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
char *filename;
|
||||
int email;
|
||||
char *endptr;
|
||||
int file_dir;
|
||||
int file_sub;
|
||||
char *filen;
|
||||
// char *static_buffer;
|
||||
|
||||
page = NULL;
|
||||
@ -572,6 +575,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_);
|
||||
@ -853,7 +866,115 @@ int www_handler(void * cls, struct MHD_Connection * connection, const char * url
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
}
|
||||
} else if (strcasecmp(url, "/files/areas/") == 0 || strcasecmp(url, "/files/areas") == 0) {
|
||||
page = www_files_areas();
|
||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||
} else if (strncasecmp(url, "/files/areas/", 13) == 0) {
|
||||
file_dir = -1;
|
||||
file_sub = -1;
|
||||
filen = NULL;
|
||||
url_copy = strdup(&url[13]);
|
||||
|
||||
aptr = strtok(url_copy, "/");
|
||||
if (aptr != NULL) {
|
||||
file_dir = strtol(aptr, &endptr, 10);
|
||||
if (endptr == aptr) {
|
||||
file_dir = -1;
|
||||
}
|
||||
aptr = strtok(NULL, "/");
|
||||
if (aptr != NULL) {
|
||||
file_sub = strtol(aptr, &endptr, 10);
|
||||
if (endptr == aptr) {
|
||||
file_sub = -1;
|
||||
}
|
||||
aptr = strtok(NULL, "/");
|
||||
if (aptr != NULL) {
|
||||
filen = strdup(aptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
free(url_copy);
|
||||
|
||||
if (file_dir != -1 && file_sub != -1 && filen == NULL) {
|
||||
if (file_dir >= 0 && file_dir < conf.file_directory_count && file_sub >= 0 && file_sub < conf.file_directories[file_dir]->file_sub_count) {
|
||||
if (conf.file_directories[file_dir]->display_on_web) {
|
||||
page = www_files_display_listing(file_dir, file_sub);
|
||||
}
|
||||
}
|
||||
} else if (file_dir != -1 && file_sub != -1 && filen != NULL) {
|
||||
if (file_dir >= 0 && file_dir < conf.file_directory_count && file_sub >= 0 && file_sub < conf.file_directories[file_dir]->file_sub_count) {
|
||||
if (conf.file_directories[file_dir]->display_on_web) {
|
||||
// send file
|
||||
filename = www_files_get_from_area(file_dir, file_sub, filen);
|
||||
free(filen);
|
||||
if (filename != NULL) {
|
||||
mime = NULL;
|
||||
// get mimetype
|
||||
for (i=strlen(filename);i>0;--i) {
|
||||
if (filename[i] == '.') {
|
||||
mime = www_get_mime_type(&filename[i+1]);
|
||||
break;
|
||||
}
|
||||
if (filename[i] == '/') {
|
||||
mime = www_get_mime_type(NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mime = NULL) {
|
||||
mime = www_get_mime_type(NULL);
|
||||
}
|
||||
if (stat(filename, &s) == 0 && S_ISREG(s.st_mode)) {
|
||||
fno = open(filename, O_RDONLY);
|
||||
if (fno != -1) {
|
||||
|
||||
|
||||
response = MHD_create_response_from_fd(s.st_size, fno);
|
||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, mime);
|
||||
sprintf(buffer, "%ld", s.st_size);
|
||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_LENGTH, buffer);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "attachment; filename=\"%s\"", basename(filename));
|
||||
MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_DISPOSITION, buffer);
|
||||
ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
|
||||
MHD_destroy_response (response);
|
||||
free(header);
|
||||
free(footer);
|
||||
free(filename);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
free(filename);
|
||||
}
|
||||
if (www_404(header, footer, connection) != 0) {
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_NO;
|
||||
}
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
} else {
|
||||
free(filen);
|
||||
}
|
||||
} else {
|
||||
free(filen);
|
||||
}
|
||||
}
|
||||
if (page == NULL) {
|
||||
if (www_403(header, footer, connection) != 0) {
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_NO;
|
||||
}
|
||||
free(header);
|
||||
free(footer);
|
||||
return MHD_YES;
|
||||
}
|
||||
whole_page = (char *)malloc(strlen(header) + strlen(page) + strlen(footer) + 1);
|
||||
|
||||
sprintf(whole_page, "%s%s%s", header, page, footer);
|
||||
} else if (strncasecmp(url, "/files/", 7) == 0) {
|
||||
filename = www_decode_hash(&url[7]);
|
||||
if (filename != NULL) {
|
||||
|
121
src/www_blog.c
Normal file
121
src/www_blog.c
Normal file
@ -0,0 +1,121 @@
|
||||
#if defined(ENABLE_WWW)
|
||||
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
int hour;
|
||||
|
||||
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, "<div class=\"content-header\"><h2>System Blog</h2></div>\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, "<p>No Entries</p>\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;i<blog_entry_count;i++) {
|
||||
localtime_r(&blog_entries[i]->date, &thetime);
|
||||
if (thetime.tm_hour >= 12) {
|
||||
hour = thetime.tm_hour - 12;
|
||||
} else {
|
||||
hour = thetime.tm_hour;
|
||||
}
|
||||
sprintf(buffer, "<div class=\"blog-header\"><div class=\"blog-title\"><h3>%s</h3></div><div class=\"blog-date\">%d:%02d%s %s, %s %d %d</div><div class=\"blog-author\">by %s</div></div>", blog_entries[i]->subject,(hour == 0 ? 12 : hour), 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, "<div class=\"blog-entry\"><p>");
|
||||
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;j<strlen(blog_entries[i]->body);j++) {
|
||||
if (blog_entries[i]->body[j] == '\r') {
|
||||
if (blog_entries[i]->body[j+1] == '\r') {
|
||||
sprintf(buffer, "</p><p>");
|
||||
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++] = ' ';
|
||||
page[len] = '\0';
|
||||
}
|
||||
} 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, "</p></div>");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
}
|
||||
|
||||
for (i=0;i<blog_entry_count;i++) {
|
||||
free(blog_entries[i]->subject);
|
||||
free(blog_entries[i]->author);
|
||||
free(blog_entries[i]->body);
|
||||
free(blog_entries[i]);
|
||||
}
|
||||
free(blog_entries);
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
#endif
|
327
src/www_files.c
327
src/www_files.c
@ -9,13 +9,65 @@
|
||||
|
||||
extern struct bbs_config conf;
|
||||
extern struct user_record *gUser;
|
||||
extern char * aha(char *input);
|
||||
|
||||
static char *www_decode(char *clean_url) {
|
||||
char *url = (char *)malloc(strlen(clean_url) + 1);
|
||||
int i;
|
||||
int j = 0;
|
||||
unsigned char c;
|
||||
if (clean_url == NULL) {
|
||||
free(url);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<strlen(clean_url);i++) {
|
||||
if (clean_url[i] == '%') {
|
||||
c = clean_url[i+1] * 16 + clean_url[i+2];
|
||||
url[j++] = (char)c;
|
||||
url[j] = '\0';
|
||||
i+=2;
|
||||
} else {
|
||||
url[j++] = clean_url[i];
|
||||
url[j] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
static char *www_encode(char *url) {
|
||||
char *clean_url = (char *)malloc(strlen(url) * 3 + 1);
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (url == NULL) {
|
||||
free(clean_url);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
memset(clean_url, 0, strlen(url) * 3);
|
||||
|
||||
for (i=0;i<strlen(url);i++) {
|
||||
if (isalnum(url[i]) || url[i] == '~' || url[i] == '.' || url[i] == '_') {
|
||||
sprintf(&clean_url[j], "%c", url[i]);
|
||||
j++;
|
||||
} else {
|
||||
sprintf(&clean_url[j], "%%%02X", url[i]);
|
||||
j+=3;
|
||||
}
|
||||
}
|
||||
|
||||
return clean_url;
|
||||
}
|
||||
|
||||
void www_expire_old_links() {
|
||||
char buffer[PATH_MAX];
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
char sql[] = "delete from wwwhash where expire <= ?";
|
||||
char sql[] = "delete from wwwhash where expiry <= ?";
|
||||
char *ret;
|
||||
time_t now = time(NULL);
|
||||
|
||||
@ -44,7 +96,7 @@ int www_check_hash_expired(char *hash) {
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
time_t now = time(NULL);
|
||||
char sql[] = "select id from wwwhash where hash = ? and expire > ?";
|
||||
char sql[] = "select id from wwwhash where hash = ? and expiry > ?";
|
||||
snprintf(buffer, PATH_MAX, "%s/www_file_hashes.sq3", conf.bbs_path);
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
@ -169,16 +221,10 @@ char *www_decode_hash(char *hash) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// TODO: check security level...
|
||||
|
||||
if (conf.file_directories[dir]->sec_level < )
|
||||
#endif
|
||||
// get filename from database
|
||||
snprintf(buffer, PATH_MAX, "%s/%s.sq3", conf.bbs_path, conf.file_directories[dir]->file_subs[sub]->database);
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
return NULL;
|
||||
}
|
||||
sqlite3_busy_timeout(db, 5000);
|
||||
@ -233,5 +279,270 @@ char *www_create_link(int dir, int sub, int fid) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
char *www_files_display_listing(int dir, int sub) {
|
||||
char *page;
|
||||
int max_len;
|
||||
int len;
|
||||
char buffer[4096];
|
||||
char *sql = "select id, filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY filename";
|
||||
char *filename;
|
||||
char c;
|
||||
int size;
|
||||
char *aha_out;
|
||||
char *description;
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
int i;
|
||||
char *clean_url;
|
||||
|
||||
page = (char *)malloc(4096);
|
||||
max_len = 4096;
|
||||
len = 0;
|
||||
memset(page, 0, 4096);
|
||||
|
||||
snprintf(buffer, 4096, "<div class=\"content-header\"><h2>Files: %s - %s</h2></div>\n", conf.file_directories[dir]->name, conf.file_directories[dir]->file_subs[sub]->name);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
snprintf(buffer, 4096, "%s/%s.sq3", conf.bbs_path, conf.file_directories[dir]->file_subs[sub]->database);
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
free(page);
|
||||
return NULL;
|
||||
}
|
||||
sqlite3_busy_timeout(db, 5000);
|
||||
rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);
|
||||
if (rc != SQLITE_OK) {
|
||||
sqlite3_close(db);
|
||||
free(page);
|
||||
return NULL;
|
||||
}
|
||||
snprintf(buffer, 4096, "<table class=\"fileentry\"><thead><tr><td>Filename</td><td>Size</td><td>Description</td></tr></thead><tbody>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
while (sqlite3_step(res) == SQLITE_ROW) {
|
||||
filename = strdup(sqlite3_column_text(res, 1));
|
||||
clean_url = www_encode(basename(filename));
|
||||
snprintf(buffer, 4096, "<tr><td class=\"filename\"><a href=\"%sfiles/areas/%d/%d/%s\">%s</a></td>", conf.www_url, dir, sub, basename(clean_url), basename(filename));
|
||||
free(clean_url);
|
||||
free(filename);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
size = sqlite3_column_int(res, 3);
|
||||
|
||||
if (size > 1024 * 1024 * 1024) {
|
||||
size = size / 1024 / 1024 / 1024;
|
||||
c = 'G';
|
||||
} else if (size > 1024 * 1024) {
|
||||
size = size / 1024 / 1024;
|
||||
c = 'M';
|
||||
} else if (size > 1024) {
|
||||
size = size / 1024;
|
||||
c = 'K';
|
||||
} else {
|
||||
c = 'b';
|
||||
}
|
||||
|
||||
snprintf(buffer, 4096, "<td class=\"filesize\">%d%c</td>", size, c);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
description = strdup((char *)sqlite3_column_text(res, 2));
|
||||
|
||||
for (i=0;i<strlen(description);i++) {
|
||||
if (description[i] == '\n') {
|
||||
description[i] = '\r';
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buffer, 4096, "<td class=\"filedesc\">");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
aha_out = aha(description);
|
||||
|
||||
while (len + strlen(aha_out) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, aha_out);
|
||||
len += strlen(aha_out);
|
||||
|
||||
free(aha_out);
|
||||
free(description);
|
||||
|
||||
snprintf(buffer, 4096, "</td></tr>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
}
|
||||
|
||||
snprintf(buffer, 4096, "</tbody></table>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
char *www_files_areas() {
|
||||
char *page;
|
||||
int max_len;
|
||||
int len;
|
||||
char buffer[4096];
|
||||
int i;
|
||||
int j;
|
||||
|
||||
page = (char *)malloc(4096);
|
||||
max_len = 4096;
|
||||
len = 0;
|
||||
memset(page, 0, 4096);
|
||||
|
||||
sprintf(buffer, "<div class=\"content-header\"><h2>File Directories</h2></div>\n");
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
for (i=0;i<conf.file_directory_count;i++) {
|
||||
if (conf.file_directories[i]->display_on_web) {
|
||||
sprintf(buffer, "<div class=\"conference-list-item\">%s</div>\n", conf.file_directories[i]->name);
|
||||
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;j<conf.file_directories[i]->file_sub_count;j++) {
|
||||
sprintf(buffer, "<div class=\"area-list-item\"><a href=\"%sfiles/areas/%d/%d/\">%s</a></div>\n", conf.www_url, i, j, conf.file_directories[i]->file_subs[j]->name);
|
||||
if (len + strlen(buffer) > max_len - 1) {
|
||||
max_len += 4096;
|
||||
page = (char *)realloc(page, max_len);
|
||||
}
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
char *www_files_get_from_area(int dir, int sub, char *clean_file) {
|
||||
char *sql = "SELECT filename FROM files WHERE approved=1 AND filename LIKE ? ESCAPE \"^\"";
|
||||
char *filenamelike;
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
char buffer[PATH_MAX];
|
||||
char *ret = NULL;
|
||||
int i;
|
||||
int extra = 0;
|
||||
int j;
|
||||
char *file;
|
||||
|
||||
file = www_decode(clean_file);
|
||||
|
||||
for (i=0;i<strlen(file);i++) {
|
||||
if (file[i] == '^' || file[i] == '%' || file[i] == '_') {
|
||||
extra++;
|
||||
}
|
||||
}
|
||||
|
||||
filenamelike = (char *)malloc(strlen(file) + 3 + extra);
|
||||
|
||||
i = 0;
|
||||
filenamelike[i++] = '%';
|
||||
filenamelike[i] = '\0';
|
||||
|
||||
for (j = 0; j < strlen(file); j++) {
|
||||
switch(file[j]) {
|
||||
case '^':
|
||||
filenamelike[i++] = '^';
|
||||
filenamelike[i++] = '^';
|
||||
filenamelike[i] = '\0';
|
||||
break;
|
||||
case '_':
|
||||
filenamelike[i++] = '^';
|
||||
filenamelike[i++] = '_';
|
||||
filenamelike[i] = '\0';
|
||||
break;
|
||||
case '%':
|
||||
filenamelike[i++] = '^';
|
||||
filenamelike[i++] = '%';
|
||||
filenamelike[i] = '\0';
|
||||
break;
|
||||
default:
|
||||
filenamelike[i++] = file[j];
|
||||
filenamelike[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// sprintf(filenamelike, "%%/%s", file);
|
||||
|
||||
free(file);
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/%s.sq3", conf.bbs_path, conf.file_directories[dir]->file_subs[sub]->database);
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
if (rc != SQLITE_OK) {
|
||||
return NULL;
|
||||
}
|
||||
sqlite3_busy_timeout(db, 5000);
|
||||
rc = sqlite3_prepare_v2(db, sql, -1, &res, 0);
|
||||
if (rc != SQLITE_OK) {
|
||||
sqlite3_close(db);
|
||||
return NULL;
|
||||
}
|
||||
sqlite3_bind_text(res, 1, filenamelike, -1, 0);
|
||||
|
||||
rc = sqlite3_step(res);
|
||||
if (rc == SQLITE_ROW) {
|
||||
ret = strdup(sqlite3_column_text(res, 0));
|
||||
|
||||
}
|
||||
|
||||
free(filenamelike);
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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,10 +56,18 @@ char *www_last10() {
|
||||
for (z=0;z<i;z++) {
|
||||
localtime_r(&callers[z].time, &l10_time);
|
||||
if (conf.date_style == 1) {
|
||||
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 {
|
||||
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;
|
||||
page = (char *)realloc(page, max_len);
|
||||
|
117
src/www_msgs.c
117
src/www_msgs.c
@ -15,7 +15,7 @@ extern struct bbs_config conf;
|
||||
|
||||
|
||||
static char *www_wordwrap(char *content, int cutoff);
|
||||
static char *www_sanitize(char *inp) {
|
||||
char *www_sanitize(char *inp) {
|
||||
int i;
|
||||
char *result;
|
||||
int len = 0;
|
||||
@ -150,7 +150,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
}
|
||||
mhrs = read_message_headers(conference, area, user);
|
||||
mhrs = read_message_headers(conference, area, user, 0);
|
||||
|
||||
if (mhrs == NULL) {
|
||||
sprintf(buffer, "<h3>No Messages</h3>\n");
|
||||
@ -174,6 +174,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
jb = open_jam_base(conf.mail_conferences[conference]->mail_areas[area]->path);
|
||||
if (!jb) {
|
||||
free(page);
|
||||
free_message_headers(mhrs);
|
||||
return NULL;
|
||||
}
|
||||
if (JAM_ReadLastRead(jb, user->id, &jlr) == JAM_NO_USER) {
|
||||
@ -181,7 +182,7 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
||||
jlr.HighReadMsg = 0;
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
|
||||
free(jb);
|
||||
skip_f = mhrs->msg_count - skip;
|
||||
skip_t = mhrs->msg_count - skip - 50;
|
||||
if (skip_t < 0) {
|
||||
@ -271,6 +272,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
char *replyid = NULL;
|
||||
char *body = NULL;
|
||||
char *body2 = NULL;
|
||||
char *replybody = NULL;
|
||||
int z;
|
||||
struct tm msg_date;
|
||||
time_t date;
|
||||
@ -283,7 +285,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
char *from_s;
|
||||
char *subject_s;
|
||||
char *to_s;
|
||||
|
||||
int l1, l2;
|
||||
char *aha_text;
|
||||
char *aha_out;
|
||||
|
||||
@ -303,11 +305,13 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
z = JAM_ReadMsgHeader(jb, msg - 1, &jmh, &jsp);
|
||||
if (z != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
if (jmh.Attribute & JAM_MSG_DELETED) {
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -390,6 +394,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
free(replyid);
|
||||
}
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -411,6 +416,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
|
||||
JAM_WriteLastRead(jb, user->id, &jlr);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
|
||||
page = (char *)malloc(4096);
|
||||
max_len = 4096;
|
||||
@ -605,13 +611,27 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
||||
strcat(page, buffer);
|
||||
len += strlen(buffer);
|
||||
|
||||
replybody = (char *)malloc(strlen(body) + 1);
|
||||
|
||||
l2 = 0;
|
||||
for (l1=0;l1<strlen(body);l1++){
|
||||
if (body[l1] == '\e' && body[l1+1] == '[') {
|
||||
while (strchr("ABCDEFGHIGJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", body[l1]) == NULL && l1 < strlen(body))
|
||||
l1++;
|
||||
} else {
|
||||
replybody[l2++] = body[l1];
|
||||
replybody[l2] ='\0';
|
||||
}
|
||||
}
|
||||
|
||||
free(body);
|
||||
chars = 0;
|
||||
body2 = www_wordwrap(body, 69);
|
||||
body2 = www_wordwrap(replybody, 69);
|
||||
|
||||
if (body2 == NULL) {
|
||||
body2 = body;
|
||||
body2 = replybody;
|
||||
} else {
|
||||
free(body);
|
||||
free(replybody);
|
||||
}
|
||||
|
||||
for (i=0;i<strlen(body2);i++) {
|
||||
@ -699,24 +719,78 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
int i;
|
||||
int line_count = 0;
|
||||
char *last_space = NULL;
|
||||
char *ret = (char *)malloc(len + 1);
|
||||
char *ret;
|
||||
int at = 0;
|
||||
int extra = 0;
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
int quote_line = 0;
|
||||
|
||||
for (i=0;i<len;i++) {
|
||||
if (content[i] == '\n') {
|
||||
continue;
|
||||
}
|
||||
content[at++] = content[i];
|
||||
}
|
||||
|
||||
content[at] = '\0';
|
||||
at = 0;
|
||||
len = strlen(content);
|
||||
|
||||
for (i=0;i<len-1;i++) {
|
||||
if (content[i] == '>' && line_count < 4) {
|
||||
quote_line = 1;
|
||||
}
|
||||
|
||||
if (content[i] == '\r' && content[i+1] != '\r') {
|
||||
if (content[i+1] == ' ' && quote_line != 1) {
|
||||
content[at++] = '\r';
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
} else if (quote_line != 1) {
|
||||
if (at > 0 && content[at-1] != '\r' && content[at-1] != ' ') {
|
||||
content[at++] = ' ';
|
||||
line_count++;
|
||||
}
|
||||
} else if (quote_line == 1) {
|
||||
content[at++] = '\r';
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
}
|
||||
} else if (content[i] == '\r' && content[i+1] == '\r') {
|
||||
content[at++] = '\r';
|
||||
content[at++] = '\r';
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
i++;
|
||||
} else {
|
||||
content[at++] = content[i];
|
||||
line_count++;
|
||||
}
|
||||
}
|
||||
content[at++] = content[i];
|
||||
content[at] = '\0';
|
||||
|
||||
|
||||
at = 0;
|
||||
|
||||
len = strlen(content);
|
||||
ret = (char *)malloc(len + 1);
|
||||
if (ret == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
|
||||
for (i=0;i<len;i++) {
|
||||
if (content[i] != '\r') {
|
||||
ret[at] = content[i];
|
||||
if (content[i] == ' ') {
|
||||
last_space = &ret[at];
|
||||
}
|
||||
at++;
|
||||
|
||||
if (content[i] == '>' && line_count < 4) {
|
||||
quote_line = 1;
|
||||
}
|
||||
} else {
|
||||
ret[at++] = content[i];
|
||||
}
|
||||
@ -725,12 +799,21 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
if (content[i] == '\r') {
|
||||
line_count = 0;
|
||||
last_space = NULL;
|
||||
quote_line = 0;
|
||||
} else if (line_count == cutoff) {
|
||||
// wrap
|
||||
if (last_space != NULL) {
|
||||
if (quote_line == 1) {
|
||||
while (i < len - 1 && content[i + 1] != '\r') {
|
||||
i++;
|
||||
}
|
||||
last_space = NULL;
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
} else if (last_space != NULL) {
|
||||
*last_space = '\r';
|
||||
line_count = strlen(&last_space[1]);
|
||||
last_space = NULL;
|
||||
quote_line = 0;
|
||||
} else {
|
||||
extra++;
|
||||
ret = (char *)realloc(ret, strlen(content) + extra + 1);
|
||||
@ -741,6 +824,7 @@ static char *www_wordwrap(char *content, int cutoff) {
|
||||
ret[at] = '\0';
|
||||
last_space = NULL;
|
||||
line_count = 0;
|
||||
quote_line = 0;
|
||||
}
|
||||
} else {
|
||||
line_count++;
|
||||
@ -868,11 +952,13 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
sleep(1);
|
||||
} else {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (z != 0) {
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -903,6 +989,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
JAM_UnlockMB(jb);
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
body3 = (char *)malloc(strlen(body2) + 2 + strlen(buffer));
|
||||
@ -911,6 +998,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
JAM_UnlockMB(jb);
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -924,6 +1012,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
JAM_UnlockMB(jb);
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
free(jb);
|
||||
return 0;
|
||||
} else {
|
||||
if (conf.mail_conferences[conference]->mail_areas[area]->type == TYPE_ECHOMAIL_AREA) {
|
||||
@ -941,7 +1030,7 @@ int www_send_msg(struct user_record *user, char *to, char *subj, int conference,
|
||||
|
||||
JAM_DelSubPacket(jsp);
|
||||
JAM_CloseMB(jb);
|
||||
|
||||
free(jb);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
51
utils/dosbox_shim/Makefile
Normal file
51
utils/dosbox_shim/Makefile
Normal file
@ -0,0 +1,51 @@
|
||||
OS := $(shell uname -s)
|
||||
|
||||
ifeq ($(OS), FreeBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include
|
||||
LDFLAGS=-L/usr/local/lib
|
||||
endif
|
||||
ifeq ($(OS), DragonFly)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include -I/usr/local/include/ncurses
|
||||
LDFLAGS=-L/usr/local/lib
|
||||
endif
|
||||
ifeq ($(OS), NetBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/pkg/include
|
||||
LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib
|
||||
endif
|
||||
ifeq ($(OS), OpenBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include
|
||||
LDFLAGS=-L/usr/local/lib
|
||||
endif
|
||||
ifeq ($(OS), Linux)
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
LDFLAGS=
|
||||
endif
|
||||
ifeq ($(OS), Darwin)
|
||||
CC=cc
|
||||
CFLAGS=
|
||||
LDFLAGS=
|
||||
endif
|
||||
ifeq ($(OS), SunOS)
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
LDFLAGS=
|
||||
endif
|
||||
|
||||
DEPS = main.c
|
||||
|
||||
OBJ = main.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
shim: $(OBJ)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) shim
|
116
utils/dosbox_shim/main.c
Normal file
116
utils/dosbox_shim/main.c
Normal file
@ -0,0 +1,116 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(__OpenBSD__)
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int port;
|
||||
int node;
|
||||
char *script;
|
||||
pid_t pid;
|
||||
int server_socket;
|
||||
int on = 1;
|
||||
struct sockaddr_in server, client;
|
||||
int client_fd;
|
||||
int c;
|
||||
fd_set master, read_fds;
|
||||
int len;
|
||||
char inbuf[256];
|
||||
int i;
|
||||
char *arguments[4];
|
||||
|
||||
if (argc < 4) {
|
||||
fprintf(stderr, "Usage ./dosbox_shim [port] [node] [script]\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
node = atoi(argv[2]);
|
||||
script = strdup(argv[3]);
|
||||
|
||||
|
||||
pid = fork();
|
||||
|
||||
if (pid < 0) {
|
||||
fprintf(stderr, "Error forking!\n");
|
||||
exit(-1);
|
||||
} else if (pid == 0) {
|
||||
arguments[0] = strdup(script);
|
||||
sprintf(inbuf, "%d", port);
|
||||
arguments[1] = strdup(inbuf);
|
||||
sprintf(inbuf, "%d", node);
|
||||
arguments[2] = strdup(inbuf);
|
||||
arguments[3] = NULL;
|
||||
|
||||
|
||||
execvp(script, arguments);
|
||||
} else {
|
||||
server_socket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (server_socket == -1) {
|
||||
fprintf(stderr, "Couldn't create socket.\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) {
|
||||
fprintf(stderr, "setsockopt(SO_REUSEADDR) failed");
|
||||
exit(1);
|
||||
}
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_addr.s_addr = INADDR_ANY;
|
||||
server.sin_port = htons(port);
|
||||
|
||||
c = sizeof(struct sockaddr_in);
|
||||
|
||||
if (bind(server_socket, (struct sockaddr *)&server, sizeof(server)) < 0) {
|
||||
perror("Bind Failed, Error\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
listen(server_socket, 1);
|
||||
|
||||
client_fd = accept(server_socket, (struct sockaddr *)&client, (socklen_t *)&c);
|
||||
|
||||
if (client_fd == -1) {
|
||||
perror("accept");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
FD_ZERO(&master);
|
||||
|
||||
FD_SET(STDIN_FILENO, &master);
|
||||
FD_SET(client_fd, &master);
|
||||
|
||||
while(1) {
|
||||
read_fds = master;
|
||||
|
||||
if (select(client_fd + 1, &read_fds, NULL, NULL, NULL) == -1) {
|
||||
perror("select");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (FD_ISSET(STDIN_FILENO, &read_fds)) {
|
||||
len = read(STDIN_FILENO, inbuf, 256);
|
||||
for (i=0;i<len;i++) {
|
||||
write(client_fd, &inbuf[i], 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (FD_ISSET(client_fd, &read_fds)) {
|
||||
len = read(client_fd, inbuf, 256);
|
||||
if (len == 0) {
|
||||
close(client_fd);
|
||||
exit(0);
|
||||
}
|
||||
for (i=0;i<len;i++) {
|
||||
write(STDOUT_FILENO, &inbuf[i], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
51
utils/filecenter/Makefile
Normal file
51
utils/filecenter/Makefile
Normal file
@ -0,0 +1,51 @@
|
||||
OS := $(shell uname -s)
|
||||
|
||||
ifeq ($(OS), FreeBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include
|
||||
LDFLAGS=-L/usr/local/lib -lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), DragonFly)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include -I/usr/local/include/ncurses
|
||||
LDFLAGS=-L/usr/local/lib -lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), NetBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/pkg/include
|
||||
LDFLAGS=-R/usr/pkg/lib -L/usr/pkg/lib -lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), OpenBSD)
|
||||
CC=cc
|
||||
CFLAGS=-I/usr/local/include
|
||||
LDFLAGS=-L/usr/local/lib -lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), Linux)
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
LDFLAGS=-lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), Darwin)
|
||||
CC=cc
|
||||
CFLAGS=
|
||||
LDFLAGS=-lsqlite3 -lncurses
|
||||
endif
|
||||
ifeq ($(OS), SunOS)
|
||||
CC=gcc
|
||||
CFLAGS=
|
||||
LDFLAGS=-lsqlite3 -lcurses
|
||||
endif
|
||||
|
||||
DEPS = main.c
|
||||
|
||||
OBJ = main.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS) -I../../deps/cdk-5.0-20161210/include/
|
||||
|
||||
filecenter: $(OBJ)
|
||||
$(CC) -o $@ $^ ../../deps/cdk-5.0-20161210/libcdk.a ../../src/inih/ini.o $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) filecenter
|
3
utils/filecenter/editor.sh
Executable file
3
utils/filecenter/editor.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/vi $1
|
28
utils/filecenter/filecenter.h
Normal file
28
utils/filecenter/filecenter.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __FILECENTER_H__
|
||||
#define __FILECENTER_H__
|
||||
|
||||
struct file_sub {
|
||||
char *name;
|
||||
char *database;
|
||||
char *upload_path;
|
||||
int upload_sec_level;
|
||||
int download_sec_level;
|
||||
};
|
||||
|
||||
struct file_directory {
|
||||
char *name;
|
||||
char *path;
|
||||
int sec_level;
|
||||
int display_on_web;
|
||||
int file_sub_count;
|
||||
struct file_sub **file_subs;
|
||||
};
|
||||
|
||||
struct archiver {
|
||||
char *name;
|
||||
char *extension;
|
||||
char *unpack;
|
||||
char *pack;
|
||||
};
|
||||
|
||||
#endif
|
1176
utils/filecenter/main.c
Normal file
1176
utils/filecenter/main.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -184,8 +184,10 @@ bool IsArc(char *file)
|
||||
if(strlen(file)!=12) return(FALSE);
|
||||
if(file[8]!='.') return(FALSE);
|
||||
|
||||
for(c=0;c<8;c++)
|
||||
for(c=0;c<8;c++) {
|
||||
if (c == 4 && tolower(file[c]) == 'p') continue;
|
||||
if((file[c]<'0' || file[c]>'9') && ((tolower(file[c]) < 'a') || (tolower(file[c]) > 'f'))) return(FALSE);
|
||||
}
|
||||
|
||||
strncpy(ext,&file[9],2);
|
||||
ext[2]=0;
|
||||
|
Reference in New Issue
Block a user