Ban Hostnames by Pri

A place to download and discuss the latest WinMX software by Pri

Moderator: DrGirlfriendMD

User avatar
Pri
Site Admin
Site Admin
Posts: 5433
Joined: Fri Dec 14, 2007 8:59 am

Ban Hostnames by Pri

Thu Oct 15, 2009 5:39 pm

Ban.Hostnames.by.Pri.xml
THIS IS ABANDON-WARE. NO MORE UPDATES TO THIS SCRIPT FROM PRI.
(8.23 KiB) Downloaded 396 times
To add this to your Metis, put the file above in your Metis Pluggins folder and add this line to your MXC.xml
<include file="Ban.Hostnames.by.Pri.xml"/>

Then add some code to your pre-exsisting OnEnter script. If you don't have one of those then just surround that piece of code with <OnEnter type="script"></OnEnter>
Someone on WinMXWorld wanted this made so I've just whipped this up quick and posting it here for you guys. I'm going to post it as a file and in code-tags.

Script edited on 2nd of November due to a small bug.

Code: Select all

<config>

///////////
// 'Ban.Hostnames.by.Pri' Made 15th of October 2009 for Defender
// Script uses code from 'Pri.Installer' an install script for Metis developers available from mxpulse.com & mxmadness.org
// Scroll down to the bottom of the script to view which variables are in use, all variables begin with BH_ for banhost to stop conflicts with other scripts
// Modification of this script is allowed, re-distribution of the script is allowed if you supply credit by Pri somewhere in the scripts header (Like this one)
///////////

<command type="script">
<in>/banhostname %PARAM%</in>
// Check if the command was typed at the start of a sentance, if not break
<out type="push" extdata="BH_CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="BH_CMD_REQ"><operator type="strleft" lvalue="$BH_CMD_REQ$" rvalue="13"/></out>
<out type="break" condition="!_?" lvalue="$BH_CMD_REQ$" rvalue="/banhostname "></out>
// Let the Admins with W access know that this user has attempted to use the /banhostname feature
<out>/hidecmd /gnotice W <%RAWNAME%> #c9#%TRIGGER%</out>
// Check if the dependencies for this script are installed, if not install them
<out type="push" extdata="BH_INSTALL_RESULT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\install.log\installation.logfile.ini" lvalue="l" rvalue="1"/></out>
// If the above log file does not exsist begin installation
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c9#No past install was detected. A new installation will now begin. (v0.1)</out>
// Install main installation folder and log file
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c2#Installing #c57#Main Directory:</out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\install.log</out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\install.log\installation.logfile.ini" mode="t">1\nv0.1\nInstallation Completed on %DATE%, Install initiated by %RAWNAME%</out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c4#Installation of main directory completed. #c63#(#c57#C:\Pri.Script.Dependencies#c63#)</out>
// Install Folder for Ban.Hostnames.by.Pri
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c2#Installing #c57#Ban.Hostnames.by.Pri v0.1</out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Ban.Hostnames</out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c4##c4#Installation of #c63#"#c1#Ban.Hostnames.by.Pri#c63#" #c4#completed #c63#(#c57#C:\Pri.Script.Dependencies\Ban.Hostnames#c63#)</out>
// take the user paramater provided at the start and add it to the Ban file
<out type="file" extdata="C:\Pri.Script.Dependencies\Ban.Hostnames\list.of.hostnames.that.are.banned.ini" mode="a">%PARAM%\n</out>
<out>/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] %PARAM% has been added to the list of banned hostnames</out>
</command>

<command type="script">
<in>/listhostbans</in>
// Check if the command was typed at the start of a sentance, if not break
<out type="push" extdata="BH_CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="BH_CMD_REQ"><operator type="strleft" lvalue="$BH_CMD_REQ$" rvalue="13"/></out>
<out type="break" condition="!_?" lvalue="$BH_CMD_REQ$" rvalue="/listhostbans"></out>
// Check if the script has been installed yet, if it has not break script
<out type="push" extdata="BH_INSTALL_RESULT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\install.log\installation.logfile.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue="">/hidecmd /privnotice %RAWNAME% [#c9#PVT#c8#] #c1#The script has not yet been installed so there cannot be any banned Hostnames</out>
<out type="break"  condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue=""></out>
// Start reading back the file
// Push 0 to the Line Count so we can start reading the file in from Line 1
<out type="push" extdata="BH_FILE_LINE">0</out>
<out type="push" extdata="BH_FILE_LINE"><operator type="+" lvalue="%USERVAR[BH_FILE_LINE]%" rvalue="1"/></out>
<out type="push" extdata="BH_BANHOSTNAME_OUTPUT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Ban.Hostnames\list.of.hostnames.that.are.banned.ini" lvalue="l" rvalue="%USERVAR[BH_FILE_LINE]%"/></out>
<out condition="!=" lvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%" rvalue="">/hidecmd /privnotice %RAWNAME% %USERVAR[BH_BANHOSTNAME_OUTPUT]%</out>
// If we reach the end of the file then stop looping through the file for content and just continue on
<out type="goto" extdata="-3" condition="!=" lvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%" rvalue=""></out>
<out>/hidecmd /privnotice %RAWNAME% Listing Complete</out>
</command>

<command type="script">
<in>/clearhostbans</in>
// Check if the command was typed at the start of a sentance, if not break
<out type="push" extdata="BH_CMD_REQ">%TRIGGER%</out>
<out type="push" extdata="BH_CMD_REQ"><operator type="strleft" lvalue="$BH_CMD_REQ$" rvalue="14"/></out>
<out type="break" condition="!_?" lvalue="$BH_CMD_REQ$" rvalue="/clearhostbans"></out>
// Erase the listing by pushing blank-ness to the file
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Ban.Hostnames\list.of.hostnames.that.are.banned.ini"></out>
<out>/hidecmd /gnotice W The list of Banned Hostnames has been erased by %NAME%</out>
</command>

///////////
// THE CODE BELOW MUST BE INSERTED IN TO YOUR <ONENTER> SCRIPT. IT IS PROVIDED SEPERATELY, ONCE YOU HAVE DONE SO REMOVE THE BELOW CODE FROM THIS FILE
///////////

// Check if the script has been installed yet, if it has not assume no hostnames have been saved and skip this part of the script
<out type="push" extdata="BH_INSTALL_RESULT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\install.log\installation.logfile.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="9" condition="==" lvalue="$BH_INSTALL_RESULT$" rvalue=""></out>
// Push 0 to the Line Count so we can start reading the file in from Line 1
<out type="push" extdata="BH_FILE_LINE">0</out>
<out type="push" extdata="BH_FILE_LINE"><operator type="+" lvalue="%USERVAR[BH_FILE_LINE]%" rvalue="1"/></out>
// Read in the file to BH_BANHOSTNAME_OUTPUT then check it for a hostname that matches
<out type="push" extdata="BH_BANHOSTNAME_OUTPUT"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Ban.Hostnames\list.of.hostnames.that.are.banned.ini" lvalue="l" rvalue="%USERVAR[BH_FILE_LINE]%"/></out>
// If we reach the end of the file just jump all the rest of this
<out type="goto" extdata="5" condition="==" lvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%" rvalue=""></out>
// If a match is found, stop reading in the file and skip to the /kickban part
<out type="goto" extdata="2" condition="_?" lvalue="%HOSTNAME%" rvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%"></out>
// If we reach the end of the file then stop looping through the file for content and just continue on
<out type="goto" extdata="-4" condition="!=" lvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%" rvalue=""></out>
// Ban the user if their Hostname contains a part of the hostname from the banned file
<out condition="_?" lvalue="%HOSTNAME%" rvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%">/hidecmd /kickban %RAWNAME%</out>
// Let Admins with W access know that the user was banned for having the same Hostname as one from the ban file
<out condition="_?" lvalue="%HOSTNAME%" rvalue="%USERVAR[BH_BANHOSTNAME_OUTPUT]%">/hidecmd /gnotice W %NAME% was banned based on their Hostname matching one in the Hostname Ban File</out>


///////////
// variables in use:
// BH_CMD_REQ = Used to check if the command used by the User was from the start of a sentance or not
// BH_INSTALL_RESULT = Used to check if a previous installation of this script has been made
// BH_BANHOSTNAME_OUTPUT = Used to hold data from the current hostname ban file to check it for relevancy
// BH_FILE_LINE = Holds the current line number that the bot is reading from the hostname ban file
///////////

</config>
Attachments
Ban.Hostnames.by.Pri.xml
(8.13 KiB) Downloaded 395 times
]2aven
Member
Member
Posts: 8
Joined: Fri Aug 14, 2009 11:33 pm

Re: Ban by Hostname for Metis

Tue Nov 03, 2009 12:52 am

Nice script Pri .. ty for the update. :mrgreen:
User avatar
Pri
Site Admin
Site Admin
Posts: 5433
Joined: Fri Dec 14, 2007 8:59 am

Re: Ban by Hostname for Metis

Tue Nov 03, 2009 1:03 am

You're welcome :)

Return to “Scripts & WinMX Related Software”

Who is online

Users browsing this forum: No registered users and 1 guest