-
Notifications
You must be signed in to change notification settings - Fork 0
/
uStatistiken.pas
1152 lines (1008 loc) · 32.4 KB
/
uStatistiken.pas
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
unit uStatistiken;
interface
uses uStatisticsBase, cStats, cArticle, uDateTime, uDBBase;
type
//Path - Statistics
tStatPathFeedsOf = class (tStatisticBase)
public
function GetShowOptions : tStatShow; override;
procedure MakeStatistic( Groups : tGroupList); override;
end;
tStatPathRelay = class (tStatisticBase)
private
procedure GetPathList(const allHdr: String; var tsa, tsg: tStatList);
protected
function OneText(tit : String; TS : tStatList;
findAll, findBAD : Integer) : String;
public
function GetShowOptions : tStatShow; override;
procedure MakeStatistic( Groups : tGroupList); override;
end;
tStatPathMyFeeds = class (tStatisticBase)
private
procedure GetPathList(const allHdr: String; const FeedMax : Integer;
var Feed: array of String; out HdrLast: String);
function OneText(tit : String; TS : tStatList;
findAll, findBAD : Integer) : String;
public
function GetShowOptions : tStatShow; override;
procedure MakeStatistic( Groups : tGroupList); override;
end;
///DAU Jones ;-)
tStatDAUJonesBase = class (tStatisticBase)
protected
function DauJones( Article: tArticle; AddEach: Boolean;
GrpTS, SumTS: TStatList ): Integer;
procedure MakeDAUStatistic(Groups: tGroupList; GroupByName : Boolean);
end;
tStatDAUJones = class (tStatDAUJonesBase)
public
function GetShowOptions : tStatShow; override;
procedure MakeStatistic( Groups : tGroupList); override;
end;
tStatDAUJonesName = class (tStatDAUJonesBase)
public
function GetShowOptions : tStatShow; override;
procedure MakeStatistic( Groups : tGroupList); override;
end;
implementation
uses sysutils, uTools, uoTools, cArts, uEncoding;
{ tStatDAUJones }
function tStatDAUJonesBase.DauJones( Article: tArticle; AddEach: Boolean;
GrpTS, SumTS: TStatList ): Integer;
var Art : TArt;
s, h : String;
i, j, k, n : Integer;
qc : Char;
fr : tFrom;
procedure DauAdd( Pts: Integer; Why: String );
begin
Result := Result + Pts;
if AddEach then begin
GrpTS.Add( Why, Pts, 2 );
SumTS.Add( Why, Pts, 2 );
end;
end;
begin
Result := 0;
fr := tFrom.Create;
try
s := LowerCase( Article.Header['From:'] );
i := Pos( '@', s );
if (i<=1) or (i=length(s)) then begin
DauAdd(50,'invalid From:');
end else begin
h := copy( s, i+1, 255 );
if Pos('.',h)=0 then DauAdd(50,'invalid From:');
end;
for n:=1 to 2 do begin
if Pos('@dev.nul',s)>0 then DauAdd(25,'From:-fake assumed');
if Pos('xxx' ,s)>0 then DauAdd(25,'From:-fake assumed');
i := Pos('this',s);
if i>0 then begin
j:=Pos('remove',s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('erase' ,s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('del' ,s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('cut' ,s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
end;
i := Pos('spam',s);
if i>0 then begin
j:=Pos('no' ,s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('stop',s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('dont',s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
j:=Pos('anti',s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
end;
i := Pos('sig',s);
if i>0 then begin
j:=Pos('see',s); if (j>0) and (j<i) then DauAdd(25,'From:-fake assumed');
end;
s := ROT13(s);
end;
s := LowerCase( Article.Header['From:'] );
n := 1;
repeat
i := Pos(' ',s);
j := Pos('_',s);
if i=0 then i:=j;
if (i>0) and (j>0) and (j<i) then i:=j;
if i>0 then begin inc(n); System.Delete(s,1,i); end;
until i=0;
if n<3 then DauAdd(10,'no name in From: assumed');
fr.Whole := Article.Header['From:'];
s := LowerCase( fr.EMailAdress );
fr.Whole := Article.Header['Reply-To:'];
h := LowerCase( fr.EMailAdress );
if h<>'' then begin
if s=h then DauAdd(1,'Reply-To: = From:');
i := Pos('@',h);
if (i=0) then DauAdd(25,'invalid Reply-To:');
if (i=1) or (i=length(h)) then begin i:=0; DauAdd(25,'invalid Reply-To:'); end;
if (i=2) and (h[1]='<') then begin i:=0; DauAdd(25,'invalid Reply-To:'); end;
if i>0 then begin
h := copy(h,i+1,255);
if Pos('.',h)=0 then DauAdd(25,'invalid Reply-To:');
end;
end;
s := Article.Header['Message-ID:'];
i := Pos('@',s);
if i=0 then DauAdd(5,'invalid M-ID:')
else begin
if Pos('.',s)=0 then DauAdd(5,'invalid M-ID: assumed');
end;
s := Article.Header['Newsgroups:'];
n := 0;
repeat
i:=Pos(',',s);
if i>0 then begin inc(n); System.Delete(s,1,i); end;
until i=0;
s := Article.Header['Followup-To:'];
if s<>'' then begin
if Pos(',',s)=0 then n:=0 else inc(n);
end;
if n>0 then DauAdd( n*10, 'crosspost w/o FollowUp-To' );
Art := TArt.Create;
try
Art.Text := Article.Text;
for i:=0 to Art.Count-1 do begin
s := Lowercase(Trim(Art[i]));
if copy(s,1,13)='content-type:' then begin
if Pos('html',s)>0 then DauAdd(50,'html');
if Pos('vcard',s)>0 then DauAdd(25,'vcard');
if Pos('application/octet-stream',s)>0 then begin
h := LowerCase( Article.Header['Newsgroups:'] );
if Pos('bina',h)+Pos('datei',h)=0 then DauAdd(50,'binary in non-b.-group assumed');
end;
end;
end;
n := 0;
for i:=0 to Art.Count-1 do begin
s := Art[i];
if s='' then break;
for k:=1 to length(s) do begin
if Ord(s[k])>=$80 then begin inc(n); break; end;
end;
if n>0 then begin DauAdd(5,'uncoded 8bit-chars in header'); break; end;
end;
Art.SkipBoundary;
Art.SkipHeader;
qc := Art.GetQuoteChar;
if Art.Count>10 then begin
n := 0;
for i:=0 to Art.Count-1 do begin
s := Art[i];
if (s='-- ') or (s='--=20') or (s='-- =') then break;
s := Trim(s);
if (s<>'') and (s<>qc) then begin
if s[1]=qc then inc(n) else dec(n);
end;
end;
if n>=10 then DauAdd( n ,'quote-ratio');
n := 0;
for i:=0 to Art.Count-1 do begin
s := Art[i];
if (s='-- ') or (s='--=20') or (s='-- =') then break;
if Pos('-----== Posted via D',s)=1 then break; // Deja News
s := Trim(s);
if (s<>'') and (s<>qc) then begin
if copy(s,1,1)=qc then
inc(n)
else begin
if n>9 then DauAdd( n ,'mega-quote');
n := 0;
end;
end;
end;
if n>9 then DauAdd( n*2 ,'trailing mega-quote');
end;
k := -1;
for i:=0 to Art.Count-1 do begin
s := Art[i];
if (s='-- ') or (s='--=20') or (s='-- =') then begin
n := (Art.Count-1) - i;
if n>4 then begin
if Art[Art.Count-1]='' then dec(n);
if n>4 then DauAdd(n,'.sig > 4 lines');
end;
k := i;
break;
end;
end;
if k<0 then begin
j := Art.Count - 1;
while (j>0) and (Trim(Art[j])='') do dec(j);
dec(j,2);
k := -1;
for i:=0 to j do begin
s := Art[i];
if (copy(s,1,2)='--') and (copy(s,1,5)<>'-----') and (length(s)<10) then begin
if s<>'-->' then k:=i;
end;
end;
if k>0 then begin
DauAdd(1,'pseudo-.sig assumed "'+Art[k]+'"');
n := (Art.Count-1) - k;
if n>4 then begin
if Art[Art.Count-1]='' then dec(n);
if n>4 then DauAdd(n,'pseudo-.sig > 4 lines assumed');
end;
end;
end;
n := 0;
j := Art.Count-1;
while (j>=0) and (Art[j]='') do begin inc(n); dec(j); end;
if n>1 then DauAdd(n-1,'trailing empty-lines');
finally
Art.Free;
end;
if Result<0 then Result:=0; // no bonus-points
if AddEach then begin
GrpTS.Add( '(probe count)', Result, 0 );
SumTS.Add( '(probe count)', Result, 0 );
if Result<=0 then begin
GrpTS.Add( '"DAU Jones ;-)" tested and approved!', 0, 1 );
SumTS.Add( '"DAU Jones ;-)" tested and approved!', 0, 1 );
end else begin
GrpTS.Add( '"DAU Jones ;-)" failed!', Result, 1 );
SumTS.Add( '"DAU Jones ;-)" failed!', Result, 1 );
end;
end;
finally
fr.free;
end;
end;
procedure tStatDAUJonesBase.MakeDAUStatistic(Groups: tGroupList; GroupByName : Boolean);
const DAUHeader = 'DAU Jones ;-) ';
procedure Report( const Title: String;
const TS: TStatList );
var s: String;
i, summsg, sumdau, d, l: Integer;
TH: TStatInfo;
begin
if fStatOptions.Param<>'' then fStatOptions.Ranking := False; // nur bei Ranking
if fStatOptions.Ranking then TS.SortBy_Group_WCRatioDesc
else TS.SortBy_GroupDesc_Weight;
fResultAsText := fResultAsText + Title + CRLF;
s := 'Pos.' + #9 + 'DAUs';
s := s + #9 + 'Msgs';
s := s + #9 + 'Ratio';
if fStatOptions.Param='' then s := s + #9 + 'Who'
else s := s + #9 + 'Why';
fResultAsText := fResultAsText + s + CRLF;
if fStatOptions.Param='' then begin
for i:=0 to TS.Count-1 do begin
TH := TS.Infos[i];
if TH.Weight>0 then begin
s := inttostr(i+1) + #9 + IntToStr(TH.Weight);
s := s + #9 + IntToStr(TH.Counter);
s := s + #9 + FloatToStrF( 1.0*TH.Weight/TH.Counter, ffFixed, 7, 2 );
s := s + #9 + TS.Keys[i];
fResultAsText := fResultAsText + s + CRLF;
end;
end;
end else begin
summsg := 1;
sumdau := 1;
d := -1;
l := 0;
for i:=0 to TS.Count-1 do begin
TH := TS.Infos[i];
if TH.Group<>d then begin
d := TH.Group;
l := 0;
fResultAsText := fResultAsText + CRLF;
end;
inc( l );
if TH.Group=0 then begin
summsg := TH.Counter;
sumdau := TH.Weight;
s := inttostr(TH.Group)+'.'+inttostr(l) + #9 + IntToStr(TH.Weight);
s := s + #9 + IntToStr(TH.Counter);
s := s + #9 + FloatToStrF( 1.0*TH.Weight/TH.Counter, ffFixed, 7, 2 );
end else begin
if TH.Group=1 then begin
s := inttostr(TH.Group)+'.'+inttostr(l) + #9 + IntToStr(TH.Weight);
s := s + #9 + IntToStr(TH.Counter);
s := s + #9 + FloatToStrF( 100.0*TH.Counter/summsg, ffFixed, 7, 2 )+'%';
end else begin
s := inttostr(TH.Group)+'.'+inttostr(l) + #9 + IntToStr(TH.Weight);
s := s + #9; // + IntToStr(TH.Anz);
s := s + #9 + FloatToStrF( 100.0*TH.Weight/sumdau, ffFixed, 7, 2 )+'%';
end;
end;
s := s + #9 + TS.Keys[i];
fResultAsText := fResultAsText + s + CRLF;
end;
end;
fResultAsText := fResultAsText + CRLF;
end;
var
GrpCnt, DJ: Integer;
gnr,anr: LongInt;
Hdr : String;
GrpTS, SumTS: TStatList;
Art : tArticle;
s : string;
i : integer;
fr : tFrom;
cancel : Boolean;
begin
cancel := false;
if length(Groups)=0 then exit;
ClearFindCount;
Art := tArticle.Create;
fr := tFrom.Create;
try
fResultAsText := '';
if fStatOptions.Param='' then fResultAsText := fResultAsText +
DAUHeader + '(Ranking)' + CRLF
else fResultAsText := fResultAsText +
DAUHeader + 'for "'+fStatOptions.Param+'"' + CRLF;
fResultAsText := fResultAsText + '(based on msgs with bodies '+StatDayBaseText+', i.e. not killfiled yet ...)' + CRLF
+ CRLF;
SumTS := TStatList.Create;
GrpTS := TStatList.Create;
GrpCnt := 0;
for gnr := 0 to length(Groups)-1 do begin
with Groups[gnr].DB.Create do try
GrpTS.Clear;
Open(Groups[gnr].Path^);
ClearGrpCount(Groups[gnr].name, Count);
for anr:=Min to Max do begin
cancel := incGrpCount;
if cancel then break;
GetArticle(anr, s, i);
art.text := s;
if DayOK( art.GetGMTDateDT ) then begin
IncFindCount;
if fStatOptions.Param='' then begin
Hdr := Art.Header['From:'];
//hdr := DecodeHeaderValue(Hdr[1], length(hdr));
if GroupByName then begin
//Hdr := FilterNameOfFrom(Hdr);
fr.Whole := Hdr;
Hdr := fr.Name;
if (Hdr = '') then Hdr := fr.EMailAdress;
end;
DJ := DauJones( Art, False, nil, nil );
GrpTS.Add( Hdr, DJ, 0 );
SumTS.Add( Hdr, DJ, 0 );
end else begin
Hdr := LowerCase( Art.Header['From:'] );
//Hdr := DecodeHeaderValue(Hdr[1], length(Hdr));
if GroupByName then begin
//Hdr := FilterNameOfFrom(Hdr);
fr.Whole := Hdr;
Hdr := fr.Name;
if (Hdr = '') then Hdr := fr.EMailAdress;
end;
if (fStatOptions.Param='@') or (Pos(LowerCase(fStatOptions.Param),Hdr)>0) then begin
DauJones( Art, True, GrpTS, SumTS );
end;
end;
end;
end;
Close;
Report( Groups[gnr].Name, GrpTS );
inc( GrpCnt );
finally
free
end;
if cancel then begin
fResultAsText := fResultAsText + CRLF + 'Cancelled...'+CRLF;
break;
end;
fResultAsText := fResultAsText + GetGruppenTrenner();
end;
if GrpCnt > 1 then Report( 'All selected groups', SumTS );
GrpTS.Free;
SumTS.Free;
finally
Fr.Free;
Art.Free;
end;
end;
{Normal}
function tStatDAUJones.GetShowOptions: tStatShow;
begin
with Result do begin
Options := [ssoRanking, ssoBDate, ssoEDate, ssoEdParam];
Caption := 'DAU Jones ;-)';
ParamCapt := 'From:-part (@ for all posters; leave empty for ranking)';
DefParam := '';
end
end;
procedure tStatDAUJones.MakeStatistic(Groups: tGroupList);
begin
MakeDAUStatistic(Groups, false)
end;
{Name}
function tStatDAUJonesName.GetShowOptions: tStatShow;
begin
with Result do begin
Options := [ssoRanking, ssoBDate, ssoEDate, ssoEdParam];
Caption := 'DAU Jones ;-) (grouped, name)';
ParamCapt := 'From:-part (@ for all posters; leave empty for ranking)';
DefParam := '';
end
end;
procedure tStatDAUJonesName.MakeStatistic(Groups: tGroupList);
begin
MakeDAUStatistic(Groups, True)
end;
{ tStatPathFeedsOf }
function tStatPathFeedsOf.GetShowOptions: tStatShow;
begin
with Result do begin
Options := [ssoBDate, ssoEDate, ssoEdParam];
Caption := 'Path: Feeds of ...';
ParamCapt := 'Newsserver';
DefParam := ''
// DefParam := AgtIni.ReadString('Temp','FeedsOfSrv','');
end
end;
procedure tStatPathFeedsOf.MakeStatistic(Groups: tGroupList);
var
i,k,findSum : Integer;
gnr,anr,l: LongInt;
s : String;
TH : TStatInfo;
TS : TStatList;
Path, PredSrv, SuccSrv : String;
OldGroup : Integer;
AllFeeds : Boolean;
Newsserver : String;
Art : tArticle;
cancel : Boolean;
begin
cancel := false;
if length(Groups)=0 then exit;
ClearFindCount;
FindSum := 0;
NewsServer := fStatOptions.Param;
if NewsServer='' then begin
AllFeeds := True;
end else begin
AllFeeds := False;
// AgtIni.WriteString( 'Temp', 'FeedsOfSrv', NewsServer );
end;
fResultAsText := 'Feeds of: ' + Newsserver + CRLF
+ '(based on msgs with bodies '+StatDayBaseText+')' + CRLF
+ CRLF
+ 'Pos.'+#9+'Count'+#9+'Weight'+#9+'Feed' + CRLF
+ CRLF;
Art := tArticle.Create;
TS := TStatList.Create;
try
for gnr := 0 to length(Groups)-1 do begin
with Groups[gnr].DB.Create do try
Open(Groups[gnr].Path^);
clearGrpCount(Groups[gnr].name, Count);
for anr:=Min to Max do begin
cancel := incGrpCount;
if cancel then break;
GetArticle(anr, s, i);
art.text := s;
if DayOK( art.GetGMTDateDT ) then begin
Path := Art.Header[ 'Path:' ];
if AllFeeds then begin
incFindCount;
inc(FindSum);
PredSrv := '';
i := Pos('!',Path);
if i>0 then begin PredSrv:=copy(Path,1,i-1); System.Delete(Path,1,i); end;
while Path<>'' do begin
i := Pos('!',Path);
if i=0 then begin
SuccSrv := Path;
Path := '';
end else begin
SuccSrv := copy(Path,1,i-1);
System.Delete(Path,1,i);
end;
if SuccSrv<>'not-for-mail' then TS.Add( PredSrv + ' <- ' + SuccSrv, 1, 9 );
PredSrv := SuccSrv;
end;
end else begin
i := Pos( '!' + NewsServer + '!', Path );
if i>0 then begin
incFindCount;
inc(FindSum);
PredSrv := '';
k := i - 1;
while (k>0) and (Path[k]<>'!') do begin
PredSrv := Path[k] + PredSrv;
dec(k);
end;
if PredSrv='' then PredSrv:='.';
SuccSrv := '';
k := i + length(NewsServer) + 2;
while (k<=length(Path)) and (Path[k]<>'!') do begin
SuccSrv := SuccSrv + Path[k];
inc(k);
end;
if SuccSrv='not-for-mail' then SuccSrv:='';
if SuccSrv='' then SuccSrv:='.';
TS.Add( NewsServer + ' <- ' + SuccSrv, 1, 1 );
TS.Add( NewsServer + ' -> ' + PredSrv, 1, 2 );
end;
end;
end;
end;
Close;
finally
free
end;
if cancel then begin
fResultAsText := fResultAsText + CRLF + 'Cancelled...'+CRLF;
break;
end;
fResultAsText := fResultAsText + GetGruppenTrenner();
end;
{Sortieren}
TS.SortBy_GroupDesc_Counter;
{"Bericht" erstellen}
fResultAsText := fResultAsText
+ #9 + IntToStr(FindSum)
+ #9 + ValToPercent(FindSum, FindSum)+'%'
+ #9 + '(probe count)'
+ CRLF;
OldGroup := -1;
l := 0;
for i:=0 to TS.Count-1 do begin
TH := TS.Infos[i];
if TH.Group<>OldGroup then begin
fResultAsText := fResultAsText + CRLF;
if TH.Group=1 then fResultAsText := fResultAsText + '[IN]' + CRLF;
if TH.Group=2 then fResultAsText := fResultAsText + '[OUT]' + CRLF;
OldGroup := TH.Group;
l := 0;
end;
inc(l);
fResultAsText := fResultAsText
+ IntToStr(l)
+ #9 + IntToStr(TH.Counter)
+ #9 + ValToPercent(TH.Counter, FindSum)+'%'
+ #9 + TS.Keys[i]
+ CRLF;
end;
finally
TS.Free;
Art.Free
end;
end;
{ tStatPathMyFeeds }
procedure tStatPathMyFeeds.GetPathList(const allHdr: String;
const FeedMax: Integer; var Feed: array of String; out HdrLast: String);
var
i : Integer;
HdrFirst : Boolean;
Hdr : String;
feedLfd : Integer;
begin
HdrLast := '';
for i := 0 to FeedMax-1 do Feed[i] := '';
Hdr := '';
HdrFirst := true;
feedLfd := 0;
//Alle Zeichen durchgehen
for i := 1 to length(allHdr) do begin
//Ende eines Teiles
if allHdr[i] in [#13, #0, '!'] then begin
if Hdr='' then Hdr:='(no value)';
if (Hdr<>'not-for-mail') then begin
if not HdrFirst then begin
if FeedLfd<FeedMax then begin
Feed[FeedLfd] := Hdr;
inc(FeedLfd);
end; //Kein Break!
HdrLast := Hdr;
end;
HdrFirst := False;
end;
Hdr := '';
end else begin //Not in [#13, #0, '!']
//if length(Hdr)<255 then //WOZU?!
Hdr := Hdr + allHdr[i];
end;
//Am Ende der Zeile beenden
if allHdr[i] in [#13, #0] then break; //Urks
end;
end;
function tStatPathMyFeeds.GetShowOptions: tStatShow;
begin
with Result do begin
Options := [ssoBDate, ssoEDate, ssoEdParam];
Caption := 'Path: My Feeds';
ParamCapt := 'Max. Relayers (1-10)';
DefParam := '1'
end
end;
procedure tStatPathMyFeeds.MakeStatistic(Groups: tGroupList);
var
i : Integer;
gnr,anr: LongInt;
s : String;
TSG : TStatList;
TSA : TStatList;
HdrLast : String;
allHdr : String;
Feed : array of String;
FeedMax : LongInt;
Art : tArticle;
FindAll, FindGrp, findBAD : Integer;
DTA : tDateTime;
cancel : Boolean;
begin
cancel := false;
if length(Groups)=0 then exit;
clearFindCount;
FindAll := 0;
findBAD := 0;
if fStatOptions.Param='' then exit;
FeedMax := StrToIntDef(fStatOptions.Param, 0);
if FeedMax<1 then FeedMax:=1;
//if FeedMax>10 then FeedMax:=10;
SetLength(Feed, FeedMax);
fResultAsText := 'Path-statistics: My Feeds (<= '+IntToStr(FeedMax)+' relayer)' + CRLF
+ '(based on msgs with bodies '+StatDayBaseText+')' + CRLF
+ CRLF
+ 'Pos.'+#9+'Count'+#9+'Weight'+#9+'Relayer' + CRLF
+ CRLF;
fResultAsText := fResultAsText + 'IMPORTANT: Perhaps buggy (new implemented)!' + CRLF;
Art := tArticle.Create;
TSG := TStatList.Create;
TSA := TStatList.Create;
try
for gnr := 0 to length(Groups)-1 do begin
FindGrp := 0;
with Groups[gnr].DB.Create do try
Open(Groups[gnr].Path^);
clearGrpCount(Groups[gnr].name, Count);
for anr:=Min to Max do begin
cancel := incGrpCount;
if cancel then break;
GetArticle(anr, s, i);
art.text := s;
DTA := art.GetGMTDateDT;
if DayOK( DTA ) then begin
allHdr := Art.Header['Path:'] + #0;
if (allHdr<>'') then begin
incFindCount;
inc(FindGrp);
inc(FindAll);
if (DTA = oldDefault) then inc(findBAD);
GetPathList(allHdr, FeedMax, Feed, HdrLast);
//Letzter Path ueberall loeschen
for i:=0 to FeedMax-1 do begin
if Feed[i]=HdrLast then Feed[i]:='';
end;
//Wenn der Feed nicht leer ist als Path hinzufuegen
if Feed[0]<>'' then begin
s := Feed[0];
for i:=1 to FeedMax-1 do begin
if Feed[i]='' then Feed[i]:='.';
s := s+'!'+Feed[i];
end;
TSG.Add( s );
TSA.Add( s );
end;
end;
end;
end;
Close;
finally free end;
if cancel then begin
fResultAsText := fResultAsText + CRLF + 'Cancelled...'+CRLF;
break;
end;
fResultAsText := fResultAsText
+ OneText(Groups[gnr].Name, TSG, findGrp, findBAD) + CRLF
+ GetGruppenTrenner();
end;
if (not cancel) and (length(Groups)>1) then begin
fResultAsText := fResultAsText
+ OneText('All selected groups', TSA, findAll, findBAD);
end
finally
TSG.Free;
TSA.Free;
Art.Free
end;
SetLength(Feed, 0);
end;
function tStatPathMyFeeds.OneText(tit : String; TS : tStatList;
findAll, findBAD : Integer) : String;
var
i, l : integer;
TH : TStatInfo;
begin
//Sortieren nach Anzahl
TS.SortBy_Counter;
Result := '';
l := 0;
for i:=0 to TS.Count-1 do begin
TH := TS.Infos[i];
if TH.Counter>0 then begin
inc(l);
if l<=100 then begin
Result := Result
+ IntToStr(l)
+ #9 + IntToStr(TH.Counter)
+ #9 + ValToPercent(TH.Counter, FindAll)+'%'
+ #9 + TS.Keys[i]
+ CRLF;
end;
end;
end;
Result := Result
+ CRLF
+ #9 + IntToStr(findBAD)
+ #9 + ValToPercent(findBAD,FindAll)+'%'
+ #9 + '(BAD dates)'
+ CRLF
+ #9 + IntToStr(FindAll)
+ #9 + ValToPercent(FindAll,FindAll)+'%'
+ #9 + '(probe count)'
+ CRLF
+ CRLF;
end;
{ tStatPathRelay }
function tStatPathRelay.GetShowOptions: tStatShow;
begin
with Result do begin
Options := [ssoBDate, ssoEDate];
Caption := 'Path: Relayers (Top 100)';
ParamCapt := '';
DefParam := ''
end
end;
(*procedure tStatPathRelay.MakeStatistic(Groups: tGroupList);
var
i : Integer;
gnr,anr,l: LongInt;
s : String;
Hdr : String;
TH : TStatInfo;
TS : TStatList;
HdrPtr : PChar;
HdrC : Char;
HdrFirst : Boolean;
HdrLast : String;
Art : tArticle;
begin
if length(Groups)=0 then exit;
clearFindCount;
fResultAsText := 'Path-statistics: Relayers (Top 100)' + CRLF
+ '(based on msgs with bodies within last 14 days)' + CRLF
+ CRLF
+ 'Pos.'+#9+'Count'+#9+'Weight'+#9+'Relayer' + CRLF
+ CRLF;
fResultAsText := fResultAsText + 'IMPORTANT: Not implemented yet!' + CRLF;
// Application.ProcessMessages;
Art := tArticle.Create;
TS := TStatList.Create;
try
for gnr := 0 to length(Groups)-1 do begin
with Groups[gnr].DB.Create do try
Open(Groups[gnr].Path);
for anr:=Min to Max do begin
{ inc( Form1.BalkenCount );
if (Form1.BalkenCount mod 25)=0 then begin
Form1.FindStatus(TG,anr);
Form1.BalkenG.Progress := Form1.BalkenCount;
end;
}
GetArticle(anr, s, i);
art.text := s;
if DayOK( art.GetGMTDateDT ) then begin
(*
ArtTextSize := AgtArtTextLen(HArt);
ArtText := AgtArtTextPtr(HArt);
HdrPtr := AgtArtHeaderStartPtr( HArt, 'Path:' );
if HdrPtr<>nil then begin
inc(Form1.FindCount);
Hdr := '';
HdrFirst := True;
repeat
HdrC := HdrPtr^;
HdrPtr := (HdrPtr+1);
if (HdrC<>#13) and (HdrC<>#0) and (HdrC<>'!') then begin
if length(Hdr)<255 then Hdr := Hdr + HdrC;
end else begin
if Hdr='' then Hdr:='(no value)';
if Hdr<>'not-for-mail' then begin
if not HdrFirst then begin
TS.Add( Hdr );
HdrLast := Hdr;
end;
HdrFirst := False;
end;
Hdr := '';
end;
until (HdrC=#13) or (HdrC=#0);
TS.Add( HdrLast, -1 );
end; {if HdrPtr<>nil ...}
end;
end;
CloseMyArt;
Application.ProcessMessages;
end;
Application.ProcessMessages;
end;
{Sortieren nach Anzahl}
TS.SortBy_Weight;
{"Bericht" erstellen}
l := 0;
for i:=0 to TS.Count-1 do begin
inc( l );
if l<=100 then begin
TH := TS.Infos[i];
if TH.Weight>1 then begin
s := IntToStr(l) + #9 + IntToStr(TH.Weight);
s := s + #9 + ValToPercent(TH.Weight,Form1.FindCount)+'%';
s := s + #9 + TS.Keys[i];
Form1.rtfStat.Lines.Add( s );
end;
end;
end;
Form1.rtfStat.Lines.Add( '' );
s := #9 + IntToStr(Form1.FindCount);
s := s + #9 + ValToPercent(Form1.FindCount,Form1.FindCount)+'%';
s := s + #9 + '(probe count)';
Form1.rtfStat.Lines.Add( s );
Form1.rtfStat.Lines.Add( '' );
Application.ProcessMessages;
*
end;
end;
Close
finally free end;
fResultAsText := fResultAsText + GruppenTrenner;
end;
finally
TS.Free;
Art.Free
end;
end;
*)
procedure tStatPathRelay.GetPathList(const allHdr: String; var tsa, tsg : tStatList);
var
i : Integer;
HdrFirst : Boolean;
Hdr, HdrLast : String;
begin
HdrLast := '';
Hdr := '';