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


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

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