| 81 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 82 |
{ |
{ |
| 83 |
log_error("editor_data_load() error\n"); |
log_error("editor_data_load() error\n"); |
| 84 |
return -2; |
ret = -1; |
| 85 |
|
goto cleanup; |
| 86 |
} |
} |
| 87 |
|
|
| 88 |
// Set title and sign |
// Set title and sign |
| 110 |
{ |
{ |
| 111 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 112 |
{ |
{ |
| 113 |
|
case KEY_NULL: |
| 114 |
|
case KEY_TIMEOUT: |
| 115 |
|
goto cleanup; |
| 116 |
case CR: |
case CR: |
| 117 |
igetch_reset(); |
igetch_reset(); |
| 118 |
break; |
break; |
| 176 |
{ |
{ |
| 177 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 178 |
{ |
{ |
| 179 |
|
case KEY_NULL: |
| 180 |
|
case KEY_TIMEOUT: |
| 181 |
|
goto cleanup; |
| 182 |
case CR: |
case CR: |
| 183 |
igetch_reset(); |
igetch_reset(); |
| 184 |
case 'S': |
case 'S': |
| 207 |
} |
} |
| 208 |
} |
} |
| 209 |
|
|
| 210 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 211 |
|
{ |
| 212 |
|
goto cleanup; |
| 213 |
|
} |
| 214 |
|
|
| 215 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 216 |
if (content == NULL) |
if (content == NULL) |
| 217 |
{ |
{ |
| 224 |
if (len_content < 0) |
if (len_content < 0) |
| 225 |
{ |
{ |
| 226 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 227 |
ret = -2; |
ret = -1; |
| 228 |
goto cleanup; |
goto cleanup; |
| 229 |
} |
} |
| 230 |
|
|
| 389 |
goto cleanup; |
goto cleanup; |
| 390 |
} |
} |
| 391 |
|
|
| 392 |
|
mysql_close(db); |
| 393 |
|
db = NULL; |
| 394 |
|
|
| 395 |
clearscr(); |
clearscr(); |
| 396 |
moveto(1, 1); |
moveto(1, 1); |
| 397 |
prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval); |
prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval); |
| 444 |
return 0; |
return 0; |
| 445 |
} |
} |
| 446 |
|
|
|
if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) |
|
|
{ |
|
|
clearscr(); |
|
|
moveto(1, 1); |
|
|
prints("您没有权限在本版块发表文章\n"); |
|
|
press_any_key(); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
| 447 |
db = db_open(); |
db = db_open(); |
| 448 |
if (db == NULL) |
if (db == NULL) |
| 449 |
{ |
{ |
| 450 |
log_error("db_open() error: %s\n", mysql_error(db)); |
log_error("db_open() error: %s\n", mysql_error(db)); |
| 451 |
return -1; |
ret = -1; |
| 452 |
|
goto cleanup; |
| 453 |
} |
} |
| 454 |
|
|
| 455 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 461 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 462 |
{ |
{ |
| 463 |
log_error("Query article content error: %s\n", mysql_error(db)); |
log_error("Query article content error: %s\n", mysql_error(db)); |
| 464 |
ret = -2; |
ret = -1; |
| 465 |
goto cleanup; |
goto cleanup; |
| 466 |
} |
} |
| 467 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 468 |
{ |
{ |
| 469 |
log_error("Get article content data failed\n"); |
log_error("Get article content data failed\n"); |
| 470 |
ret = -2; |
ret = -1; |
| 471 |
goto cleanup; |
goto cleanup; |
| 472 |
} |
} |
| 473 |
|
|
| 485 |
content[ARTICLE_CONTENT_MAX_LEN - 1] = '\0'; |
content[ARTICLE_CONTENT_MAX_LEN - 1] = '\0'; |
| 486 |
|
|
| 487 |
// Remove control sequence |
// Remove control sequence |
| 488 |
len_content = ctrl_seq_filter(content); |
len_content = str_filter(content, 0); |
| 489 |
|
|
| 490 |
p_editor_data = editor_data_load(content); |
p_editor_data = editor_data_load(content); |
| 491 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 492 |
{ |
{ |
| 493 |
log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); |
log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); |
| 494 |
ret = -3; |
ret = -1; |
| 495 |
goto cleanup; |
goto cleanup; |
| 496 |
} |
} |
| 497 |
|
|
| 517 |
{ |
{ |
| 518 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 519 |
{ |
{ |
| 520 |
|
case KEY_NULL: |
| 521 |
|
case KEY_TIMEOUT: |
| 522 |
|
goto cleanup; |
| 523 |
case CR: |
case CR: |
| 524 |
igetch_reset(); |
igetch_reset(); |
| 525 |
case 'S': |
case 'S': |
| 540 |
} |
} |
| 541 |
} |
} |
| 542 |
|
|
| 543 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 544 |
|
{ |
| 545 |
|
goto cleanup; |
| 546 |
|
} |
| 547 |
|
|
| 548 |
// Allocate buffers in big size |
// Allocate buffers in big size |
| 549 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 550 |
if (content == NULL) |
if (content == NULL) |
| 558 |
if (len_content < 0) |
if (len_content < 0) |
| 559 |
{ |
{ |
| 560 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 561 |
ret = -2; |
ret = -1; |
| 562 |
goto cleanup; |
goto cleanup; |
| 563 |
} |
} |
| 564 |
|
|
| 637 |
|
|
| 638 |
// Update article |
// Update article |
| 639 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 640 |
"UPDATE bbs SET CID = %d, length = %ld WHERE AID = %d", |
"UPDATE bbs SET CID = %d, length = %ld, excerption = 0 WHERE AID = %d", // Set excerption = 0 explictly in case of rare condition |
| 641 |
p_article_new->cid, len_content, p_article->aid); |
p_article_new->cid, len_content, p_article->aid); |
| 642 |
|
|
| 643 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 675 |
goto cleanup; |
goto cleanup; |
| 676 |
} |
} |
| 677 |
|
|
| 678 |
|
mysql_close(db); |
| 679 |
|
db = NULL; |
| 680 |
|
|
| 681 |
clearscr(); |
clearscr(); |
| 682 |
moveto(1, 1); |
moveto(1, 1); |
| 683 |
prints("修改完成,新内容通常会在%d秒后可见", BBS_section_list_load_interval); |
prints("修改完成,新内容通常会在%d秒后可见", BBS_section_list_load_interval); |
| 741 |
|
|
| 742 |
p_article_new->title[0] = '\0'; |
p_article_new->title[0] = '\0'; |
| 743 |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
| 744 |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len); |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len, 0); |
| 745 |
title_input[len] = '\0'; |
title_input[len] = '\0'; |
| 746 |
|
|
| 747 |
db = db_open(); |
db = db_open(); |
| 748 |
if (db == NULL) |
if (db == NULL) |
| 749 |
{ |
{ |
| 750 |
log_error("db_open() error: %s\n", mysql_error(db)); |
log_error("db_open() error: %s\n", mysql_error(db)); |
| 751 |
return -1; |
ret = -1; |
| 752 |
|
goto cleanup; |
| 753 |
} |
} |
| 754 |
|
|
| 755 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 759 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 760 |
{ |
{ |
| 761 |
log_error("Query article status error: %s\n", mysql_error(db)); |
log_error("Query article status error: %s\n", mysql_error(db)); |
| 762 |
return -2; |
ret = -1; |
| 763 |
|
goto cleanup; |
| 764 |
} |
} |
| 765 |
if ((rs = mysql_store_result(db)) == NULL) |
if ((rs = mysql_store_result(db)) == NULL) |
| 766 |
{ |
{ |
| 767 |
log_error("Get article status data failed\n"); |
log_error("Get article status data failed\n"); |
| 768 |
return -2; |
ret = -1; |
| 769 |
|
goto cleanup; |
| 770 |
} |
} |
| 771 |
|
|
| 772 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 781 |
|
|
| 782 |
if (topic_locked) // Reply is not allowed |
if (topic_locked) // Reply is not allowed |
| 783 |
{ |
{ |
| 784 |
|
mysql_close(db); |
| 785 |
|
db = NULL; |
| 786 |
|
|
| 787 |
clearscr(); |
clearscr(); |
| 788 |
moveto(1, 1); |
moveto(1, 1); |
| 789 |
prints("该主题谢绝回复"); |
prints("该主题谢绝回复"); |
| 801 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 802 |
{ |
{ |
| 803 |
log_error("Query article content error: %s\n", mysql_error(db)); |
log_error("Query article content error: %s\n", mysql_error(db)); |
| 804 |
return -2; |
ret = -1; |
| 805 |
|
goto cleanup; |
| 806 |
} |
} |
| 807 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 808 |
{ |
{ |
| 809 |
log_error("Get article content data failed\n"); |
log_error("Get article content data failed\n"); |
| 810 |
return -2; |
ret = -1; |
| 811 |
|
goto cleanup; |
| 812 |
} |
} |
| 813 |
|
|
| 814 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 834 |
content_f[len] = '\0'; |
content_f[len] = '\0'; |
| 835 |
|
|
| 836 |
// Remove control sequence |
// Remove control sequence |
| 837 |
len = ctrl_seq_filter(content_f); |
len = str_filter(content_f, 0); |
| 838 |
|
|
| 839 |
len = snprintf(content, ARTICLE_CONTENT_MAX_LEN, |
len = snprintf(content, ARTICLE_CONTENT_MAX_LEN, |
| 840 |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
| 841 |
p_article->username, p_article->nickname); |
p_article->username, p_article->nickname); |
| 842 |
|
|
| 843 |
quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1); |
quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0); |
| 844 |
for (i = 0; i < quote_content_lines; i++) |
for (i = 0; i < quote_content_lines; i++) |
| 845 |
{ |
{ |
| 846 |
memcpy(content + len, ": ", 2); // quote line prefix |
memcpy(content + len, ": ", 2); // quote line prefix |
| 847 |
len += 2; |
len += 2; |
| 848 |
memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i])); |
memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i])); |
| 849 |
len += (line_offsets[i + 1] - line_offsets[i]); |
len += (line_offsets[i + 1] - line_offsets[i]); |
| 850 |
|
if (content[len - 1] != '\n') // Appennd \n if not exist |
| 851 |
|
{ |
| 852 |
|
content[len] = '\n'; |
| 853 |
|
len++; |
| 854 |
|
} |
| 855 |
} |
} |
| 856 |
if (content[len - 1] != '\n') // Appennd \n if not exist |
if (content[len - 1] != '\n') // Appennd \n if not exist |
| 857 |
{ |
{ |
| 867 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 868 |
{ |
{ |
| 869 |
log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); |
log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0])); |
| 870 |
ret = -3; |
ret = -1; |
| 871 |
goto cleanup; |
goto cleanup; |
| 872 |
} |
} |
| 873 |
|
|
| 905 |
{ |
{ |
| 906 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 907 |
{ |
{ |
| 908 |
|
case KEY_NULL: |
| 909 |
|
case KEY_TIMEOUT: |
| 910 |
|
goto cleanup; |
| 911 |
case CR: |
case CR: |
| 912 |
igetch_reset(); |
igetch_reset(); |
| 913 |
break; |
break; |
| 965 |
{ |
{ |
| 966 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 967 |
{ |
{ |
| 968 |
|
case KEY_NULL: |
| 969 |
|
case KEY_TIMEOUT: |
| 970 |
|
goto cleanup; |
| 971 |
case CR: |
case CR: |
| 972 |
igetch_reset(); |
igetch_reset(); |
| 973 |
case 'S': |
case 'S': |
| 996 |
} |
} |
| 997 |
} |
} |
| 998 |
|
|
| 999 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 1000 |
|
{ |
| 1001 |
|
goto cleanup; |
| 1002 |
|
} |
| 1003 |
|
|
| 1004 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 1005 |
if (content == NULL) |
if (content == NULL) |
| 1006 |
{ |
{ |
| 1013 |
if (len_content < 0) |
if (len_content < 0) |
| 1014 |
{ |
{ |
| 1015 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 1016 |
ret = -2; |
ret = -1; |
| 1017 |
goto cleanup; |
goto cleanup; |
| 1018 |
} |
} |
| 1019 |
|
|
| 1194 |
goto cleanup; |
goto cleanup; |
| 1195 |
} |
} |
| 1196 |
|
|
| 1197 |
|
mysql_close(db); |
| 1198 |
|
db = NULL; |
| 1199 |
|
|
| 1200 |
clearscr(); |
clearscr(); |
| 1201 |
moveto(1, 1); |
moveto(1, 1); |
| 1202 |
prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval); |
prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval); |