-
Notifications
You must be signed in to change notification settings - Fork 2
/
chs-wiki
546 lines (546 loc) · 7.21 KB
/
chs-wiki
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#!/system/bin/sh
hos="/sdcard/ba"
whk="$hos/wiki"
err="echo 错误!"
fgx="============"
inc="echo 输入数字或指令:"
[ -e "$hos/" ]&&echo '欢迎使用MaBBS&WIKI'||{
echo 安装中...
mkdir -p "$hos/main" "$hos/user" "$whk"
touch "$hos/ai"
echo 管理员名称:SYSOP
echo 密码:
read mnp
smk="$hos/user/SYSOP"
mkdir -p "$smk/diary" "$smk/mail"
echo "$mnp">>$smk/pwd
}
wblg(){
clear
echo 登录:
read ua
echo 密码:
read pa
[ "$ua" = "" ]&&np=0||{
[ -e "$hos/user/$ua" ]&&np="`cat "$hos/user/$ua/pwd"`ck"
}
[ "${pa}ck" == "$np" ]&&{
na="$ua"
usv="$hos/user/$na"
}||{
$err
echo 加入我们?[Y/N]:
read ju
case $ju in
Y|y)
echo 请输入用户名:
read nep
echo 密码:
read npd
chk="`ls "$hos/user" | grep "$nep"`"
[ "$chk" == "$nep" -o "$nep" = "" ]||{
echo 验证码:
vv="`cat /proc/sys/kernel/random/uuid`"
vv="${vv%%-*}"
echo $vv
read vc
[ "$vc" == "$vv" ]&&{
usk="$hos/user/$nep"
mkdir -p "$usk/diary" "$usk/mail"
echo $npd>>$usk/pwd
na="$nep"
usv="$hos/user/$na"
}
}
;;
esac
}
}
fid(){
while true
do
clear
cat "$rmk"
echo 按回车返回
[ "$na" == "guest" ]&&{
read nul
break 1
}||{
echo 输入 e 插入新段落
echo 输入 c 继续写
read pd
case $pd in
e)
clear
echo 标题:
read tt
echo 内容:
read nwd
echo >>$rmk
echo $tt >>$rmk
echo -------- >>$rmk
echo $nwd >>$rmk
;;
c)
echo 文字:
read nw
echo $nw >>$rmk
;;
*)
break 1
;;
esac
}
done
}
zxth(){
while true
do
clear
cat "$wbb"
echo '输入回复(输入 e 返回):'
read ry
if [ "$ry" == "e" ]
then
break 1
elif [ "$ry" == "" ]
then
echo 刷新...
else
[ "$na" == "guest" ]&&wblg||{
echo $na `date` >>$wbb
echo $ry >>$wbb
echo >>$wbb
}
fi
done
}
pxcx(){
while read nr
do
co=$(($co+1))
[ "$sel" -le "$co" -a "$(($sel+10))" -ge "$co" ]&&echo $co.$nr
done
}
chse(){
[ "$na" == "guest" ]&&wblg||{
vck="`cat "$wbb/opt/$1" | grep "$na"`"
[ "$na" == "$vck" ]||{
echo $na >> "$wbb/opt/$1"
clear
cat "$wbb/opt/$1"
echo 选择了这个.
sleep 3
}
}
}
pdg(){
wbn=""
co="0"
ls "$1"|while read nr
do
co=$(($co+1))
[ "$int" == "$co" ]&&echo "$nr"
done
}
cc(){
for lop in `ls "$wbb/opt/"`
do
echo $lop.$1 \(`cat "$wbb/opt/$lop" | wc -l`\)
shift
done
}
na="guest"
sleep 1
while true
do
clear
echo MaWiki 用户:$na
echo 总条目:`ls "$whk" | wc -l`
echo $fgx
echo 1.搜索
echo 2.退出
echo 3.前往MaBBS
echo 4.随机
[ "$na" == "guest" ]&&echo 5.登录||{
echo 5.创建新条目
echo 6.日记
echo 7.重置密码
}
echo 请输入指令:
read cmd
case $cmd in
1)
clear
echo 输入关键词或标签:
read kw
[ "$kw" == "" ]||{
clear
echo 结果
echo $fgx
ls "$whk" | grep "$kw" | while read jg
do
echo ${jg%%+*}
done
echo 选择一个:
read mtt
[ "$mtt" == "" ]||{
tkw=`ls "$whk" | grep "$mtt"`
[ "$tkw" == "" ]||{
[ -e "$whk/$tkw" ]&&{
rmk="$whk/$tkw"
fid
}
}
}
}
;;
2)
echo 再见
break
;;
3)
while true
do
clear
echo 欢迎,$na
date
[ -e "$hos/bul" ]&&echo 公告:`cat "$hos/bul"`
echo $fgx
co=0
ls "$hos/main" | while read bm
do
co=$(($co+1))
echo $co.$bm \(`ls "$hos/main/$bm/" | wc -l `\)
done
echo $fgx
echo a.邮箱
echo b.返回到MaWiki
[ "$na" == "SYSOP" ]&&{
echo c.创建板块
echo d.删除板块
echo e.更新公告
}
$inc
read pac
[ "$pac" == "" ]&&pac="#"
case $pac in
a)
[ "$na" == "guest" ]&&wblg||{
sel=0
while true
do
clear
echo 邮箱
echo $fgx
co="0"
ls "$usv/mail" | pxcx
echo $fgx
echo a.发送邮件
echo b.返回
[ `ls "$usv/mail" | wc -l ` -ge 10 ]&&echo c.下一页
$inc
read int
case $int in
a)
clear
echo 来自:$na
echo 到:
read st
[ "$st" == "" ]||{
[ "$st" == "AI" ]&&
{
echo 文字:
read swd
[ "$swd" == "学习" ]&&{
echo 你说:
read ys
echo AI 回答:
read as
echo $ys-$as >>${hos}/ai
}
ais="`grep "$swd" "$hos/ai"`"
ais=${ais#*-}
[ "$swd" == "" -o "$ais" == "" ]&&ais="抱歉,我不知道你说什么"
echo Talk AI >>$usv/mail/Talk_AI
date >>$usv/mail/Talk_AI
echo $ais >>$usv/mail/Talk_AI
echo >>$usv/mail/Talk_AI
}
[ -e "$hos/user/$st" ]&&{
echo $fgx
echo 主题:
read swd
isw="$hos/user/$st/mail/$swd"
[ "$swd" == "" -o -e "$isw" ]||{
echo 内容:
read iwd
echo 来自:$na>>$isw
echo 到:$st>>$isw
date>>$isw
echo $fgx>>$isw
echo $iwd >>$isw
echo OK!
}
}
}
sleep 1
;;
b)
break 1
;;
c)
[ `ls "$usv/mail" | wc -l` -ge 10 ]&&sel="$(($sel+10))"
;;
*)
clear
wbn="`pdg "$usv/mail"`"
[ "$wbn" == "" ]||{
cat "$usv/mail/$wbn"
echo 按回车返回
echo 输入 d 删除
read nul
[ "$nul" == "d" ]&&rm -rf "$usv/mail/$wbn"
}
;;
esac
done
}
;;
b)
break
;;
c)
clear
[ "$na" == "SYSOP" ]&&{
echo 板块名:
read npn
mkdir "$hos/main/$npn"
}
;;
d)
[ "$na" == "SYSOP" ]&&{
echo 板块名:
read dpw
rm -rf "$hos/main/$dpw"
}
;;
e)
[ "$na" == "SYSOP" ]&&{
clear
echo 输入公告:
read bul
echo "$bul" > $hos/bul
}
;;
*)
int="$pac"
pac="`pdg "$hos/main"`"
[ "$pac" == "" ]||{
sel="0"
while true
do
pcz="$hos/main/$pac"
clear
echo 欢迎,$na 板块:$pac
echo $fgx
co="0"
ls "$pcz" | pxcx
echo $fgx
echo a.发帖
echo b.返回
[ `ls "$pcz" | wc -l ` -ge 10 ]&&echo c.下一页
[ "$na" == "SYSOP" ]&&echo d.删帖
$inc
read int
case $int in
a)
[ "$na" == "guest" ]&&wblg||{
clear
echo '这是一个 [1.帖子 2.投票]:'
read cht
case $cht in
1)
clear
echo 输入标题:
read tit
[ "`ls "$pcz" | grep "$tit"`" == "" ]&&{
echo 内容:
read wod
stt="$pcz/$tit"
echo $tit >>$stt
echo $fgx >>$stt
echo 楼主:$na `date` >>$stt
echo $wod >>$stt
echo >>$stt
}
;;
2)
clear
echo 输入标题:
read tit
[ "`ls "$pcz" | grep "$tit"`" == "" ]&&{
echo 信息:
read wod
echo "选项头:"
read oph
echo "选项:"
read opt
echo '使用讨论?[Y/N]:'
read utk
tsm="$pcz/$tit"
mkdir "$tsm"
echo $tit >>$tsm/main
echo $fgx >>$tsm/main
echo 楼主:$na `date` >>$tsm/main
echo $wod >>$tsm/main
echo $opt>>$tsm/data
mkdir "$tsm/opt"
for sle in $oph
do
touch "$tsm/opt/$sle"
done
[ "$utk" == "y" ]&&{
echo 讨论>>"$tsm/talk"
echo $fgx >>"$tsm/talk"
}
}
;;
esac
}
;;
b)
break 1
;;
c)
[ `ls "$pcz" | wc -l ` -ge 10 ]&&sel="$(($sel+10))"
;;
d)
[ "$na" == "SYSOP" ]&&{
echo 帖子名:
read tdw
rm -rf "$pcz/$tdw"
}
;;
*)
wbn="`pdg "$pcz"`"
[ "$wbn" == "" ]||{
wbb="$pcz/$wbn"
[ -f "$wbb" ]&&zxth||{
clear
cat "$wbb/main"
echo $fgx
cc `cat "$wbb/data"`
[ -e "$wbb/talk" ]&&echo 输入 t 讨论,或
echo '选择一个:'
read ry
[ "$ry" == "" ]||{
[ "$ry" == "t" ]&&{
[ -e "$wbb/talk" ]&&{
wbb="$wbb/talk"
zxth
}
}||{
[ -e "$wbb/opt/$ry" ]&&chse $ry
}
}
}
}
;;
esac
done
}
;;
esac
done
;;
5)
[ "$na" == "guest" ]&&wblg||{
clear
echo 主标题:
read mt
[ "`ls "$whk" | grep "$mt"`" == "" ]&&{
echo 标签:
read tgs
echo 内容:
read wd
mwt="$whk/$mt+$tgs"
echo $mt>>$mwt
echo 创建于:$na `date`>>$mwt
echo 标签:$tgs>>$mwt
echo $fgx >>$mwt
echo $wd >>$mwt
rmk="$whk/$mt+$tgs"
fid
}
}
;;
4)
jld="`ls "$whk" | wc -l`"
[ "$jld" == "0" ]&&{
echo 找不到...
sleep 1
}||{
int=$((`date +%s`%$jld+1))
rmk="$whk/`pdg "$whk"`"
fid
}
;;
6)
[ "$na" == "guest" ]&&wblg||{
cfd="$usv/diary"
sel="0"
while true
do
clear
echo 欢迎,$na
echo $fgx
co="0"
ls "$cfd" | pxcx
echo $fgx
echo a.写日记
echo b.返回
[ `ls "$cfd" | wc -l ` -ge 10 ]&&echo c.下一页
$inc
read int
case $int in
a)
clear
mt="`date +%y.%m.%d`"
[ "`ls "$cfd" | grep "$mt"`" == "" ]&&{
echo 内容:
read wd
mwt="$cfd/$mt"
echo 日记:$mt>>$mwt
echo $wd >>$mwt
}
rmk="$cfd/$mt"
fid
;;
b)
break 1
;;
c)
[ `ls "$cfd" | wc -l ` -ge 10 ]&&sel="$(($sel+10))"
;;
*)
wbn="`pdg "$cfd"`"
[ "$wbn" == "" ]||{
rmk="$cfd/$wbn"
fid
}
;;
esac
done
}
;;
7)
[ "$na" == "guest" ]&&wblg||{
clear
echo 输入新密码:
read nrd
[ "$nrd" == "" ]||echo $nrd>$usv/pwd
}
;;
esac
done