--- lbbs/src/article_post.c 2025/06/14 11:15:46 1.9 +++ lbbs/src/article_post.c 2025/06/14 12:30:15 1.12 @@ -63,6 +63,16 @@ int article_post(const SECTION_LIST *p_s log_error("NULL pointer error\n"); } + if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) + { + clearscr(); + moveto(1, 1); + prints("您没有权限在本版块发表文章\n"); + press_any_key(); + + return 0; + } + p_article_new->title[0] = '\0'; title_input[0] = '\0'; p_article_new->transship = 0; @@ -410,6 +420,16 @@ int article_modify(const SECTION_LIST *p return 0; } + if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) + { + clearscr(); + moveto(1, 1); + prints("您没有权限在本版块发表文章\n"); + press_any_key(); + + return 0; + } + db = db_open(); if (db == NULL) { @@ -655,6 +675,16 @@ int article_reply(const SECTION_LIST *p_ log_error("NULL pointer error\n"); } + if (!checkpriv(&BBS_priv, p_section->sid, S_POST)) + { + clearscr(); + moveto(1, 1); + prints("您没有权限在本版块发表文章\n"); + press_any_key(); + + return 0; + } + if (p_article->lock) // Reply is not allowed { clearscr(); @@ -975,8 +1005,9 @@ int article_reply(const SECTION_LIST *p_ snprintf(sql, sizeof(sql), "INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, " "sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) " - "VALUES(%d, 0, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', 1, %d, NOW(), 1, %ld)", - p_section->sid, BBS_priv.uid, BBS_username, nickname_f, title_f, + "VALUES(%d, %d, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', 1, %d, NOW(), 1, %ld)", + p_section->sid, (p_article->tid == 0 ? p_article->aid : p_article->tid), + BBS_priv.uid, BBS_username, nickname_f, title_f, p_article_new->cid, hostaddr_client, BBS_user_exp, len_content); if (mysql_query(db, sql) != 0) @@ -992,8 +1023,16 @@ int article_reply(const SECTION_LIST *p_ snprintf(sql, sizeof(sql), "UPDATE bbs SET reply_count = reply_count + 1, " "last_reply_dt = NOW(), last_reply_UID=%d, last_reply_username = '%s', " - "last_reply_nickname = '%s' WHERE Aid = %d", - BBS_priv.uid, BBS_username, nickname_f, p_article->aid); + "last_reply_nickname = '%s' WHERE AID = %d", + BBS_priv.uid, BBS_username, nickname_f, + (p_article->tid == 0 ? p_article->aid : p_article->tid)); + + if (mysql_query(db, sql) != 0) + { + log_error("Update topic article error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } // Link content to article snprintf(sql, sizeof(sql),