summaryrefslogtreecommitdiffstats
path: root/mbbsd/xyz.c
blob: fb48c846e56d3e7db996c7bae7689865227a3426 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
/* $Id$ */
#include "bbs.h"

#if 0
/* 各種統計及相關資訊列表 */
/* Ptt90年度大學聯招查榜系統  */
int
x_90(void)
{
    use_dict("(90)准考證號/姓名/學校/科系/類組", "etc/90");
    return 0;
}

/* Ptt89年度大學聯招查榜系統  */
int
x_89(void)
{
    use_dict("(89)准考證號/姓名/學校/科系/類組", "etc/89");
    return 0;
}
/* Ptt88年度大學聯招查榜系統  */
int
x_88(void)
{
    use_dict("(88)准考證號/姓名/學校/科系/類組", "etc/88");
    return 0;
}
/* Ptt87年度大學聯招查榜系統  */
int
x_87(void)
{
    use_dict("(87)准考證號/姓名/學校/科系", "etc/87");
    return 0;
}

/* Ptt86年度大學聯招查榜系統  */
int
x_86(void)
{
    use_dict("(86)准考證號/姓名/學校/科系", "etc/86");
    return 0;
}

#endif
int
x_boardman(void)
{
    more("etc/topboardman", YEA);
    return 0;
}

int
x_user100(void)
{
    more("etc/topusr100", YEA);
    return 0;
}

int
x_history(void)
{
    more("etc/history", YEA);
    return 0;
}

#ifdef HAVE_X_BOARDS
static int
x_boards(void)
{
    more("etc/topboard.tmp", YEA);
    return 0;
}
#endif

int
x_birth(void)
{
    more("etc/birth.today", YEA);
    return 0;
}

int
x_weather(void)
{
    more("etc/weather.tmp", YEA);
    return 0;
}

int
x_mrtmap(void)
{
    more("etc/MRT.map", YEA);
    return 0;
}

int
x_stock(void)
{
    more("etc/stock.tmp", YEA);
    return 0;
}

int
x_note(void)
{
    more(fn_note_ans, YEA);
    return 0;
}

int
x_issue(void)
{
    more("etc/day", YEA);
    return 0;
}

int
x_week(void)
{
    more("etc/week", YEA);
    return 0;
}

int
x_today(void)
{
    more("etc/today", YEA);
    return 0;
}

int
x_yesterday(void)
{
    more("etc/yesterday", YEA);
    return 0;
}

int
x_login(void)
{
    more("etc/Welcome_login.0", YEA);
    return 0;
}

#ifdef HAVE_INFO
static int
x_program(void)
{
    more("etc/version", YEA);
    return 0;
}
#endif

#ifdef HAVE_LICENSE
static int
x_gpl(void)
{
    more("etc/GPL", YEA);
    return 0;
}
#endif

int
note(void)
{
    char    *fn_note_tmp = "note.tmp";
    char    *fn_note_dat = "note.dat";
    int             total = 0, i, collect, len;
    struct stat     st;
    char            buf[256], buf2[80];
    int             fd, fx;
    FILE           *fp, *foo;

    typedef struct notedata_t {
    time4_t         date;
    char            userid[IDLEN + 1];
    char            nickname[19];
    char            buf[3][80];
    }               notedata_t;
    notedata_t      myitem;

    if (cuser.money < 5) {
    vmsg(ANSI_COLOR(1;41) " 哎呀! 要投五銀才能留言...沒錢耶.." ANSI_RESET);
    return 0;
    }
    setutmpmode(EDNOTE);
    do {
    myitem.buf[0][0] = myitem.buf[1][0] = myitem.buf[2][0] = '\0';
    move(12, 0);
    clrtobot();
    outs("\n投五銀... 嗶... 請留言 (至多三行),按[Enter]結束");
    for (i = 0; (i < 3) && getdata(16 + i, 0, ":", myitem.buf[i],
                       sizeof(myitem.buf[i]) - 5, DOECHO)
         && *myitem.buf[i]; i++);
    getdata(b_lines - 1, 0, "(S)儲存 (E)重新來過 (Q)取消?[S] ",
        buf, 3, LCECHO);

    if (buf[0] == 'q' || (i == 0 && *buf != 'e'))
        return 0;
    } while (buf[0] == 'e');
    demoney(-5);
    strcpy(myitem.userid, cuser.userid);
    strncpy(myitem.nickname, cuser.nickname, 18);
    myitem.nickname[18] = '\0';
    myitem.date = now;

    /* begin load file */
    if ((foo = fopen(".note", "a")) == NULL)
    return 0;

    if ((fp = fopen(fn_note_ans, "w")) == NULL) {
    fclose(fp);
    return 0;
    }

    if ((fx = open(fn_note_tmp, O_WRONLY | O_CREAT, 0644)) <= 0) {
    fclose(foo);
    fclose(fp);
    return 0;
    }

    if ((fd = open(fn_note_dat, O_RDONLY)) == -1)
    total = 1;
    else if (fstat(fd, &st) != -1) {
    total = st.st_size / sizeof(notedata_t) + 1;
    if (total > MAX_NOTE)
        total = MAX_NOTE;
    }
    fputs(ANSI_COLOR(1;31;44) "⊙┬──────────────┤"
      ANSI_COLOR(37) "酸甜苦辣板" ANSI_COLOR(31) "├──────────────┬⊙"
      ANSI_RESET "\n", fp);
    collect = 1;

    while (total) {
    snprintf(buf, sizeof(buf), ANSI_COLOR(1;31) "╔┤" ANSI_COLOR(32) " %s " ANSI_COLOR(37) "(%s)",
        myitem.userid, myitem.nickname);
    len = strlen(buf);

    for (i = len; i < 71; i++)
        strcat(buf, " ");
    snprintf(buf2, sizeof(buf2), " " ANSI_COLOR(1;36) "%.16s" ANSI_COLOR(31) "   ├╗" ANSI_RESET "\n",
        Cdate(&(myitem.date)));
    strcat(buf, buf2);
    fputs(buf, fp);
    if (collect)
        fputs(buf, foo);
    for (i = 0; i < 3 && *myitem.buf[i]; i++) {
        fprintf(fp, ANSI_COLOR(1;31) "│" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "│" ANSI_RESET "\n",
            myitem.buf[i]);
        if (collect)
        fprintf(foo, ANSI_COLOR(1;31) "│" ANSI_RESET "%-74.74s" ANSI_COLOR(1;31) "│" ANSI_RESET "\n",
            myitem.buf[i]);
    }
    fputs(ANSI_COLOR(1;31) "╚┬───────────────────────"
          "────────────┬╝" ANSI_RESET "\n", fp);

    if (collect) {
        fputs(ANSI_COLOR(1;31) "╚┬─────────────────────"
          "──────────────┬╝" ANSI_RESET "\n", foo);
        fclose(foo);
        collect = 0;
    }
    write(fx, &myitem, sizeof(myitem));

    if (--total)
        read(fd, (char *)&myitem, sizeof(myitem));
    }
    fputs(ANSI_COLOR(1;31;44) "⊙┴───────────────────────"
      "────────────┴⊙" ANSI_RESET "\n", fp);
    fclose(fp);
    close(fd);
    close(fx);
    Rename(fn_note_tmp, fn_note_dat);
    more(fn_note_ans, YEA);
    return 0;
}

static void
mail_sysop(void)
{
    FILE           *fp;
    char            genbuf[200];

    if ((fp = fopen("etc/sysop", "r"))) {
    int             i, j;
    char           *ptr;

    typedef struct sysoplist_t {
        char            userid[IDLEN + 1];
        char            duty[40];
    }               sysoplist_t;
    sysoplist_t     sysoplist[9];

    j = 0;
    while (fgets(genbuf, 128, fp)) {
        if ((ptr = strchr(genbuf, '\n'))) {
        *ptr = '\0';
        if ((ptr = strchr(genbuf, ':'))) {
            *ptr = '\0';
            do {
            i = *++ptr;
            } while (i == ' ' || i == '\t');
            if (i) {
            strcpy(sysoplist[j].userid, genbuf);
            strcpy(sysoplist[j++].duty, ptr);
            }
        }
        }
    }
    fclose(fp);

    move(12, 0);
    clrtobot();
    outs("            編號   站長 ID           權責劃分\n\n");

    for (i = 0; i < j; i++)
        prints("%15d.   " ANSI_COLOR(1;%d) "%-16s%s" ANSI_COLOR(0) "\n",
         i + 1, 31 + i % 7, sysoplist[i].userid, sysoplist[i].duty);
    prints("%-14s0.   " ANSI_COLOR(1;%d) "離開" ANSI_COLOR(0) "", "", 31 + j % 7);
    getdata(b_lines - 1, 0, "                   請輸入代碼[0]:",
        genbuf, 4, DOECHO);
    i = genbuf[0] - '0' - 1;
    if (i >= 0 && i < j) {
        clear();
        do_send(sysoplist[i].userid, NULL);
    }
    }
}

int
m_sysop(void)
{
    setutmpmode(MSYSOP);
    mail_sysop();
    return 0;
}

int
Goodbye(void)
{
    char            genbuf[100];

    getdata(b_lines - 1, 0, "您確定要離開【 " BBSNAME " 】嗎(Y/N)?[N] ",
        genbuf, 3, LCECHO);

    if (*genbuf != 'y')
    return 0;

    movie(999);
    if (cuser.userlevel) {
    getdata(b_lines - 1, 0,
        "(G)隨風而逝 (M)托夢站長 (N)酸甜苦辣流言板?[G] ",
        genbuf, 3, LCECHO);
    if (genbuf[0] == 'm')
        mail_sysop();
    else if (genbuf[0] == 'n')
        note();
    }
    clear();


    more("etc/Logout", NA);

    {
    int diff = (now - login_start_time) / 60;
    sprintf(genbuf, "此次停留時間: %d 小時 %2d 分",
        diff / 60, diff % 60);
    }
    if(!(cuser.userlevel & PERM_LOGINOK))
    vmsg("尚未完成註冊。如要提昇權限請參考本站公佈欄辦理註冊");
    else
    vmsg(genbuf);
    // pressanykey();

    u_exit("EXIT ");
    return QUIT;
}