 Rem File: Cmd096.bas
 Rem Sub: Change.Password
 Rem $Include: 'dndbbs.inc'
 Const PassTries=3
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 096 -- Change.Password."
    Color 7,0
    End
 Endif
 Call Change.Password
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Change.PassWord
 On Local Error Goto Err.Trp2
 Graphics.Off=True
 Strng="Change your password(y/n/q)? "
 No.Input.Out="N"
 Call IO.I
 If No Or Quit Then
    Strng="Password not changed."
    Call IO.O
    Exit Sub
 Endif
 If Yes Then
    If Local.Mode And Sysop Then
       Goto New.Password
    Endif
Old.Password:
    VarZ1=VarZ1+1
    If VarZ1>PassTries Then
       Strng="Password entry error!"
       Call IO.O
       Exit Sub
    Endif
    If Lost.Carrier Then
       Exit Sub
    Endif
    Strng="Type in old password for verification:"
    Line.Length=20
    Hidden=True
    Call IO.I
    Hidden=False
    Out2=Ltrim$(Out2)
    Out2=Rtrim$(Out2)
    Out2=Ucase$(Out2)
    Call Cryptograph(Out2)
    Out2=Rtrim$(Out2)
    Strng=UserRecord.PassWord
    Strng=Rtrim$(Strng)
    If Strng<>Out2 Then
       Strng="Passwords don't match!"
       Call IO.O
       Call Sleep.Second(3!)
       Goto Old.Password
    Endif
New.Password:
    VarZ2=VarZ2+1
    If VarZ2>PassTries Then
       Strng="Password entry error!"
       Call IO.O
       Exit Sub
    Endif
    If Lost.Carrier Then
       Exit Sub
    Endif
    Strng="Type in new password(20 char. max.)"
    Call IO.O
    Line.Length=20
    Strng="?"
    Hidden=True
    Call IO.I
    Hidden=False
    If No.Input Then
       Strng="Password not changed."
       Call IO.O
       Exit Sub
    Endif
    Out2=Ucase$(Rtrim$(Ltrim$(Out2)))
    If Len(Out2)<3 Then
       Strng="Password must be at least three characters."
       Call IO.O
       Goto New.Password
    Endif
    Strng2=Out2
    Call Cryptograph(Strng2)
    UserRecord.PassWord=Strng2
    Strng2=Out2
    Call Crypto(Strng2)
    UserRecord.PassWord3=Strng2
    Strng="Password changed."
    Call IO.O
 Endif
Err.Rsm2:
 Exit Sub
Err.Trp2:
 Resume Err.Rsm2
End Sub
