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

Diff of /lbbs/src/section_list_display.c

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

Revision 1.63 by sysadm, Mon Nov 3 02:32:11 2025 UTC Revision 1.65 by sysadm, Mon Nov 3 06:45:18 2025 UTC
# Line 33  Line 33 
33  #include "user_info_display.h"  #include "user_info_display.h"
34  #include "user_list_display.h"  #include "user_list_display.h"
35  #include "user_priv.h"  #include "user_priv.h"
36    #include <ctype.h>
37  #include <errno.h>  #include <errno.h>
38  #include <string.h>  #include <string.h>
39  #include <time.h>  #include <time.h>
# Line 59  enum select_cmd_t Line 60  enum select_cmd_t
60          FIRST_TOPIC_ARTICLE,          FIRST_TOPIC_ARTICLE,
61          LAST_TOPIC_ARTICLE,          LAST_TOPIC_ARTICLE,
62          SCAN_NEW_ARTICLE,          SCAN_NEW_ARTICLE,
63            SCAN_ARTICLE_BACKWARD_BY_USER,
64            SCAN_ARTICLE_FORWARD_BY_USER,
65          VIEW_EX_DIR,          VIEW_EX_DIR,
66          SHOW_TOP10,          SHOW_TOP10,
67          SEARCH_USER,          SEARCH_USER,
# Line 409  static enum select_cmd_t section_list_se Line 412  static enum select_cmd_t section_list_se
412                                  return SCAN_NEW_ARTICLE;                                  return SCAN_NEW_ARTICLE;
413                          }                          }
414                          break;                          break;
415                    case 'A':
416                            if (item_count > 0)
417                            {
418                                    return SCAN_ARTICLE_BACKWARD_BY_USER;
419                            }
420                            break;
421                    case 'a':
422                            if (item_count > 0)
423                            {
424                                    return SCAN_ARTICLE_FORWARD_BY_USER;
425                            }
426                            break;
427                  case 'u':                  case 'u':
428                          return SEARCH_USER;                          return SEARCH_USER;
429                  case 'h':                  case 'h':
# Line 564  int section_list_display(const char *sna Line 579  int section_list_display(const char *sna
579          const ARTICLE *p_article_locate;          const ARTICLE *p_article_locate;
580          USER_INFO user_info;          USER_INFO user_info;
581          char user_intro[BBS_user_intro_max_len];          char user_intro[BBS_user_intro_max_len];
582            char username[BBS_username_max_len + 1];
583            char username_list[1][BBS_username_max_len + 1];
584            int32_t uid;
585            int i;
586            int ok;
587    
588          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
589          if (p_section == NULL)          if (p_section == NULL)
# Line 1036  int section_list_display(const char *sna Line 1056  int section_list_display(const char *sna
1056                          page_id_cur = page_id;                          page_id_cur = page_id;
1057                          ret = locate_article_in_section(p_section, p_article_locate, 0, 0,                          ret = locate_article_in_section(p_section, p_article_locate, 0, 0,
1058                                                                                          &page_id, &selected_index, &article_count);                                                                                          &page_id, &selected_index, &article_count);
1059                            if (ret < 0)
1060                            {
1061                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
1062                                                      p_section->sid, p_article_locate->aid);
1063                                    return -3;
1064                            }
1065                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
1066                            {
1067                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1068                                    if (ret < 0)
1069                                    {
1070                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
1071                                            return -3;
1072                                    }
1073                            }
1074                            break;
1075                    case SCAN_ARTICLE_BACKWARD_BY_USER:
1076                    case SCAN_ARTICLE_FORWARD_BY_USER:
1077                            direction = (ret == SCAN_ARTICLE_FORWARD_BY_USER ? 1 : -1);
1078                            strncpy(username, p_articles[selected_index]->username, sizeof(username) - 1);
1079                            username[sizeof(username) - 1] = '\0';
1080                            uid = 0;
1081    
1082                            moveto(SCREEN_ROWS, 1);
1083                            clrtoeol();
1084                            get_data(SCREEN_ROWS, 1,
1085                                             (direction == 1 ? "向下搜寻作者: " : "向上搜寻作者: "),
1086                                             username, sizeof(username), BBS_username_max_len);
1087    
1088                            if (username[0] == '\0')
1089                            {
1090                                    break;
1091                            }
1092    
1093                            // Verify format
1094                            for (i = 0, ok = 1; ok && username[i] != '\0'; i++)
1095                            {
1096                                    if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_'))))
1097                                    {
1098                                            ok = 0;
1099                                    }
1100                            }
1101                            if (ok && i > BBS_username_max_len)
1102                            {
1103                                    ok = 0;
1104                            }
1105                            if (!ok)
1106                            {
1107                                    break;
1108                            }
1109    
1110                            ret = query_user_info_by_username(username, 1, &uid, username_list);
1111                            if (ret < 0)
1112                            {
1113                                    log_error("query_user_info_by_username(%s) error\n", username);
1114                                    break;
1115                            }
1116    
1117                            if (uid > 0)
1118                            {
1119                                    ret = scan_article_in_section_by_uid(p_section, p_articles[selected_index],
1120                                                                                                             direction, uid, &p_article_locate);
1121                                    if (ret < 0)
1122                                    {
1123                                            log_error("scan_article_in_section_by_uid(sid=%d, aid=%d, direction=%d, uid=%d) error\n",
1124                                                              p_section->sid, p_articles[selected_index]->aid, direction, uid);
1125                                            return -3;
1126                                    }
1127                                    else if (ret == 0) // not found
1128                                    {
1129                                            break;
1130                                    }
1131                            }
1132                            else // uid == 0
1133                            {
1134                                    ret = scan_article_in_section_by_username(p_section, p_articles[selected_index],
1135                                                                                                                      direction, username, &p_article_locate);
1136                                    if (ret < 0)
1137                                    {
1138                                            log_error("scan_article_in_section_by_username(sid=%d, aid=%d, direction=%d, username=%s) error\n",
1139                                                              p_section->sid, p_articles[selected_index]->aid, direction, username);
1140                                            return -3;
1141                                    }
1142                                    else if (ret == 0) // not found
1143                                    {
1144                                            break;
1145                                    }
1146                            }
1147    
1148                            page_id_cur = page_id;
1149                            ret = locate_article_in_section(p_section, p_article_locate, 0, 0,
1150                                                                                            &page_id, &selected_index, &article_count);
1151                          if (ret < 0)                          if (ret < 0)
1152                          {                          {
1153                                  log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",                                  log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",


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

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