Added Default exec function

Formatting
This commit is contained in:
ChocoTaco1 2020-12-18 19:53:57 -05:00
parent d339db7b5a
commit ee2f370686

View file

@ -5,15 +5,25 @@
//$Host::dtBanlist = "prefs/dtBanlist.cs"; //$Host::dtBanlist = "prefs/dtBanlist.cs";
if(isFile($Host::dtBanlist)) package dtBan
exec($Host::dtBanlist); {
package dtBan{ function ClassicLoadBanlist()
function BanList::add(%guid, %ipAddress, %days){ {
if (%guid > 0){ $ClassicPermaBans = 0;
if(isFile($Host::dtBanlist))
exec($Host::dtBanlist);
$ClassicWhitelists = 0;
exec($Host::ClassicWhitelist);
}
function BanList::add(%guid, %ipAddress, %days)
{
if (%guid > 0)
$dtBanList::GUID[%guid] = dtBanDay() TAB getBanYear() TAB %days; $dtBanList::GUID[%guid] = dtBanDay() TAB getBanYear() TAB %days;
}
if (getSubStr(%ipAddress, 0, 3) $= "IP:"){ if (getSubStr(%ipAddress, 0, 3) $= "IP:")
{
// add IP ban // add IP ban
%bareIP = getSubStr(%ipAddress, 3, strLen(%ipAddress)); %bareIP = getSubStr(%ipAddress, 3, strLen(%ipAddress));
%bareIP = getSubStr(%bareIP, 0, strstr(%bareIP, ":")); %bareIP = getSubStr(%bareIP, 0, strstr(%bareIP, ":"));
@ -25,15 +35,18 @@ package dtBan{
// write out the updated bans to the file // write out the updated bans to the file
export("$dtBanList*", $Host::dtBanlist); export("$dtBanList*", $Host::dtBanlist);
} }
function banList_checkIP(%client){
function banList_checkIP(%client)
{
%ip = %client.getAddress(); %ip = %client.getAddress();
%ip = getSubStr(%ip, 3, strLen(%ip)); %ip = getSubStr(%ip, 3, strLen(%ip));
%ip = getSubStr(%ip, 0, strstr(%ip, ":")); %ip = getSubStr(%ip, 0, strstr(%ip, ":"));
%ip = strReplace(%ip, ".", "_"); %ip = strReplace(%ip, ".", "_");
%time = $dtBanList::IP[%ip]; %time = $dtBanList::IP[%ip];
if (%time !$= "" && %time !$= "UNBAN"){ if (%time !$= "" && %time !$= "UNBAN")
{
%delta = getBanCount(getField(%time,0), getField(%time,1)); %delta = getBanCount(getField(%time,0), getField(%time,1));
if (%delta < getField(%time,2)) if (%delta < getField(%time,2))
return 1; return 1;
@ -41,10 +54,13 @@ package dtBan{
$dtBanList::IP[%ip] = "UNBAN"; $dtBanList::IP[%ip] = "UNBAN";
} }
return 0; return 0;
} }
function banList_checkGUID(%guid){
function banList_checkGUID(%guid)
{
%time = $dtBanList::GUID[%guid]; %time = $dtBanList::GUID[%guid];
if (%time !$= "" && %time !$= "UNBAN"){ if (%time !$= "" && %time !$= "UNBAN")
{
%delta = getBanCount(getField(%time,0), getField(%time,1)); %delta = getBanCount(getField(%time,0), getField(%time,1));
if (%delta < getField(%time,2)) if (%delta < getField(%time,2))
return 1; return 1;
@ -52,12 +68,15 @@ package dtBan{
$dtBanList::GUID[%guid] = "UNBAN"; $dtBanList::GUID[%guid] = "UNBAN";
} }
return 0; return 0;
} }
}; };
if (!isActivePackage(dtBan)) if (!isActivePackage(dtBan))
activatePackage(dtBan); activatePackage(dtBan);
function getBanCount(%d, %year){ function getBanCount(%d, %year)
{
%dif = getBanYear() - %year; %dif = getBanYear() - %year;
%days += 365 * (%dif-1); %days += 365 * (%dif-1);
%days += 365 - %d; %days += 365 - %d;
@ -65,7 +84,8 @@ function getBanCount(%d, %year){
return %days; return %days;
} }
function dtBanDay(){ function dtBanDay()
{
%date = formattimestring("mm dd yy"); %date = formattimestring("mm dd yy");
%m = getWord(%date,0);%d = getWord(%date,1);%y = getWord(%date,2); %m = getWord(%date,0);%d = getWord(%date,1);%y = getWord(%date,2);
%count = 0; %count = 0;
@ -74,13 +94,17 @@ function dtBanDay(){
%days[4] = "30"; %days[5] = "31"; %days[6] = "30"; %days[4] = "30"; %days[5] = "31"; %days[6] = "30";
%days[7] = "31"; %days[8] = "31"; %days[9] = "30"; %days[7] = "31"; %days[8] = "31"; %days[9] = "30";
%days[10] = "31"; %days[11] = "30"; %days[12] = "31"; %days[10] = "31"; %days[11] = "30"; %days[12] = "31";
for(%i = 1; %i <= %m-1; %i++){
for(%i = 1; %i <= %m-1; %i++)
{
%count += %days[%i]; %count += %days[%i];
} }
return %count + %d; return %count + %d;
} }
function getBanYear(){ function getBanYear()
{
return formattimestring("yy"); return formattimestring("yy");
} }