-
Notifications
You must be signed in to change notification settings - Fork 0
/
lawebmanagement.php
executable file
·7587 lines (6901 loc) · 398 KB
/
lawebmanagement.php
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
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Send email class using SMTP Authentication
*
* @class Email
* @package Snipworks\SMTP
*/
class Email
{
const CRLF = "\r\n";
const TLS = 'tcp';
const SSL = 'ssl';
const OK = 250;
protected $server;
protected $hostname;
protected $port;
protected $socket;
protected $username;
protected $password;
protected $connectionTimeout;
protected $responseTimeout;
protected $subject;
protected $to = array();
protected $cc = array();
protected $bcc = array();
protected $from = array();
protected $replyTo = array();
protected $attachments = array();
protected $protocol = null;
protected $textMessage = null;
protected $htmlMessage = null;
protected $isHTML = false;
protected $isTLS = false;
protected $logs = array();
protected $charset = 'utf-8';
protected $headers = array();
protected $result;
public function getSendResult(){
return $this->result;
}
public function __construct($server, $port = 25, $connectionTimeout = 30, $responseTimeout = 8, $hostname = null)
{
$this->port = $port;
$this->server = $server;
$this->connectionTimeout = $connectionTimeout;
$this->responseTimeout = $responseTimeout;
$this->hostname = empty($hostname) ? gethostname() : $hostname;
$this->headers['X-Mailer'] = 'PHP/' . phpversion();
$this->headers['MIME-Version'] = '1.0';
}
public function addTo($address, $name = null)
{
$this->to[] = array($address, $name);
return $this;
}
public function addCc($address, $name = null)
{
$this->cc[] = array($address, $name);
return $this;
}
public function addBcc($address, $name = null)
{
$this->bcc[] = array($address, $name);
return $this;
}
public function addReplyTo($address, $name = null)
{
$this->replyTo[] = array($address, $name);
return $this;
}
public function addAttachment($attachment)
{
if (file_exists($attachment)) {
$this->attachments[] = $attachment;
}
return $this;
}
public function setLogin($username, $password)
{
$this->username = $username;
$this->password = $password;
return $this;
}
public function setCharset($charset)
{
$this->charset = $charset;
return $this;
}
public function setProtocol($protocol = null)
{
if ($protocol === self::TLS) {
$this->isTLS = true;
}
$this->protocol = $protocol;
return $this;
}
public function setFrom($address, $name = null)
{
$this->from = array($address, $name);
return $this;
}
public function setSubject($subject)
{
$this->subject = $subject;
return $this;
}
public function setTextMessage($message)
{
$this->textMessage = $message;
return $this;
}
public function setHtmlMessage($message)
{
$this->htmlMessage = $message;
return $this;
}
public function getLogs()
{
return $this->logs;
}
public function send($wait_timeout)
{
$message = NULL;
$this->socket = fsockopen(
$this->getServer(),
$this->port,
$errorNumber,
$errorMessage,
$this->connectionTimeout
);
if (empty($this->socket)) {
return false;
}
$this->logs['CONNECTION'] = $this->getResponse();
$this->logs['HELLO'][1] = $this->sendCommand('EHLO ' . $this->hostname);
if ($this->isTLS) {
$this->logs['STARTTLS'] = $this->sendCommand('STARTTLS');
stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
$this->logs['HELLO'][2] = $this->sendCommand('EHLO ' . $this->hostname);
}
$this->logs['AUTH'] = $this->sendCommand('AUTH LOGIN');
$this->logs['USERNAME'] = $this->sendCommand(base64_encode($this->username));
$this->logs['PASSWORD'] = $this->sendCommand(base64_encode($this->password));
$this->logs['MAIL_FROM'] = $this->sendCommand('MAIL FROM: <' . $this->from[0] . '>');
$recipients = array_merge($this->to, $this->cc, $this->bcc);
foreach ($recipients as $address) {
$this->logs['RECIPIENTS'][] = $this->sendCommand('RCPT TO: <' . $address[0] . '>');
}
$this->headers['Date'] = date('r');
$this->headers['Subject'] = $this->subject;
$this->headers['From'] = $this->formatAddress($this->from);
$this->headers['Return-Path'] = $this->formatAddress($this->from);
$this->headers['To'] = $this->formatAddressList($this->to);
if (!empty($this->replyTo)) {
$this->headers['Reply-To'] = $this->formatAddressList($this->replyTo);
}
if (!empty($this->cc)) {
$this->headers['Cc'] = $this->formatAddressList($this->cc);
}
if (!empty($this->bcc)) {
$this->headers['Bcc'] = $this->formatAddressList($this->bcc);
}
$boundary = md5(uniqid(microtime(true), true));
if (!empty($this->attachments)) {
$this->headers['Content-Type'] = 'multipart/mixed; boundary="mixed-' . $boundary . '"';
$message = '--mixed-' . $boundary . self::CRLF;
$message .= 'Content-Type: multipart/alternative; boundary="alt-' . $boundary . '"' . self::CRLF . self::CRLF;
} else {
$this->headers['Content-Type'] = 'multipart/alternative; boundary="alt-' . $boundary . '"';
}
if (!empty($this->textMessage)) {
$message .= '--alt-' . $boundary . self::CRLF;
$message .= 'Content-Type: text/plain; charset=' . $this->charset . self::CRLF;
$message .= 'Content-Transfer-Encoding: base64' . self::CRLF . self::CRLF;
$message .= chunk_split(base64_encode($this->textMessage)) . self::CRLF;
}
if (!empty($this->htmlMessage)) {
$message .= '--alt-' . $boundary . self::CRLF;
$message .= 'Content-Type: text/html; charset=' . $this->charset . self::CRLF;
$message .= 'Content-Transfer-Encoding: base64' . self::CRLF . self::CRLF;
$message .= chunk_split(base64_encode($this->htmlMessage)) . self::CRLF;
}
$message .= '--alt-' . $boundary . '--' . self::CRLF . self::CRLF;
if (!empty($this->attachments)) {
foreach ($this->attachments as $attachment) {
$filename = pathinfo($attachment, PATHINFO_BASENAME);
$contents = file_get_contents($attachment);
$type = mime_content_type($attachment);
if (!$type) {
$type = 'application/octet-stream';
}
$message .= '--mixed-' . $boundary . self::CRLF;
$message .= 'Content-Type: ' . $type . '; name="' . $filename . '"' . self::CRLF;
$message .= 'Content-Disposition: attachment; filename="' . $filename . '"' . self::CRLF;
$message .= 'Content-Transfer-Encoding: base64' . self::CRLF . self::CRLF;
$message .= chunk_split(base64_encode($contents)) . self::CRLF;
}
$message .= '--mixed-' . $boundary . '--';
}
$headers = '';
foreach ($this->headers as $k => $v) {
$headers .= $k . ': ' . $v . self::CRLF;
}
$this->logs['MESSAGE'] = $message;
$this->logs['HEADERS'] = $headers;
$this->logs['DATA'][1] = $this->sendCommand('DATA');
$this->logs['DATA'][2] = $this->sendCommand($headers . self::CRLF . $message . self::CRLF . '.');
$this->logs['QUIT'] = $this->sendCommand('QUIT');
fclose($this->socket);
$this->result['recipients'] = $recipients;
$this->result['status'] = substr($this->logs['DATA'][2], 0, 3);
return $this->result['status'] == self::OK;
}
protected function getServer()
{
return ($this->protocol) ? $this->protocol . '://' . $this->server : $this->server;
}
protected function getResponse()
{
$response = '';
stream_set_timeout($this->socket, $this->responseTimeout);
while (($line = fgets($this->socket, 515)) !== false) {
$response .= trim($line) . "\n";
if (substr($line, 3, 1) == ' ') {
break;
}
}
return trim($response);
}
protected function sendCommand($command)
{
fputs($this->socket, $command . self::CRLF);
return $this->getResponse();
}
protected function formatAddress($address)
{
return (empty($address[1])) ? $address[0] : '"' . $address[1] . '" <' . $address[0] . '>';
}
protected function formatAddressList(array $addresses)
{
$data = array();
foreach ($addresses as $address) {
$data[] = $this->formatAddress($address);
}
return implode(', ', $data);
}
}
#
# LAManagement version 1.0 By ChengduLittleA-YimingWu
# http://www.wellobserve.com
#
$UserData = "LAUsers.md";
include 'Parsedown.php';
include 'ParsedownExtra.php';
class LAManagement{
protected $PDE;
protected $UserConfig;
protected $List301;
protected $UserDsipName;
protected $UserID;
protected $userIsMature;
protected $PagePath;
protected $LanguageAppendix;
protected $FileTitle;
protected $FolderNameList;
protected $FileNameList;
protected $OtherFileNameList;
protected $RecentUpdatedList;
protected $PrivateFolderList;
protected $IsEditing;
protected $IsTaskManager;
protected $TaskManagerEntries;
protected $TaskManagerTitle;
protected $TaskManagerGroups;
protected $TaskManagerSelf;
protected $TrackerFile;
protected $Trackable;
protected $GLOBAL_TASK_I;
protected $MailHost;
protected $MailUser;
protected $MailPort;
protected $MailPassword;
protected $MailTitle;
protected $MailTitleEN;
protected $MailFoot;
protected $MailFootEN;
protected $MailSendResults;
protected $SubscriberTitle;
protected $SubscriberFolder;
protected $SubscriberID;
protected $SubscriberIDExisting;
protected $SubscriberMailAddress;
protected $SubscriberLanguage;
protected $MailSubscribers;
protected $PrevFile;
protected $NextFile;
protected $Additional;
protected $AdditionalLayout;
protected $IsMainPassage;
protected $AudioList;
protected $SceneList;
protected $BlockImageList; //doubles as video
protected $LinkList;
protected $AfterPassage2D;
protected $AfterPassage3D;
protected $MainFileTitle;
protected $MainFileIsNSFW;
protected $FileIsNSFW;
protected $Title;
protected $TitleEN;
protected $StringTitle;
protected $StringTitleEN;
protected $Footnote;
protected $FootnoteEN;
protected $SmallQuoteName;
protected $StatsFile;
protected $IsStatsDisplay;
protected $TaskHighlightInvert;
protected $BackgroundSemi;
protected $MainContentAlreadyBegun;
protected $unique_item_count;
protected $force_last_line;
protected $DICT;
protected $prefer_dark;
protected $cblack;
protected $cwhite;
protected $csemiwhite;
protected $chalfhighlight;
protected $chighlight;
protected $lock_file;
function ChooseColorScheme(){
if($this->prefer_dark){
$this->cwhite = 'black';
$this->cblack = 'white';
$this->csemiwhite = "rgba(0,0,0,0.9)";
$this->chighlight = 'cornflowerblue';
$this->chalfhighlight = '#365181';
}else{
$this->cwhite = 'white';
$this->cblack = 'black';
$this->csemiwhite = "rgba(255,255,255,0.9)";
$this->chighlight = 'gold';
$this->chalfhighlight = '#fff4b9';
}
}
function DoSetColorScheme(){
$hour = intval(date('H'));
if(isset($_GET['theme'])){
$theme = $_GET['theme'];
if($theme == 'unset') unset($_SESSION['la_theme']);
else $_SESSION['la_theme']=$theme;
}
if(isset($_SESSION['la_theme'])){
if($_SESSION['la_theme'] == 'black'){
if($hour>=19 || $hour<6){
unset($_SESSION['la_theme']);
}
$this->prefer_dark = 1;
}else{
if(!($hour>=19 || $hour<6)){
unset($_SESSION['la_theme']);
}
}
}else{
if($hour>=19 || $hour<6){
$this->prefer_dark = 1;
}
}
}
function AddTranslationEntry($zh,$en){
$entry['zh'] = $zh;
$entry['en'] = $en;
$this->DICT[] = $entry;
}
function FROM_ZH($zh){
if(!$this->LanguageAppendix) return $zh;
foreach($this->DICT as $entry){
if($entry['zh']==$zh)
return $entry[$this->LanguageAppendix];
}
return $zh;
}
function FROM_EN($en){
if(!$this->LanguageAppendix) return $en;
foreach($this->DICT as $entry){
if($entry['en']==$en)
return $entry[$this->LanguageAppendix];
}
return $en;
}
function UseLanguage(){
if(!$this->LanguageAppendix) return 'zh';
else return $this->LanguageAppendix;
}
function LockRoot(){
if(!file_exists("la_lock")){
$f = fopen("la_lock","w");
fclose($f);
}
$this->lock_file = fopen("la_lock","r");
flock($this->lock_file,LOCK_EX);
}
function __construct() {
$this->PDE = new ParsedownExtra();
$this->PDE->SetInterlinkPath('/');
$this->AddTranslationEntry('返回','Back');
$this->AddTranslationEntry('上级','Up');
$this->AddTranslationEntry('首页','Home');
$this->AddTranslationEntry('列表','List');
$this->AddTranslationEntry('夜间','Night');
$this->AddTranslationEntry('明亮','Day');
$this->AddTranslationEntry('在夜间模式','In night mode');
$this->AddTranslationEntry('调成明亮','Brighten up');
$this->AddTranslationEntry('进入夜间模式','Go to night mode');
$this->AddTranslationEntry('进入夜间','Night mode');
$this->AddTranslationEntry('列表','List');
$this->AddTranslationEntry('管理','Files');
$this->AddTranslationEntry('写文','Write');
$this->AddTranslationEntry('查看全部','View all');
$this->AddTranslationEntry('那么的','LAMD');
$this->AddTranslationEntry('相册','ALBUM');
$this->AddTranslationEntry('声音','Sound');
$this->AddTranslationEntry('今天','Today');
$this->AddTranslationEntry('更多','More');
$this->AddTranslationEntry('编辑','Edit');
$this->AddTranslationEntry('完成','Finish');
$this->AddTranslationEntry('放弃','Discard');
$this->AddTranslationEntry('放弃修改','Discard changes');
$this->AddTranslationEntry('个字','words');
$this->AddTranslationEntry('长度','len');
$this->AddTranslationEntry('已编辑','Modified');
$this->AddTranslationEntry('登录','Log in');
$this->AddTranslationEntry('用户名','User name');
$this->AddTranslationEntry('密码','Password');
$this->AddTranslationEntry('登出','Log out');
$this->AddTranslationEntry('过滤','Filter');
$this->AddTranslationEntry('春','Spring');
$this->AddTranslationEntry('夏','Summer');
$this->AddTranslationEntry('秋','Altumn');
$this->AddTranslationEntry('冬','Winter');
$this->AddTranslationEntry('跟踪','Tracker');
$this->AddTranslationEntry('正在跟踪','Tracking');
$this->AddTranslationEntry('总览','Overview');
$this->AddTranslationEntry('当前在','At');
$this->AddTranslationEntry('新增','New');
$this->AddTranslationEntry('在事件组','in event group');
$this->AddTranslationEntry('事件描述','Event description');
$this->AddTranslationEntry('标签','Tags');
$this->AddTranslationEntry('取消','Cancel');
$this->AddTranslationEntry('保存','Save');
$this->AddTranslationEntry('修改','Edit');
$this->AddTranslationEntry('进行','Run');
$this->AddTranslationEntry('丢弃','Cancel');
$this->AddTranslationEntry('删除','Del');
$this->AddTranslationEntry('暂缓','Wait');
$this->AddTranslationEntry('放回队列','Put back');
$this->AddTranslationEntry('删除条目','Delete item');
$this->AddTranslationEntry('确认','Confirm');
$this->AddTranslationEntry('确定','Confirm');
$this->AddTranslationEntry('新增事件','New event');
$this->AddTranslationEntry('到','to');
$this->AddTranslationEntry('设置分组','Config grouping');
$this->AddTranslationEntry('进入分组','Detailes');
$this->AddTranslationEntry('编辑文字','Edit text');
$this->AddTranslationEntry('添加组','New group');
$this->AddTranslationEntry('删','Del');
$this->AddTranslationEntry('创建索引','Create index');
$this->AddTranslationEntry('选组','Select groups');
$this->AddTranslationEntry('位于','at');
$this->AddTranslationEntry('正常','Normal');
$this->AddTranslationEntry('较早','Delayed');
$this->AddTranslationEntry('很早','Ancient');
$this->AddTranslationEntry('下一页','Next');
$this->AddTranslationEntry('上一页','Prev');
$this->AddTranslationEntry('不看了','Leave');
$this->AddTranslationEntry('返回顶部','Back to top');
$this->AddTranslationEntry('今日更新数','Updates<br />today');
$this->AddTranslationEntry('选项','Options');
$this->AddTranslationEntry('上传','Upload');
$this->AddTranslationEntry('新文件夹','New folder');
$this->AddTranslationEntry('新文件夹名','folder name');
$this->AddTranslationEntry('到这里','Put');
$this->AddTranslationEntry('选这个','Select');
$this->AddTranslationEntry('进入','Enter');
$this->AddTranslationEntry('移动','Move');
$this->AddTranslationEntry('改名','Rename');
$this->AddTranslationEntry('调整','Adjust');
$this->AddTranslationEntry('选这个','Select');
$this->AddTranslationEntry('的新名字','\'s new name');
$this->AddTranslationEntry('网站设置','Settings');
$this->AddTranslationEntry('查看为','View as');
$this->AddTranslationEntry('退出','Exit');
$this->AddTranslationEntry('设置中心','Settings');
$this->AddTranslationEntry('网站信息','Website');
$this->AddTranslationEntry('链接跳转项目','Redirect');
$this->AddTranslationEntry('管理员','Admin');
$this->AddTranslationEntry('网站标题','Title');
$this->AddTranslationEntry('标签显示标题','HTML Title');
$this->AddTranslationEntry('页脚附加文字','Footer string');
$this->AddTranslationEntry('“我说”名片抬头文字','"Say" region title');
$this->AddTranslationEntry('站点事件跟踪器','Site event tracker');
$this->AddTranslationEntry('事件高亮显示','Event highlights');
$this->AddTranslationEntry('反转','Invert');
$this->AddTranslationEntry('自动重定向的链接','Redirected links');
$this->AddTranslationEntry('修改账户昵称','Change display name');
$this->AddTranslationEntry('重设管理账户名','Change admin id');
$this->AddTranslationEntry('重设管理密码','Change admin password');
$this->AddTranslationEntry('保存所有更改','Save all changes');
$this->AddTranslationEntry('新闻稿','Newletter');
$this->AddTranslationEntry('过往新闻稿','Old newsletters');
$this->AddTranslationEntry('在这里填写您的邮箱','E-mail address here');
$this->AddTranslationEntry('成功','Success');
$this->AddTranslationEntry('不再订阅','Unsubscribe');
$this->AddTranslationEntry('重新发送确认邮件','Re-send confirmation e-mail');
$this->AddTranslationEntry('邮件发送状态','Mail sender status');
$this->AddTranslationEntry('页面不存在。','Page does not exist.');
$this->AddTranslationEntry('创建这个页面','Create this page');
$this->AddTranslationEntry('停一下','Whoa there');
$this->AddTranslationEntry('访客不能访问这个页面。','Visitors can not access this page.');
$this->AddTranslationEntry('出错','Ooops');
$this->AddTranslationEntry('文件上传遇到了未知问题,上传的文件可能不完整。','Unknown error during uploading, file could be incomplete.');
$this->AddTranslationEntry('完成','Finished');
$this->AddTranslationEntry('文件上传到下面的目录:','File has been uploaded to the path below:');
$this->AddTranslationEntry('已收到您的订阅','Request received');
$this->AddTranslationEntry('请检查您收件箱中的确认信,您需要通过确认信中的链接确认订阅。','Please check your mailbox for confirmation e-mail, you need the link there to activate your subscription.');
$this->AddTranslationEntry('我知道了','Got it');
$this->AddTranslationEntry('设置订阅','Configure Subscription');
$this->AddTranslationEntry('您已经订阅过这个栏目。','You have already subscribed to this channel.');
$this->AddTranslationEntry('请到您的收件箱检查确认信,它可能被某些邮件提供商标记为垃圾邮件。','Please check your mailbox for confirmation e-mail, it may be marked as trash by some e-mail providers.');
$this->AddTranslationEntry('邮件传输错误','Mail Transfer Error');
$this->AddTranslationEntry('已经记录下您的订阅申请,但是未能发送确认邮件。','Your subscription request is recorded, however we are not able to send you a confirmation e-mail.');
$this->AddTranslationEntry('订阅已确认','Subscription Confirmed');
$this->AddTranslationEntry('您将收到新闻稿。','You will recieve newsletters in the future.');
$this->AddTranslationEntry('附加显示','Additional');
$this->AddTranslationEntry('应用','Apply');
$this->AddTranslationEntry('显示','Show');
$this->AddTranslationEntry('显示为','Show as');
$this->AddTranslationEntry('最近篇目数量','Display count');
$this->AddTranslationEntry('天内完成的','Days Limit');
$this->AddTranslationEntry('区域标题','Region Title');
$this->AddTranslationEntry('方块列数量','Columns');
$this->AddTranslationEntry('一行的照片数','In a row');
$this->AddTranslationEntry('时间线列表按钮','Timeline Btn');
$this->AddTranslationEntry('关闭快速发帖','Disable quick post');
$this->AddTranslationEntry('启用快速发帖','Enable quick post');
$this->AddTranslationEntry('改显示为摘要','Set excript');
$this->AddTranslationEntry('改显示为全文','Set full');
$this->AddTranslationEntry('描述文字','Description');
$this->AddTranslationEntry('小声哔哔…','Chatter quietly...');
$this->AddTranslationEntry('大声宣扬','Speak Loudly');
$this->GLOBAL_TASK_I=0;
}
function __deconstruct(){
if(!isset($this->lock_file)) return;
flock($this->lock_file,LOCK_UN);
fclose($this->lock_file);
}
function SetSubscriberCustomizationInfo($title, $folder, $mail_address, $id, $lang){
$this->SubscriberTitle = $title;
$this->SubscriberFolder = $folder;
$this->SubscriberID = $id;
$this->SubscriberMailAddress = $mail_address;
$this->SubscriberLanguage = $lang;
}
function LimitAccess($mode){
echo $this->MakeCenterContainerBegin();
echo "<div class='the_body'>";
echo "<div class='main_content' style='text-align:center;'>";
if($mode==-1){
echo "<h1>".$this->FROM_ZH("成功")."</h1><p>";
if(isset($this->MailSendResults[0])){
echo "<div style='text-align:left; max-height:50vh;'>";
echo $this->FROM_ZH("邮件发送状态")."<br />";
foreach($this->MailSendResults as $result){
echo '['.$result['status'].'] ';
foreach($result['recipients'] as $people){
echo $people[0].' ';
}
echo "<br />";
}
echo "</div>";
}
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
else echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==0){
echo "<h1>404</h1>";
echo "<p>".$this->FROM_ZH("页面不存在。")."<br />Page does not exist.<br />".$_GET["page"]."</p><p>";
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
if($this->IsLoggedIn()) echo "<p><a href='?page=".$_GET["page"]."&operation=new&title=".pathinfo($_GET["page"],PATHINFO_FILENAME)."'>".$this->FROM_ZH("创建这个页面")."</a></p>";
}else if($mode==1){
echo "<h1>".$this->FROM_ZH("停一下")."</h1>";
echo $this->FROM_ZH("访客不能访问这个页面。");
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==2){
echo "<h1>".$this->FROM_ZH("出错")."</h1>";
echo $this->FROM_ZH("文件上传遇到了未知问题,上传的文件可能不完整。");
echo "<!--FILE_UPLOAD_ERROR-->";
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
else echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==3){
echo "<h1>".$this->FROM_ZH("完成")."</h1>";
echo $this->FROM_ZH("文件上传到下面的目录:");
echo $this->InterlinkPath().'/'.$_FILES['upload_file_name']['name']."<p>";
echo "<!--FILE_UPLOADED-->";
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
else echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==4){
echo "<h1>".$this->FROM_ZH("已收到您的订阅")."</h1>";
echo $this->FROM_ZH("请检查您收件箱中的确认信,您需要通过确认信中的链接确认订阅。");
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("我知道了")."</a>";
else echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==5){
echo "<h1>".$this->FROM_ZH("设置订阅")."</h1>";
echo $this->FROM_ZH("您已经订阅过这个栏目。");
if(isset($this->SubscriberIDExisting) &&$this->SubscriberIDExisting!='CONFIRMED'){
echo "<p>".$this->FROM_ZH("请到您的收件箱检查确认信,它可能被某些邮件提供商标记为垃圾邮件。")."<br /><a href='?page=index.md".
"&resend_email=true&folder=".$this->SubscriberFolder."&id=".$this->SubscriberIDExisting.
"&title=".$this->SubscriberTitle."&mail_address=".$this->SubscriberMailAddress."&subscribe_language=".$this->SubscriberLanguage."'>".$this->FROM_ZH("重新发送确认邮件")."</a></p>";
}else{
echo "<p>选择您喜欢的新闻稿语言。(部分稿件可能只有一种语言)<br />".
"Choose preferred language for this subscription. (Some letters may only have one language)</p>".
"<a href='?page=index.md&select_subscriber_langguage=true&folder=".$this->SubscriberFolder."&mail_address=".$this->SubscriberMailAddress."&subscribe_language=zh&set_translation=zh'>中文</a> ".
"<a href='?page=index.md&select_subscriber_langguage=true&folder=".$this->SubscriberFolder."&mail_address=".$this->SubscriberMailAddress."&subscribe_language=en&set_translation=en'>English</a>".
"</p>";
echo "<p><a href='?page=index.md&unsubscribe=true&folder=".$this->SubscriberFolder."&mail_address=".$this->SubscriberMailAddress."'>".$this->FROM_ZH("不再订阅")."</a></p>";
}
echo "<p>";
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰 ".$this->FROM_ZH("返回")."</a>";
echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==6){
echo "<h1>".$this->FROM_ZH("邮件传输错误")."</h1>";
echo "<p>".$this->FROM_ZH("已经记录下您的订阅申请,但是未能发送确认邮件。")."</p>";
if(isset($_SERVER["HTTP_REFERER"])) echo "<a href='".$_SERVER["HTTP_REFERER"]."'>🡰".$this->FROM_ZH("返回")."</a>";
else echo " <a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}else if($mode==7){
echo "<h1>".$this->FROM_ZH("订阅已确认")."</h1>";
echo $this->FROM_ZH("您将收到新闻稿。");
echo "<p><a href='?page=index.md'>⌂ ".$this->FROM_ZH("首页")."</a></p>";
}
echo "</div>";
echo "</div>";
echo $this->MakeCenterContainerEnd();
exit;
}
function InstallLaMDWiki(){
$index = fopen('index.md','w');
$navigation = fopen('navigation.md','w');
$conf = fopen('la_config.md','w');
fwrite($index,'# 欢迎使用那么的维基!'.PHP_EOL.PHP_EOL);
fwrite($index,'那么的维基已经成功安装在您的服务器。'.PHP_EOL.PHP_EOL.'点击右上角的🌐︎图标以登录管理,管理员默认帐号是admin,密码是Admin。注意二者均区分大小写。'.PHP_EOL.PHP_EOL);
fwrite($index,'登录以后,点击您的用户名可以显示账户选项,也可进入网站设置页面。你可以在设置页面修改你的帐号显示名、登录名和密码,并配置网站的全局选项。'.PHP_EOL.PHP_EOL);
fwrite($index,'打开[那么的维基手册](http://www.wellobserve.com/?page=MDWiki/index.md),立即学习更多网站管理窍门。'.PHP_EOL.PHP_EOL);
fwrite($index,'---------'.PHP_EOL.PHP_EOL.'那么的维基由BlenderCN-成都小A编写,请访问[小A的网站](http://www.wellobserve.com/)了解更多信息。'.PHP_EOL.PHP_EOL);
fclose($index);
fwrite($navigation,'[首页](index.md)');
fclose($navigation);
fwrite($conf,'网站配置文件'.PHP_EOL.PHP_EOL);
fwrite($conf,'<!-- Users -->'.PHP_EOL.PHP_EOL);
fwrite($conf,'admin'.PHP_EOL);
fwrite($conf,'- DisplayName = WikiAdmin'.PHP_EOL);
fwrite($conf,'- Password = Admin'.PHP_EOL);
fwrite($conf,'- Mature = 0'.PHP_EOL);
fwrite($conf, PHP_EOL);
fwrite($conf,'<!-- end of Users -->'.PHP_EOL.PHP_EOL);
fclose($conf);
}
function GetRelativePath($from, $to) {
//echo $from.' -- '.$to;
//$from = preg_replace('/^\.\//','',$from);
//if($from == '.') $from='';
$dir = explode('/', is_file($from) ? dirname($from) : rtrim($from, '/'));
$file = explode('/', $to);
//if(count($dir)==1 && $dir[0]=='.') array_shift($dir);
while ($dir && $file && ($dir[0] == $file[0])) {
array_shift($dir);
array_shift($file);
}
return str_repeat('..'.'/', count($dir)) . implode('/', $file);
}
function DoRedirect($path){
if(!isset($this->List301))
return;
foreach($this->List301 as $item){
if($item['from'] == $path)
header('Location:index.php?page='.$item['to']);
}
}
function SetPagePath($path){
if ((!file_exists('la_config.md') || is_readable('la_config.md') == false) &&
(!file_exists('index.md') || is_readable('index.md') == false)){
$this->InstallLaMDWiki();
}
$this->GetWebsiteSettings();
$this->DoRedirect($path);
$this->Trackable = $this->TryExtractTaskManager($this->TrackerFile,1);
while($path[0]=='/' || $path[0]=='\\') $path = substr($path,1);
$len = strlen($path);
if (is_dir($path)){
if($path[$len-1] != '/' && $path[$len-1] != '\\') $path = $path.'/';
$path=$path.'index.md';
}
$this->PagePath = $path;
$this->SwitchToTargetLanguageIfPossible();
if((!file_exists($this->PagePath) || is_readable($this->PagePath) == false)
&&!isset($_GET['operation'])
&&!isset($_GET['moving'])
&&!isset($_POST['button_new_passage'])) {
return false;
}
$this->StatsFile = preg_replace('/^\.\/(.*)/','$1',$this->StatsFile);
$path_clean = preg_replace('/^\.\/(.*)/','$1',$this->PagePath);
if($this->StatsFile == $path_clean){
$this->IsStatsDisplay = 1;
}
return true;
}
function SetEditMode($mode){
$this->IsEditing = $mode;
}
function GetEditMode(){
return $this->IsEditing;
}
function ConfirmMainPassage(){
$this->IsMainPassage=1;
}
//===========================================================================================================
function ParseMarkdownConfig($Content){
$Returns = Null;
$BeginOffset = 0;
$i = 0;
$Content = preg_replace("/([\S\s]*)```([\S\s]*)```/U", "$1", $Content);
while (preg_match("/([\S\s]*)<!--([^@]*)-->([\S\s]*)<!--([^@]*)-->/U", $Content, $Matches, PREG_OFFSET_CAPTURE)){
$BlockName = trim($Matches[2][0]);
$Returns[$i]["IsConfig"] = False;
$Returns[$i]["Content"] = trim($Matches[1][0]);
$i++;
$Returns[$i]["IsConfig"] = True;
$Returns[$i]["BlockName"] = $BlockName;
$j = -1; $k = 0; $new=False;
$lines=explode("\n",trim($Matches[3][0]));
foreach($lines as $Line){
if (isset($Line[0]) && $Line[0] == "-"){
if ($j<0) continue;
else{
$Analyze = explode("=",$Line,2);
if(count($Analyze)<2) continue;
$Returns[$i]["Items"][$j]["Items"][$k]["Argument"] = trim(substr($Analyze[0],1));
$Returns[$i]["Items"][$j]["Items"][$k]["Value"] = trim($Analyze[1]);
$k++;
}
}else{
if(!preg_match("/[\S]+/",$Line)) $new=True; else $new=False;
if($new==True) continue;
$j++;
$k=0;
$Analyze = explode("=", $Line,2);
if(count($Analyze)<2){
$Returns[$i]["Items"][$j]["Name"] = trim($Line);
$Returns[$i]["Items"][$j]["Value"] = NULL;
}else{
$Returns[$i]["Items"][$j]["Name"] = trim($Analyze[0]);
$Returns[$i]["Items"][$j]["Value"] = trim($Analyze[1]);
}
}
}
$i++;
$Content = preg_replace("/([\S\s]*)<!--([^@]*)-->([\S\s]*)<!--([^@]*)-->/U", "", $Content, $limit=1);
}
return $Returns;
}
function WriteMarkdownConfig($Config,$File){
foreach($Config as $Block){
if(!isset($Block["IsConfig"])) continue;
if($Block["IsConfig"]==False){
fwrite($File,$Block["Content"]);
fwrite($File,PHP_EOL.PHP_EOL);
}else{
fwrite($File,"<!-- ".$Block["BlockName"]." -->".PHP_EOL.PHP_EOL);
if(isset($Block["Items"])){
foreach($Block["Items"] as $Name){
fwrite($File,$Name["Name"]);
if(isset($Name["Value"])&&$Name["Value"]!='') fwrite($File," = ".$Name["Value"]);
fwrite($File,PHP_EOL);
if(isset($Name["Items"]))
foreach($Name["Items"] as $Argument){
fwrite($File,"- ".$Argument["Argument"]." = ".$Argument["Value"].PHP_EOL);
}
fwrite($File,PHP_EOL);
}
}
fwrite($File,"<!-- End of ".$Block["BlockName"]." -->".PHP_EOL.PHP_EOL);
}
}
}
function AddBlock(&$Config,$BlockName){
$i=0;
while(isset($Config[$i]))$i++;
$Config[$i]['IsConfig'] = True;
$Config[$i]['BlockName'] = $BlockName;
return $i;
}
function RemoveBlockByName(&$Config,$BlockName){
$i=0;
foreach($Config as $Block){
if(isset($Block["BlockName"]) && $Block["BlockName"]==$BlockName){
unset($Config[$i]); break;
}
$i++;
}
}
function RemoveBlock(&$Config,$Block){
unset($Config[$Block]);
}
function GetBlock(&$Config,$BlockName){
$i=0;
if(!$Config) return Null;
foreach($Config as $Block){
if(isset($Block["BlockName"]) && $Block["BlockName"]==$BlockName){
return $i;
}
$i++;
}
return Null;
}
function EditBlock(&$Config,$BlockName){
if (($block = $this->GetBlock($Config,$BlockName))==Null){
return $this->AddBlock($Config,$BlockName);
}else{
return $block;
}
}
function SetBlockName(&$Config,$Block,$BlockName){
$Config[$Block]["BlockName"] = $BlockName;
}
function FindGeneralLine(&$Config,$Block,$Name){
$i=0;
if(!isset($Config[$Block]['Items']))return Null;
foreach($Config[$Block]['Items'] as $Line){
if(isset($Line["Name"]) && $Line["Name"]==$Name){
return $i;
}
$i++;
}
return Null;
}
function ForceLastGeneralLine(){
$this->force_last_line=1;
}
function RestoreGeneralLine(){
$this->force_last_line=0;
}
function FindGeneralLineN(&$Config,$Block,$Name,$Number){
$i=0;
$c=0;
if(!isset($Config[$Block]['Items']))return Null;