sub UserKill_Config_Init ( \ Config as UserKill_Config_Type ) ////////////////////////////////////////////////////////////////////// Config.Kill_Days = UserKill_Default_Kill_Days Config.Save_Fee = UserKill_Default_Save_Fee end sub sub UserKill_Config_Load ( \ Config as UserKill_Config_Type ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer dim Line as string ////////////////////////////////////////////////////////////////////// if Exists ( PROGNAME_CFG ) then File_Num = FreeFile open PROGNAME_CFG for input as File_Num if not EOF ( File_Num ) then input #File_Num, Line // Configuration version number would go here. // end if if not EOF ( File_Num ) then input #File_Num, Line if String_Is_Integer ( Line ) then Config.Kill_Days = Val ( Line ) end if end if if not EOF ( File_Num ) then input #File_Num, Line if String_Is_Integer ( Line ) then Config.Save_Fee = Val ( Line ) end if end if close ( File_Num ) else ? PROGNAME_CFG; " configuration file not found." end if end sub sub UserKill_Config_Menu ( \ Config as UserKill_Config_Type ) ////////////////////////////////////////////////////////////////////// dim Config_Changed as boolean dim Option as string*1 dim Default as string*1 dim New_Setting as integer ////////////////////////////////////////////////////////////////////// Config_Changed = false Default = "K" do cls ? Copyright; ". Registered to "; Registration; "." ? ? "If you change the configuration settings, be sure to save"; ? " them if you " ? "want them to stay changed for the next time UserKill is run." ? ? "If UserKill is installed as an event and run while the SysOp" ? "is not logged in, these configuration settings will be used." ? ? "1 -- Days of inactivity to kill users = "; Config.Kill_Days ? "2 -- Fee to maintain inactive account = "; ? Dollars_Str ( Config.Save_Fee ) ? "D -- set all settings to initial installation Defaults" ? "K -- search for inactive users to kill" ? "L -- Load configuration from file" ? "Q -- Quit" ? "S -- Save current configuration settings to file" ? ? "Option ["; Default; "]: "; input Option ? if Option = "" then Option = Default end if Option = UCase ( Option ) select case Option case "1" ? "This setting determines the number of days of inactivity," ? "as based on the user's Last Called and User Since data," ? "before the user is considered eligible to be killed." ? New_Setting = Integer_Ask ( \ "Days of inactivity for killing user ", 0, 999, \ Config.Kill_Days ) if New_Setting <> Config.Kill_Days then Config_Changed = true Config.Kill_Days = New_Setting Default = "S" end if case "2" ? "The inactive user maintenance fee is charged to users'" ? "account balances each time UserKill is run and the" ? "users have been inactive over for the number of days" ? "specified by the inactivity kill days setting. If the" ? "account balance is less than the fee, the user is killed." ? ? "Set this value to 0 to disable killing users." ? "Set this value to 32767 to kill users regardless of" ? "how much they have in their account balances." ? ? "If you run UserKill once a day as an event," ? "set this value to 1 to charge users a penny a day" ? "for inactivity over the limit." ? ? "If you run UserKill once a week as an event," ? "set this value to 70 to charge users a dime a day," ? "on average, for inactivity over the limit." ? New_Setting = Integer_Ask ( \ "Inactive user maintenance fee, in cents ", \ 0, , Config.Save_Fee ) if New_Setting <> Config.Save_Fee then Config_Changed = true Config.Save_Fee = New_Setting end if case "D" ? "Setting to installation defaults..."; UserKill_Config_Init ( Config ) ? "done." Default = "K" Config_Changed = true WaitEnter case "K" UserKill_Run ( Config ) if Config_Changed then Default = "S" else Default = "Q" end if case "L" ? "Loading..."; UserKill_Config_Load ( Config ) ? "done." Default = "K" Config_Changed = false WaitEnter case "Q" exit do case "S" ? "Saving..."; UserKill_Config_Save ( Config ) ? "done." Default = "K" Config_Changed = false WaitEnter case else Beep end select loop if Config_Changed then ? ? "You have changed your configuration settings." ? "You may save these new settings to a file if you want them to" ? "load as currently set each time you run EvalFile." ? ? "Do you want to save your current configuration settings?"; if InputYesNo ( " (y/N): ", false ) then ? "Saving..."; UserKill_Config_Save ( Config ) ? "done." WaitEnter end if end if end sub sub UserKill_Config_Save ( \ Config as UserKill_Config_Type ) ////////////////////////////////////////////////////////////////////// dim File_Num as integer ////////////////////////////////////////////////////////////////////// File_Num = FreeFile open PROGNAME_CFG for output as File_Num ? #File_Num, "1.0" ? #File_Num, Config.Kill_Days ? #File_Num, Config.Save_Fee close ( File_Num ) end sub sub UserKill_Run ( \ Config as UserKill_Config_Type ) ////////////////////////////////////////////////////////////////////// dim Days_Last_Called as long dim Option as string*1 dim User_Found as boolean dim User_Killed as boolean dim User_Rec as UserRecord ////////////////////////////////////////////////////////////////////// ActivityLog ( Program_Name + ": searching for users to kill" ) if EventRunning then MorePrompt Off else Color ( 14 ) ? "Press SPACEBAR to stop searching for users to kill." end if User_Found = GetUser ( User_Rec, "" ) do while User_Found if not EventRunning then if ( Inkey <> "" ) or DisplayStopped then if not InputYesNo ( \ "Continue searching for users to kill? (Y/n): ", true ) then exit sub end if end if end if Color ( 10 ) ? FormatNumber ( User_Rec.UserID, "@####" ); ? " "; Pad ( User_Rec.Name, 25 ); " "; Days_Last_Called = Days_Since ( User_Rec.LastCall ) ? FormatNumber ( Days_Last_Called, "@##" ); " days $"; ? FormatNumber ( User_Rec.SubscriptionBalance / 100, "@##.##" ); ? " "; Color ( 14 ) if Days_Last_Called >= Config.Kill_Days then if Days_Since_Today ( User_Rec.UserSince ) >= Config.Kill_Days then if Trim ( User_Rec.Name ) <> "DEFAULT" then if not User_Is_Never_Delete ( User_Rec ) then if User_Rec.SubscriptionBalance < Config.Save_Fee then if EventRunning then User_Killed = DeleteUser ( User_Rec.UserID ) Color ( 12 ) if User_Killed then ? "KILLED" ActivityLog ( Program_Name + ": killed user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name \ + " (" + Dollars_Str ( User_Rec.SubscriptionBalance ) \ + ")" ) else ? "FAILED" end if Color ( 10 ) else ? Color ( 11 ) ? "(K)ill, (N)ever delete, (Q)uit, [S]pare this time: "; input Option Color ( 14 ) Option = UCase ( Option ) if Option = "K" then User_Killed = DeleteUser ( User_Rec.UserID ) Color ( 12 ) if User_Killed then ? "KILLED" ActivityLog ( Program_Name + ": killed user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name \ + " (" + Dollars_Str ( User_Rec.SubscriptionBalance ) \ + ")" ) else ? "FAILED" end if Color ( 10 ) elseif Option = "N" then if User_Rec.UserID <> User.UserID then FlagSet ( User_Rec.UFlags, FLAG_USER_NEVER_DELETE ) UpdateUser ( User_Rec ) else FlagSet ( User.UFlags, FLAG_USER_NEVER_DELETE ) end if ? "NEVER DELETE" elseif Option = "Q" then if InputYesNo ( "Quit searching for users to kill? (Y/n): ", \ true ) then exit sub else ? "SPARED" end if else ? "SPARED" end if end if else Color ( 12 ) if User.UserID <> User_Rec.UserID then User_Rec.SubscriptionBalance \ = User_Rec.SubscriptionBalance - Config.Save_Fee if UpdateUser ( User_Rec ) then ActivityLog ( Program_Name + ": charged " \ + Dollars_Str ( Config.Save_Fee ) \ + " to user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name ) ? "PAID FEE" else ? "FAILED" end if else User.SubscriptionBalance \ = User.SubscriptionBalance - Config.Save_Fee ActivityLog ( Program_Name + ": charged " \ + Dollars_Str ( Config.Save_Fee ) \ + " to user " \ + FormatNumber ( User_Rec.UserID, "@####" ) \ + " " + User_Rec.Name ) ? "PAID FEE" end if Color ( 10 ) end if else ? "NEVER DELETE" end if else ? "SPECIAL USER" end if else ? "CALLED RECENTLY" end if else ? "CALLED RECENTLY" end if User_Found = GetNextUser ( User_Rec ) loop if not EventRunning then ? ? "End of search." ? WaitEnter end if end sub sub UserKill_Start ( \ byval Registration as string, \ byval Copyright as string ) ////////////////////////////////////////////////////////////////////// dim Config as UserKill_Config_Type ////////////////////////////////////////////////////////////////////// cls ? Copyright; ". Registered to "; Registration; "." ? UserKill_Config_Init ( Config ) UserKill_Config_Load ( Config ) if not EventRunning then UserKill_Config_Menu ( Config ) else UserKill_Run ( Config ) end if end sub