/***************************************************/
/* $VER: LastUser_4.21 (11 Aug 1994)               */
/* $Filename: logon.rexx $                         */
/* $Version: 4.21 $                                */
/* $Date: 11 Aug 1994 $                            */
/* $Creation: 04 Nov 1993 $                        */
/***************************************************/

parse arg LineNumber
signal on ERROR

DoorName = "LastUser"

if( ~show( 'l', "mebbsarexx.library" ) )then do
   say "Opening mebbsarexx.library"
 if( ~addlib( "mebbsarexx.library", 0, -30, 0 ) )then do
      say "Could not open library"
      exit 10
   end
end

call GetVar DoorName,LineNumber,1  ;  username=result
call GetVar DoorName,LineNumber,4  ;  city=result
call GetVar DoorName,LineNumber,8  ;  gfx=result
call GetVar DoorName,LineNumber,11 ;  calls=result
call GetVar DoorName,LineNumber,18 ;  total_calls=result
call GetVar DoorName,LineNumber,20 ;  access=result

if ~open(baud,'mebbsnet:call.log','R') then do
	bps = "????"
	call START
	end
parse value readln(baud) with word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11
if word10 = "(1200" then bps = "1200"
if word10 = "(2400" then bps = "2400"
if word10 = "(4800" then bps = "4800"
if word10 = "(9600" then bps = "9600"
if word10 = "(14400" then bps = "14k4"
if word10 = "(16800" then bps = "16k8"
if word10 = "(19200" then bps = "19k2"
if word10 = "(21600" then bps = "21k6"
if word10 = "(28800" then bps = "28k8"
if word10 = "(38400" then bps = "38k4"
if word10 = "" then bps = "Local"
call close(baud)

START:
CLS = '[0;0H[J[2J'
path="DOORS:"
a=0
if gfx=0 then do
   ROD    ='[31m'
   GRON   ='[32m'
   GUL    ='[33m'
   BLA    ='[34m'
   LILA   ='[35m'
   CYAN   ='[36m'
   VIT    ='[37m'
   SVART2 ='[40m'
   BLA2   ='[44m'
end
if gfx>=1 then do
   ROD    ='[31m'
   GRON   ='[32m'
   GUL    ='[33m'
   BLA    ='[34m'
   LILA   ='[35m'
   CYAN   ='[36m'
   VIT    ='[37m'
   SVART2 ='[40m'
   BLA2   ='[44m'
end

if ~exists(path'lastuser') then do
   address command 'c:Makedir 'path'lastuser'
   call open(file,PATH'lastuser/lastuser.txt','W')
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call writeln file, " Name                l Axxl City          l Baud l Callsl Logon - Logoffl"
   call close(file)
end

calls=left(calls, 5, '')
time=left(time(), 5, 3)
city=left(compress(CITY'', '0123456789 '), 14, ' ')
city=translate(city, '}{|][\\\{', 'åäöÅÄÖ™”„', ' ')
username=translate(username, '}{|][\\\{', 'åäöÅÄÖ™”„', ' ')
username=left(username, 20, ' ')
access=left(access, 3, '')
bps=left(bps, 4, '')

LastUser=vit"[1m "username""cyan"l "access"[0m"cyan"l "vit"[1m"city"[0m"cyan"l "vit"[1m"Bps "[0m"cyan"l "vit"[1m"calls"[0m"cyan"l "vit"[1m"TIME"[0m"cyan" - [1m"vit"??:??[0m"cyan" l"

call open(logon,PATH'Lastuser/Lastuser.txt','R')
     do until a=9
        a=a+1
        rad.a = readln(logon)
        if length(rad.a)<67 then rad.a=rad.a'Hang! l'
     end
     call close(logon)

lng=length(total_calls)

if access="0" then call WRITE

START:
string=CLS
call output ; string=""
call output ; string="[1m                        LastUser v4.21 for MebbsNet BBS"
call output ; string="    Copyright (c) 1994 Active! Mikael Johansson M6005, All Rights Reserved. [0m"
call output ; string="[37m"
call output ; string=vit" +"cyan"--"vit"+"cyan"---------------------"vit"+"cyan"----"vit"+"cyan"---------------"vit"+"cyan"------"vit"+"cyan"------"vit"+"cyan"-------"vit"+"cyan"-------"vit"+"
call output ; string=vit" l"bla2""vit"##"svart2""vit"l"bla2""vit" Name                "vit"l"bla2""vit" Axx"svart2""vit"l"bla2""vit" City          "svart2""vit"l"bla2""vit" Baud "svart2""vit"l"bla2""vit" Calls"svart2""vit"l"bla2""vit" Logon "svart2""vit"l"bla2""vit" Logoff"svart2""vit"l"
call output ; string=vit" +"cyan"--"vit"+"cyan"---------------------"vit"+"cyan"----"vit"+"cyan"---------------"vit"+"cyan"------"vit"+"cyan"------"vit"+"cyan"---------------"vit"+"
call output ; string=cyan" l"bla2""vit" 1"svart2""cyan"l"LastUser
call output ; string=cyan" l"bla2""vit" 2"svart2""cyan"l"cyan""rad.1
call output ; string=cyan" l"bla2""vit" 3"svart2""cyan"l"CYAN""rad.2
call output ; string=cyan" l"bla2""vit" 4"svart2""cyan"l"CYAN""rad.3
call output ; string=cyan" l"bla2""vit" 5"svart2""cyan"l"CYAN""rad.4
call output ; string=cyan" l"bla2""vit" 6"svart2""cyan"l"CYAN""rad.5
call output ; string=cyan" l"bla2""vit" 7"svart2""cyan"l"CYAN""rad.6
call output ; string=cyan" l"bla2""vit" 8"svart2""cyan"l"CYAN""rad.7
call output ; string=cyan" l"bla2""vit" 9"svart2""cyan"l"CYAN""rad.8
call output ; string=cyan" l"bla2""vit"10"svart2""cyan"l"CYAN""rad.9
call output ; string=vit" +"cyan"--"vit"+"cyan"---------------------"vit"+"cyan"----"vit"+"cyan"---------------"vit"+"cyan"------"vit"+"cyan"------"vit"+"cyan"---------------"vit"+"

if lng=1 then do
	call output
	string=vit" l"bla2"                           Total calls today: "total_calls"                            "svart2"l"
	end

if lng=2 then do
	call output
	string=vit" l"bla2"                           Total calls today: "total_calls"                           "svart2"l"
	end

call output ; string=vit" +"cyan"---------------------------------------------------------------------------"vit"+"
call output ; string="                                                                           "
call output
call HotKey DoorName,LineNumber,"Press any key "

WRITE:
if LineNumber ~= "0" then do
   LastUser=" "username"l "access"l "city"l "bps" l "calls"l "TIME" - "
   call open file, (PATH'Lastuser/Lastuser.txt'), 'W'
   call writeln file, LastUser
   call writeln file, rad.1
   call writeln file, rad.2
   call writeln file, rad.3
   call writeln file, rad.4
   call writeln file, rad.5
   call writeln file, rad.6
   call writeln file, rad.7
   call writeln file, rad.8
   call writeln file, rad.9
   call close file
end

call end_it

output:
call message DoorName,LineNumber,string,1
return 

ERROR:
	string=''                                                      
	call output ; string='*BOOM*  Got an error.  PLEASE notify the sysop.'       
	call output ; string='Line:' SIGL '   Severity:' RC                          
	call output ; string=''                                                      
	call output ; string='PLEASE write down the TYPE of ERROR and the LINE # and'
	call output ; string='leave the SYSOP a message so he may get it corrected.' 
	call output
	call HotKey DoorName,LineNumber,"Press any key "
	call Exit_Door DoorName,LineNumber
	exit 10

end_it:
call DELETE("mebbsnet:call.log")
call OPEN file, ('mebbsnet:call.log'), 'W'
call WRITECH(file,'')
call CLOSE file

call Exit_Door DoorName,LineNumber
exit 0
