| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
|
#include "section_list_display.h" |
|
|
#include "section_list_loader.h" |
|
| 17 |
#include "article_cache.h" |
#include "article_cache.h" |
| 18 |
#include "article_post.h" |
#include "article_post.h" |
| 19 |
|
#include "article_view_log.h" |
| 20 |
#include "article_del.h" |
#include "article_del.h" |
| 21 |
#include "common.h" |
#include "common.h" |
| 22 |
#include "io.h" |
#include "io.h" |
|
#include "screen.h" |
|
| 23 |
#include "log.h" |
#include "log.h" |
| 24 |
#include "user_priv.h" |
#include "login.h" |
| 25 |
#include "article_view_log.h" |
#include "section_list_display.h" |
| 26 |
|
#include "section_list_loader.h" |
| 27 |
|
#include "screen.h" |
| 28 |
#include "str_process.h" |
#include "str_process.h" |
| 29 |
|
#include "user_priv.h" |
| 30 |
#include <string.h> |
#include <string.h> |
| 31 |
#include <time.h> |
#include <time.h> |
| 32 |
#include <sys/param.h> |
#include <sys/param.h> |
| 81 |
} |
} |
| 82 |
} |
} |
| 83 |
|
|
|
article_flag = (is_viewed ? ' ' : 'N'); |
|
|
|
|
| 84 |
if (p_articles[i]->excerption) |
if (p_articles[i]->excerption) |
| 85 |
{ |
{ |
| 86 |
article_flag = (is_viewed ? 'm' : 'M'); |
article_flag = (is_viewed ? 'm' : 'M'); |
| 89 |
{ |
{ |
| 90 |
article_flag = 'x'; |
article_flag = 'x'; |
| 91 |
} |
} |
| 92 |
|
else |
| 93 |
|
{ |
| 94 |
|
article_flag = (is_viewed ? ' ' : 'N'); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
localtime_r(&p_articles[i]->sub_dt, &tm_sub); |
localtime_r(&p_articles[i]->sub_dt, &tm_sub); |
| 98 |
if (tm_now - p_articles[i]->sub_dt < 3600 * 24 * 365) |
if (tm_now - p_articles[i]->sub_dt < 3600 * 24 * 365) |
| 116 |
|
|
| 117 |
moveto(4 + i, 1); |
moveto(4 + i, 1); |
| 118 |
prints(" %s%7d\033[m %c %s%*s %s %s%s\033[m", |
prints(" %s%7d\033[m %c %s%*s %s %s%s\033[m", |
| 119 |
(p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")), |
(p_articles[i]->ontop |
| 120 |
|
? "\033[47;30m" |
| 121 |
|
: (p_articles[i]->aid == section_topic_view_tid |
| 122 |
|
? "\033[1;33m" |
| 123 |
|
: (p_articles[i]->tid == section_topic_view_tid |
| 124 |
|
? "\033[1;36m" |
| 125 |
|
: ""))), |
| 126 |
p_articles[i]->aid, |
p_articles[i]->aid, |
| 127 |
article_flag, |
article_flag, |
| 128 |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
| 130 |
: BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))), |
: BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))), |
| 131 |
"", |
"", |
| 132 |
str_time, |
str_time, |
| 133 |
(p_articles[i]->aid == section_topic_view_tid ? "\033[1;33m" : (p_articles[i]->tid == section_topic_view_tid ? "\033[1;36m" : "")), |
(p_articles[i]->aid == section_topic_view_tid |
| 134 |
|
? "\033[1;33m" |
| 135 |
|
: (p_articles[i]->tid == section_topic_view_tid |
| 136 |
|
? "\033[1;36m" |
| 137 |
|
: "")), |
| 138 |
title_f); |
title_f); |
| 139 |
} |
} |
| 140 |
|
|
| 479 |
show_bottom(page_info_str); |
show_bottom(page_info_str); |
| 480 |
iflush(); |
iflush(); |
| 481 |
|
|
| 482 |
|
if (user_online_update(sname) < 0) |
| 483 |
|
{ |
| 484 |
|
log_error("user_online_update(%s) error\n", sname); |
| 485 |
|
} |
| 486 |
|
|
| 487 |
ret = section_list_select(page_count, article_count, &page_id, &selected_index); |
ret = section_list_select(page_count, article_count, &page_id, &selected_index); |
| 488 |
switch (ret) |
switch (ret) |
| 489 |
{ |
{ |
| 516 |
break; |
break; |
| 517 |
} |
} |
| 518 |
|
|
| 519 |
|
if (user_online_update("VIEW_ARTICLE") < 0) |
| 520 |
|
{ |
| 521 |
|
log_error("user_online_update(VIEW_ARTICLE) error\n"); |
| 522 |
|
} |
| 523 |
|
|
| 524 |
ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0, |
ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0, |
| 525 |
display_article_key_handler, DATA_READ_HELP); |
display_article_key_handler, DATA_READ_HELP); |
| 526 |
|
|
| 623 |
} |
} |
| 624 |
break; |
break; |
| 625 |
case 'r': // Reply article |
case 'r': // Reply article |
| 626 |
|
if (user_online_update("REPLY_ARTICLE") < 0) |
| 627 |
|
{ |
| 628 |
|
log_error("user_online_update(REPLY_ARTICLE) error\n"); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
if (article_reply(p_section, p_articles[selected_index], &article_new) < 0) |
if (article_reply(p_section, p_articles[selected_index], &article_new) < 0) |
| 632 |
{ |
{ |
| 633 |
log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid); |
log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid); |
| 634 |
} |
} |
| 635 |
loop = 1; |
loop = 1; |
| 636 |
break; |
break; |
| 665 |
|
|
| 666 |
// Update current topic |
// Update current topic |
| 667 |
section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid); |
section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid); |
| 668 |
|
|
| 669 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 670 |
|
{ |
| 671 |
|
log_error("section_list_draw_screen() error\n"); |
| 672 |
|
return -2; |
| 673 |
|
} |
| 674 |
|
break; |
| 675 |
case CHANGE_NAME_DISPLAY: |
case CHANGE_NAME_DISPLAY: |
| 676 |
display_nickname = !display_nickname; |
display_nickname = !display_nickname; |
| 677 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 681 |
} |
} |
| 682 |
break; |
break; |
| 683 |
case POST_ARTICLE: |
case POST_ARTICLE: |
| 684 |
|
if (user_online_update("POST_ARTICLE") < 0) |
| 685 |
|
{ |
| 686 |
|
log_error("user_online_update(POST_ARTICLE) error\n"); |
| 687 |
|
} |
| 688 |
|
|
| 689 |
if ((ret = article_post(p_section, &article_new)) < 0) |
if ((ret = article_post(p_section, &article_new)) < 0) |
| 690 |
{ |
{ |
| 691 |
log_error("article_post(sid=%d) error\n", p_section->sid); |
log_error("article_post(sid=%d) error\n", p_section->sid); |
| 711 |
{ |
{ |
| 712 |
break; // No permission |
break; // No permission |
| 713 |
} |
} |
| 714 |
|
|
| 715 |
|
if (user_online_update("EDIT_ARTICLE") < 0) |
| 716 |
|
{ |
| 717 |
|
log_error("user_online_update() error\n"); |
| 718 |
|
} |
| 719 |
|
|
| 720 |
if (article_modify(p_section, p_articles[selected_index], &article_new) < 0) |
if (article_modify(p_section, p_articles[selected_index], &article_new) < 0) |
| 721 |
{ |
{ |
| 722 |
log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid); |
log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid); |