PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: TecMaster on 03 December, 2004, 10:06:10

Title: Remote update of script
Post by: TecMaster on 03 December, 2004, 10:06:10
I have search but not found a script for admins that allow them to remote update scripts in other network hubs. Someone that can help me with that?
Title:
Post by: Dj_OcTaGoN on 03 December, 2004, 11:18:23
You mean something like this?

-- save string
-- by chill
-- Great script chill ....thx

-- Minor Mods by Mutor
-- Added Right Click Menu
-- Added help
--
--- touched by Herodes 6 / 8 - 2004
--- secured all the folders apart from 'scripts' folder of PtokaX
--- added folder operations ... (create / delete ) 7 / 8 - 2004
--
-- +save filename text
-- e.g. +save txt/textfile.txt text
--
-- +load filename
-- +del filename
-- +list dir
-- +edhelp
--
--
aprof = 0 -- for only masters
secure = "on"  --- change to anything else to be able to access any folder any where on the pc its running on...
thisfile = "texteditor.lua" --- !! SECURITY WARNING !! --- BE SURE TO PUT THE FILENAME OF THIS SCRIPT HERE (replace between the quotes ex: "filename.lua" )
--

function NewUserConnected(curUser)
if curUser.iProfile == aprof then
customCMDS(curUser)
curUser:SendData(" *** Notice :: Right click hub tab for editor commands. ***")
else
return
end
end

OpConnected = NewUserConnected

--$UserCommand 1 X  Where -> 1=Hub Menu 2=User Menu 3=Hub/User Menu
function customCMDS(curUser)
--curUser:SendData("$UserCommand 255 7") --clear the menu first
curUser:SendData("$UserCommand 1 3 [Editor]\\List Dir $<%[mynick]> +list %[line:Folder]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Read File $<%[mynick]> +load %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Save File $<%[mynick]> +save %[line:Path/Filename] %[line:Text]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Delete File $<%[mynick]> +del %[line:Path/Filename]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Create Dir $<%[mynick]> +dirdo %[line:Name of Folder]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Delete Dir $<%[mynick]> +dirdel %[line:Name of Folder]||")
curUser:SendData("$UserCommand 1 3 [Editor]\\Editor Help $<%[mynick]> +edhelp .||")
end

function DataArrival(curUser,data)
if (strsub(data,1,1) == "<") and (curUser.iProfile == aprof) then
local _,_,cmd,fileordir = strfind(data,"^%b<>%s+(%S+)%s+([^|^ ]+)")
if fileordir ~= "" and fileordir ~= nil then
if strfind(fileordir, thisfile) and secure == "on" then
curUser:SendData(curUser.sName, "Sorry I can't allow you to access this file ...")
return 1
else
if cmd == "+save" then
local _,_,sdata = strfind(data,"^%b<>%s+%S+%s+%S+%s+(.*)|$")
if sdata then
SaveFile(fileordir,sdata)
SendPM(curUser,"Saved data to: "..fileordir)
end
return 1
elseif cmd == "+load" then
local sdata = LoadFile(fileordir)
SendPM(curUser,"File Loaded: "..fileordir..",\r\n"..sdata)
return 1
elseif cmd == "+del" then
DelFile(fileordir)
SendPM(curUser,"Deleted File: "..fileordir)
return 1
elseif cmd == "+list" then
if strfind(fileordir, "/%.%.") and secure == "on" then
curUser:SendData(curUser.sName, "You cant access this folder I am afraid ... sorry")
return 1
else
local dir = ListDir(fileordir)
SendPM(curUser,dir)
return 1
end
elseif( strfind(data, "+edhelp" ,1))  then
hmsg = "\r\n"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t\t\t [ Editor Help ]"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
hmsg = hmsg.."\r\n\t+save \t=\tSave to file\t-> 'path/filename' 'text'"
hmsg = hmsg.."\r\n\t+load \t=\tLoad a file\t-> 'path/filename'"
hmsg = hmsg.."\r\n\t+del \t=\tDelete file\t\t-> 'path/filename'"
hmsg = hmsg.."\r\n\t+list \t=\tList folder\t\t-> 'path' [/ = scripts dir]"
hmsg = hmsg.."\r\n\t+dirdo\t=\tCreate folder\t-> 'foldername'"
hmsg = hmsg.."\r\n\t+dirdel\t=\tDelete folder\t-> 'foldername'"
hmsg = hmsg.."\r\n\t+edhelp \t=\tShow help"
hmsg = hmsg.."\r\n\t--<>----------------------------------------------------------------------------<>--"
SendPM(curUser,hmsg)
return 1
elseif cmd == "!banip" then
local ip = fileordir
local handle = openfile("ipban/"..date("%d%m%Y").."-ipban.txt","a")
write(handle,date("%d/%m/%Y-%H:%M:%S")..", Banner: "..curUser.sName..", Banned IP: "..ip.."\n")
closefile(handle)
elseif cmd == "+dirdo" then
execute("mkdir "..fileordir)
SendPM(curUser,"Created Folder: "..fileordir)
return 1
elseif cmd == "+dirdel" then
if strfind(fileordir, "/%.%.") and secure == "on" then
curUser:SendData(curUser.sName, "You cant delete this folder ... sorry")
return 1
else
execute("rmdir "..fileordir)
SendPM(curUser,"Deleted Folder: "..fileordir)
return 1
end
end
end
end
end
end

function SendPM(curUser,data)
curUser:SendPM(curUser.sName,data)
end


function SaveFile(filename,sdata)
local handle = openfile(filename,"w")
write(handle,sdata)
closefile(handle)
end

function LoadFile(filename)
local handle = openfile(filename,"r")
local sdata = ""
if handle then
sdata = read(handle,"*a")
sdata = gsub(sdata,"|",strchar(166))
sdata = gsub(sdata,"\n","\r\n")
closefile(handle)
end
return sdata
end

function DelFile(filename)
remove(filename)
end

function ListDir(dir)
if (dir == "/") or (dir == "dir") then
dir = ""
end
--execute("dir \""..dir.."\" /a-d /b > dirlist.txt") --Show Directories in bare format
--execute("dir \""..dir.."\" /b > dirlist.txt") --Bare Format
--execute("dir \""..dir.."\" /a-d > dirlist.txt") --Show Directories
execute("dir \""..dir.."\" /o:gn > dirlist.txt") --Show Directories first then files , by name
local sdata = LoadFile("dirlist.txt")
DelFile("dirlist.txt")
return("\r\n"..sdata)
end
Title:
Post by: TecMaster on 03 December, 2004, 14:08:15
Yeah, just like that. Thanks alot.
? trevlig Helg  :))
Title:
Post by: Dj_OcTaGoN on 04 December, 2004, 11:30:29
hehe detsamma  ;)