<config>


//////////////
//
//  Proxy Blocker v1.5.1 by Pri (1st of September 2013)
//  This script requires Metis v2.82 or higher & RoboMX v2.08 http://bit.ly/ldk6C3
//  Website: http://www.renmx.com
//  Forum: http://www.mxpulse.com/board
//
///////  COMMANDS
//
//  !Download - Forcibly check for recent Proxy Servers to Ban that were used in other rooms
//  !Proxy [IP Address] - Check if an IP Address is a known Proxy Server or not
//  !ProxyPardon [IP Address] - Allows you to whitelist an IP to allow them to bypass the Proxy Blocker when they enter
//  !Proxy Status - Check the status of the Proxy Blocker and its API's
//  !ProxyLockdown On/Off - Allow the script to lock down your room when a large proxy spam attack is detected inside your room (Default is Off)
//
///////  SERVER SUPPORT
//
//  WCS, RCS, ZCS, RSWCS, and FXServer are all supported out of the box
//  ZCS support is limited, WCS, RSWCS or FXServe are recommended.
//
//////////////


<OnEnter type="script">
// Clear some variables for a clean run
<out type="pop" extdata="Proxy_UI_Result"/>
<out type="pop" extdata="Private_IP_Detected"/>
// Break if the IP is private (127.0.0.1, 192.168.x.x, 10.0.x.x and so on)
<out type="push" extdata="Joined_IP">:%IP%</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%IP%" rvalue="127.0.0.1">1</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%IP%" rvalue="0.0.0.0">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":169.254.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.16.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.17.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.18.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.19.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.20.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.21.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.22.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.23.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.24.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.25.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.26.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.27.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.28.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.29.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.30.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.31.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":192.168.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":10.">1</out>
// Break here if a Private IP Was detected
<out type="break" condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1"></out>
// Check that the user has the correct version of Metis to run this script by quering server and checking for a file, if this file doesn't display right tell the user to update
// The reason this variable is called Pulse is because it shares this variable among all my scripts to make sure the right Metis is being used, saves queries
<out type="push" extdata="Pulse_Metis_Check" condition="!=" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue="6042117849"><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
// Check if the user is using a compatible version of Metis or not and also check if the server is online or not
<out type="break" condition="?" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue="Error: The operation timed out"></out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849"></out>
// Perform an online check to see if this version of Metis is supported by this script or not
<out type="push" extdata="Prox_Script_Compatability_Check" condition="==" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue=""><operator type="readweb" nvalue="http://metis.mxpulse.com/script.compatibility.ini" lvalue="l" rvalue="1"/></out>
// The proxy blocker now requires version 2.82 of Metis or higher, if the user is not using this version or better tell the admins and break
<out condition="!?" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue="%VERSION%">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#This script requires Metis v2.82 minimum, please upgrade from v%VERSION%#c63#: #c62#http://bit.ly/ldk6C3</out>
<out type="break" condition="!?" lvalue="%USERVAR[Prox_Script_Compatability_Check]%" rvalue="%VERSION%"></out>
// Check that the scripts folder and settings file has been setup. If it hasn't do it.
<out type="push" extdata="Prox_Setup_Check"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" lvalue="l" rvalue="1"/></out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="exec" extdata="1">cmd.exe /c MD C:\Pri.Script.Dependencies\Proxy.Blocker\Cache</out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="sleep" extdata="3000"></out>
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" mode="t">2\nv1.5.1</out>
// Create a Whitelist File if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#A Whitelist file has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You may fill this file with Proxy IP's or Usernames of the people you trust to use Proxy Servers</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" mode="t">You can place Proxy Server IP's OR Usernames in this file, one entry per line, unlimited size, Please do not delete this line explaining how to use the file!\n</out>
// Create an 'Exile to x Room' file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Exileroom_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#An Exile File has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You can put your main room name here for the Proxy Blocker to exile users to it #c63#(#c62#Once Verified#c63#)</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#If you do not need this feature simply leave the file as-is and users will not be exiled anywhere</out>
<out condition="==" lvalue="$Exileroom_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" mode="t">Enter the name of your room on the line directly below this one, Make sure it's the correct address. DO NOT DELETE THIS LINE OR BAD THINGS WILL HAPPEN!\n</out>
// Create a 'Force Login Password' file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="ForceLoginPass_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#A Force Login Password File has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You can put a password here for the Proxy Blocker to log users in with #c63#(#c62#Once Verified#c63#)</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#If you do not need this feature simply leave the file as-is and users will not be logged in. The command that the bot uses for this is /forcelogin so make sure your server supports this command. FXServe, WCS and RSWCS support it.</out>
<out condition="==" lvalue="$ForceLoginPass_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" mode="t">Enter your password on the line directly below this one to have them logged in with it after they enter your room. DO NOT DELETE THIS LINE OR BAD THINGS WILL HAPPEN!\n</out>
// Create the Spam Lockdown settings file if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Lockdown_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#This version of Proxy Blocker supports a new "Lockdown" feature - It is OFF by default but you can activate it by typing #c4#!ProxyLockdown On</out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#When this feature is active the Proxy Blocker is able to stop any and all users from entering your room for up to a maximum of 1 hour when a large proxy attack against your room is detected</out>
<out condition="==" lvalue="$Lockdown_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" mode="t">0\n</out>
// Download some special characters required for this to function (Metis by itself doesn't allow these characters inside the code so they have to be loaded as varibles)
<out type="push" extdata="Special_1" condition="==" lvalue="%USERVAR[Special_1]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.assistant.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Special_3" condition="==" lvalue="%USERVAR[Special_3]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.assistant.txt" lvalue="l" rvalue="3"/></out>
// Check the status of the Proxy Blocker API's - Only under the condition that this is the first run of the Proxy Blocker since the bot started up
<out type="push" extdata="Proxy_Blocker_Status_LSC" condition="==" lvalue="%USERVAR[Proxy_Blocker_Status_LSC]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPEB" condition="==" lvalue="%USERVAR[Proxy_Blocker_Status_WUPEB]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="Proxy_Blocker_Status_MPC" condition="==" lvalue="%USERVAR[Proxy_Blocker_Status_MPC]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPC" condition="==" lvalue="%USERVAR[Proxy_Blocker_Status_WUPC]%" rvalue=""><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="1"/></out>
// If the IP supplied to the bot is blank then load in the Access Level reminder counter (should be blank at first, then goes up to 3+)
<out type="push" extdata="ReminderCount" condition="==" lvalue="%IP%" rvalue=""><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Bot.Access.Level.Reminder.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="ReminderCount" condition="==" lvalue="%IP%" rvalue=""><operator type="+" lvalue="$ReminderCount$" rvalue="1"/></out>
<out condition="==" lvalue="%IP%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Bot.Access.Level.Reminder.ini" mode="t">$ReminderCount$</out>
// Break if the IP is blank then tell the Admins that they need to give their Bot high enough access to see IP Addresses
<out type="goto" extdata="3" condition=">" lvalue="$ReminderCount$" rvalue="3"></out> 
<out condition="==" lvalue="%IP%" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#Your bot doesn't have a high enough access level to see the IP's of people who enter your room, Try logging it in as Admin or Host to correct this, or make your bot its own password with the necessary access level</out>
<out condition="==" lvalue="%IP%" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#Reminder #c62#%USERVAR[ReminderCount]%#c9# of 3</out>
<out type="break" condition="==" lvalue="%IP%" rvalue=""></out>
// Sometimes the creation of the Folder for the Setup Check is too slow causing the install check file to not save, so let's just re-attempt that if this is a first time install
<out condition="!=" lvalue="$Prox_Setup_Check$" rvalue="2" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.setup.check.ini" mode="t">2\nv1.5.1</out>
// Reference the Whitelist file incase this user has been given permission to use a Proxy Server in this room
// The whitelist checks for both a designated Proxy Server IP Address and the users Username from this file
<out type="push" extdata="Proxy_Permission">0</out>
<out type="push" extdata="Whitelist_Line">0</out>
<out type="push" extdata="Whitelist_Line"><operator type="+" lvalue="$Whitelist_Line$" rvalue="1"/></out>
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="$Whitelist_Line$"/></out>
<out type="push" extdata="Proxy_Permission" condition="==" lvalue="%NAME%" rvalue="%USERVAR[Whitelist_Result]%">1</out>
<out type="push" extdata="Proxy_Permission" condition="==" lvalue="%IP%" rvalue="%USERVAR[Whitelist_Result]%">1</out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="-5" condition="!=" lvalue="%USERVAR[Whitelist_Result]%" rvalue=""></out>
// Check the Cache for this IP, if the IP is found don't query the IP with the API and just push it to the API Result variable
<out type="push" extdata="Live_Check_Cache_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Live_Check_Cache_Content" condition="==" lvalue="%USERVAR[Live_Check_Cache_Date]%" rvalue="%DAY%"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" lvalue="l" rvalue="2"/></out>
// If the API is requesting the local Cache to be turned off then ignore the cache output and make a web query to the API instead
<out type="push" extdata="Live_Check_Cache_Date" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_LSC]%" rvalue="OFFLINE">Ignore-Cache</out>
// Check the Cache output for a proxy or not and push those variables so that duplicate queries are not made within the past day for this IP
<out type="push" extdata="Proxy_Server_API_Result" condition="==" lvalue="%USERVAR[Live_Check_Cache_Content]%" rvalue="1">Proxy Detected in the Cache</out>
<out type="push" extdata="Proxy_Server_API_Result" condition="==" lvalue="%USERVAR[Live_Check_Cache_Content]%" rvalue="0">0</out>
<out type="goto" extdata="15" condition="==" lvalue="%USERVAR[Live_Check_Cache_Date]%" rvalue="%DAY%"></out>
// Query the Proxy API to see if this IP Address is a proxy or not
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="http://winmxunlimited.net/utilities/api/proxy/?ip=%IP%%USERVAR[Special_1]%winmx=1" lvalue="l" rvalue="1"/></out>
// If the API is reporting the WinMX Unlimited Proxy Check API is offline then change the output from the site to Offline
<out type="push" extdata="Proxy_Server_API_Result" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_WUPC]%" rvalue="OFFLINE">Offline</out>
// If the winmxunlimited API is down use the MXPulse version of the API instead, if MXPulse API is also down break
<out type="push" extdata="Use_MXPulse_API">1</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Live" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="0" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Proxy_Server_API_Result" condition="==" lvalue="1" rvalue="%USERVAR[Use_MXPulse_API]%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Proxy.API.php?ip=%IP%%USERVAR[Special_1]%winmx=1" lvalue="l" rvalue="1"/></out>
// If the API is reporting the WinMX Unlimited Proxy Check API is offline then change the output from the site to Offline
<out type="goto" extdata="3" condition="==" lvalue="%USERVAR[Use_MXPulse_API]%" rvalue="0"></out>
<out type="push" extdata="Proxy_Server_API_Result" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_MPC]%" rvalue="OFFLINE">Offline</out>
<out type="push" extdata="Use_MXPulse_API">1</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Live" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="0" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="break" condition="==" lvalue="%USERVAR[Use_MXPulse_API]%" rvalue="1"></out>
// Format the API output to make it a little nicer
<out type="push" extdata="Proxy_UI_Result">%USERVAR[Proxy_Server_API_Result]%</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Live" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">Tor Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
// If the user had permission to use a proxy do not kick them but tell the admins they are using a proxy if they are
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="0"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c10#%NAME% #c9#is using a Proxy but has permission and won't be kicked. #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
// If a match was found, Kick/Ban and alert admins to this users Proxy use unless they had permission in which case skip this part
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">/banip %IP% 1440</out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">/kick %RAWNAME%</out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c10#%NAME% #c9#is using a Proxy and has had their IP banned for 24 Hours. #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
// If the user has setup the exile in the ".exile.room.ini" file then exile this user to that room if they are not a Proxy Server, Just exile if the user is Whitelisted however
<out type="push" extdata="Exileroom_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.exile.room.ini" lvalue="l" rvalue="2"/></out>
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[Exileroom_Result]%" rvalue=""></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="2" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0"></out>
<out>/exile %RAWNAME% %USERVAR[Exileroom_Result]%</out>
// If the user has setup the forcelogin voice feature then log this user in if they are not a proxy
<out type="push" extdata="ForceLoginPass_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.forcelogin.password.ini" lvalue="l" rvalue="2"/></out>
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[ForceLoginPass_Result]%" rvalue=""></out>
<out type="goto" extdata="2" condition="==" lvalue="%USERVAR[Proxy_Permission]%" rvalue="1"></out>
<out type="goto" extdata="2" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0"></out>
<out>/forcelogin %RAWNAME% %USERVAR[ForceLoginPass_Result]%</out>
// Replace some symbols from the name that just don't work in a httpget request to the web server, and other characters we just don't want saved
<out type="push" extdata="Cleaned_Name">%RAWNAME%</out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_1]%lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_1]%" rvalue="[and]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="\" rvalue="[bslash]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="/" rvalue="[fslash]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="%USERVAR[Special_3]%" rvalue="[dollar]"/></out>
<out type="push" extdata="Cleaned_Name"><operator type="strrep" nvalue="%USERVAR[Cleaned_Name]%" lvalue="#" rvalue="[hash]"/></out>
// Replace some symbols from the Roomname that don't work in httpget requests - Send the roomname to the Analytics API only if a Proxy was kicked from this room
<out type="push" extdata="Cleaned_Room">%ROOMNAME%</out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_1]%lowast;" rvalue="[star]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_1]%" rvalue="[and]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="\" rvalue="[bslash]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="/" rvalue="[fslash]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="%USERVAR[Special_3]%" rvalue="[dollar]"/></out>
<out type="push" extdata="Cleaned_Room"><operator type="strrep" nvalue="%USERVAR[Cleaned_Room]%" lvalue="#" rvalue="[hash]"/></out>
// If this user was detected as using a proxy, send the IP, Username and Room Name to MXPulse (Analytical data for Pri)
<out type="push" extdata="Analytics_Response" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0"><operator type="readweb" nvalue="http://analytics.mxpulse.com/v1/?ip=%IP%&amp;name=%USERVAR[Cleaned_Name]%&amp;room=%USERVAR[Cleaned_Room]%&amp;via=%USERVAR[Proxy_UI_Result]%" lvalue="l" rvalue="1"/></out>
// Create a cache for this IP so that we don't query it again atleast within 24 hours - Don't save this if the API doesn't want a cache created
<out type="goto" extdata="3" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_LSC]%" rvalue="OFFLINE"></out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" mode="t">%DAY%\n1\n%USERVAR[Proxy_UI_Result]%\nBanned from inside your room\n%DAY%</out>
<out condition="==" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%IP%.Live.Cache.ini" mode="t">%DAY%\n0\nNot detected as a Proxy\nUsername: %RAWNAME%</out>
// Check for recent bans on the API and cache those
<out type="self" condition="!=" lvalue="%USERVAR[Proxy_Previous_Download_Minute]%" rvalue="%MINUTE%">!botpreempban</out>
// If there is 3 positive detections in the last 60 seconds then send /limit 5 to the server to stop any other connections
<out type="push" extdata="Proxy_Spam_Counter" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">0</out>
<out type="push" extdata="Prox_Last_Minute" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">%MINUTE%</out>
<out type="push" extdata="Proxy_Spam_Counter" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0"><operator type="+" lvalue="$Proxy_Spam_Counter$" rvalue="1"/></out>
<out type="push" extdata="MINUTEUNTILNEXTHOUR"><operator type="-" lvalue="60" rvalue="%MINUTE%"/></out>
<out type="push" extdata="spam_lockdown_setting"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="4" condition="!=" lvalue="%USERVAR[spam_lockdown_setting]%" rvalue="1"></out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/limit 5</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c8#A proxy based spam attack has been detected in your room. The room has entered into lock down mode. No one will be able to enter your room for %USERVAR[MINUTEUNTILNEXTHOUR]% minutes</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">1\n%HOUR%-%DATE%</out>
If 5 attacks are detected within the past minute tell the admins they can turn the Lockdown feature on (Only give this notice once per day)
<out type="goto" extdata="4" condition="==" lvalue="%USERVAR[spam_lockdown_setting]%" rvalue="1"></out>
<out type="goto" extdata="3" condition="==" lvalue="%USERVAR[Block_Lockdown_Message]%" rvalue="1-%DATE%"></out>
<out condition="==" lvalue="5-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#A large Proxy Spam attack has been detected against your room, you can block this and future large attacks by typing #c4#!ProxyLockdown On</out>
<out type="push" extdata="Block_Lockdown_Message" condition="==" lvalue="5-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">1-%DATE%</out>
// Break here if this is a proxy, only check for updates when the user has not been detected as a proxy
<out type="break" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0"></out>
// Check for an updated version of this script (Now with Auto Update if wget is found!)
<out type="push" extdata="Version_Info">v1.5.1</out>
<out type="pop" extdata="Version_Release_Message"/>
<out type="push" extdata="Version_Check_Date"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Version.Check.Date.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Server_Health" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="Version_Info" condition="!=" lvalue="%USERVAR[Version_Check_Date]%" rvalue="%DATE%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="Version_Release_Message" condition="!=" lvalue="%USERVAR[Version_Info]%" rvalue="v1.5.1"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Version.ini" lvalue="l" rvalue="2"/></out>
// Check if the Version_Server_Health is okay, if it isn't skip this update entirely
<out type="break" condition="!=" lvalue="%USERVAR[Version_Server_Health]%" rvalue="BQ0PC4JUX81KGWL"></out>
// Auto Update Code
<out type="break" condition="==" lvalue="%USERVAR[Version_Info]%" rvalue="v1.5.1"></out>
<out type="push" extdata="wget_check"><operator type="readfile" nvalue="Plugins\wget\wget.exe" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="7" condition="==" lvalue="$wget_check$" rvalue=""></out>
<out type="push" extdata="URL">http://proxy.blocker.mxpulse.com/Version.ini</out>
<out type="push" extdata="Update_Filename"><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="Update_URL"><operator type="readweb" nvalue="$URL$" lvalue="l" rvalue="4"/></out>
<out type="exec" extdata="1">Plugins\wget\wget.exe -q -O Plugins\%USERVAR[Update_Filename]% %USERVAR[Update_URL]%</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#%USERVAR[Version_Info]%#c63#): #c1#Your Proxy Blocker plugin has just downloaded and installed an update.</out>
<out>/mxc load</out>
// Normal Update Code
<out type="goto" extdata="2" condition="!=" lvalue="$wget_check$" rvalue=""></out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c1#A new version (%USERVAR[Version_Info]%) of Proxy Blocker is available.</out>
<out condition="!=" lvalue="%USERVAR[Version_Release_Message]%" rvalue="">/opmsg #c4# · Update Notes#c63#: #c62#%USERVAR[Version_Release_Message]%</out>
<out type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Version.Check.Date.txt" mode="t">%DATE%</out>
</OnEnter>

<command type="script">
<in>!proxy %PARAM%</in>
// Check that the command was used at the beginning of a sentence
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="7"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!proxy "></out>
// Check the status of the Proxy Blocker API's
<out type="push" extdata="Proxy_Blocker_Status_AAPI"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="Proxy_Blocker_Status_LSC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPEB"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="Proxy_Blocker_Status_MPC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="1"/></out>
// Output the status if the user used status as their parameter
<out condition="_?" lvalue="%PARAM%" rvalue="status">#c4#Proxy Blocker API Status#c63#:</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[Proxy_Blocker_Status_LSC]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[Proxy_Blocker_Status_WUPEB]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[Proxy_Blocker_Status_MPC]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[Proxy_Blocker_Status_WUPC]%</out>
<out condition="_?" lvalue="%PARAM%" rvalue="status">%USERVAR[Proxy_Blocker_Status_AAPI]%</out>
<out type="break" condition="_?" lvalue="%PARAM%" rvalue="status"></out>
// Break if the IP is private (127.0.0.1, 192.168.x.x, 10.0.x.x and so on)
<out type="push" extdata="Joined_IP">:%PARAM%</out>
<out type="push" extdata="Private_IP_Detected">0</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%PARAM%" rvalue="127.0.0.1">1</out>
<out type="push" extdata="Private_IP_Detected" condition="==" lvalue="%PARAM%" rvalue="0.0.0.0">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":169.254.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.16.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.17.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.18.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.19.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.20.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.21.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.22.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.23.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.24.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.25.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.26.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.27.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.28.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.29.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.30.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":172.31.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":192.168.">1</out>
<out type="push" extdata="Private_IP_Detected" condition="?" lvalue="%USERVAR[Joined_IP]%" rvalue=":10.">1</out>
<out condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You cannot check an internal IP with the Proxy Blocker</out>
<out type="break" condition="==" lvalue="%USERVAR[Private_IP_Detected]%" rvalue="1"></out>
// Break if input doesn't contain a dot (just a really basic check to see if this is actually an IP Address, it isn't full proof but lots more code would be needed to properly verify input with Metis)
<out condition="!?" lvalue="%PARAM%" rvalue=".">#c62#Your parameter #c63#"#c4#%PARAM%#c63#" #c62#is not a valid IP Address. Valid Example#c63#: #c4#!proxy 137.56.163.46</out>
<out type="break" condition="!?" lvalue="%PARAM%" rvalue="."></out>
// Push the PARAM to a variable so that it works inside the readweb operator
<out type="push" extdata="Proxy_Query_IP">%PARAM%</out>
// Check that the user has the correct version of Metis to run this script by quering server and checking for a file, if this file doesn't display right tell the user to update
// The reason this variable is called Pulse is because it shares this variable among all my scripts to make sure the right Metis is being used, saves queries
<out type="push" extdata="Pulse_Metis_Check" condition="==" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue=""><operator type="readweb" nvalue="http://pulse.protection.mxpulse.com/metis.check.ini" lvalue="l" rvalue="1"/></out>
// Check if the user is using a compatible version of Metis or not and also check if the server is online or not
<out type="break" condition="?" lvalue="%USERVAR[Pulse_Metis_Check]%" rvalue="Error: The operation timed out"></out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You appear to be running an outdated version of Metis.</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You can download the latest one here#c63#: #c62#http://bit.ly/ldk6C3</out>
<out condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#To install this file replace your old Metis.r2x file located in your script plugins folder</out>
<out type="break" condition="!=" lvalue="$Pulse_Metis_Check$" rvalue="6042117849"></out>
// Query the Proxy API to see if this IP Address is a proxy or not
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="http://winmxunlimited.net/utilities/api/proxy/?ip=%USERVAR[Proxy_Query_IP]%" lvalue="l" rvalue="1"/></out>
// If the API is reporting the WinMX Unlimited Proxy Check API is offline then change the output from the site to Offline
<out type="push" extdata="Proxy_Server_API_Result" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_WUPC]%" rvalue="OFFLINE">Offline</out>
// If the winmxunlimited API is down use the MXPulse version of the API instead, if MXPulse API is also down break
<out type="push" extdata="Use_MXPulse_API">1</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Public" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="0" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Proxy_Server_API_Result" condition="==" lvalue="1" rvalue="%USERVAR[Use_MXPulse_API]%"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/Proxy.API.php?ip=%USERVAR[Proxy_Query_IP]%" lvalue="l" rvalue="1"/></out>
// If the API is reporting the WinMX Unlimited Proxy Check API is offline then change the output from the site to Offline
<out type="goto" extdata="3" condition="==" lvalue="%USERVAR[Use_MXPulse_API]%" rvalue="0"></out>
<out type="push" extdata="Proxy_Server_API_Result" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_MPC]%" rvalue="OFFLINE">Offline</out>
<out type="push" extdata="Use_MXPulse_API">1</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Live" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
<out type="push" extdata="Use_MXPulse_API" condition="==" lvalue="0" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
// If both API's failed to give any valid responses then tell the admins both API's are offline and to try again later
<out condition="==" lvalue="%USERVAR[Use_MXPulse_API]%" rvalue="1">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c5#The Proxy Server API Service is currently offline, please try your query again later.</out>
<out type="break" condition="==" lvalue="%USERVAR[Use_MXPulse_API]%" rvalue="1"></out>
// Format the API output to make it a little nicer
<out type="push" extdata="Proxy_UI_Result">%USERVAR[Proxy_Server_API_Result]%</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Public" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Live" rvalue="%USERVAR[Proxy_Server_API_Result]%">Random Public Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="Tor" rvalue="%USERVAR[Proxy_Server_API_Result]%">Tor Proxy</out>
<out type="push" extdata="Proxy_UI_Result" condition="==" lvalue="" rvalue="%USERVAR[Proxy_Server_API_Result]%">0</out>
// Tell the user if the IP they have queries is a proxy server or not
<out condition="==" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#%PARAM%#c63#: #c4#This IP is believed not to be a Proxy Server.</out>
<out condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="0">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#%PARAM%#c63#: #c8#Known Proxy Server #c63#(#c62#%USERVAR[Proxy_UI_Result]%#c63#)</out>
</command>


<command type="script">
<in>!ProxyLockdown on</in>
<in>!ProxyLockdown off</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="15"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!ProxyLockdown "></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Process which command the user typed
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="on" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini">1</out>
<out type="file" mode="t" condition="_?" lvalue="%TRIGGER%" rvalue="off" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.spam.lockdown.setting.ini">0</out>
// Output message to Opmsg explaining which setting was chosen and what it does
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#The #c63#"#c1#Proxy Blocker Lockdown#c63#"#c9# feature has been turned #c8#OFF</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="off">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#When this setting is off the Bot will not attempt to lockdown your room even when it detects a large proxy based spam attack</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#The #c63#"#c1#Proxy Blocker Lockdown#c63#"#c9# feature has been turned #c4#ON</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#When this Setting is On the Bot will be able to block ALL users from being able to enter your room for a maximum of 60 minutes whenever a large proxy spam attack has been detected inside your room</out>
<out condition="_?" lvalue="%TRIGGER%" rvalue="on">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#This feature only supports WCS, RCS, RSWCS, FXServe and ZCS - Other servers may not support it</out>
// End any lockdown currently in progress if the user turned this feature off
<out type="goto" extdata="7" condition="_?" lvalue="%TRIGGER%" rvalue="on"></out>
<out type="push" extdata="Spam_Protect_Status"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="1"/></out>
<out type="break" condition="!=" lvalue="$Spam_Protect_Status$" rvalue="1"></out>
<out>/limit 150</out>
<out>/reload</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#The server has exited Lock Down mode, users are again able to connect to the room, if you want to re-enable this feature for future attacks type #c4#!ProxyLockdown On</out>
<out type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">0\n%HOUR%-%DATE%</out>
// If there is 3 positive detections in the last 60 seconds then send /limit 5 to the server to stop any other connections
<out type="break" condition="_?" lvalue="%TRIGGER%" rvalue="off"></out>
<out type="push" extdata="Proxy_Spam_Counter" condition=">" lvalue="$Proxy_Spam_Counter$" rvalue="3">3</out>
<out type="push" extdata="Prox_Last_Minute" condition="!=" lvalue="%MINUTE%" rvalue="$Prox_Last_Minute$">%MINUTE%</out>
<out type="push" extdata="MINUTEUNTILNEXTHOUR"><operator type="-" lvalue="60" rvalue="%MINUTE%"/></out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/limit 5</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c8#A proxy based spam attack has been detected in your room. The room has entered into lock down mode. No one will be able to enter your room for %USERVAR[MINUTEUNTILNEXTHOUR]% minutes</out>
<out condition="==" lvalue="3-%MINUTE%" rvalue="$Proxy_Spam_Counter$-$Prox_Last_Minute$" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">1\n%HOUR%-%DATE%</out>
</command>


<OnRename type="script">
// This part of the script will check if there is any new IP's to be banned anytime someone in your room changes their username.
// I've used this method because I do not want to use an OnTimer event as Metis only allows 1 to be used per Bot and I wouldn't want to 'steal' your only OnTimer and possibly break other scripts you are using.
// Check for recent bans on the API and cache those
<out type="self" condition="!=" lvalue="%USERVAR[Proxy_Previous_Download_Minute]%" rvalue="%MINUTE%">!botpreempban</out>
</OnRename>


<command type="script">
<in>!botpreempban</in>
<in>!download</in>
// If the channel limit is set to 5 but the hour is up, re-set it back to 150
<out type="push" extdata="Spam_Protect_Status"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="1"/></out>
<out type="goto" extdata="6" condition="!=" lvalue="$Spam_Protect_Status$" rvalue="1"></out>
<out type="push" extdata="Spam_Protect_DateTime"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" lvalue="l" rvalue="2"/></out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/limit 150</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/reload</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c62#The server has exited Lock Down mode, users are again able to connect to the room</out>
<out condition="!=" lvalue="$Spam_Protect_DateTime$" rvalue="%HOUR%-%DATE%" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.proxy.lockdown.cache.ini" mode="t">0\n%HOUR%-%DATE%</out>
// Check if the API is requesting any of the functions of this script to be turned off temporarily
<out type="push" extdata="Proxy_Blocker_Status_LSC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPEB"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="Proxy_Blocker_Status_MPC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="Proxy_Blocker_Status_WUPC"><operator type="readweb" nvalue="http://proxy.blocker.mxpulse.com/API.Status.txt" lvalue="l" rvalue="1"/></out>
// Push the current minute to a variable so another check in the script can make sure this doesn't run more often than once a minute
<out type="push" extdata="Proxy_Previous_Download_Minute">%MINUTE%</out>
// Break here if the Pre-Emptive system has been set to off by the Proxy API
<out type="goto" extdata="2" condition="!_?" lvalue="%TRIGGER%" rvalue="!download"></out>
<out condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_WUPEB]%" rvalue="OFFLINE">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c5#The Pre-Emptive Ban feature has been temporarily disabled, please try again later.</out>
<out type="break" condition="?" lvalue="%USERVAR[Proxy_Blocker_Status_WUPEB]%" rvalue="OFFLINE"></out>
// Generate a random number to be used in the query to the API to make sure the results are not from the readweb cache
<out type="push" extdata="Random_Number">%RANDOMNUM[1337]%</out>
// Pick the appropriate command to be used for different servers. Use /banip as the default however.
<out type="push" extdata="Server_Appropriate_CMD">/banip</out>
<out type="push" extdata="Server_Appropriate_CMD" condition="_?" lvalue="%SERVER%" rvalue="RCS">/hidecmd /banip</out>
<out type="push" extdata="Server_Appropriate_CMD" condition="_?" lvalue="%SERVER%" rvalue="WCS">/hidecmd /banip</out>
// Read in recent ban (start line 20 then go down) - Due to the way this is coded it actually starts with line 21 but its then reduced to line 20 before it begins reading the actual webpage
<out type="push" extdata="Proxy_Server_API_Result_Line">21</out>
// Set the Ban Message to off for a clean run
<out type="push" extdata="IP_Ban_Message">0</out>
// Set the banned IP Count to 0 for a clean run
<out type="push" extdata="Amount_of_Proxies_Banned">0</out>
// Reduce the line we are reading by 1, the reason we read the highest line first is so that Metis can cache all the lines and then reference that, basically for performance
<out type="push" extdata="Proxy_Server_API_Result_Line"><operator type="-" lvalue="%USERVAR[Proxy_Server_API_Result_Line]%" rvalue="1"/></out>
// Read in the webpage on the Line we have selected
<out type="push" extdata="Proxy_Server_API_Result"><operator type="readweb" nvalue="http://winmxunlimited.net/utilities/api/proxy/tools/recentdetections.php?rand=%USERVAR[Random_Number]%" lvalue="l" rvalue="%USERVAR[Proxy_Server_API_Result_Line]%"/></out>
// If the divider [:@:] isn't found in the server output then consider the server bugged out or missing data and skip this line
<out type="goto" extdata="12" condition="!?" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="[:@:]"></out>
// Replace the data seperator with something more Metis friendly
<out type="push" extdata="Proxy_Server_API_Result"><operator type="strrep" nvalue="%USERVAR[Proxy_Server_API_Result]%" lvalue="[:@:]" rvalue="^"/></out>
// Find the new seperator and push the variables on both sides (Left = IP, Right = Proxy Type)
<out type="push" extdata="Found_Divider"><operator type="strrfind" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="^"/></out>
<out type="push" extdata="Cache_Line01"><operator type="strleft" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="$Found_Divider$"/></out>
<out type="push" extdata="Found_Divider"><operator type="+" lvalue="%USERVAR[Found_Divider]%" rvalue="1"/></out>
<out type="push" extdata="Cache_Line02"><operator type="strright" lvalue="%USERVAR[Proxy_Server_API_Result]%" rvalue="$Found_Divider$"/></out>
// Check that this Proxy wasn't already banned in the past 24 hours, if it was then just skip forward to the next IP
<out type="push" extdata="Cache_Line03"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Cache_Line01]%.Live.Cache.ini" lvalue="l" rvalue="5"/></out>
<out type="goto" extdata="5" condition="==" lvalue="%USERVAR[Cache_Line03]%" rvalue="%DAY%"></out>
// Save this Proxy to the local cache so that the system doesn't try and ban it again for 24 hours
<out condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Cache_Line01]%.Live.Cache.ini" mode="t">%DAY%\n1\n%USERVAR[Cache_Line02]%\nPre-emptive Ban from the API\n%DAY%</out>
// Ban the IP in the rooms server
<out condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="">%USERVAR[Server_Appropriate_CMD]% %USERVAR[Cache_Line01]% 1440</out>
<out type="push" extdata="IP_Ban_Message" condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue="">1</out>
// +1 the amount of IP's banned if some IP's were banned
<out type="push" extdata="Amount_of_Proxies_Banned" condition="!=" lvalue="%USERVAR[Cache_Line01]%" rvalue=""><operator type="+" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1"/></out>
// Process this code a few more times or until we reach line 1 in which case finish
<out type="goto" extdata="-14" condition="!=" lvalue="%USERVAR[Proxy_Server_API_Result_Line]%" rvalue="1"></out>
// Proxy Servers were banned message creation
<out type="push" extdata="Proxy_Opmsg_Output" condition=">" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1">%USERVAR[Amount_of_Proxies_Banned]% Proxy Servers have been banned in your room for 24 Hours #c63#(#c62#Pre-Emptive Bans#c63#)</out>
<out type="push" extdata="Proxy_Opmsg_Output" condition="==" lvalue="%USERVAR[Amount_of_Proxies_Banned]%" rvalue="1">%USERVAR[Amount_of_Proxies_Banned]% Proxy Server has been banned in your room for 24 Hours #c63#(#c62#Pre-Emptive Bans#c63#)</out>
// Output to the admins that some IP's were banned if they were banned
<out condition="==" lvalue="%USERVAR[IP_Ban_Message]%" rvalue="1">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#%USERVAR[Proxy_Opmsg_Output]%</out>
<out type="break" condition="==" lvalue="%TRIGGER%" rvalue="!botpreempban"></out>
<out condition="==" lvalue="%USERVAR[IP_Ban_Message]%" rvalue="0">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#No Proxy Servers were found to ban at this time #c63#(#c62#Pre-Emptive Bans#c63#)</out>
</command>

<command type="script">
<in>!ProxyPardon %PARAM%</in>
// Check if the command was typed at the start of a sentence, if not break
<out type="push" extdata="req">%TRIGGER%</out>
<out type="push" extdata="req"><operator type="strleft" lvalue="$req$" rvalue="13"/></out>
<out type="break" condition="!_?" lvalue="$req$" rvalue="!ProxyPardon "></out>
// Check if the Metis version is below v2.83 so we know that %USERMODE% works
<out type="push" extdata="Supports_Usermode">1</out>
<out type="push" extdata="Supports_Usermode" condition="?" lvalue="%VERSION%" rvalue="2.80">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.81">0</out>
<out type="push" extdata="Supports_Usermode" condition="==" lvalue="%VERSION%" rvalue="2.82">0</out>
<out type="goto" extdata="3" condition="!=" lvalue="%USERVAR[Supports_Usermode]%" rvalue="1"></out>
// If the user doesn't have an @ in the User List, tell them they need to login to use this command and break
<out condition="!=" lvalue="%USERMODE%" rvalue="@">#c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#Login and show an #c62#@ #c9#in the userlist to use this command.</out>
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>
// Do a really basic IP Check by checking if the paramter contains a .
<out condition="!?" lvalue="%PARAM%" rvalue=".">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#Your parameter #c63#"#c4#%PARAM%#c63#" #c62#is not a valid IP Address. Valid Example#c63#: #c4#!ProxyPardon 137.56.163.46</out>
<out type="break" condition="!?" lvalue="%PARAM%" rvalue="."></out>
// Create a Whitelist File if one doesn't exsist and tell the admins how to use it
<out type="push" extdata="Whitelist_Result"><operator type="readfile" nvalue="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" lvalue="l" rvalue="1"/></out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#A Whitelist file has been created here#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="">/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#You may fill this file with Proxy IP's or Usernames of the people you trust to use Proxy Servers</out>
<out condition="==" lvalue="$Whitelist_Result$" rvalue="" type="file" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini" mode="t">You can place Proxy Server IP's OR Usernames in this file, one entry per line, unlimited size, Please do not delete this line explaining how to use the file!\n</out>
// Push the user parameter to a variable
<out type="push" extdata="Pardon_User_IP">%PARAM%</out>
// Process which command the user typed
<out type="file" mode="t" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\Cache\%USERVAR[Pardon_User_IP]%.Live.Cache.ini">1\n0\nIP Pardoned by %NAME%\nNo username, only IP Address supplied as this was a pardon placed by an Administrator.</out>
<out type="file" mode="a" extdata="C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini">%USERVAR[Pardon_User_IP]%\n</out>
// Output message to Opmsg explaining this users IP has been pardoned
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#The IP #c63#"#c1#%USERVAR[Pardon_User_IP]%#c63#"#c9# has been added to your local Proxy IP Whitelist</out>
<out>/opmsg #c4#Proxy Blocker #c63#(#c62#v1.5.1#c63#): #c9#To edit the file manually#c63#: #c62#C:\Pri.Script.Dependencies\Proxy.Blocker\.Whitelist.ini</out>
</command>

</config>