| 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 |
| 213 |
if (len_content < 0) |
if (len_content < 0) |
| 214 |
{ |
{ |
| 215 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 216 |
ret = -2; |
ret = -1; |
| 217 |
goto cleanup; |
goto cleanup; |
| 218 |
} |
} |
| 219 |
|
|
| 430 |
return 0; |
return 0; |
| 431 |
} |
} |
| 432 |
|
|
|
if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) |
|
|
{ |
|
|
clearscr(); |
|
|
moveto(1, 1); |
|
|
prints("您没有权限在本版块发表文章\n"); |
|
|
press_any_key(); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
| 433 |
db = db_open(); |
db = db_open(); |
| 434 |
if (db == NULL) |
if (db == NULL) |
| 435 |
{ |
{ |
| 436 |
log_error("db_open() error: %s\n", mysql_error(db)); |
log_error("db_open() error: %s\n", mysql_error(db)); |
| 437 |
return -1; |
ret = -1; |
| 438 |
|
goto cleanup; |
| 439 |
} |
} |
| 440 |
|
|
| 441 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 447 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 448 |
{ |
{ |
| 449 |
log_error("Query article content error: %s\n", mysql_error(db)); |
log_error("Query article content error: %s\n", mysql_error(db)); |
| 450 |
ret = -2; |
ret = -1; |
| 451 |
goto cleanup; |
goto cleanup; |
| 452 |
} |
} |
| 453 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 454 |
{ |
{ |
| 455 |
log_error("Get article content data failed\n"); |
log_error("Get article content data failed\n"); |
| 456 |
ret = -2; |
ret = -1; |
| 457 |
goto cleanup; |
goto cleanup; |
| 458 |
} |
} |
| 459 |
|
|
| 477 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 478 |
{ |
{ |
| 479 |
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])); |
| 480 |
ret = -3; |
ret = -1; |
| 481 |
goto cleanup; |
goto cleanup; |
| 482 |
} |
} |
| 483 |
|
|
| 536 |
if (len_content < 0) |
if (len_content < 0) |
| 537 |
{ |
{ |
| 538 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 539 |
ret = -2; |
ret = -1; |
| 540 |
goto cleanup; |
goto cleanup; |
| 541 |
} |
} |
| 542 |
|
|
| 615 |
|
|
| 616 |
// Update article |
// Update article |
| 617 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 618 |
"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 |
| 619 |
p_article_new->cid, len_content, p_article->aid); |
p_article_new->cid, len_content, p_article->aid); |
| 620 |
|
|
| 621 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 697 |
long quote_content_lines; |
long quote_content_lines; |
| 698 |
long i; |
long i; |
| 699 |
long ret = 0; |
long ret = 0; |
| 700 |
|
int topic_locked = 0; |
| 701 |
|
|
| 702 |
if (p_section == NULL || p_article == NULL) |
if (p_section == NULL || p_article == NULL) |
| 703 |
{ |
{ |
| 714 |
return 0; |
return 0; |
| 715 |
} |
} |
| 716 |
|
|
|
if (p_article->lock) // Reply is not allowed |
|
|
{ |
|
|
clearscr(); |
|
|
moveto(1, 1); |
|
|
prints("该文章谢绝回复"); |
|
|
press_any_key(); |
|
|
|
|
|
return 0; |
|
|
} |
|
|
|
|
| 717 |
p_article_new->title[0] = '\0'; |
p_article_new->title[0] = '\0'; |
| 718 |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
| 719 |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len); |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len); |
| 723 |
if (db == NULL) |
if (db == NULL) |
| 724 |
{ |
{ |
| 725 |
log_error("db_open() error: %s\n", mysql_error(db)); |
log_error("db_open() error: %s\n", mysql_error(db)); |
| 726 |
return -1; |
ret = -1; |
| 727 |
|
goto cleanup; |
| 728 |
|
} |
| 729 |
|
|
| 730 |
|
snprintf(sql, sizeof(sql), |
| 731 |
|
"SELECT `lock` FROM bbs WHERE AID = %d", |
| 732 |
|
(p_article->tid == 0 ? p_article->aid : p_article->tid)); |
| 733 |
|
|
| 734 |
|
if (mysql_query(db, sql) != 0) |
| 735 |
|
{ |
| 736 |
|
log_error("Query article status error: %s\n", mysql_error(db)); |
| 737 |
|
ret = -1; |
| 738 |
|
goto cleanup; |
| 739 |
|
} |
| 740 |
|
if ((rs = mysql_store_result(db)) == NULL) |
| 741 |
|
{ |
| 742 |
|
log_error("Get article status data failed\n"); |
| 743 |
|
ret = -1; |
| 744 |
|
goto cleanup; |
| 745 |
|
} |
| 746 |
|
|
| 747 |
|
if ((row = mysql_fetch_row(rs))) |
| 748 |
|
{ |
| 749 |
|
if (atoi(row[0]) != 0) |
| 750 |
|
{ |
| 751 |
|
topic_locked = 1; |
| 752 |
|
} |
| 753 |
|
} |
| 754 |
|
mysql_free_result(rs); |
| 755 |
|
rs = NULL; |
| 756 |
|
|
| 757 |
|
if (topic_locked) // Reply is not allowed |
| 758 |
|
{ |
| 759 |
|
clearscr(); |
| 760 |
|
moveto(1, 1); |
| 761 |
|
prints("该主题谢绝回复"); |
| 762 |
|
press_any_key(); |
| 763 |
|
|
| 764 |
|
goto cleanup; |
| 765 |
} |
} |
| 766 |
|
|
| 767 |
snprintf(sql, sizeof(sql), |
snprintf(sql, sizeof(sql), |
| 773 |
if (mysql_query(db, sql) != 0) |
if (mysql_query(db, sql) != 0) |
| 774 |
{ |
{ |
| 775 |
log_error("Query article content error: %s\n", mysql_error(db)); |
log_error("Query article content error: %s\n", mysql_error(db)); |
| 776 |
return -2; |
ret = -1; |
| 777 |
|
goto cleanup; |
| 778 |
} |
} |
| 779 |
if ((rs = mysql_use_result(db)) == NULL) |
if ((rs = mysql_use_result(db)) == NULL) |
| 780 |
{ |
{ |
| 781 |
log_error("Get article content data failed\n"); |
log_error("Get article content data failed\n"); |
| 782 |
return -2; |
ret = -1; |
| 783 |
|
goto cleanup; |
| 784 |
} |
} |
| 785 |
|
|
| 786 |
if ((row = mysql_fetch_row(rs))) |
if ((row = mysql_fetch_row(rs))) |
| 834 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 835 |
{ |
{ |
| 836 |
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])); |
| 837 |
ret = -3; |
ret = -1; |
| 838 |
goto cleanup; |
goto cleanup; |
| 839 |
} |
} |
| 840 |
|
|
| 969 |
if (len_content < 0) |
if (len_content < 0) |
| 970 |
{ |
{ |
| 971 |
log_error("editor_data_save() error\n"); |
log_error("editor_data_save() error\n"); |
| 972 |
ret = -2; |
ret = -1; |
| 973 |
goto cleanup; |
goto cleanup; |
| 974 |
} |
} |
| 975 |
|
|