From 7165246ba6a85b6d9443ccb396f60250baee6931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E9=BB=91=E5=99=9C?= <51919849+ytht@users.noreply.github.com> Date: Tue, 11 Nov 2025 19:19:27 +0800 Subject: [PATCH 1/7] Add CI workflow for lbbs_dev branch --- .github/workflows/lbbs_dev.yml | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/lbbs_dev.yml diff --git a/.github/workflows/lbbs_dev.yml b/.github/workflows/lbbs_dev.yml new file mode 100644 index 00000000..92208bf2 --- /dev/null +++ b/.github/workflows/lbbs_dev.yml @@ -0,0 +1,38 @@ +name: Makefile CI + +on: + push: + branches: [ "lbbs_dev" ] + pull_request: + branches: [ "lbbs_dev" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: autogen + run: sh autogen.sh + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y libssh-dev libsystemd-dev + + - name: Display GCC version + run: gcc -v + + - name: configure + run: ./configure + + - name: Run make + run: make V=1 + + - name: Run check + run: make check + + - name: Run distcheck + run: make distcheck From dd4045b09c558567b6d43ca884e586a960c35444 Mon Sep 17 00:00:00 2001 From: ytht <2391669999@qq.com> Date: Tue, 11 Nov 2025 19:22:52 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E5=B9=B6yml=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 1 + .github/workflows/lbbs_dev.yml | 38 ---------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) create mode 100644 .gitattributes delete mode 100644 .github/workflows/lbbs_dev.yml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..91bae6d9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.github/workflows/*.yml merge=notMerge diff --git a/.github/workflows/lbbs_dev.yml b/.github/workflows/lbbs_dev.yml deleted file mode 100644 index 92208bf2..00000000 --- a/.github/workflows/lbbs_dev.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Makefile CI - -on: - push: - branches: [ "lbbs_dev" ] - pull_request: - branches: [ "lbbs_dev" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: autogen - run: sh autogen.sh - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y libssh-dev libsystemd-dev - - - name: Display GCC version - run: gcc -v - - - name: configure - run: ./configure - - - name: Run make - run: make V=1 - - - name: Run check - run: make check - - - name: Run distcheck - run: make distcheck From c0345b7b7c633b430e8b8a59c398a251e2ac5df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E9=BB=91=E5=99=9C?= <51919849+ytht@users.noreply.github.com> Date: Tue, 11 Nov 2025 19:39:33 +0800 Subject: [PATCH 3/7] Add lbbs_dev branch to CI workflow --- .github/workflows/makefile.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 00d389ca..ed8a470e 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -2,10 +2,14 @@ name: Makefile CI on: push: - branches: [ "main" ] + branches: + - "main" + - "lbbs_dev" pull_request: - branches: [ "main" ] - + branches: + - "main" + - "lbbs_dev" + jobs: build: From e576a07fef403dc0f3afb56c00f4082240d5a823 Mon Sep 17 00:00:00 2001 From: ytht <2391669999@qq.com> Date: Mon, 17 Nov 2025 21:03:38 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=94=B6=E5=BD=95/=E7=A7=BB=E5=87=BA=E6=96=87=E6=91=98?= =?UTF-8?q?=E5=8C=BA=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/article_op.h | 6 ++ src/article_op.c | 196 +++++++++++++++++++++++++++++++++++++ src/section_list_display.c | 19 ++++ 3 files changed, 221 insertions(+) diff --git a/include/article_op.h b/include/article_op.h index f9423dfd..9642a1ed 100644 --- a/include/article_op.h +++ b/include/article_op.h @@ -11,6 +11,12 @@ #include +enum bbs_article_op_type_t +{ + BBS_article_set_excerption = 'E', + BBS_article_unset_excerption = 'O', +}; extern int display_article_meta(int32_t aid); +extern int article_exc_set(int32_t aid, int8_t is_exc); #endif //_ARTICLE_OP_H_ diff --git a/src/article_op.c b/src/article_op.c index 50080a8b..bf8014ed 100644 --- a/src/article_op.c +++ b/src/article_op.c @@ -12,8 +12,19 @@ #include "article_op.h" #include "bbs.h" +#include "common.h" +#include "database.h" #include "io.h" +#include "log.h" #include "screen.h" +#include "user_priv.h" +#include +#include + +enum ret_msg_len_t +{ + ret_msg_len = 20, +}; int display_article_meta(int32_t aid) { @@ -26,3 +37,188 @@ int display_article_meta(int32_t aid) return 0; } + +int article_exc_set(int32_t aid, int8_t is_exc) +{ + MYSQL *db = NULL; + MYSQL_RES *rs = NULL; + MYSQL_ROW row; + char sql[SQL_BUFFER_LEN]; + int ret = 0; + int uid = 0; + int tid = 0; + int sid = 0; + int8_t transship = 0; + int8_t excerption = 0; + int8_t set_exc = !is_exc; + char ret_msg[ret_msg_len] = ""; + + db = db_open(); + if (db == NULL) + { + log_error("db_open() error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + // Begin transaction + if (mysql_query(db, "SET autocommit=0") != 0) + { + log_error("SET autocommit=0 error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + if (mysql_query(db, "BEGIN") != 0) + { + log_error("Begin transaction error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + snprintf(sql, sizeof(sql), + "SELECT UID, TID, SID, transship, excerption FROM bbs WHERE visible and AID=%d FOR UPDATE", + aid); + if (mysql_query(db, sql) != 0) + { + log_error("Query bbs error: %s\n", mysql_error(db)); + ret = -2; + goto cleanup; + } + if ((rs = mysql_store_result(db)) == NULL) + { + log_error("Get article data failed\n"); + ret = -2; + goto cleanup; + } + if ((row = mysql_fetch_row(rs))) + { + uid = atoi(row[0]); + tid = atoi(row[1]); + sid = atoi(row[2]); + transship = (int8_t)atoi(row[3]); + excerption = (int8_t)atoi(row[4]); + } + else + { + if (mysql_errno(db)) + { + log_error("mysql_fetch_row() error: %s\n", mysql_error(db)); + ret = -2; + } + else + { + strncpy(ret_msg, "文章不存在", ret_msg_len); + ret = -1; + } + goto cleanup; + } + mysql_free_result(rs); + rs = NULL; + + // Check if already set + if (set_exc == excerption) + { + snprintf(ret_msg, sizeof(ret_msg), "已%s文摘区", set_exc ? "收录" : "移出"); + ret = 1; + goto cleanup; + } + + // Update article(s) + snprintf(sql, sizeof(sql), + "UPDATE bbs SET excerption = %d WHERE AID=%d", + set_exc, aid); + if (mysql_query(db, sql) != 0) + { + log_error("Update article set error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + // Clear gen_ex if unset excerption + if (set_exc == 0) + { + snprintf(sql, sizeof(sql), + "UPDATE bbs SET gen_ex = 0, static = 0 WHERE AID=%d OR TID =%d", + aid, aid); + + if (mysql_query(db, sql) != 0) + { + log_error("Clear gen_ex error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + // Delete ex_dir path if head of thread + if (tid == 0) + { + snprintf(sql, sizeof(sql), + "DELETE FROM ex_file WHERE AID = %d", + aid); + + if (mysql_query(db, sql) != 0) + { + log_error("Delete ex_dir error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + } + } + + // Change UID of attachments + snprintf(sql, sizeof(sql), + "UPDATE upload_file SET UID = %d WHERE ref_AID = %d AND deleted = 0", + set_exc ? 0 : uid, aid); + if (mysql_query(db, sql) != 0) + { + log_error("Change UID error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + // Modify exp + if (checkpriv(&BBS_priv, sid, S_GETEXP)) // Except in test section + { + snprintf(sql, sizeof(sql), + "UPDATE user_pubinfo SET exp = exp + %d WHERE UID = %d", + (set_exc ? 1 : -1) * (tid == 0 ? (transship ? 20 : 50) : 10), uid); + + if (mysql_query(db, sql) != 0) + { + log_error("Update exp error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + } + + // Add log + snprintf(sql, sizeof(sql), + "INSERT INTO bbs_article_op(AID, UID, type, op_dt, op_ip)" + "VALUES(%d, %d, '%c', NOW(), '%s')", + aid, BBS_priv.uid, set_exc ? BBS_article_set_excerption : BBS_article_unset_excerption, hostaddr_client); + + if (mysql_query(db, sql) != 0) + { + log_error("Add log error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + // Commit transaction + if (mysql_query(db, "COMMIT") != 0) + { + log_error("Commit transaction error: %s\n", mysql_error(db)); + ret = -1; + goto cleanup; + } + + mysql_close(db); + db = NULL; + + snprintf(ret_msg, sizeof(ret_msg), "已%s文摘区", set_exc ? "收录" : "移出"); + ret = 1; // Success + +cleanup: + mysql_free_result(rs); + mysql_close(db); + press_any_key_ex(ret_msg, 3); + return ret; +} diff --git a/src/section_list_display.c b/src/section_list_display.c index 8ab93c9d..2e79f45f 100644 --- a/src/section_list_display.c +++ b/src/section_list_display.c @@ -58,6 +58,7 @@ enum select_cmd_t QUERY_USER, SET_FAVOR_ARTICLE, UNSET_FAVOR_ARTICLE, + SET_EXCERPTION_ARTICLE, FIRST_TOPIC_ARTICLE, LAST_TOPIC_ARTICLE, LAST_SECTION_ARTICLE, @@ -335,6 +336,12 @@ static enum select_cmd_t section_list_select(int total_page, int item_count, int return UNSET_FAVOR_ARTICLE; } break; + case 'm': + if (item_count > 0) + { + return SET_EXCERPTION_ARTICLE; + } + break; case KEY_HOME: *p_page_id = 0; case 'P': @@ -1087,6 +1094,18 @@ int section_list_display(const char *sname, int32_t aid) p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid); } break; + case SET_EXCERPTION_ARTICLE: + if (!checkpriv(&BBS_priv, p_section->sid, S_POST) || !checkpriv(&BBS_priv, p_section->sid, S_MAN_S)) + { + break; + } + ret = article_exc_set(p_articles[selected_index]->aid, p_articles[selected_index]->excerption); + if (ret < 0) + { + log_error("article_exc_set(aid=%d, excerption=%d) error\n", + p_articles[selected_index]->aid, p_articles[selected_index]->excerption); + } + break; case FIRST_TOPIC_ARTICLE: case LAST_TOPIC_ARTICLE: page_id_cur = page_id; From f4b1df2139b709d9b6f3224471bc8fb8a3bb124c Mon Sep 17 00:00:00 2001 From: ytht <2391669999@qq.com> Date: Thu, 4 Dec 2025 20:22:00 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=94=B6=E5=BD=95/=E7=A7=BB=E5=87=BA=E6=96=87=E6=91=98?= =?UTF-8?q?=E5=8C=BA=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/article_op.h | 7 ++++--- src/article_op.c | 12 ++++++++++-- src/section_list_display.c | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/article_op.h b/include/article_op.h index 9642a1ed..f6afe138 100644 --- a/include/article_op.h +++ b/include/article_op.h @@ -9,14 +9,15 @@ #ifndef _ARTICLE_OP_H_ #define _ARTICLE_OP_H_ +#include #include enum bbs_article_op_type_t { - BBS_article_set_excerption = 'E', - BBS_article_unset_excerption = 'O', + BBS_article_set_excerption = 'E', + BBS_article_unset_excerption = 'O', }; extern int display_article_meta(int32_t aid); -extern int article_exc_set(int32_t aid, int8_t is_exc); +extern int article_exc_set(SECTION_LIST *p_section,int32_t aid, int8_t is_exc); #endif //_ARTICLE_OP_H_ diff --git a/src/article_op.c b/src/article_op.c index ba2d914f..c482d353 100644 --- a/src/article_op.c +++ b/src/article_op.c @@ -38,7 +38,7 @@ int display_article_meta(int32_t aid) return 0; } -int article_exc_set(int32_t aid, int8_t is_exc) +int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) { MYSQL *db = NULL; MYSQL_RES *rs = NULL; @@ -202,9 +202,17 @@ int article_exc_set(int32_t aid, int8_t is_exc) goto cleanup; } + section_list_rw_lock(p_section); + section_list_set_article_excerption(p_section,aid,set_exc); + section_list_rw_unlock(p_section); + // Commit transaction if (mysql_query(db, "COMMIT") != 0) { + section_list_rw_lock(p_section); + section_list_set_article_excerption(p_section,aid,!set_exc); + section_list_rw_unlock(p_section); + log_error("Commit transaction error: %s\n", mysql_error(db)); ret = -1; goto cleanup; @@ -219,6 +227,6 @@ int article_exc_set(int32_t aid, int8_t is_exc) cleanup: mysql_free_result(rs); mysql_close(db); - press_any_key_ex(ret_msg, 3); + //press_any_key_ex(ret_msg, 3); return ret; } diff --git a/src/section_list_display.c b/src/section_list_display.c index d6738434..59fc5818 100644 --- a/src/section_list_display.c +++ b/src/section_list_display.c @@ -1099,7 +1099,7 @@ int section_list_display(const char *sname, int32_t aid) { break; } - ret = article_exc_set(p_articles[selected_index]->aid, p_articles[selected_index]->excerption); + ret = article_exc_set(p_section, p_articles[selected_index]->aid, p_articles[selected_index]->excerption); if (ret < 0) { log_error("article_exc_set(aid=%d, excerption=%d) error\n", From f97b25262485837bc64106896e34dbbb8013f5f0 Mon Sep 17 00:00:00 2001 From: ytht <2391669999@qq.com> Date: Mon, 8 Dec 2025 07:01:18 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=94=B6=E5=BD=95/=E7=A7=BB=E5=87=BA=E6=96=87=E6=91=98?= =?UTF-8?q?=E5=8C=BA=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/article_op.c | 87 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/src/article_op.c b/src/article_op.c index c482d353..240cf235 100644 --- a/src/article_op.c +++ b/src/article_op.c @@ -52,6 +52,16 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) int8_t excerption = 0; int8_t set_exc = !is_exc; char ret_msg[ret_msg_len] = ""; + int section_set_exc_ret = 0; + + if (p_section == NULL) + { + log_error("NULL pointer error\n"); + ret = -1; + goto cleanup; + } + + sid = p_section->sid; db = db_open(); if (db == NULL) @@ -91,24 +101,21 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) } if ((row = mysql_fetch_row(rs))) { + if (sid != atoi(row[2])) + { + log_error("sid error: sid = %d, row[2]= %s, aid = %d\n", sid, row[2], aid); + ret = -2; + goto cleanup; + } uid = atoi(row[0]); tid = atoi(row[1]); - sid = atoi(row[2]); transship = (int8_t)atoi(row[3]); excerption = (int8_t)atoi(row[4]); } else { - if (mysql_errno(db)) - { - log_error("mysql_fetch_row() error: %s\n", mysql_error(db)); - ret = -2; - } - else - { - strncpy(ret_msg, "文章不存在", ret_msg_len); - ret = -1; - } + log_error("mysql_fetch_row() error: %s\n", mysql_error(db)); + ret = -2; goto cleanup; } mysql_free_result(rs); @@ -116,7 +123,7 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) // Check if already set if (set_exc == excerption) - { + { snprintf(ret_msg, sizeof(ret_msg), "已%s文摘区", set_exc ? "收录" : "移出"); ret = 1; goto cleanup; @@ -202,16 +209,58 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) goto cleanup; } - section_list_rw_lock(p_section); - section_list_set_article_excerption(p_section,aid,set_exc); - section_list_rw_unlock(p_section); + if (section_list_rw_lock(p_section) != 0) + { + log_error("section_list_rw_lock error on section %d\n", sid); + ret = -1; + goto cleanup; + } + section_set_exc_ret = section_list_set_article_excerption(p_section, aid, set_exc); + if (section_set_exc_ret == 0) + { + ret = 1; + goto cleanup; + } + else if (section_set_exc_ret < 0) + { + log_error("section_list_set_article_excerption error sid = %d, aid= %d, set_exc= %d\n", sid, aid, set_exc); + ret = -1; + goto cleanup; + } + if (section_list_rw_unlock(p_section) != 0) + { + log_error("section_list_rw_unlock error on section %d\n", sid); + ret = -1; + goto cleanup; + } // Commit transaction if (mysql_query(db, "COMMIT") != 0) { - section_list_rw_lock(p_section); - section_list_set_article_excerption(p_section,aid,!set_exc); - section_list_rw_unlock(p_section); + if (section_list_rw_lock(p_section) != 0) + { + log_error("section_list_rw_lock error on section %d\n", sid); + ret = -1; + goto cleanup; + } + section_set_exc_ret = section_list_set_article_excerption(p_section, aid, !set_exc); + if (section_set_exc_ret == 0) + { + ret = -1; + goto cleanup; + } + else if (section_set_exc_ret < 0) + { + log_error("section_list_set_article_excerption error sid = %d, aid= %d, set_exc= %d\n", sid, aid, !set_exc); + ret = -1; + goto cleanup; + } + if (section_list_rw_unlock(p_section) != 0) + { + log_error("section_list_rw_unlock error on section %d\n", sid); + ret = -1; + goto cleanup; + } log_error("Commit transaction error: %s\n", mysql_error(db)); ret = -1; @@ -227,6 +276,6 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) cleanup: mysql_free_result(rs); mysql_close(db); - //press_any_key_ex(ret_msg, 3); + // press_any_key_ex(ret_msg, 3); return ret; } From aacdade10addd6aab788a5ef3b4a0633ee2344a3 Mon Sep 17 00:00:00 2001 From: ytht <2391669999@qq.com> Date: Sat, 20 Dec 2025 16:53:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=94=B6=E5=BD=95/=E7=A7=BB=E5=87=BA=E6=96=87=E6=91=98?= =?UTF-8?q?=E5=8C=BA=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/article_op.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/article_op.c b/src/article_op.c index 240cf235..da255250 100644 --- a/src/article_op.c +++ b/src/article_op.c @@ -123,7 +123,7 @@ int article_exc_set(SECTION_LIST *p_section, int32_t aid, int8_t is_exc) // Check if already set if (set_exc == excerption) - { + { snprintf(ret_msg, sizeof(ret_msg), "已%s文摘区", set_exc ? "收录" : "移出"); ret = 1; goto cleanup;