/[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.20 by sysadm, Mon Jun 16 01:36:56 2025 UTC Revision 1.33 by sysadm, Fri Oct 17 01:25:08 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #define _POSIX_C_SOURCE 200809L  
   
 #include "article_post.h"  
17  #include "article_cache.h"  #include "article_cache.h"
18  #include "editor.h"  #include "article_post.h"
 #include "screen.h"  
19  #include "bbs.h"  #include "bbs.h"
20  #include "log.h"  #include "database.h"
21    #include "editor.h"
22  #include "io.h"  #include "io.h"
23    #include "log.h"
24  #include "lml.h"  #include "lml.h"
25  #include "database.h"  #include "screen.h"
26  #include "user_priv.h"  #include "user_priv.h"
27  #include <ctype.h>  #include <ctype.h>
28  #include <string.h>  #include <string.h>
29  #include <stdlib.h>  #include <stdlib.h>
30  #include <time.h>  #include <time.h>
31    
32  #define TITLE_INPUT_MAX_LEN 74  #define TITLE_INPUT_MAX_LEN 72
33  #define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB  #define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB
34  #define ARTICLE_QUOTE_MAX_LINES 20  #define ARTICLE_QUOTE_MAX_LINES 20
35  #define ARTICLE_QUOTE_LINE_MAX_LEN 76  #define ARTICLE_QUOTE_LINE_MAX_LEN 76
# Line 46  int article_post(const SECTION_LIST *p_s Line 44  int article_post(const SECTION_LIST *p_s
44          char sql[SQL_BUFFER_LEN];          char sql[SQL_BUFFER_LEN];
45          char *sql_content = NULL;          char *sql_content = NULL;
46          EDITOR_DATA *p_editor_data = NULL;          EDITOR_DATA *p_editor_data = NULL;
47          char title_input[TITLE_INPUT_MAX_LEN + 1];          char title_input[BBS_article_title_max_len + 1];
48          char title_f[BBS_article_title_max_len * 2 + 1];          char title_f[BBS_article_title_max_len * 2 + 1];
49          char *content = NULL;          char *content = NULL;
50          char *content_f = NULL;          char *content_f = NULL;
51          long len_content;          long len_content;
52            int content_display_length;
53          char nickname_f[BBS_nickname_max_len * 2 + 1];          char nickname_f[BBS_nickname_max_len * 2 + 1];
54          int sign_id = 0;          int sign_id = 0;
55            int reply_note = 1;
56          long len;          long len;
57          int ch;          int ch;
58          char *p, *q;          char *p, *q;
# Line 67  int article_post(const SECTION_LIST *p_s Line 67  int article_post(const SECTION_LIST *p_s
67          {          {
68                  clearscr();                  clearscr();
69                  moveto(1, 1);                  moveto(1, 1);
70                  prints("您没有权限在本版块发表文章\n");                  prints("鎮ㄦ病鏈夋潈闄愬湪鏈増鍧楀彂琛ㄦ枃绔燶n");
71                  press_any_key();                  press_any_key();
72    
73                  return 0;                  return 0;
# Line 90  int article_post(const SECTION_LIST *p_s Line 90  int article_post(const SECTION_LIST *p_s
90          {          {
91                  clearscr();                  clearscr();
92                  moveto(21, 1);                  moveto(21, 1);
93                  prints("发表文章于 %s[%s] 讨论区,类型: %s", p_section->stitle, p_section->sname, (p_article_new->transship ? "转载" : "原创"));                  prints("鍙戣〃鏂囩珷浜 %s[%s] 璁ㄨ鍖猴紝绫诲瀷: %s锛屽洖澶嶉氱煡锛%s",
94                               p_section->stitle, p_section->sname,
95                               (p_article_new->transship ? "杞浇" : "鍘熷垱"),
96                               (reply_note ? "寮鍚" : "鍏抽棴"));
97                  moveto(22, 1);                  moveto(22, 1);
98                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));                  prints("鏍囬: %s", (p_article_new->title[0] == '\0' ? "[鏃燷" : p_article_new->title));
99                  moveto(23, 1);                  moveto(23, 1);
100                  prints("使用第 %d 个签名", sign_id);                  prints("浣跨敤绗 %d 涓鍚", sign_id);
101    
102                  if (toupper(ch) != 'T')                  if (toupper(ch) != 'T')
103                  {                  {
104                          prints("    按0~3选签名档(0表示不使用)");                          prints("    鎸0~3閫夌鍚嶆。(0琛ㄧず涓嶄娇鐢)");
105    
106                          moveto(24, 1);                          moveto(24, 1);
107                          prints("T改标题, C取消, Z设为转载, Y设为原创, Enter继续: ");                          prints("T鏀规爣棰, C鍙栨秷, Z璁句负%s, N%s, Enter缁х画: ",
108                                       (p_article_new->transship ? "鍘熷垱" : "杞浇"),
109                                       (reply_note ? "鍏抽棴鍥炲閫氱煡" : "寮鍚洖澶嶉氱煡"));
110                          iflush();                          iflush();
111                          ch = 0;                          ch = 0;
112                  }                  }
# Line 114  int article_post(const SECTION_LIST *p_s Line 119  int article_post(const SECTION_LIST *p_s
119                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
120                                  goto cleanup;                                  goto cleanup;
121                          case CR:                          case CR:
                                 igetch_reset();  
122                                  break;                                  break;
123                          case 'T':                          case 'T':
124                                  moveto(24, 1);                                  len = get_data(24, 1, "鏍囬: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN);
                                 clrtoeol();  
                                 len = get_data(24, 1, "标题: ", title_input, TITLE_INPUT_MAX_LEN, 1);  
125                                  for (p = title_input; *p == ' '; p++)                                  for (p = title_input; *p == ' '; p++)
126                                          ;                                          ;
127                                  for (q = title_input + len; q > p && *(q - 1) == ' '; q--)                                  for (q = title_input + len; q > p && *(q - 1) == ' '; q--)
# Line 136  int article_post(const SECTION_LIST *p_s Line 138  int article_post(const SECTION_LIST *p_s
138                          case 'C':                          case 'C':
139                                  clearscr();                                  clearscr();
140                                  moveto(1, 1);                                  moveto(1, 1);
141                                  prints("取消...");                                  prints("鍙栨秷...");
142                                  press_any_key();                                  press_any_key();
143                                  goto cleanup;                                  goto cleanup;
                         case 'Y':  
                                 p_article_new->transship = 0;  
                                 break;  
144                          case 'Z':                          case 'Z':
145                                  p_article_new->transship = 1;                                  p_article_new->transship = (p_article_new->transship ? 0 : 1);
146                                    break;
147                            case 'N':
148                                    reply_note = (reply_note ? 0 : 1);
149                                  break;                                  break;
150                          case '0':                          case '0':
151                          case '1':                          case '1':
# Line 169  int article_post(const SECTION_LIST *p_s Line 171  int article_post(const SECTION_LIST *p_s
171    
172                          clearscr();                          clearscr();
173                          moveto(1, 1);                          moveto(1, 1);
174                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");                          prints("(S)鍙戦, (C)鍙栨秷, (T)鏇存敼鏍囬 or (E)鍐嶇紪杈? [S]: ");
175                          iflush();                          iflush();
176    
177                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))
# Line 180  int article_post(const SECTION_LIST *p_s Line 182  int article_post(const SECTION_LIST *p_s
182                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
183                                          goto cleanup;                                          goto cleanup;
184                                  case CR:                                  case CR:
                                         igetch_reset();  
185                                  case 'S':                                  case 'S':
186                                          break;                                          break;
187                                  case 'C':                                  case 'C':
188                                          clearscr();                                          clearscr();
189                                          moveto(1, 1);                                          moveto(1, 1);
190                                          prints("取消...");                                          prints("鍙栨秷...");
191                                          press_any_key();                                          press_any_key();
192                                          goto cleanup;                                          goto cleanup;
193                                  case 'T':                                  case 'T':
# Line 265  int article_post(const SECTION_LIST *p_s Line 266  int article_post(const SECTION_LIST *p_s
266                  rs = NULL;                  rs = NULL;
267          }          }
268    
269            // Calculate display length of content
270            content_display_length = str_length(content, 1);
271    
272          // Begin transaction          // Begin transaction
273          if (mysql_query(db, "SET autocommit=0") != 0)          if (mysql_query(db, "SET autocommit=0") != 0)
274          {          {
# Line 328  int article_post(const SECTION_LIST *p_s Line 332  int article_post(const SECTION_LIST *p_s
332          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
333                           "INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, "                           "INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, "
334                           "sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) "                           "sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) "
335                           "VALUES(%d, 0, %d, '%s', '%s', '%s', %d, %d, NOW(), '%s', 1, %d, NOW(), 1, %ld)",                           "VALUES(%d, 0, %d, '%s', '%s', '%s', %d, %d, NOW(), '%s', %d, %d, NOW(), 1, %d)",
336                           p_section->sid, BBS_priv.uid, BBS_username, nickname_f, title_f,                           p_section->sid, BBS_priv.uid, BBS_username, nickname_f, title_f,
337                           p_article_new->cid, p_article_new->transship, hostaddr_client, BBS_user_exp, len_content);                           p_article_new->cid, p_article_new->transship, hostaddr_client,
338                             reply_note, BBS_user_exp, content_display_length);
339    
340          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
341          {          {
# Line 394  int article_post(const SECTION_LIST *p_s Line 399  int article_post(const SECTION_LIST *p_s
399    
400          clearscr();          clearscr();
401          moveto(1, 1);          moveto(1, 1);
402          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);          prints("鍙戦佸畬鎴愶紝鏂版枃绔犻氬父浼氬湪%d绉掑悗鍙", BBS_section_list_load_interval);
403          press_any_key();          press_any_key();
404          ret = 1; // Success          ret = 1; // Success
405    
# Line 421  int article_modify(const SECTION_LIST *p Line 426  int article_modify(const SECTION_LIST *p
426          char *content = NULL;          char *content = NULL;
427          char *content_f = NULL;          char *content_f = NULL;
428          long len_content;          long len_content;
429            int content_display_length;
430            int reply_note = 1;
431          int ch;          int ch;
432          long ret = 0;          long ret = 0;
433          time_t now;          time_t now;
# Line 438  int article_modify(const SECTION_LIST *p Line 445  int article_modify(const SECTION_LIST *p
445          {          {
446                  clearscr();                  clearscr();
447                  moveto(1, 1);                  moveto(1, 1);
448                  prints("该文章无法被编辑,请联系版主。");                  prints("璇ユ枃绔犳棤娉曡缂栬緫锛岃鑱旂郴鐗堜富銆");
449                  press_any_key();                  press_any_key();
450    
451                  return 0;                  return 0;
# Line 453  int article_modify(const SECTION_LIST *p Line 460  int article_modify(const SECTION_LIST *p
460          }          }
461    
462          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
463                           "SELECT bbs_content.CID, bbs_content.content "                           "SELECT bbs_content.CID, bbs_content.content, reply_note "
464                           "FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID "                           "FROM bbs INNER JOIN bbs_content ON bbs.CID = bbs_content.CID "
465                           "WHERE bbs.AID = %d",                           "WHERE bbs.AID = %d",
466                           p_article->aid);                           p_article->aid);
# Line 497  int article_modify(const SECTION_LIST *p Line 504  int article_modify(const SECTION_LIST *p
504    
505                  free(content);                  free(content);
506                  content = NULL;                  content = NULL;
507    
508                    reply_note = atoi(row[2]);
509          }          }
510          mysql_free_result(rs);          mysql_free_result(rs);
511          rs = NULL;          rs = NULL;
# Line 508  int article_modify(const SECTION_LIST *p Line 517  int article_modify(const SECTION_LIST *p
517          {          {
518                  editor_display(p_editor_data);                  editor_display(p_editor_data);
519    
520                  clearscr();                  while (!SYS_server_exit)
                 moveto(1, 1);  
                 prints("(S)保存, (C)取消 or (E)再编辑? [S]: ");  
                 iflush();  
   
                 for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))  
521                  {                  {
522                            clearscr();
523                            moveto(1, 1);
524                            prints("(S)淇濆瓨, (C)鍙栨秷, (N)%s鍥炲閫氱煡 or (E)鍐嶇紪杈? [S]: ",
525                                       (reply_note ? "鍏抽棴" : "寮鍚"));
526                            iflush();
527    
528                            ch = igetch_t(MAX_DELAY_TIME);
529                          switch (toupper(ch))                          switch (toupper(ch))
530                          {                          {
531                          case KEY_NULL:                          case KEY_NULL:
532                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
533                                  goto cleanup;                                  goto cleanup;
534                          case CR:                          case CR:
                                 igetch_reset();  
535                          case 'S':                          case 'S':
536                                  break;                                  break;
537                          case 'C':                          case 'C':
538                                  clearscr();                                  clearscr();
539                                  moveto(1, 1);                                  moveto(1, 1);
540                                  prints("取消...");                                  prints("鍙栨秷...");
541                                  press_any_key();                                  press_any_key();
542                                  goto cleanup;                                  goto cleanup;
543                            case 'N':
544                                    reply_note = (reply_note ? 0 : 1);
545                                    continue;
546                          case 'E':                          case 'E':
547                                  break;                                  break;
548                          default: // Invalid selection                          default: // Invalid selection
# Line 567  int article_modify(const SECTION_LIST *p Line 580  int article_modify(const SECTION_LIST *p
580          strftime(str_modify_dt, sizeof(str_modify_dt), "%Y-%m-%d %H:%M:%S (UTC %z)", &tm_modify_dt);          strftime(str_modify_dt, sizeof(str_modify_dt), "%Y-%m-%d %H:%M:%S (UTC %z)", &tm_modify_dt);
581    
582          len_content += snprintf(content + len_content, LINE_BUFFER_LEN,          len_content += snprintf(content + len_content, LINE_BUFFER_LEN,
583                                                          "\n--\n※ 作者已于 %s 修改本文※\n",                                                          "\n--\n鈥 浣滆呭凡浜 %s 淇敼鏈枃鈥籠n",
584                                                          str_modify_dt);                                                          str_modify_dt);
585    
586            // Calculate display length of content
587            content_display_length = str_length(content, 1);
588    
589          db = db_open();          db = db_open();
590          if (db == NULL)          if (db == NULL)
591          {          {
# Line 637  int article_modify(const SECTION_LIST *p Line 653  int article_modify(const SECTION_LIST *p
653    
654          // Update article          // Update article
655          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
656                           "UPDATE bbs SET CID = %d, length = %ld, excerption = 0 WHERE AID = %d", // Set excerption = 0 explictly in case of rare condition                           "UPDATE bbs SET CID = %d, length = %d, reply_note = %d, excerption = 0 WHERE AID = %d", // Set excerption = 0 explictly in case of rare condition
657                           p_article_new->cid, len_content, p_article->aid);                           p_article_new->cid, content_display_length, reply_note, p_article->aid);
658    
659          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
660          {          {
# Line 680  int article_modify(const SECTION_LIST *p Line 696  int article_modify(const SECTION_LIST *p
696    
697          clearscr();          clearscr();
698          moveto(1, 1);          moveto(1, 1);
699          prints("修改完成,新内容通常会在%d秒后可见", BBS_section_list_load_interval);          prints("淇敼瀹屾垚锛屾柊鍐呭閫氬父浼氬湪%d绉掑悗鍙", BBS_section_list_load_interval);
700          press_any_key();          press_any_key();
701          ret = 1; // Success          ret = 1; // Success
702    
# Line 712  int article_reply(const SECTION_LIST *p_ Line 728  int article_reply(const SECTION_LIST *p_
728          char *content = NULL;          char *content = NULL;
729          char *content_f = NULL;          char *content_f = NULL;
730          long len_content;          long len_content;
731            int content_display_length;
732          char nickname_f[BBS_nickname_max_len * 2 + 1];          char nickname_f[BBS_nickname_max_len * 2 + 1];
733          int sign_id = 0;          int sign_id = 0;
734            int reply_note = 0;
735          long len;          long len;
736          int ch;          int ch;
737          char *p, *q;          char *p, *q;
# Line 723  int article_reply(const SECTION_LIST *p_ Line 741  int article_reply(const SECTION_LIST *p_
741          long i;          long i;
742          long ret = 0;          long ret = 0;
743          int topic_locked = 0;          int topic_locked = 0;
744            char msg[BBS_msg_max_len];
745            char msg_f[BBS_msg_max_len * 2 + 1];
746            int len_msg;
747    
748          if (p_section == NULL || p_article == NULL)          if (p_section == NULL || p_article == NULL)
749          {          {
# Line 733  int article_reply(const SECTION_LIST *p_ Line 754  int article_reply(const SECTION_LIST *p_
754          {          {
755                  clearscr();                  clearscr();
756                  moveto(1, 1);                  moveto(1, 1);
757                  prints("您没有权限在本版块发表文章\n");                  prints("鎮ㄦ病鏈夋潈闄愬湪鏈増鍧楀彂琛ㄦ枃绔燶n");
758                  press_any_key();                  press_any_key();
759    
760                  return 0;                  return 0;
# Line 786  int article_reply(const SECTION_LIST *p_ Line 807  int article_reply(const SECTION_LIST *p_
807    
808                  clearscr();                  clearscr();
809                  moveto(1, 1);                  moveto(1, 1);
810                  prints("该主题谢绝回复");                  prints("璇ヤ富棰樿阿缁濆洖澶");
811                  press_any_key();                  press_any_key();
812    
813                  goto cleanup;                  goto cleanup;
# Line 830  int article_reply(const SECTION_LIST *p_ Line 851  int article_reply(const SECTION_LIST *p_
851                  }                  }
852    
853                  // Apply LML render to content body                  // Apply LML render to content body
854                  len = lml_plain(row[1], content_f, ARTICLE_CONTENT_MAX_LEN);                  len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, 0);
855                  content_f[len] = '\0';                  content_f[len] = '\0';
856    
857                  // Remove control sequence                  // Remove control sequence
858                  len = str_filter(content_f, 0);                  len = str_filter(content_f, 0);
859    
860                  len = snprintf(content, ARTICLE_CONTENT_MAX_LEN,                  len = snprintf(content, ARTICLE_CONTENT_MAX_LEN,
861                                             "\n\n【 在 %s (%s) 的大作中提到: 】\n",                                             "\n\n銆 鍦 %s (%s) 鐨勫ぇ浣滀腑鎻愬埌: 銆慭n",
862                                             p_article->username, p_article->nickname);                                             p_article->username, p_article->nickname);
863    
864                  quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0);                  quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0, NULL);
865                  for (i = 0; i < quote_content_lines; i++)                  for (i = 0; i < quote_content_lines; i++)
866                  {                  {
867                          memcpy(content + len, ": ", 2); // quote line prefix                          memcpy(content + len, ": ", 2); // quote line prefix
# Line 885  int article_reply(const SECTION_LIST *p_ Line 906  int article_reply(const SECTION_LIST *p_
906          {          {
907                  clearscr();                  clearscr();
908                  moveto(21, 1);                  moveto(21, 1);
909                  prints("回复文章于 %s[%s] 讨论区", p_section->stitle, p_section->sname);                  prints("鍥炲鏂囩珷浜 %s[%s] 璁ㄨ鍖猴紝鍥炲閫氱煡锛%s", p_section->stitle, p_section->sname, (reply_note ? "寮鍚" : "鍏抽棴"));
910                  moveto(22, 1);                  moveto(22, 1);
911                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));                  prints("鏍囬: %s", (p_article_new->title[0] == '\0' ? "[鏃燷" : p_article_new->title));
912                  moveto(23, 1);                  moveto(23, 1);
913                  prints("使用第 %d 个签名", sign_id);                  prints("浣跨敤绗 %d 涓鍚", sign_id);
914    
915                  if (toupper(ch) != 'T')                  if (toupper(ch) != 'T')
916                  {                  {
917                          prints("    按0~3选签名档(0表示不使用)");                          prints("    鎸0~3閫夌鍚嶆。(0琛ㄧず涓嶄娇鐢)");
918    
919                          moveto(24, 1);                          moveto(24, 1);
920                          prints("T改标题, C取消, Enter继续: ");                          prints("T鏀规爣棰, C鍙栨秷, N%s, Enter缁х画: ",
921                                       (reply_note ? "鍏抽棴鍥炲閫氱煡" : "寮鍚洖澶嶉氱煡"));
922                          iflush();                          iflush();
923                          ch = 0;                          ch = 0;
924                  }                  }
# Line 909  int article_reply(const SECTION_LIST *p_ Line 931  int article_reply(const SECTION_LIST *p_
931                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
932                                  goto cleanup;                                  goto cleanup;
933                          case CR:                          case CR:
                                 igetch_reset();  
934                                  break;                                  break;
935                          case 'T':                          case 'T':
936                                  moveto(24, 1);                                  len = get_data(24, 1, "鏍囬: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN);
                                 clrtoeol();  
                                 len = get_data(24, 1, "标题: ", title_input, TITLE_INPUT_MAX_LEN, 1);  
937                                  for (p = title_input; *p == ' '; p++)                                  for (p = title_input; *p == ' '; p++)
938                                          ;                                          ;
939                                  for (q = title_input + len; q > p && *(q - 1) == ' '; q--)                                  for (q = title_input + len; q > p && *(q - 1) == ' '; q--)
# Line 931  int article_reply(const SECTION_LIST *p_ Line 950  int article_reply(const SECTION_LIST *p_
950                          case 'C':                          case 'C':
951                                  clearscr();                                  clearscr();
952                                  moveto(1, 1);                                  moveto(1, 1);
953                                  prints("取消...");                                  prints("鍙栨秷...");
954                                  press_any_key();                                  press_any_key();
955                                  goto cleanup;                                  goto cleanup;
956                            case 'N':
957                                    reply_note = (reply_note ? 0 : 1);
958                                    break;
959                          case '0':                          case '0':
960                          case '1':                          case '1':
961                          case '2':                          case '2':
# Line 958  int article_reply(const SECTION_LIST *p_ Line 980  int article_reply(const SECTION_LIST *p_
980    
981                          clearscr();                          clearscr();
982                          moveto(1, 1);                          moveto(1, 1);
983                          prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: ");                          prints("(S)鍙戦, (C)鍙栨秷, (T)鏇存敼鏍囬 or (E)鍐嶇紪杈? [S]: ");
984                          iflush();                          iflush();
985    
986                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))                          for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME))
# Line 969  int article_reply(const SECTION_LIST *p_ Line 991  int article_reply(const SECTION_LIST *p_
991                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
992                                          goto cleanup;                                          goto cleanup;
993                                  case CR:                                  case CR:
                                         igetch_reset();  
994                                  case 'S':                                  case 'S':
995                                          break;                                          break;
996                                  case 'C':                                  case 'C':
997                                          clearscr();                                          clearscr();
998                                          moveto(1, 1);                                          moveto(1, 1);
999                                          prints("取消...");                                          prints("鍙栨秷...");
1000                                          press_any_key();                                          press_any_key();
1001                                          goto cleanup;                                          goto cleanup;
1002                                  case 'T':                                  case 'T':
# Line 1054  int article_reply(const SECTION_LIST *p_ Line 1075  int article_reply(const SECTION_LIST *p_
1075                  rs = NULL;                  rs = NULL;
1076          }          }
1077    
1078            // Calculate display length of content
1079            content_display_length = str_length(content, 1);
1080    
1081          // Begin transaction          // Begin transaction
1082          if (mysql_query(db, "SET autocommit=0") != 0)          if (mysql_query(db, "SET autocommit=0") != 0)
1083          {          {
# Line 1117  int article_reply(const SECTION_LIST *p_ Line 1141  int article_reply(const SECTION_LIST *p_
1141          snprintf(sql, sizeof(sql),          snprintf(sql, sizeof(sql),
1142                           "INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, "                           "INSERT INTO bbs(SID, TID, UID, username, nickname, title, CID, transship, "
1143                           "sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) "                           "sub_dt, sub_ip, reply_note, exp, last_reply_dt, icon, length) "
1144                           "VALUES(%d, %d, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', 1, %d, NOW(), 1, %ld)",                           "VALUES(%d, %d, %d, '%s', '%s', '%s', %d, 0, NOW(), '%s', %d, %d, NOW(), 1, %d)",
1145                           p_section->sid, (p_article->tid == 0 ? p_article->aid : p_article->tid),                           p_section->sid, (p_article->tid == 0 ? p_article->aid : p_article->tid),
1146                           BBS_priv.uid, BBS_username, nickname_f, title_f,                           BBS_priv.uid, BBS_username, nickname_f, title_f,
1147                           p_article_new->cid, hostaddr_client, BBS_user_exp, len_content);                           p_article_new->cid, hostaddr_client,
1148                             reply_note, BBS_user_exp, content_display_length);
1149    
1150          if (mysql_query(db, sql) != 0)          if (mysql_query(db, sql) != 0)
1151          {          {
# Line 1158  int article_reply(const SECTION_LIST *p_ Line 1183  int article_reply(const SECTION_LIST *p_
1183                  goto cleanup;                  goto cleanup;
1184          }          }
1185    
1186            // Notify the authors of the topic / article which is replyed.
1187            snprintf(sql, sizeof(sql),
1188                             "SELECT DISTINCT UID FROM bbs WHERE (AID = %d OR AID = %d) "
1189                             "AND visible AND reply_note AND UID <> %d",
1190                             p_article->tid, p_article->aid, BBS_priv.uid);
1191    
1192            if (mysql_query(db, sql) != 0)
1193            {
1194                    log_error("Read reply info error: %s\n", mysql_error(db));
1195                    ret = -1;
1196                    goto cleanup;
1197            }
1198            if ((rs = mysql_store_result(db)) == NULL)
1199            {
1200                    log_error("Get reply info failed\n");
1201                    ret = -1;
1202                    goto cleanup;
1203            }
1204    
1205            while ((row = mysql_fetch_row(rs)))
1206            {
1207                    // Send notification message
1208                    len_msg = snprintf(msg, BBS_msg_max_len,
1209                                                       "鏈変汉鍥炲浜嗘偍鎵鍙戣〃/鍥炲鐨勬枃绔狅紝蹇潵"
1210                                                       "[article %d]鐪嬬湅[/article]銆%s銆嬪惂锛乗n",
1211                                                       p_article_new->aid, title_f);
1212    
1213                    mysql_real_escape_string(db, msg_f, msg, (unsigned long)len_msg);
1214    
1215                    snprintf(sql, sizeof(sql),
1216                                     "INSERT INTO bbs_msg(fromUID, toUID, content, send_dt, send_ip) "
1217                                     "VALUES(%d, %d, '%s', NOW(), '%s')",
1218                                     BBS_sys_id, atoi(row[0]), msg_f, hostaddr_client);
1219    
1220                    if (mysql_query(db, sql) != 0)
1221                    {
1222                            log_error("Insert msg error: %s\n", mysql_error(db));
1223                            ret = -1;
1224                            goto cleanup;
1225                    }
1226            }
1227            mysql_free_result(rs);
1228            rs = NULL;
1229    
1230          // Add exp          // Add exp
1231          if (checkpriv(&BBS_priv, p_section->sid, S_GETEXP)) // Except in test section          if (checkpriv(&BBS_priv, p_section->sid, S_GETEXP)) // Except in test section
1232          {          {
# Line 1199  int article_reply(const SECTION_LIST *p_ Line 1268  int article_reply(const SECTION_LIST *p_
1268    
1269          clearscr();          clearscr();
1270          moveto(1, 1);          moveto(1, 1);
1271          prints("发送完成,新文章通常会在%d秒后可见", BBS_section_list_load_interval);          prints("鍙戦佸畬鎴愶紝鏂版枃绔犻氬父浼氬湪%d绉掑悗鍙", BBS_section_list_load_interval);
1272          press_any_key();          press_any_key();
1273          ret = 1; // Success          ret = 1; // Success
1274    


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

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