PtokaX forum

PtokaX => Support => Topic started by: m4xx on 07 August, 2007, 17:33:53

Title: Leviathan Unreg users
Post by: m4xx on 07 August, 2007, 17:33:53
Okay thanks Mutor, i decided to take the easy way out and just load Leviathan 2.4, but it wont allow unregistered users, i tried searching the script for that part, could you pls show me how to allow UNREGISTERED users pls? Heres my modified code:

Settings = {}
Commands = {}
Functions = {}
tPrefixes = {}
ProtectionTable = {}
RightClickTable = {}
SafeAddressTable = {}
NetworkTable = {}
tabTimers = {n=0}
awayArray = {}

LUA = "Leviathan/Lua/" -- Path to all .lua files
TBL = "Leviathan/Tables/" -- Path to all .tbl files
TXT = "Leviathan/Txt/" -- Path to all .txt files

SettingsFile = "Leviathan/Settings.ini" --
NetworkFile = "Leviathan/Txt/Network.txt" --
SafeAddressFile = ""..TBL.."safeadvert.tbl"

dofile(SettingsFile)
dofile(""..LUA.."functions.lua")
dofile(""..LUA.."commands.lua")
dofile(""..LUA.."kickbancommands.lua")
dofile(""..TBL.."scriptlevel.tbl")
dofile(""..TBL.."scripthelp.tbl")
dofile(""..TBL.."rightclick.tbl")
dofile(""..TBL.."protection.tbl")
dofile(""..TXT.."Hubadvert.txt")

-------------------------------------------------------------
--// Advertising addresses
-------------------------------------------------------------

AddressTable = {
"ath.cx","awenet.org","baanapojat","blogdns","boldlygoingnowhere.org","clanpimp","d2g","deftonzs.com","dns2go",
"dnsalias","dnsdojo","dvrdns.org","dynalias","dyn.ro","dyndns","dyn dns","dynip","dyn-o-saur.com","finx.org","flamenap",
"ftpaccess.cc","galy.szm","getmyip.com","gotdns","game-host.org","game-server.cc","homeunix","hopto.org",
"ham-radio-op.net","hobby-site.com","homedns.org","homeftp","homeip.net","homelinux","homeunix","idlegames",
"ihmemaa.org","ip.org","ipactive","is-a-chef","is-a-geek","isa-geek","kicks-ass","merseine.nu","mine.nu",
"myftp","myftpsite","myip.hu","myphotos.cc","n0 - 1p","n0 .1p","n0 1p","n0 -1p","n0.1p","no - ip","no .ip",
"no dash ip","no ip","no -ip","no.ip","no-ip","n.o.-.i.p"," -ip","org:"," .org","orgdns","podzone","outwar.com","scrapping.cc","selfip","servebeer",
"servebbs","serveftp","servegame","staticip","sytes","shacknet.nu","bet.com","uni.cc","urlcut.com","xs4all","bounceme.net","bounce me",
}
--------------------------------------------------------------
--// Converting functions
--------------------------------------------------------------

tConvertProfile = { ["master"] = "Master", ["op"] = "Operator", ["vip"] = "VIP", ["reg"] = "REG", ["user"] = "User" }
tConvertMode = { ["A"] = "Active", ["P"] = "Passive", [5] = "Socket 5" }
tConvertSwitch = { [0] = "Disabled", [1] = "Enabled" }
tConvertSwitch2 = { ["off"] = "Allowed", ["on"] = "Forbidden" }
tConvertSwitch3 = { ["off"] = "Disabled",  ["on"] = "Enabled" }
tConvertSwitch4 = { [0] = "No", [1] = "Yes" }

Sec = 1000
Min = 60*Sec
Hour = 60*Min
Day = 24*Hour
TmrFreq = 1*Sec
Version = "2.4"

UnknownArrival = function(user,data)
if string.find(data,"UserIP") then
user:SendData(Settings["Bot"]["Name"], "\r\n\r\n\r\n\t"..
"\[ ATTENTION! \]\r\n\t"..
"Since our hub doesnt support $UserIP (v1) anymore, you'll be disconnected immediately.\r\n\t"..
"Please disable sending $UserIP for users in your client or use regular DC++ to enter our hub\r\n\t"..
"That can be found from favourite hubs(this hub)(DCDM++ & R2++)\r\n")
end
end

ConvertInteger = function(value)
if value and value ~= 0 then
return value end end

tProfileName = function(nr)
local name = GetProfileName(nr) or "User" --// Get ProfileName
return name end

GetRegisterInfo = function(name)
local iProfileNumber = GetUserProfile(name) or -1
local sProfileName = GetProfileName(iProfileNumber) or "User"
local sPass = frmHub:GetUserPassword(name)
return sProfileName,iProfileNumber,sPass end

GetShareByUnit = function(Share, Unit)
local tUnits = {
["KB"] = Share / 1024,
["MB"] = Share / 1024 / 1024,
["GB"] = Share / 1024 / 1024 / 1024,
["TB"] = Share / 1024 / 1024 / 1024 / 1024
}
return tUnits[Unit] end

ConvShare = function(share)
local tmes = { "B","KB","MB","GB","TB" } --// Convert Sharesize
local num = 1024
for i = 1,table.getn(tmes) do
local snum = num^i
if (share < snum) or (i==table.getn(tmes)) then
return string.format("%4.2f",share/snum*num).." "..tmes[i]
end end end

GetUptime = function(sec)
local weeks,days,hours,minutes,seconds = math.floor(sec/604800), math.floor(math.mod(sec/86400, 7)), math.floor(math.mod(sec/3600, 24)), math.floor(math.mod(sec/60, 60)), math.floor(math.mod(sec/1, 60))
return weeks,days,hours,minutes,seconds end

---------------------------------------------------------------
--// Main function
---------------------------------------------------------------
Main = function()
RegTimer(Timer1, 240*Min)
if Settings["Bot"]["Advert"] == "on" then RegTimer(Timer2, Settings["Bot"]["AdvertTime"]*Min) end
SetTimer(TmrFreq) StartTimer()
frmHub:UnregBot(Settings["Bot"]["Name"]) frmHub:RegBot(Settings["Bot"]["Name"]) frmHub:SetHubBot(1)
frmHub:SetHubBotIsAlias(1) frmHub:SetHubBotName(Settings["Bot"]["Name"])
frmHub:SetHubBotData(Settings["Bot"]["Name"],Settings["Bot"]["Email"])
if loadfile(SafeAddressFile) then dofile(SafeAddressFile) end
if loadfile(NetworkFile) then dofile(NetworkFile) end
for a,b in pairs(frmHub:GetPrefixes()) do tPrefixes[b] = 1 end
frmHub:SetNickRuleRedirAddr(frmHub:GetRedirectAddress() or "") frmHub:SetNickLenRedirAddr(frmHub:GetRedirectAddress() or "")
frmHub:SetTempBanRedirAddr(frmHub:GetRedirectAddress() or "") frmHub:SetBanRedirAddr(frmHub:GetRedirectAddress() or "")
frmHub:SetRegOnlyRedirect(1) frmHub:SetRegOnly(1) frmHub:SetRegOnlyRedirAddr(frmHub:GetRedirectAddress() or "")
end

---------------------------------------------------------------
--// Timer function
---------------------------------------------------------------

Timer1 = function()
Clear()
end

Timer2 = function()
SendAdMessage()
end

Timer3 = function()
end

Timer4 = function()
end

RegTimer = function(f, Interval)
local tmpTrig = Interval / TmrFreq
assert(Interval >= TmrFreq , "RegTimer(): Please Adjust TmrFreq")
local Timer = {n=0}
Timer.func=f
Timer.trig=tmpTrig
Timer.count=1
table.insert(tabTimers, Timer) end

OnTimer = function()
for i in ipairs(tabTimers) do
tabTimers[i].count = tabTimers[i].count + 1
if tabTimers[i].count > tabTimers[i].trig then
tabTimers[i].count=1
tabTimers[i]:func()
end end end

BuildHelp = function(user, table1, table2, table3)
local line = ""
for a,b in ipairs(table1) do
if table2[b][GetProfileName(user.iProfile)] == 1 then
line = line.."\t  !"..table3[b].."\r\n"
end end return line end

GetRightClick = function(user, table1, table2)
for cmd,level in table1 do
if table1[cmd][GetProfileName(user.iProfile)] == 1 then
if table2[cmd] then
user:SendData(table2[cmd].."&#124;")
end end end end

GetCommandStatus = function(command, profile)
if ScriptLevel[command][profile] == 1 then
return "Enabled"
else
return "Disabled"
end end

ProfileCounter = function(what)
local online,offline = 0,0
local tTable,disp = GetUsersByProfile(what),""
for i,who in pairs(tTable) do
if GetItemByName(who) then online = online + 1 else offline = offline + 1 end
end
disp = disp..""..offline.." "..online
return disp end

MyINFOArrival = function(user, data)
if user.bHasTag then
DoVirusCheck(user)
local Share = user.iShareSize
local Slots = user.iSlots
local Hubs = user.iHubs
return Functions.SlotsHubsShare(user, Hubs, Slots, Share)
end end

DoVirusCheck = function(user)
if user.sEmail and string.find(user.sEmail, "myemail@host.com") then
SendToAll(Settings["Bot"]["Name"],"Possible Win32.Tibick virus user--> "..user.sName)   
user:SendData(Settings["Bot"]["Name"], "Your DC++ system is infected by Win32.Tibick virus. Please clean it before entering our hub!")
user:SendData(Settings["Bot"]["Name"], "For more info double click: http://www.spywareguide.com/product_show.php?id=2108")
end end

ToArrival = function(user, data)
Functions.AdvertCheck2(user,data)
local data = string.sub(data, 1, (string.len(data)-1))
local s,e,to,from,msg = string.find(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.+)")
if to == Settings["Bot"]["Name"] then
user.SendMessage = user.SendPM return Functions.GetCommands(user, data)
end end

ChatArrival = function(user, data)
Functions.AdvertCheck1(user,data)
local data = string.sub(data, 1, (string.len(data)-1))
user.SendMessage = user.SendData return Functions.GetCommands(user, data) end


NewUserConnected = function(user)
if Settings[GetProfileName(user.iProfile)]["LoginInfo"] == "on" then
local Greeting = "It's nice of you to stop by..."
local Prof
local Topic
Prof= GetProfileName(user.iProfile) or "Unregistered User"
Topic = frmHub:GetHubTopic() or "There is no current topic."
local art = string.rep("?",40).."\r\n"
local ul = string.rep("?",13).."\r\n"
local tmp = "\r\n\r\n\t"..art.."\tHub Information:\r\n\t"..ul..

"\tWelcome:\t"..user.sName..", "..Greeting.."\r\n"..
"\tHub Name: \t"..frmHub:GetHubName()..",  "..Topic.."\r\n"..
"\tHubOwner:\t"..Settings["Bot"]["HubOwner"].."\r\n"..
"\tUptime:\t\t"..string.format("%.0f Minutes",frmHub:GetUpTime() / 60).."\r\n"..
"\tPeak Users:\t"..frmHub:GetMaxUsersPeak().."\r\n"..
"\tHub Share:\t"..string.format("%.2f Tb.",frmHub:GetCurrentShareAmount()/(1024 * 1024 * 1024 * 1024)).."\r\n"..
"\tThere Are Now:\t"..frmHub:GetUsersCount().." of "..frmHub:GetMaxUsers().." max users online.\r\n\r\n"..
"\t"..art.."\tYour Information:\r\n\t"..ul..
"\tUsername:\t"..user.sName.."\r\n"..
"\tUser Profile:\t"..Prof.."\r\n"..
"\tIP Address:\t"..user.sIP.."\r\n"..
"\tShare Size:\t"..string.format("%.2f Gb.",user.iShareSize/(1024 * 1024 * 1024)).."\r\n"..
"\tProfile Name:\t"..Prof.."\r\n"..
"\tDC Tag:\t\t"..GetEnable(user.sTag).."\r\n"..
"\tDescription:\t"..GetEnable(user.sDescription).."\r\n"..
"\tEmail:\t\t"..GetEnable(user.sEmail).."\r\n"..
"\tConnection:\t"..GetEnable(user.sConnection).."\r\n\r\n\t"..art..
"\t? [ This information is only being shown to you ] ?\r\n\r\n\t"..art
user:SendData(tmp) end
user:SendData(Settings["Bot"]["Name"])
Functions.SendCommands(user) end

function GetEnable(enable)
if enable == nil or enable == "" or not enable then
enable = "not set"
end
return enable
end

OpConnected = NewUserConnected
--OpConnected = function(user)
-- user:SendData(Settings["Bot"]["Name"])
-- Functions.SendCommands(user) end

KickArrival = function(user, data)
local s,e,name = string.find(data,"$Kick+%s+(%S+)%|")
local victim = GetItemByName(name)
if victim ~= nil then
if ProtectionTable[GetProfileName(user.iProfile)][GetProfileName(victim.iProfile)] == 0 then
user:SendData(Settings["Bot"]["Name"], "You silly mortal... you cant kick profile ["..tProfileName(victim.iProfile).."] with that profile!!!")
victim:SendPM(user.sName, "This kick was blocked by "..Settings["Bot"]["Name"].." from: "..frmHub:GetHubName())
return 1 else end end end

checkSafe = function(msg)
for i = 1,table.getn(SafeAddressTable) do
for a = 1,table.getn(NetworkTable) do
if string.find(msg,SafeAddressTable[i][2],1,true) or string.find(msg,NetworkTable[a][2],1,true) or string.find(msg,"addsafe") or string.find(msg,"addnetwork") or string.find(msg,frmHub:GetHubAddress(),1,true) then
return 1 end end end end

checkForAdvertising = function(msg)
for i = 1,table.getn(AddressTable) do
if string.find(msg,AddressTable[i],1,true)then
return 1 end end end

GetLines = function(startpos, endpos)
local text = ""
for i = startpos, endpos, -1 do
if SafeAddressTable[i] then
text = text.."\tNr: ["..i.."]\t Added by: "..SafeAddressTable[i][1].."\t Address: "..SafeAddressTable[i][2].." \r\n"
end end return text end

GetHubs = function(startpos, endpos)
local text = ""
for i = startpos, endpos, -1 do
if NetworkTable[i] then
text = text.."\t["..i.."]\t"..NetworkTable[i][1].."\t\t"..NetworkTable[i][3].." -------> "..NetworkTable[i][2].." \r\n"
end end return text end

ShowProfileSettings = function(profile)
local txt = ""..(ConvertInteger(Settings[profile]["MinShare"]["Share"]) or "off").." "..Settings[profile]["MinShare"]["Unit"]..""..
"\t\t"..(ConvertInteger(Settings[profile]["MaxShare"]["Share"] or "off").." "..Settings[profile]["MaxShare"]["Unit"]..""..
"\t\t"..(ConvertInteger(Settings[profile]["MinSlots"]) or "off").."\t\t"..(ConvertInteger(Settings[profile]["MaxSlots"]) or "off")..""..
"\t\t"..(ConvertInteger(Settings[profile]["MaxHubs"]) or "off").."\t\t"..(tConvertSwitch2[Settings[profile]["AntiAdvertising"]] or "Disabled")..""..
"\t\t"..(tConvertSwitch3[Settings[profile]["RightClick"]] or "Disabled"))
return txt end

Clear = function()
collectgarbage()
io.flush() end

OnError = function(ErrorMsg)
local sFile = io.open("Leviathan/error.log", "a+")
sFile:write(os.date().." - "..ErrorMsg.."\n")
sFile:close() vError = ErrorMsg
SendPmToNick(Settings["Bot"]["HubOwner"],Settings["Bot"]["Name"],ErrorMsg) end

LoadFile = function(file)
local handle = io.open(file,"r")
if handle then
local sdata = ""
local line = ""
for line in handle:lines() do
sdata = sdata..line.."\r\n"
end
return sdata
else
sdata = "File / command not available!"
return sdata end handle:close() end

Serialize = function(tTable,sTableName,hFile,sTab)
sTab = sTab or ""
hFile:write(sTab..sTableName.." = {\n")
for key,value in tTable do
if (type(value) ~= "function") then
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Serialize(value,sKey,hFile,sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write(sTab.."\t"..sKey.." = "..sValue)
end hFile:write(",\n") end end hFile:write(sTab.."}") end

saveTableToFile = function(file, table, tablename)
local handle = io.open(file,"w")
Serialize(table,tablename,handle)
    handle:close() end

HELP?? PLEASE
Title: Re: Leviathan Unreg users
Post by: Cêñoßy†ê on 07 August, 2007, 17:50:01
Remove these ;)

frmHub:SetRegOnlyRedirect(1) frmHub:SetRegOnly(1) frmHub:SetRegOnlyRedirAddr(frmHub:GetRedirectAddress() or "")


frmHub:SetRegOnlyRedirect(1) = enables registered only redirecting
frmHub:SetRegOnly(1) = makes hub registered users only
frmHub:SetRegOnlyRedirAddr(frmHub:GetRedirectAddress() or "") = adds main redirect address to registered users only redirect
Title: Re: Leviathan Unreg users
Post by: m4xx on 07 August, 2007, 18:40:42
awesome thanks! i did that but now when an unregistered user enters the script stops with the error: "Syntax Leviathan/functions.lua:9: attempt to index field '?' (a nil value)"

--//--
-- Leviathan Private Hub Script by C??o?y??
-- Started 15/8/2005
-- Thx for ?s???? for spelling corrections and beta testing =)
-- Thx Optimus and T?M??r?V?ll?R for help
-- Used parts that i have found from http://board.univ-angers.fr/main.php
--       Many thx to those who recognise ther code (cant remember what i took from where)

-- v.3.0  ALTERATIONS BY Remaster-it   ....  March 2006
-- Added extra profiles Moderator, Netfounder, Super-OP and Admin

-------------------------------------------------------------------------------------------------------------
--//----------------------------------------- Start of settings -----------------------------------------//--
-------------------------------------------------------------------------------------------------------------
KB = 1024 MB = KB*KB GB = MB*KB TB = GB*KB           -- dont touch this line!!!
tSettings = {
["BotName"] = "'TheSource",                 -- Bot's name
["BotEmail"] = "TranceLife.Hub@gmail.com",                -- Bot's E-mail addy
["HubOwner"] = "sp0t",                   -- Hub owners name (antiadvertise sends pm to this nick)
["Notf"] = 1,                                -- Should users get (Feel free to register) msg when connect 1/yes 0/no

--//  Minshare,type,Maxshare,type,minslots,maxslots,maxhubs,antiadvert(1/on 0/off)
[0] = {0,GB,9,TB,0,99,999,0}, -- Master
[1] = {0,GB,9,TB,0,99,999,0}, -- Operator
[2] = {0,GB,9,TB,0,99,999,0}, -- Vip
[3] = {0,GB,9,TB,0,99,999,0}, -- Reg
[4] = {0,GB,9,TB,0,99,999,0}, -- Moderator
[5] = {0,GB,9,TB,0,99,999,0}, -- Netfounder
[6] = {0,GB,9,TB,0,99,999,0}, -- Super-OP
[7] = {0,GB,9,TB,0,99,999,0}, -- Admin
}
-------------------------------------------------------------------------------------------------------------
--//------------------------------------------ End of settings ------------------------------------------//--
-------------------------------------------------------------------------------------------------------------
tCommands = {}
tFunctions = {}
tPrefixes = {}
dofile("Leviathan/functions.lua")
dofile("Leviathan/commands.lua")
dofile("Leviathan/rightclick.lua")

trigs = {
["!\!o - ?p"]=1,["/\/0 - /p"]=2,["ath.cx"]=3,["awenet.org"]=4,["baanapojat"]=5, ["blogdns"]=6,
["boldlygoingnowhere.org"]=7,["clanpimp"]=8,["d2g"]=9,["deftonzs.com"]=10,["dns2go"]=11,["dnsalias"]=12,
["dnsdojo"]=13,["dvrdns.org"]=14,["dynalias"]=15,["dyn.ro"]=16,["dyndns"]=17,["dynip"]=18,["dyn-o-saur.com"]=19,
["finx.org"]=20,["flamenap"]=21,["ftpaccess.cc"]=22,["galy.szm"]=23,["getmyip.com"]=24,["gotdns"]=25,
["game-host.org"]=26,["game-server.cc"]=27,["homeunix"]=28,["hopto.org"]=29,["ham-radio-op.net"]=30,
["hobby-site.com"]=31,["homedns.org"]=32,["homeftp"]=33,["homeip.net"]=34,["homelinux"]=35,["homeunix"]=36,
["idlegames"]=37,["ihmemaa.org"]=38,["ip.org"]=39,["ipactive"]=40,["is-a-chef"]=41,["is-a-geek"]=42,
["isa-geek"]=43,["kicks-ass"]=44,["merseine.nu"]=45,["mine.nu"]=46,["myftp"]=47,["myftpsite"]=48,
["myip.hu"]=49,["myphotos.cc"]=50,["n0 - 1p"]=51,["n0 .1p"]=52,["n0 1p"]=53,["n0 -1p"]=54,["n0.1p"]=55,
["no - ip"]=56,["no .ip"]=57,["no dash ip"]=58,["no ip"]=59,["no -ip"]=60,["no.ip"]=61,["no-ip"]=62,
["orgdns"]=63,["podzone"]=64,["outwar.com"]=65,["scrapping.cc"]=66,["selfip"]=67,["servebeer"]=68,["servebbs"]=69,
["serveftp"]=70,["servegame"]=71,["staticip"]=72, ["sytes"]=73,["shacknet.nu"]=74,["bet.com"]=75,["uni.cc"]=76,
["urlcut.com"]=77,["xs4all"]=78,
}
Version = "3.0"
Main = function()
frmHub:UnregBot(tSettings.BotName)
frmHub:RegBot(tSettings.BotName)
frmHub:SetHubBot(1)
frmHub:SetHubBotIsAlias(1)
frmHub:SetHubBotName(tSettings.BotName)
frmHub:SetHubBotData(tSettings.BotName,"SECURITY AND HELP BOT",tSettings.BotEmail)
if loadfile("Leviathan/Tables/SafeAdvert.tbl") then dofile("Leviathan/Tables/SafeAdvert.tbl") end
for a,b in pairs(frmHub:GetPrefixes()) do tPrefixes[b] = 1 end
frmHub:SetNickRuleRedirAddr(frmHub:GetRedirectAddress() or "")
frmHub:SetNickLenRedirAddr(frmHub:GetRedirectAddress() or "")
frmHub:SetTempBanRedirAddr(frmHub:GetRedirectAddress() or "")
frmHub:SetBanRedirAddr(frmHub:GetRedirectAddress() or "")

end

MyINFOArrival = function(user, data)
tFunctions.ProfileCheck(user,data)
end

ToArrival = function(user, data)
tFunctions.AdvertCheck2(user,data)
local data = string.sub(data, 1, (string.len(data)-1))
local s,e,to,from,msg = string.find(data,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.+)")
if to == tSettings.BotName then
user.SendMessage = user.SendPM return tFunctions.GetCommands(user, data)
end
end

ChatArrival = function(user, data)
tFunctions.AdvertCheck1(user,data)
local data = string.sub(data, 1, (string.len(data)-1))
user.SendMessage = user.SendData return tFunctions.GetCommands(user, data)
end

--===PLACE YOUR ENTRY MESSAGE IN HERE===--

NewUserConnected = function(user)
user:SendData(tSettings.BotName,"")
if tSettings.Notf == 1 then
user:SendData(tSettings.BotName,"")
end
tFunctions.SendCommands(user)

--===PLACE YOUR ENTRY MESSAGE IN HERE===--
end

UserDisconnected = function(user)
end

OpConnected = function(user)
user:SendData(tSettings.BotName,"")
if tSettings.Notf == 1 then
user:SendData(tSettings.BotName,"")
end
tFunctions.SendCommands(user)
end

OpDisconnected = function(user)
end