home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
UTILITY
/
USTATV20.ARJ
/
USERSTAT.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1989-02-15
|
23KB
|
607 lines
{$G1}
{$P1}
{$V-}
Program UserStat;
{
Well, I've decided to release this into the public domain
for two reasons, A) I don't have the time necessary to put into
this as I'm working on getting USENET feeds into WWIV, and at
getting WWIV v4.0 ported to the Macintosh (IF I ever get my Mac
back from the shop..).
B) This program could get really tricky with the right amount of
imagination and time.
I ask only two little things.
A) You send me the changes you make.
B) You DO NOT remove my name from the credits, and you do not
place my or your name into the actual text file.
That's it.. Call my BBS @ (213) 479-7043 300/1200/2400/18k (PEP)
Fred's Floating Bar and Grill.
-JGG 2/15/89
}
Const
VER = '2.0';
MODDATE = 'February 15, 1989';
NormalAttr = '[0;33;44m';
BlinkingAttr = '[1;41;44;5m';
ResetAttr = '[0m';
Type
userrec = Record
Name : String [31];
LastOn : String [9];
Posts : Integer;
Logons : Integer;
UploadK : Real;
DownloadK : Real;
End;
DataBlock = Array [1..700] of Char;
str = String [80];
regs = record
ax, bx, cx,
dx, bp, si,
di, ds, es,
flags : integer;
end;
Var
Ansi,
PostPrint,
UDPrint,
MakeTbls,
FormPrint : Boolean;
RawData : DataBlock;
MinLogon,
PValue,
HowMany,
UserNum,
Loop : Integer;
FstSeek,
Count : Byte;
UserData : Array [1..1000] of userrec;
userfile : File of DataBlock;
configfile : File of Char;
TempStr,
ResetStr,
RegStr,
BlnkStr,
PVS,
datapath,
gfilepath : String [80];
data : Char;
prntfile : Text;
{$I CLCKSTFF.PRO }
Procedure ReadInit;
Begin
{$I READINIT.PRO}
{ This procedure returns the datafile path in datapath
and the gfiles path in gfilepath. }
End;
Procedure ReadUserData;
{ This Procedure reads the user data the necessary user info in }
Begin
Assign (userfile, datapath+'USER.LST');
Reset (userfile);
Seek (userfile, FstSeek);
UserNum := 1;
Repeat
Read (userfile, RawData);
If Ord (RawData [386]) = 0 { User not deleted }
then { Read in data }
With UserData [UserNum] do
Begin
{ Converts the \00 terminated 'C' type string to
a pascal string which is not terminated, but uses
the first byte of the string to indicate the length
( ie. Name [0] is the length of Name )
}
UserNum := UserNum + 1;
Count := 0;
Loop := 1;
Name := '';
Repeat
Name := Name + RawData [Loop + Count];
Count := Count + 1;
Until Ord (RawData [Loop + Count]) = 0; { End of 'C' string }
Count := 0;
Loop := 82; { This is the same as above, but }
LastOn := ''; { with the Last date on string. }
Repeat
LastOn := LastOn + RawData [Loop + Count];
Count := Count + 1;
Until Ord (RawData [Loop + Count]) = 0;
Posts := Ord (RawData [435]) + (Ord (RawData [436]) * 256);
Logons := Ord (RawData [459]) + (Ord (RawData [460]) * 256);
UploadK := Ord (RawData [465]) + (Ord (RawData [466]) * 256.0) +
(Ord (RawData [467]) * 65536.0) +
(Ord (RawData [468]) * 4294967296.0);
DownloadK := Ord (RawData [469]) + (Ord (RawData [470]) * 256.0) +
(Ord (RawData [471]) * 65536.0) +
(Ord (RawData [472]) * 4294967296.0); { <- Really! }
If (Logons < MinLogon) or
((UDprint or FormPrint) and
((DownloadK = 0) and (UploadK < 200.0)))
then
{ Not enough Activity -- Ignore }
UserNum := UserNum - 1;
End;
Until EOF (UserFile);
UserNum := UserNum - 1;
Close (UserFile);
End;
Function UDRatio (Data : userrec):Real;
Begin
With Data do
Begin
If (DownloadK = 0) and (UploadK = 0) {Should Never occur}
then {filtered out earlier}
UDRatio := 0.00;
If (DownloadK = 0) and (UploadK <> 0)
then
UDRatio := UploadK;
If (UploadK = 0) and (DownloadK <> 0)
then
UDRatio := 0.00 - (DownloadK);
If (DownloadK <> 0) and (UploadK <> 0)
then
UDRatio := UploadK / DownloadK;
End;
End;
Function PostRatio (Data : userrec):Real;
Begin
With Data do
Begin
If Logons = 0
then
Begin
Writeln (' How the heck can a user have zero logons? ');
Writeln (' Something is REALLY screwed. Find that user');
Writeln (' And delete it, or I won''t continue.');
Writeln (' Abnormal Program Termination. LOG ZERO');
Halt;
End;
PostRatio := Posts / Logons;
End;
End;
Function FormRatio (Data : userrec):Real;
Begin
With Data do
Begin
If (DownloadK = 0) and ((UploadK + (Posts * PValue)) = 0)
then
FormRatio := 0.00;
If (DownloadK = 0) and ((UploadK + (Posts * PValue)) <> 0)
then
FormRatio := UploadK + (Posts * PValue);
If ((UploadK + (Posts * PValue)) = 0) and (DownloadK <> 0)
then
FormRatio := 0.00 - (DownloadK);
If (DownloadK <> 0) and ((UploadK + (Posts * PValue)) <> 0)
then
FormRatio := (UploadK + (Posts * PValue)) / DownloadK;
End;
End;
Function Ratio (NameCode : Str; Data : userrec):Real;
Var
PrntRatio : Real;
Begin
If NameCode = 'UD'
then
PrntRatio := UDRatio (Data);
If NameCode = 'FM'
then
PrntRatio := FormRatio (Data);
If NameCode = 'PL'
then
PrntRatio := PostRatio (Data);
Ratio := PrntRatio;
If PrntRatio >= 100.0
then
Ratio := 99.99;
If PrntRatio <= -100.0
then
Ratio := -99.99;
End;
Procedure WrtGfile (NameCode : Str; Title : Str; Tbl : Boolean);
Var
Fill,
Num : String [2];
Spaces : String [80];
Begin
If Tbl
then
Begin
Spaces := ' ';
Write ('Writing File ');
If Ansi
then
Assign (prntfile, gfilepath+'USERSTAT\'+NameCode+'TABLE.ANS')
else
Assign (prntfile, gfilepath+'USERSTAT\'+NameCode+'TABLE.MSG');
Rewrite (prntfile);
Writeln (prntfile, RegStr+Title+Copy (Spaces, 1, Length (Title)));
Writeln (prntfile, Spaces);
Writeln (prntfile, 'Name | Ratio | Up K | Dn K | Posts | Logons | Last On ');
Writeln (prntfile, '-------------------------------------------------------------------------------');
{ The Jolly German Giant -99.999 28000k 14000k 500 1057 01/01/89}
With UserData [1] do
Begin
Write ('.');
If Ratio (NameCode, UserData [1]) < 0
then
Fill := ''
else
Fill := ' ';
Writeln (prntfile, BlnkStr+Copy (Name, 1, 26)+
Copy (Spaces, 1, 26 - Length (Name)), Fill,
Ratio (NameCode, UserData [1]):6:3, ' ',
UploadK:5:0, 'k ',
DownloadK:5:0, 'k ',
Posts:5, ' ',
Logons:5, ' ', Laston);
End;
For Loop := 2 to UserNum do
With UserData [Loop] do
Begin
Write ('.');
If Ratio (NameCode, UserData [Loop]) < 0
then
Fill := ''
else
Fill := ' ';
Writeln (prntfile, RegStr+Copy (Name, 1, 26)+
Copy (Spaces, 1, 26 - Length (Name)), Fill,
Ratio (NameCode, UserData [Loop]):6:3, ' ',
UploadK:5:0, 'k ',
DownloadK:5:0, 'k ',
Posts:5, ' ',
Logons:5, ' ',
Laston);
End;
Writeln (prntfile, RegStr+Spaces);
Writeln (prntfile,RegStr+' Please note, ratios greater than 100 and less than -100 are truncated ');
Writeln (prntfile,RegStr+' all ratios rounded off to 2 decimal places. ');
Writeln (prntfile, RegStr+Spaces);
If FstSeek = 1
then
Writeln (prntfile, RegStr+' Sysop is included in list')
else
Writeln (prntfile, RegStr+' Sysop is NOT included in list');
end
else
Begin
Spaces := ' ';
Write ('Writing File ');
If Ansi
then
Assign (prntfile, gfilepath+'USERSTAT\'+NameCode+'RATIO.ANS')
else
Assign (prntfile, gfilepath+'USERSTAT\'+NameCode+'RATIO.MSG');
Rewrite (prntfile);
(* {$I-}
If IoResult <> 0
then
Begin
MakeDir (gfilepath+'\USERSTAT');
Rewrite (prntfile);
If IoResult <> 0
then
Begin
Writeln ('Couldn''t write to output file. Sorry.');
Halt;
End;
End;
{$I+}
*) Writeln (prntfile, RegStr+Spaces);
Writeln (prntfile, RegStr+Title+Copy(Spaces, 1, (80 - Length (Title))));
TempStr := ' Run at: ' + dat;
Writeln (prntfile, RegStr+TempStr+Copy(Spaces, 1, (80 - Length (TempStr))));
Writeln (prntfile, RegStr+Spaces);
Writeln (prntfile, RegStr+' BEST WORST ');
Writeln (prntfile, RegStr+Spaces);
Loop := 1;
Num := ' 1';
Write ('.');
With UserData [Loop] do
Name := Name + Copy (Spaces, 1, 30 - Length (Name));
With UserData [UserNum - (Loop - 1)] do
Name := Name + Copy (Spaces, 1, 30 - Length (Name));
Writeln (prntfile, BlnkStr+Num, ' ',
UserData [Loop].Name,
Ratio(NameCode, UserData [Loop]):5:2, ' ',
Num, ' ',
UserData [UserNum - (Loop - 1)].Name,
Ratio (NameCode, UserData [UserNum - (Loop - 1)]):5:2);
For Loop := 2 to HowMany do
Begin
Write ('.');
If Loop > 9
then
Num := Chr (48 + (Loop DIV 10)) + Chr (48 + (Loop - ((Loop DIV 10) * 10)))
else
Num := ' ' + Chr (48 + Loop);
With UserData [Loop] do
Name := Name + Copy (Spaces, 1, 30 - Length (Name));
With UserData [UserNum - (Loop - 1)] do
Name := Name + Copy (Spaces, 1, 30 - Length (Name));
Writeln (prntfile, RegStr+Num, ' ',
UserData [Loop].Name,
Ratio(NameCode, UserData [Loop]):5:2, ' ',
Num, ' ',
UserData [UserNum - (Loop - 1)].Name,
Ratio (NameCode, UserData [UserNum - (Loop - 1)]):5:2);
End;
Writeln (prntfile, RegStr+Spaces);
Writeln (prntfile,RegStr+' Please note, ratios greater than 100 and less than -100 are truncated ');
Writeln (prntfile,RegStr+' all ratios rounded off to 2 decimal places. ');
Writeln (prntfile, RegStr+Spaces);
If FstSeek = 1
then
Writeln (prntfile, RegStr+' Sysop is included in list')
else
Writeln (prntfile, RegStr+' Sysop is NOT included in list');
End;
Writeln (prntfile, ResetStr);
Close (prntfile);
End;
Procedure ProcessData;
Var
Exit : Boolean;
Temp : UserRec;
Begin
{ NOTE: UserNum when entering this procedure contains the number of
users that were read in. (ie Active, non-deleted, and with
activity) }
If (UserNum < (HowMany * 2)) AND Not (MakeTbls)
then
Begin
Writeln (' I''m sorry, you have less than ', Howmany * 2, ' active users. USERSTAT');
Writeln (' cannot accurately process your userlist. For more help');
Writeln (' contact 1@16 WWIVnet The Jolly German Giant USR LST SHRT');
Writeln (' Abnormal Program Termination ');
Halt;
End;
If UDPrint
then
Begin
Repeat
Exit := True;
For Loop := 1 to (UserNum - 1) do
Begin
If UDRatio (UserData [Loop]) < UDRatio (UserData [Loop + 1])
then
Begin
Temp := UserData [Loop];
UserData [Loop] := UserData [Loop + 1];
UserData [Loop + 1] := Temp;
Exit := False;
End;
End;
Until Exit;
WrtGfile ('UD',' Upload / Download Ratio', MakeTbls);
End;
If FormPrint
then
Begin
Repeat
Exit := True;
For Loop := 1 to (UserNum - 1) do
Begin
If FormRatio (UserData [Loop]) < FormRatio (UserData [Loop + 1])
then
Begin
Temp := UserData [Loop];
UserData [Loop] := UserData [Loop + 1];
UserData [Loop + 1] := Temp;
Exit := False;
End;
End;
Until Exit;
WrtGfile ('FM', ' [Upload K + (Posts x '+PVS+'K)] / Download K Ratio', MakeTbls);
End;
If PostPrint
then
Begin
If FormPrint or UDPrint
then { ReRead the user data, this time ignore transfer activity}
Begin
FormPrint := False;
UDPrint := False;
ReadUserData;
End;
Repeat
Exit := True;
For Loop := 1 to (UserNum - 1) do
Begin
If PostRatio (UserData [Loop]) < PostRatio (UserData [Loop + 1])
then
Begin
Temp := UserData [Loop];
UserData [Loop] := UserData [Loop + 1];
UserData [Loop + 1] := Temp;
Exit := False;
End;
End;
Until Exit;
WrtGfile ('PL', ' Post to Logon Ratio', MakeTbls);
End;
End;
Procedure ReadCmdLine;
Var
Param : Char;
Code : Integer;
Begin
{ /kxx sets the k per post defaults to 3
/s tells it not to count the sysop
/u will print out the up/down ratios
/p will print the post to logon ratios
/f will print the "formula" ratios
/l sets the minimum logons defaults to 10
/dia prints out special message
/a generates ANSI color messages
/t generates tables (all users)
}
HowMany := 10;
MakeTbls := False;
UDPrint := False;
PostPrint := False;
FstSeek := 1;
FormPrint := False;
Ansi := False;
For Loop := 1 to ParamCount do
Begin
Param := Copy (ParamSTR (loop), 2, 1);
Case Upcase (Param) of
'A' : Ansi := True;
'D' : Begin
Writeln (' This software written by The Jolly German Giant 1@16 WWIVnet ');
Writeln (' Fred''s Floating Bar and Grill (213) 479-7043 300/1200/2400/19.2k baud');
Writeln (' Software dedicated to Dia Warren.. <aww> ');
End;
'F' : FormPrint := True;
'K' : Begin
Val (Copy (ParamSTR (Loop), 3, Length (ParamSTR (loop)) - 2),
PValue, Code);
PVS := Copy (ParamSTR (Loop), 3, Length (ParamSTR (loop)) - 2);
If Code <> 0
then
Begin
Writeln (' P value ignored, defaults to 3K per post ');
PValue := 3;
PVS := '3';
End
else
Begin
Writeln;
Writeln ('*** Posts now count as ', PVS,'K uploads');
Writeln;
End;
End;
'L' : Begin
Val (Copy (ParamSTR (Loop), 3, Length (ParamSTR (loop)) - 2),
MinLogon, Code);
Writeln;
Writeln;
Writeln ('*** Must have ',MinLogon, ' logons to be included.');
Writeln;
Writeln;
If Code <> 0
then
Begin
Writeln (' L value ignored, defaults to 10 logons ');
MinLogon := 10;
End;
End;
'N' : Begin
Val (Copy (ParamSTR (Loop), 3, Length (ParamSTR (loop)) - 2),
HowMany, Code);
Writeln;
Writeln;
Writeln ('*** Will print top and bottom ',HowMany, ' users.');
Writeln;
Writeln;
If (Code <> 0) or (HowMany > 99) or (HowMany < 1)
then
Begin
Writeln (' N value ignored, defaults to top & bottom 10. ');
HowMany := 10;
End;
End;
'P' : PostPrint := True;
'S' : FstSeek := 2;
'T' : MakeTbls := True;
'U' : UDPrint := True;
'?' : Begin
Writeln;
Writeln;
Writeln (' USERSTAT ',VER,' by JGG');
Writeln (' Release Date: ', ModDate);
Writeln;
Writeln (' Contact 1@16 or 502@1 for help');
Writeln;
Writeln (' This program should be run from the main WWIV directory ');
Writeln (' as it accesses the CONFIG.DAT file to find the user data');
Writeln;
Writeln (' The following options are available:');
Writeln;
Writeln (' /kxx sets the k per post defaults to 3');
Writeln (' /s tells it not to count the sysop');
Writeln (' /u will print out the up/down ratios');
Writeln (' /p will print the post to logon ratios');
Writeln (' /f will print the "formula" ratios');
Writeln (' /lxx sets the minimum logons defaults to 10');
Writeln (' /a enables ANSI output defaults to off');
Writeln (' /nxx prints top & bottom xx users defaults to 10');
Writeln (' /t generates table for "formula" ratio');
End;
End;
End;
End;
Begin
Writeln ('Running USERSTAT v' + VER + ' '+ MODDATE);
Writeln ('Written by The Jolly German Giant. 1@16 WWIVnet.');
Writeln ('/? provides help screen');
Writeln;
MinLogon := 10; { Set Defaults }
Pvalue := 3;
PVS := '3';
FstSeek := 1;
ReadCmdLine;
If NOT (FormPrint or UDPrint or PostPrint)
then
Halt;
If Ansi
then
Begin
RegStr := #27+NormalAttr;
BlnkStr := #27+BlinkingAttr;
ResetStr := #27+ResetAttr;
End
else
Begin
RegStr := '';
BlnkStr := '';
ResetStr := '';
End;
ReadInit;
ReadUserData;
ProcessData;
Writeln (#27+'[0m');
End.