PtokaX forum

Archive => Archived 5.1 boards => Conversion Requests => Topic started by: -SkA- on 18 November, 2007, 20:28:27

Title: BadFiles conversion
Post by: -SkA- on 18 November, 2007, 20:28:27
...and I really need the conversion of this script too  ::)

-- This script is converted with PtokaX LUA API Converter v0.9 at 11/17/07 11:48:14
---------------------------------------------------------------------------------------------------
-- Advanced BadFile Active Search // Stripped from Thor 6
-- By: NightLitch 2005-03-04
---------------------------------------------------------------------------------------------------
tBadFiles = {

-- {"download123456789.dat" , "NO incomplete .dat"},
-- {".GetRight" , "NO incomplete .getright"},
-- {".antifrag" , "No incomplete .antifrag"},
-- {"_INCOMPLETE_" , "NO incomplete of WinMx"},
-- {".tdc" , "NO incomplete .tdc"},
        {"preteen" , "NO preteen OSTJA!"},
        {"r@ygold" , "NO PRETEEN !"},
{".porn." , "NO .PORN.!!! PERVERT"},
{"masterbating" , "NO .PORN.!!!"},
-- {".vob" , "NO .vob"},
-- {"explorer.scf" , "NO file system in share"},
-- {".mp3.exe" , "NO shit in share! no virus"},
-- {".part.met" , "NO incomplete of emule"},
--      {".dctmp" , "NO incomplete .dctmp"},

}

---------------------------------------------------------------------------
--// Don't Edit below this point if you don't now what you are doing
---------------------------------------------------------------------------

tTimer = {}

OnStartup = function()
RegTimer(SearchForBadFiles, 10*1000, "ActiveBadFileSearch") -- Active Search Each 20 Sec

end

OnTimer = function(tmr)
for i in ipairs(tTimer) do
tTimer[i][3] = tTimer[i][3] + 1
if tTimer[i][3] > tTimer[i][2] then
tTimer[i][3] = 1; tTimer[i][1]()
end
end
end

UDPSRArrival = function(sUser,sData)
Core.GetUserAllData(sUser)
local _,_,From,Path,FileSize,FreeSlots,TotalSlots = string.find(sData, "^%$SR%s+(%S+)%s+(.*)(%d+)%s+(%d+)%/(%d+)")
if tCall["BadFileSearch"] then pcall(tCall["BadFileSearch"],sUser,Path,FileSize) end
end

tCall = {
BadFileSearch = function(sUser,Path,FileSize)
if not sUser.bOperator then
local FileFound, FileReason = BadFiles(string.lower(Path))
if FileFound then
Core.SendToNick(sUser.sNick,"<"..SetMan.GetString(21).."> *** You have been kicked for "..FileReason..". "..Path.." "..Units(FileSize))
BanMan.TempBanIP(sUser.sIP,90,Path,SetMan.GetString(21),true)
Core.Disconnect(sUser)
end
end
end
}

RegTimer = function(Function,Interval,str)
local tmpTrig = Interval / 1000
table.insert(tTimer,{Function,tmpTrig,1,str})
end

Units = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize); local sUnits;
for i in ipairs(tUnits) do
if(intSize < 1024) then sUnits = tUnits[i]; break; else intSize = intSize / 1024; end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

BadFiles = function(PathStr)
for i in ipairs(tBadFiles) do
if string.find(PathStr, string.lower(tBadFiles[i][1]), 1, true) then
return 1,tBadFiles[i][2]
end
end
return nil, "Other Files"
end

SearchForBadFiles = function()
if t == nil then
t =1
if tBadFiles[t] then
Core.SendToAll("$Search "..Core.GetHubIP()..":"..SetMan.GetString(4).." F?F?0?1?"..tBadFiles[t][1])
end
elseif t > #tBadFiles then
t = nil
else
t = t+1
if tBadFiles[t] then
Core.SendToAll("$Search "..Core.GetHubIP()..":"..SetMan.GetString(4).." F?F?0?1?"..tBadFiles[t][1])
else
t = 0
end
end
end


I've tried to convert that with Hungarista's tool but it doesn't works... (no errors from PX).

Thanks!
Title: Re: BadFiles conversion
Post by: -SkA- on 23 November, 2007, 16:46:10
Quote from: Mutor on 18 November, 2007, 23:31:04
FileSearch 1.0 LUA 5.11 [Strict] [API 1 & 2] (http://board.ptokax.ath.cx/index.php?topic=7405.0)

Thank you for that script but the script I've submitted searches for shared files, not for users searches...