/[LeafOK_CVS]/lbbs/src/article_post.c
ViewVC logotype

Diff of /lbbs/src/article_post.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.13 by sysadm, Sun Jun 15 00:02:40 2025 UTC Revision 1.18 by sysadm, Sun Jun 15 06:19:21 2025 UTC
# Line 81  int article_post(const SECTION_LIST *p_s Line 81  int article_post(const SECTION_LIST *p_s
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
# Line 212  int article_post(const SECTION_LIST *p_s Line 213  int article_post(const SECTION_LIST *p_s
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    
# Line 377  int article_post(const SECTION_LIST *p_s Line 378  int article_post(const SECTION_LIST *p_s
378                  goto cleanup;                  goto cleanup;
379          }          }
380    
381            mysql_close(db);
382            db = NULL;
383    
384          clearscr();          clearscr();
385          moveto(1, 1);          moveto(1, 1);
386          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);
# Line 429  int article_modify(const SECTION_LIST *p Line 433  int article_modify(const SECTION_LIST *p
433                  return 0;                  return 0;
434          }          }
435    
         if (!checkpriv(&BBS_priv, p_section->sid, S_POST))  
         {  
                 clearscr();  
                 moveto(1, 1);  
                 prints("您没有权限在本版块发表文章\n");  
                 press_any_key();  
   
                 return 0;  
         }  
   
436          db = db_open();          db = db_open();
437          if (db == NULL)          if (db == NULL)
438          {          {
439                  log_error("db_open() error: %s\n", mysql_error(db));                  log_error("db_open() error: %s\n", mysql_error(db));
440                  return -1;                  ret = -1;
441                    goto cleanup;
442          }          }
443    
444          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
# Line 455  int article_modify(const SECTION_LIST *p Line 450  int article_modify(const SECTION_LIST *p
450          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
451          {          {
452                  log_error("Query article content error: %s\n", mysql_error(db));                  log_error("Query article content error: %s\n", mysql_error(db));
453                  ret = -2;                  ret = -1;
454                  goto cleanup;                  goto cleanup;
455          }          }
456          if ((rs = mysql_use_result(db)) == NULL)          if ((rs = mysql_use_result(db)) == NULL)
457          {          {
458                  log_error("Get article content data failed\n");                  log_error("Get article content data failed\n");
459                  ret = -2;                  ret = -1;
460                  goto cleanup;                  goto cleanup;
461          }          }
462    
# Line 485  int article_modify(const SECTION_LIST *p Line 480  int article_modify(const SECTION_LIST *p
480                  if (p_editor_data == NULL)                  if (p_editor_data == NULL)
481                  {                  {
482                          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]));
483                          ret = -3;                          ret = -1;
484                          goto cleanup;                          goto cleanup;
485                  }                  }
486    
# Line 544  int article_modify(const SECTION_LIST *p Line 539  int article_modify(const SECTION_LIST *p
539          if (len_content < 0)          if (len_content < 0)
540          {          {
541                  log_error("editor_data_save() error\n");                  log_error("editor_data_save() error\n");
542                  ret = -2;                  ret = -1;
543                  goto cleanup;                  goto cleanup;
544          }          }
545    
# Line 623  int article_modify(const SECTION_LIST *p Line 618  int article_modify(const SECTION_LIST *p
618    
619          // Update article          // Update article
620          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
621                           "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
622                           p_article_new->cid, len_content, p_article->aid);                           p_article_new->cid, len_content, p_article->aid);
623    
624          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
# Line 661  int article_modify(const SECTION_LIST *p Line 656  int article_modify(const SECTION_LIST *p
656                  goto cleanup;                  goto cleanup;
657          }          }
658    
659            mysql_close(db);
660            db = NULL;
661    
662          clearscr();          clearscr();
663          moveto(1, 1);          moveto(1, 1);
664          prints("修改完成,新内容通常会在%d秒后可见", BBS_section_list_load_interval);          prints("修改完成,新内容通常会在%d秒后可见", BBS_section_list_load_interval);
# Line 705  int article_reply(const SECTION_LIST *p_ Line 703  int article_reply(const SECTION_LIST *p_
703          long quote_content_lines;          long quote_content_lines;
704          long i;          long i;
705          long ret = 0;          long ret = 0;
706            int topic_locked = 0;
707    
708          if (p_section == NULL || p_article == NULL)          if (p_section == NULL || p_article == NULL)
709          {          {
# Line 721  int article_reply(const SECTION_LIST *p_ Line 720  int article_reply(const SECTION_LIST *p_
720                  return 0;                  return 0;
721          }          }
722    
         if (p_article->lock) // Reply is not allowed  
         {  
                 clearscr();  
                 moveto(1, 1);  
                 prints("该文章谢绝回复");  
                 press_any_key();  
   
                 return 0;  
         }  
   
723          p_article_new->title[0] = '\0';          p_article_new->title[0] = '\0';
724          snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title);          snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title);
725          len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len);          len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len);
# Line 740  int article_reply(const SECTION_LIST *p_ Line 729  int article_reply(const SECTION_LIST *p_
729          if (db == NULL)          if (db == NULL)
730          {          {
731                  log_error("db_open() error: %s\n", mysql_error(db));                  log_error("db_open() error: %s\n", mysql_error(db));
732                  return -1;                  ret = -1;
733                    goto cleanup;
734            }
735    
736            snprintf(sql, sizeof(sql),
737                             "SELECT `lock` FROM bbs WHERE AID = %d",
738                             (p_article->tid == 0 ? p_article->aid : p_article->tid));
739    
740            if (mysql_query(db, sql) != 0)
741            {
742                    log_error("Query article status error: %s\n", mysql_error(db));
743                    ret = -1;
744                    goto cleanup;
745            }
746            if ((rs = mysql_store_result(db)) == NULL)
747            {
748                    log_error("Get article status data failed\n");
749                    ret = -1;
750                    goto cleanup;
751            }
752    
753            if ((row = mysql_fetch_row(rs)))
754            {
755                    if (atoi(row[0]) != 0)
756                    {
757                            topic_locked = 1;
758                    }
759            }
760            mysql_free_result(rs);
761            rs = NULL;
762    
763            if (topic_locked) // Reply is not allowed
764            {
765                    mysql_close(db);
766                    db = NULL;
767    
768                    clearscr();
769                    moveto(1, 1);
770                    prints("该主题谢绝回复");
771                    press_any_key();
772    
773                    goto cleanup;
774          }          }
775    
776          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
# Line 752  int article_reply(const SECTION_LIST *p_ Line 782  int article_reply(const SECTION_LIST *p_
782          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
783          {          {
784                  log_error("Query article content error: %s\n", mysql_error(db));                  log_error("Query article content error: %s\n", mysql_error(db));
785                  return -2;                  ret = -1;
786                    goto cleanup;
787          }          }
788          if ((rs = mysql_use_result(db)) == NULL)          if ((rs = mysql_use_result(db)) == NULL)
789          {          {
790                  log_error("Get article content data failed\n");                  log_error("Get article content data failed\n");
791                  return -2;                  ret = -1;
792                    goto cleanup;
793          }          }
794    
795          if ((row = mysql_fetch_row(rs)))          if ((row = mysql_fetch_row(rs)))
# Line 796  int article_reply(const SECTION_LIST *p_ Line 828  int article_reply(const SECTION_LIST *p_
828                          len += 2;                          len += 2;
829                          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]));
830                          len += (line_offsets[i + 1] - line_offsets[i]);                          len += (line_offsets[i + 1] - line_offsets[i]);
831                            if (content[len - 1] != '\n') // Appennd \n if not exist
832                            {
833                                    content[len] = '\n';
834                                    len++;
835                            }
836                  }                  }
837                  if (content[len - 1] != '\n') // Appennd \n if not exist                  if (content[len - 1] != '\n') // Appennd \n if not exist
838                  {                  {
# Line 811  int article_reply(const SECTION_LIST *p_ Line 848  int article_reply(const SECTION_LIST *p_
848                  if (p_editor_data == NULL)                  if (p_editor_data == NULL)
849                  {                  {
850                          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]));
851                          ret = -3;                          ret = -1;
852                          goto cleanup;                          goto cleanup;
853                  }                  }
854    
# Line 946  int article_reply(const SECTION_LIST *p_ Line 983  int article_reply(const SECTION_LIST *p_
983          if (len_content < 0)          if (len_content < 0)
984          {          {
985                  log_error("editor_data_save() error\n");                  log_error("editor_data_save() error\n");
986                  ret = -2;                  ret = -1;
987                  goto cleanup;                  goto cleanup;
988          }          }
989    
# Line 1127  int article_reply(const SECTION_LIST *p_ Line 1164  int article_reply(const SECTION_LIST *p_
1164                  goto cleanup;                  goto cleanup;
1165          }          }
1166    
1167            mysql_close(db);
1168            db = NULL;
1169    
1170          clearscr();          clearscr();
1171          moveto(1, 1);          moveto(1, 1);
1172          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1