Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

BlackUser Deleter Tool

RZA-PT | KilroyPT
Joined
Aug 27, 2007
Messages
936
Reaction score
85
Hi All

Just wrote up a fairly simple blackuser deleter tool (its in PHP till i get my C# down pat)
Whilst the one many of us use is good, you need to manually activate it, and you cant adjust the interval. (5 minutes is good, but would be nice to change it)

I've attached the tool and a shortcut.
The shortcut is to powershell which executes the php script along with the variables parsed.

default is to run on 2 minute intervals, no logging and non verbose.
The shortcut has been specified for logging, verbose and 1 minute intervals.

Place the BUDeleter.php in your PT-Server folder (I.E. C:\PT-Server\)

If that is not where your PT-Server folder lives, then adjust the target for the shortcut

right click -> Properties -> target

Code:
 C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "php 'C:\PT-Server\BUDeleter.php'  -s 1 -l -v"
This is the default I put for the shortcut.
-s specifies sleep period (in minutes)
-l specifies logging (logging is sent to a csv file in the PT-Server folder, entries are one line per file deleted, starting with the date it deleted).
-v specifies verbose
If you're unsure and want to test, specify -t

If you run it in command and type -h it will give you all the help information too.

It's pretty basic but it works,

It does require PHP to be running (if you've not already got it)
And for PHP to be configured properly (that means, if you open CMD and type php it should be able to execute commands, if not, you need to set up php in your system environment variables)

I built this for my server as I have it start with windows as a service (using nssm), i hope its of use to others here.

If you choose to edit the code, do so but please give credit where credits due please (to me for the attached code base)

View attachment BUDeleter.zip
 

Attachments

You must be registered for see attachments list
RZA-PT | KilroyPT
Joined
Aug 27, 2007
Messages
936
Reaction score
85
I've also written the same in powershell for if anyone wants to use it that way

Code:
<#
.SYNOPSIS
This tool will delete all .bur files in the C:\PT-Server\blackuser folder on a recurring timeframe as specified by the user or at a default interval of 2 minutes.
.DESCRIPTION
The tool will run silently unless -verbose is specified.    
.SYNTAX
The following Parameters can be specified
-sleep #     Specifying the sleep interval (in minutes) between cycles of the tool
-log         Enables logging, Default log file is "C:\PT-Server\BUDeleter_log.csv"
-test        Enables testing mode, tool will output which files are deleted but will not delete anything
-logfile     Specifies where to put the log file (output is CSV)
-folder      Specifies the blackuser folder (default is C:\PT-Server\blackuser\)
.EXAMPLE
budeleter.ps1 -sleep 1.5 -log -verbose -logfile C:\logging\bud.csv -folder E:\PT-Server\blackuser
.NOTES
Written By EuphoriA/Phatkone - All Credits To EuphoriA/Phatkone
.LINK
https://kilroypt.ddns.net
#>
param ( 
    [Parameter(mandatory=$false)]$sleep = 2,
    [Parameter(mandatory=$false)][switch]$log = $false,
    [Parameter(mandatory=$false)][switch]$test = $false,
    [Parameter(mandatory=$false)][string]$dir = "C:\Pt-server\blackuser",
    [Parameter(mandatory=$false)][string]$logfile = "C:\PT-Server\BUDeleter_Log.csv"
)
$verbose = $PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent 
function BUDelete 
{
    $search = get-childitem -path $dir -filter "*.bur" -ErrorAction SilentlyContinue
    foreach ($item in $search)
    {
        if (!$test)
       {
            $fulldir = $dir + "\" + $item.Name
            remove-item $fulldir
            if ($verbose)
            {
                write-host $item.Name Deleted...
            }
            if ($log)
            {
                if (!(test-path $logfile))
                 {
                    new-item $logfile > null
                    add-content $logfile "Date, File" -ErrorAction SilentlyContinue
                }
                $date = Get-Date -UFormat "%Y-%m-%d"
                $name = $item.Name
                add-content $logfile "$date,$name" -ErrorAction SilentlyContinue
            }
        }
       else
        {
            write-host Deleting $item.Name
        }
    }
}
function is_numeric($value) 
{
    return $value -notmatch "^[\d\.]+$"
}
while (is_numeric($sleep) == $false)
{
    [decimal] $sleep = read-host "Invalid Sleep Value. Please enter a numeric value"
}
$sleepmin = $sleep * 60
write-host "$dir will be scanned every $sleep minute(s)." -ForegroundColor Red -BackgroundColor Black
while (1)
{
    if ($verbose)
    {
        write-host Executing
    }
    BUDelete
    start-sleep $sleepmin
}
 
Last edited:
Back
Top