'$include "..\Log_Scan\Log_Scan.WCS" sub Door_Opened ( \ byval Line as string ) ////////////////////////////////////////////////////////////////////// dim Door_Num as integer ////////////////////////////////////////////////////////////////////// Line = Trim ( Line ) Line = Right ( Line, len ( Line ) - len ( Log_Str_Door ) ) Line = Left ( Line, InStr ( Line, " executed " ) - 1 ) Door_Num = Val ( Line ) ? "Door "; Door_Num Door_Count ( Door_Num ) = Door_Count ( Door_Num ) + 1 end sub sub Door_Sort_Init ////////////////////////////////////////////////////////////////////// dim Line_Num as long dim Door_Num as integer dim Line as string ////////////////////////////////////////////////////////////////////// for Door_Num = 1 to Door_Max Door_Count ( Door_Num ) = 0 next Door_Num if Exists ( DoorSort_BBS ) then open DoorSort_BBS for input as #2 Line_Num = 0 while not EOF ( 2 ) input #2, Line Line_Num = Line_Num + 1 if Line_Num >= 6 then Door_Num = Val ( Mid ( Line, 1, 5 ) ) Door_Count ( Door_Num ) = Val ( Mid ( Line, 8, 10 ) ) end if wend close ( 2 ) end if end sub sub Door_Sort ( \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Line_Num as integer dim Door_Num as integer dim Line as string dim File_Num as integer dim File_Num_2 as integer dim File_Num_3 as integer dim DoorSort_DateTime as DateTime ////////////////////////////////////////////////////////////////////// SortStart for Door_Num = 1 to Door_Max SortAdd ( \ FormatNumber ( Door_Count ( Door_Num ), "@#########" ), Door_Num ) next Door_Num Door_Num = SortPrev File_Num = FreeFile open DoorSort_BBS for output as File_Num ? #File_Num, "Doors Sorted by Popularity ("; CurrentDateTime ( DoorSort_DateTime ) ? #File_Num, FormatDate ( DoorSort_DateTime.D, "yyyy-mm-dd" ); " "; ? #File_Num, FormatTime ( DoorSort_DateTime.T, "hh:mm" ); ? #File_Num, ")" ? #File_Num, Copyright ? #File_Num, "" ? #File_Num, "Door# Times Used" ? #File_Num, "----- ----------" if Exists ( DoorList_BBS ) then CopyFile ( Doors_BBS, Doors_Old ) File_Num_3 = FreeFile open Doors_BBS for output as File_Num_3 if Exists ( DoorHead_BBS ) then File_Num_2 = FreeFile open DoorHead_BBS for input as File_Num_2 while not EOF ( File_Num_2 ) input #File_Num_2, Line print #File_Num_3, Line wend close ( File_Num_2 ) else ? DoorHead_BBS + " missing." end if else ? DoorList_BBS + " missing." end if while Door_Num >= 0 ? FormatNumber ( Door_Num, "#####" ); " "; ? FormatNumber ( Door_Count ( Door_Num ), "##########" ) if Door_Count ( Door_Num ) > 0 then ? #File_Num, FormatNumber ( Door_Num, "#####" ); " "; ? #File_Num, FormatNumber ( Door_Count ( Door_Num ), "##########" ) end if if Exists ( DoorList_BBS ) then File_Num_2 = FreeFile open DoorList_BBS for input as File_Num_2 Line_Num = 0 Line = "" do if EOF ( File_Num_2 ) then Line = "" exit do end if Line_Num = Line_Num + 1 if Line_Num > Door_Num then exit do end if input #File_Num_2, Line if Line_Num = Door_Num then exit do end if loop close ( File_Num_2 ) if Trim ( Line ) > "" then ? #File_Num_3, Line end if end if Door_Num = SortPrev wend if Exists ( DoorList_BBS ) then if Exists ( DoorTail_BBS ) then File_Num_2 = FreeFile open DoorTail_BBS for input as File_Num_2 while not EOF ( File_Num_2 ) input #File_Num_2, Line print #File_Num_3, Line wend close ( File_Num_2 ) else ? DoorTail_BBS + " missing." end if close ( File_Num_3 ) end if close ( File_Num ) end sub sub Downloaded ( byval Line as string, \ byval Download_Tmp as string ) ////////////////////////////////////////////////////////////////////// dim File_Name as string*12 dim File_Num_Download as integer dim Cost as integer dim FileRec as FileRecord ////////////////////////////////////////////////////////////////////// Line = Mid ( Line, InStr ( Line, "[" ) + 1, 13 ) File_Name = Left ( Line, InStr ( Line, "]" ) - 1 ) ? "Downloaded: "; File_Name File_Num_Download = FreeFile open Download_Tmp for append as File_Num_Download ? #File_Num_Download, Pad ( File_Name, 12 ); " "; Cost = 0 if GetFileInfo ( FileRec, File_Name ) then Cost = FileRec.Cost end if ? #File_Num_Download, "$"; FormatNumber ( Cost / 100, "@##.##" ) close ( File_Num_Download ) end sub sub Downloads_By_Users ////////////////////////////////////////////////////////////////////// dim User_ID_Str as string dim User_ID as long dim UserRec as UserRecord dim User_Dir as string ////////////////////////////////////////////////////////////////////// ? "User ID number or name ["; User.UserID; "]: "; input User_ID_Str if User_ID_Str = "" then User_ID = User.UserID else User_ID_Str = UCase ( Trim ( User_ID_Str ) ) User_ID = Val ( User_ID_Str ) if Str ( User_ID ) <> User_ID_Str then if GetUser ( UserRec, User_ID_Str ) then User_ID = UserRec.UserID else ? "User name "; User_ID_Str; " not found." WaitEnter exit sub end if else ? "User not found." WaitEnter exit sub end if end if User_Dir = UserData_Program_Dir ( User_ID, "", PROGRAM_DIR, false ) if Exists ( User_Dir + "\" + Download_Txt ) then ? ? "DOWNLOADS for User ID Number "; User_ID ? ReadBackOpen ( User_Dir + "\" + Download_Txt ) do while not ReadBackTOF ? ReadBackNext if DisplayStopped then exit do end if loop ReadBackClose WaitEnter else ? "No record of downloads found for user ID number "; ? User_ID; "." WaitEnter end if end sub sub Dropped_Carrier_Add ( \ byval User_Name as string ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer ////////////////////////////////////////////////////////////////////// File_Num = FreeFile open DropCarr_BBS for append as File_Num ? #File_Num, User_Name close ( File_Num ) end sub sub Dropped_Carrier_Init ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim DropCarr_DateTime as DateTime ////////////////////////////////////////////////////////////////////// File_Num = FreeFile open DropCarr_BBS for output as File_Num ? #File_Num, Copyright ? #File_Num, Registration ? #File_Num, "" CurrentDateTime ( DropCarr_DateTime ) ? #File_Num, FormatDate ( DropCarr_DateTime.D, "yyyy-mm-dd" ); " "; ? #File_Num, FormatTime ( DropCarr_DateTime.T, "hh:mm" ) ? #File_Num, "" ? #File_Num, "USERS WHO DROPPED CARRIER" ? #File_Num, "-------------------------" close ( File_Num ) end sub function Login ( byval Line as string ) as string ////////////////////////////////////////////////////////////////////// dim Login_User as string ////////////////////////////////////////////////////////////////////// Login = "" if Line ( 3 ) <> ":" then exit function end if if ( InStr ( Line, "[" ) = 0 ) or ( InStr ( Line, "]" ) = 0 ) then exit function end if Login_User = Mid ( Line, 7, InStr ( Line, " [" ) - 6 ) ? "Login: "; Login_User Login = Login_User end function sub Main_Loop ( \ Downloads_Found as boolean, \ byval First_Sweep as boolean, \ byval Temp_File as string, \ byval Copyright as string,\ byval Node_Str as string, \ byval Download_Tmp as string ) ////////////////////////////////////////////////////////////////////// dim Login_User as string dim Line as string dim Dropped_Carrier as boolean ////////////////////////////////////////////////////////////////////// do while not ReadBackTOF Line = READBACKNEXT if InStr ( Line, Log_Str_Login ) <> 0 then Login_User = Login ( Line ) if Login_User <> "" then if Dropped_Carrier then ? "Dropped carrier: "; Login_User Dropped_Carrier_Add ( Login_User ) Dropped_Carrier = false end if if Downloads_Found then File_Text_Append ( Download_Tmp, \ UserData_Program_Dir ( \ UserID_From_UserName ( Login_User ), Login_User, \ PROGRAM_DIR ) + "\" + Download_Txt ) if PROGRAM_DIR = "EVALFILE" then File_Text_Insert ( Download_Tmp, \ UserData_Path ( UserID_From_UserName ( Login_User ), \ Login_User ) + PROGRAM_DIR + "\" + Unevaled_Txt ) end if Downloads_Found = false del Download_Tmp if not First_Sweep then exit do end if end if end if elseif Instr (Line, Log_Str_Scanned) <> 0 then exit do elseif Instr ( Line, Log_Str_Dropped_Carrier ) <> 0 then Dropped_Carrier = true elseif First_Sweep then if Instr (Line, Log_Str_Wrong_Password ) <> 0 then Wrong_Password ( Line, Temp_File, Copyright ) elseif InStr ( Line, Log_Str_Door ) <> 0 then if Node_Str = "1" then Door_Opened ( Line ) end if elseif InStr ( Line, Log_Str_Downloaded ) <> 0 then Downloaded ( Line, Download_Tmp ) Downloads_Found = true end if end if loop end sub sub Menu ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Default as string*1 dim Option as string*1 ////////////////////////////////////////////////////////////////////// Default = "C" do Cls Color ( 15 ) ? Copyright ? Registration ? ? "ACTIVITY LOG SCAN INTERACTIVE MENU" ? ? "To run this program automatically, install as a nightly event." ? ? "A -- Abort activity log scan and exit program" ? "B -- Bulletins created from activity log scan" ? "C -- Continue with activity log scan" ? "D -- Download history for a user" ? "U -- Uninstall this BBS utility" ? ? "Option ["; Default; "]: "; input Option if Option = "" then Option = Default end if Option = UCase ( Option ) if Option = "A" then end elseif Option = "B" then Menu_Bulletins ( Registration, Copyright ) elseif Option = "C" then exit sub elseif Option = "D" then Downloads_By_Users elseif Option = "U" then Third_Party_Uninstall ( PROGRAM_DIR ) else Beep end if loop end sub sub Menu_Bulletins ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Default as string*1 dim Option as string*1 ////////////////////////////////////////////////////////////////////// Default = "1" do Cls Color ( 14 ) ? Copyright ? Registration ? ? "Activity Log Scan BULLETINS Menu" ? ? "1 -- Door Statistics ("; DoorSort_BBS; ")" ? "2 -- Users that Dropped Carrier ("; DropCarr_BBS; ")" ? "Q -- Quit to the previous Menu" ? ? "Option ["; Default; "]: "; input Option if Option = "" then Option = Default end if Option = UCase ( Option ) if Option = "Q" then exit sub elseif Option = "1" then if Exists ( DoorSort_BBS ) then DisplayTextFile ( DoorSort_BBS ) else ? DoorSort_BBS; " file not found." end if WaitEnter Default = "2" elseif Option = "2" then if Exists ( DropCarr_BBS ) then DisplayTextFile ( DropCarr_BBS ) else ? DropCarr_BBS; " file not found." end if WaitEnter Default = "Q" else Beep end if loop end sub sub Log_Scan_Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// dim Temp_File as string Dim Line As String Dim linenumber As Integer Dim tried As String Dim victim As String Dim timebaud As String Dim time as String Dim baud as String dim Node_Str as string dim Door_Num as integer dim Downloads_Found as boolean dim First_Sweep as boolean dim Download_Tmp as string ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// if not EventRunning then Menu ( Registration, Copyright ) end if MorePrompt Off Node_Str = Trim ( Str ( MakeWild.NodeID ) ) Temp_File = "Log_Scan." + Node_Str ? "Scanning the activity log for node " + Node_Str + "." if not READBACKOPEN ("activity." + Node_Str ) then Beep ? "Error. Unable to open file activity." + Node_Str + "!" Delay 10 end end if if Node_Str = "1" then Door_Sort_Init end if Dropped_Carrier_Init ( Registration, Copyright ) Download_Tmp = WCWork_Dir + "Download.Tmp" Del ( Download_Tmp ) Downloads_Found = false First_Sweep = true do while not ReadBackTOF Main_Loop ( Downloads_Found, First_Sweep, \ Temp_File, Copyright, Node_Str, Download_Tmp ) if not Exists ( Download_Tmp ) then exit do end if First_Sweep = false loop ReadBackClose Activitylog ( Log_Str_Scanned ) if Node_Str = "1" then Door_Sort ( Copyright ) end if ? Log_Str_Scanned ? "Delaying 5 seconds..." delay 5 end sub sub Wrong_Password ( \ Line as string, \ byval Temp_File as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Tried as string dim Victim as string dim TimeBaud as string dim MsgHdr as MessageHeader ////////////////////////////////////////////////////////////////////// ? trim ( Line ) tried = READBACKNEXT tried = right (tried, len ( tried ) -15) tried = left (tried, len (tried) -2) ? tried victim = Mid (READBACKNEXT, 38) victim = left (victim, len ( victim ) -1) ? victim timebaud = READBACKNEXT timebaud = right ( timebaud, len ( timebaud ) - 6 ) MsgHdr.From = MakeWild.SysopName MsgHdr.FromTitle = "Log Scan" MsgHdr.To = Victim MsgHdr.Subject = "Warning: Bad Login" MsgHdr.Flags = 1 :REM Makes it private open Temp_File for output as #1 ? #1, victim + ":" ? #1, "A failed login attempt was recently made using your username." ? #1, timebaud ? #1, "The user attempted the following passwords:" ? #1, tried ? #1, "" ? #1, "You may want to change your password. If so, be sure to" ? #1, "select a password that you are not using on another BBS." ? #1, "" ? #1, Copyright close #1 Join ( 0 ) AddMessage ( MsgHdr, Temp_File ) Del Temp_File end sub