/[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.15 by sysadm, Sun Jun 15 02:24:45 2025 UTC Revision 1.19 by sysadm, Sun Jun 15 13:42:38 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 109  int article_post(const SECTION_LIST *p_s Line 110  int article_post(const SECTION_LIST *p_s
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;
# Line 172  int article_post(const SECTION_LIST *p_s Line 176  int article_post(const SECTION_LIST *p_s
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':
# Line 200  int article_post(const SECTION_LIST *p_s Line 207  int article_post(const SECTION_LIST *p_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          {          {
# Line 212  int article_post(const SECTION_LIST *p_s Line 224  int article_post(const SECTION_LIST *p_s
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    
# Line 377  int article_post(const SECTION_LIST *p_s Line 389  int article_post(const SECTION_LIST *p_s
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);
# Line 429  int article_modify(const SECTION_LIST *p Line 444  int article_modify(const SECTION_LIST *p
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),
# Line 455  int article_modify(const SECTION_LIST *p Line 461  int article_modify(const SECTION_LIST *p
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    
# Line 485  int article_modify(const SECTION_LIST *p Line 491  int article_modify(const SECTION_LIST *p
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    
# Line 511  int article_modify(const SECTION_LIST *p Line 517  int article_modify(const SECTION_LIST *p
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':
# Line 531  int article_modify(const SECTION_LIST *p Line 540  int article_modify(const SECTION_LIST *p
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)
# Line 544  int article_modify(const SECTION_LIST *p Line 558  int article_modify(const SECTION_LIST *p
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    
# Line 661  int article_modify(const SECTION_LIST *p Line 675  int article_modify(const SECTION_LIST *p
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);
# Line 731  int article_reply(const SECTION_LIST *p_ Line 748  int article_reply(const SECTION_LIST *p_
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),
# Line 741  int article_reply(const SECTION_LIST *p_ Line 759  int article_reply(const SECTION_LIST *p_
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)))
# Line 761  int article_reply(const SECTION_LIST *p_ Line 781  int article_reply(const SECTION_LIST *p_
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("该主题谢绝回复");
# Line 778  int article_reply(const SECTION_LIST *p_ Line 801  int article_reply(const SECTION_LIST *p_
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)))
# Line 822  int article_reply(const SECTION_LIST *p_ Line 847  int article_reply(const SECTION_LIST *p_
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                  {                  {
# Line 837  int article_reply(const SECTION_LIST *p_ Line 867  int article_reply(const SECTION_LIST *p_
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    
# Line 875  int article_reply(const SECTION_LIST *p_ Line 905  int article_reply(const SECTION_LIST *p_
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;
# Line 932  int article_reply(const SECTION_LIST *p_ Line 965  int article_reply(const SECTION_LIST *p_
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':
# Line 960  int article_reply(const SECTION_LIST *p_ Line 996  int article_reply(const SECTION_LIST *p_
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          {          {
# Line 972  int article_reply(const SECTION_LIST *p_ Line 1013  int article_reply(const SECTION_LIST *p_
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    
# Line 1153  int article_reply(const SECTION_LIST *p_ Line 1194  int article_reply(const SECTION_LIST *p_
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);


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

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