| 52 |
int content_display_length; |
int content_display_length; |
| 53 |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
| 54 |
int sign_id = 0; |
int sign_id = 0; |
| 55 |
|
int reply_note = 1; |
| 56 |
long len; |
long len; |
| 57 |
int ch; |
int ch; |
| 58 |
char *p, *q; |
char *p, *q; |
| 90 |
{ |
{ |
| 91 |
clearscr(); |
clearscr(); |
| 92 |
moveto(21, 1); |
moveto(21, 1); |
| 93 |
prints("发表文章于 %s[%s] 讨论区,类型: %s", p_section->stitle, p_section->sname, (p_article_new->transship ? "转载" : "原创")); |
prints("发表文章于 %s[%s] 讨论区,类型: %s,通知:%s", |
| 94 |
|
p_section->stitle, p_section->sname, |
| 95 |
|
(p_article_new->transship ? "转载" : "原创"), |
| 96 |
|
(reply_note ? "开启" : "关闭")); |
| 97 |
moveto(22, 1); |
moveto(22, 1); |
| 98 |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
| 99 |
moveto(23, 1); |
moveto(23, 1); |
| 104 |
prints(" 按[1;32m0[m~[1;32m3[m选签名档(0表示不使用)"); |
prints(" 按[1;32m0[m~[1;32m3[m选签名档(0表示不使用)"); |
| 105 |
|
|
| 106 |
moveto(24, 1); |
moveto(24, 1); |
| 107 |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mZ[m设为转载, [1;32mY[m设为原创, [1;32mEnter[m继续: "); |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mZ[m设为%s, [1;32mN[m%s, [1;32mEnter[m继续: ", |
| 108 |
|
(p_article_new->transship ? "原创" : "转载"), |
| 109 |
|
(reply_note ? "通知关闭" : "通知开启")); |
| 110 |
iflush(); |
iflush(); |
| 111 |
ch = 0; |
ch = 0; |
| 112 |
} |
} |
| 122 |
igetch_reset(); |
igetch_reset(); |
| 123 |
break; |
break; |
| 124 |
case 'T': |
case 'T': |
| 125 |
moveto(24, 1); |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
|
clrtoeol(); |
|
|
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN, DOECHO); |
|
| 126 |
for (p = title_input; *p == ' '; p++) |
for (p = title_input; *p == ' '; p++) |
| 127 |
; |
; |
| 128 |
for (q = title_input + len; q > p && *(q - 1) == ' '; q--) |
for (q = title_input + len; q > p && *(q - 1) == ' '; q--) |
| 142 |
prints("取消..."); |
prints("取消..."); |
| 143 |
press_any_key(); |
press_any_key(); |
| 144 |
goto cleanup; |
goto cleanup; |
|
case 'Y': |
|
|
p_article_new->transship = 0; |
|
|
break; |
|
| 145 |
case 'Z': |
case 'Z': |
| 146 |
p_article_new->transship = 1; |
p_article_new->transship = (p_article_new->transship ? 0 : 1); |
| 147 |
|
break; |
| 148 |
|
case 'N': |
| 149 |
|
reply_note = (reply_note ? 0 : 1); |
| 150 |
break; |
break; |
| 151 |
case '0': |
case '0': |
| 152 |
case '1': |
case '1': |
| 334 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 335 |
"INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, " |
"INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, " |
| 336 |
"sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) " |
"sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) " |
| 337 |
"VALUES(%d, 0, %d, '%s', '%s', '%s', %d, %d, NOW(), '%s', 1, %d, NOW(), 1, %d)", |
"VALUES(%d, 0, %d, '%s', '%s', '%s', %d, %d, NOW(), '%s', %d, %d, NOW(), 1, %d)", |
| 338 |
p_section->sid, BBS_priv.uid, BBS_username, nickname_f, title_f, |
p_section->sid, BBS_priv.uid, BBS_username, nickname_f, title_f, |
| 339 |
p_article_new->cid, p_article_new->transship, hostaddr_client, BBS_user_exp, content_display_length); |
p_article_new->cid, p_article_new->transship, hostaddr_client, |
| 340 |
|
reply_note, BBS_user_exp, content_display_length); |
| 341 |
|
|
| 342 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 343 |
{ |
{ |
| 429 |
char *content_f = NULL; |
char *content_f = NULL; |
| 430 |
long len_content; |
long len_content; |
| 431 |
int content_display_length; |
int content_display_length; |
| 432 |
|
int reply_note = 1; |
| 433 |
int ch; |
int ch; |
| 434 |
long ret = 0; |
long ret = 0; |
| 435 |
time_t now; |
time_t now; |
| 462 |
} |
} |
| 463 |
|
|
| 464 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 465 |
"SELECT bbs_content.CID, bbs_content.content " |
"SELECT bbs_content.CID, bbs_content.content, reply_note " |
| 466 |
"FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID " |
"FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID " |
| 467 |
"WHERE bbs.AID = %d", |
"WHERE bbs.AID = %d", |
| 468 |
p_article->aid); |
p_article->aid); |
| 506 |
|
|
| 507 |
free(content); |
free(content); |
| 508 |
content = NULL; |
content = NULL; |
| 509 |
|
|
| 510 |
|
reply_note = atoi(row[2]); |
| 511 |
} |
} |
| 512 |
mysql_free_result(rs); |
mysql_free_result(rs); |
| 513 |
rs = NULL; |
rs = NULL; |
| 519 |
{ |
{ |
| 520 |
editor_display(p_editor_data); |
editor_display(p_editor_data); |
| 521 |
|
|
| 522 |
clearscr(); |
while (!SYS_server_exit) |
|
moveto(1, 1); |
|
|
prints("(S)保存, (C)取消 or (E)再编辑? [S]: "); |
|
|
iflush(); |
|
|
|
|
|
for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME)) |
|
| 523 |
{ |
{ |
| 524 |
|
clearscr(); |
| 525 |
|
moveto(1, 1); |
| 526 |
|
prints("(S)保存, (C)取消, (N)通知%s or (E)再编辑? [S]: ", |
| 527 |
|
(reply_note ? "关闭" : "开启")); |
| 528 |
|
iflush(); |
| 529 |
|
|
| 530 |
|
ch = igetch_t(MAX_DELAY_TIME); |
| 531 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 532 |
{ |
{ |
| 533 |
case KEY_NULL: |
case KEY_NULL: |
| 543 |
prints("取消..."); |
prints("取消..."); |
| 544 |
press_any_key(); |
press_any_key(); |
| 545 |
goto cleanup; |
goto cleanup; |
| 546 |
|
case 'N': |
| 547 |
|
reply_note = (reply_note ? 0 : 1); |
| 548 |
|
continue; |
| 549 |
case 'E': |
case 'E': |
| 550 |
break; |
break; |
| 551 |
default: // Invalid selection |
default: // Invalid selection |
| 656 |
|
|
| 657 |
// Update article |
// Update article |
| 658 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 659 |
"UPDATE bbs SET CID = %d, length = %d, excerption = 0 WHERE AID = %d", // Set excerption = 0 explictly in case of rare condition |
"UPDATE bbs SET CID = %d, length = %d, reply_note = %d, excerption = 0 WHERE AID = %d", // Set excerption = 0 explictly in case of rare condition |
| 660 |
p_article_new->cid, content_display_length, p_article->aid); |
p_article_new->cid, content_display_length, reply_note, p_article->aid); |
| 661 |
|
|
| 662 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 663 |
{ |
{ |
| 734 |
int content_display_length; |
int content_display_length; |
| 735 |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
char nickname_f[BBS_nickname_max_len * 2 + 1]; |
| 736 |
int sign_id = 0; |
int sign_id = 0; |
| 737 |
|
int reply_note = 1; |
| 738 |
long len; |
long len; |
| 739 |
int ch; |
int ch; |
| 740 |
char *p, *q; |
char *p, *q; |
| 744 |
long i; |
long i; |
| 745 |
long ret = 0; |
long ret = 0; |
| 746 |
int topic_locked = 0; |
int topic_locked = 0; |
| 747 |
|
char msg[BBS_msg_max_len]; |
| 748 |
|
char msg_f[BBS_msg_max_len * 2 + 1]; |
| 749 |
|
int len_msg; |
| 750 |
|
|
| 751 |
if (p_section == NULL || p_article == NULL) |
if (p_section == NULL || p_article == NULL) |
| 752 |
{ |
{ |
| 854 |
} |
} |
| 855 |
|
|
| 856 |
// Apply LML render to content body |
// Apply LML render to content body |
| 857 |
len = lml_plain(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, 0); |
len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, 0); |
| 858 |
content_f[len] = '\0'; |
content_f[len] = '\0'; |
| 859 |
|
|
| 860 |
// Remove control sequence |
// Remove control sequence |
| 909 |
{ |
{ |
| 910 |
clearscr(); |
clearscr(); |
| 911 |
moveto(21, 1); |
moveto(21, 1); |
| 912 |
prints("回复文章于 %s[%s] 讨论区", p_section->stitle, p_section->sname); |
prints("回复文章于 %s[%s] 讨论区,通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭")); |
| 913 |
moveto(22, 1); |
moveto(22, 1); |
| 914 |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title)); |
| 915 |
moveto(23, 1); |
moveto(23, 1); |
| 920 |
prints(" 按[1;32m0[m~[1;32m3[m选签名档(0表示不使用)"); |
prints(" 按[1;32m0[m~[1;32m3[m选签名档(0表示不使用)"); |
| 921 |
|
|
| 922 |
moveto(24, 1); |
moveto(24, 1); |
| 923 |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mEnter[m继续: "); |
prints("[1;32mT[m改标题, [1;32mC[m取消, [1;32mN[m%s, [1;32mEnter[m继续: ", |
| 924 |
|
(reply_note ? "通知关闭" : "通知开启")); |
| 925 |
iflush(); |
iflush(); |
| 926 |
ch = 0; |
ch = 0; |
| 927 |
} |
} |
| 937 |
igetch_reset(); |
igetch_reset(); |
| 938 |
break; |
break; |
| 939 |
case 'T': |
case 'T': |
| 940 |
moveto(24, 1); |
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); |
|
clrtoeol(); |
|
|
len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN, DOECHO); |
|
| 941 |
for (p = title_input; *p == ' '; p++) |
for (p = title_input; *p == ' '; p++) |
| 942 |
; |
; |
| 943 |
for (q = title_input + len; q > p && *(q - 1) == ' '; q--) |
for (q = title_input + len; q > p && *(q - 1) == ' '; q--) |
| 957 |
prints("取消..."); |
prints("取消..."); |
| 958 |
press_any_key(); |
press_any_key(); |
| 959 |
goto cleanup; |
goto cleanup; |
| 960 |
|
case 'N': |
| 961 |
|
reply_note = (reply_note ? 0 : 1); |
| 962 |
|
break; |
| 963 |
case '0': |
case '0': |
| 964 |
case '1': |
case '1': |
| 965 |
case '2': |
case '2': |
| 1146 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 1147 |
"INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, " |
"INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, " |
| 1148 |
"sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) " |
"sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) " |
| 1149 |
"VALUES(%d, %d, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', 1, %d, NOW(), 1, %d)", |
"VALUES(%d, %d, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', %d, %d, NOW(), 1, %d)", |
| 1150 |
p_section->sid, (p_article->tid == 0 ? p_article->aid : p_article->tid), |
p_section->sid, (p_article->tid == 0 ? p_article->aid : p_article->tid), |
| 1151 |
BBS_priv.uid, BBS_username, nickname_f, title_f, |
BBS_priv.uid, BBS_username, nickname_f, title_f, |
| 1152 |
p_article_new->cid, hostaddr_client, BBS_user_exp, content_display_length); |
p_article_new->cid, hostaddr_client, |
| 1153 |
|
reply_note, BBS_user_exp, content_display_length); |
| 1154 |
|
|
| 1155 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 1156 |
{ |
{ |
| 1188 |
goto cleanup; |
goto cleanup; |
| 1189 |
} |
} |
| 1190 |
|
|
| 1191 |
|
// Notify the authors of the topic / article which is replyed. |
| 1192 |
|
snprintf(sql, sizeof(sql), |
| 1193 |
|
"SELECT DISTINCT UID FROM bbs WHERE (AID = %d OR AID = %d) " |
| 1194 |
|
"AND visible AND reply_note AND UID <> %d", |
| 1195 |
|
p_article->tid, p_article->aid, BBS_priv.uid); |
| 1196 |
|
|
| 1197 |
|
if (mysql_query(db, sql) != 0) |
| 1198 |
|
{ |
| 1199 |
|
log_error("Read reply info error: %s\n", mysql_error(db)); |
| 1200 |
|
ret = -1; |
| 1201 |
|
goto cleanup; |
| 1202 |
|
} |
| 1203 |
|
if ((rs = mysql_store_result(db)) == NULL) |
| 1204 |
|
{ |
| 1205 |
|
log_error("Get reply info failed\n"); |
| 1206 |
|
ret = -1; |
| 1207 |
|
goto cleanup; |
| 1208 |
|
} |
| 1209 |
|
|
| 1210 |
|
while ((row = mysql_fetch_row(rs))) |
| 1211 |
|
{ |
| 1212 |
|
// Send notification message |
| 1213 |
|
len_msg = snprintf(msg, BBS_msg_max_len, |
| 1214 |
|
"[hide]SYS_Reply_Article[/hide]有人回复了您所发表/回复的文章,快来" |
| 1215 |
|
"[article %d]看看[/article]《%s》吧!\n", |
| 1216 |
|
p_article_new->aid, title_f); |
| 1217 |
|
|
| 1218 |
|
mysql_real_escape_string(db, msg_f, msg, (unsigned long)len_msg); |
| 1219 |
|
|
| 1220 |
|
snprintf(sql, sizeof(sql), |
| 1221 |
|
"INSERT INTO bbs_msg(fromUID, toUID, content, send_dt, send_ip) " |
| 1222 |
|
"VALUES(%d, %d, '%s', NOW(), '%s')", |
| 1223 |
|
BBS_sys_id, atoi(row[0]), msg_f, hostaddr_client); |
| 1224 |
|
|
| 1225 |
|
if (mysql_query(db, sql) != 0) |
| 1226 |
|
{ |
| 1227 |
|
log_error("Insert msg error: %s\n", mysql_error(db)); |
| 1228 |
|
ret = -1; |
| 1229 |
|
goto cleanup; |
| 1230 |
|
} |
| 1231 |
|
} |
| 1232 |
|
mysql_free_result(rs); |
| 1233 |
|
rs = NULL; |
| 1234 |
|
|
| 1235 |
// Add exp |
// Add exp |
| 1236 |
if (checkpriv(&BBS_priv, p_section->sid, S_GETEXP)) // Except in test section |
if (checkpriv(&BBS_priv, p_section->sid, S_GETEXP)) // Except in test section |
| 1237 |
{ |
{ |