local pkg = { [ "var" ] = { [ "linox.ver" ] = "Linox v0.0.1" , [ "mpc-get-repo.rpo" ] = "I staple tape worms on my penis!@#&So the flesh worm will drink brainjuice from your fetus!@#&(4X)!@#&!@#&Feel the blood gushing from your anus!@#&(2X)!@#&!@#&Feel the blood gushing from your anus!@#&(4X)!@#&!@#&Tape worms on my fucking penis!!@#&Penis!!@#&Tape worms!!@#&Tape worms on my penis!!@#&Tape worms on my penis!@#&Tape worms on my peniiiiiii....!" , } , [ "etc" ] = { [ "linoxim" ] = " !@#& 55555 !@#& 54445 !@#& 54e45 !@#& 54e45 555 !@#& 54e45 !@#& 54e45555555 555 55555555 55555 555 555 !@#& 54e44444445 555 55555555 55555 555 555 !@#& 54eeeeeee45 555 555 555 55 55 5555 !@#& 54444444445 555 555 555 55555 555 555 !@#& 55555555555 555 555 555 55555 555 555 !@#& !@#& !@#& !@#& !@#& !@#& !@#& " , [ "linoxm" ] = " !@#& 55555 !@#& 54445 !@#& 54e45 !@#& 54e45 555 !@#& 54e45 !@#& 54e45555555 555 55555555 55555 555 555 !@#& 54e44444445 555 55555555 55555 555 555 !@#& 54eeeeeee45 555 555 555 55 55 5555 !@#& 54444444445 555 555 555 55555 555 555 !@#& 55555555555 555 555 555 55555 555 555 !@#& !@#& eee eee e e !@#& e e e e e e !@#& e e e e e e e !@#& e e e eeeee e eee !@#& !@#& " , [ "bg" ] = " !@#& 55555 !@#& 54445 !@#& 54e45 !@#& 54e45 555 !@#& 54e45 !@#& 54e45555555 555 55555555 55555 555 555 !@#& 54e44444445 555 55555555 55555 555 555 !@#& 54eeeeeee45 555 555 555 55 55 55555 !@#& 54444444445 555 555 555 55555 555 555 !@#& 55555555555 555 555 555 55555 555 555 !@#& !@#& !@#& !@#& !@#& !@#& !@#& " , [ "mfb" ] = { } , } , [ "startup" ] = "if not os.getComputerLabel() then!@#& os.setComputerLabel( \" SEXY_BEAST \" )!@#&end!@#&cua = fs.open( \" /lib/usr/users \" , \" r \" )!@#&if cua.readAll() == \" \" then!@#& cua.close()!@#& sua = fs.open( \" /lib/usr/users \" , \" w \" )!@#& sua.writeLine('{[ \" admin \" ]= \" d74ff0ee8da3b9806b18c877dbf29bbde50b5bd8e4dad7a3a725000feb82e8f1 \" ,}')!@#& sua.close()!@#&else!@#& cua.close()!@#&end!@#&motd = { \" Coded by __Hithere \" , \" http://zudohackz.koding.com \" , \" ALIENS \" , \" [xx]* -<I'm a testicle!> \" , \" You can only hack my penis on singleplayer! \" , \" Internal stack failure, system halted? \" , \" Kernel Panic! \" , \" Warning: Logging in will make you a nerd \" , math.random() .. \" happy customers! \" }!@#&if not term.isColor() then!@#&os.reboot()!@#&end!@#&w, h = term.getSize()!@#&function printc(str, ln)!@#& term.setCursorPos(w/2-#str/2, ln)!@#& print(str)!@#&end!@#&os.loadAPI( \" /lib/load \" )!@#&os.loadAPI( \" /lib/linox \" )!@#&logo = { \" c c ccc cccc c c \" ,!@#& \" c c c c c c c \" ,!@#& \" c c c c c c c \" ,!@#& \" c c c c c c c c \" ,!@#& \" ccc c c c cccc c c \" }!@#&local bar = load.init( load.STANDARD, logo, 5, w-4, 17, colors.lime, \" Splitting Uranus Atoms \" , \" \" , \" Starting \" .. linox.getVerNo() )!@#&help.setPath( \" /rom/help/;/lib/help \" )!@#&os.loadAPI( \" /lib/p2 \" )!@#&function mainBoot()!@#&sleep(1)!@#&bar:triggerUpdate( \" 8=========D~~~~~~~ \" )!@#&sleep(1)!@#&-- Begin VAR setup: change if required!@#&path = \" /bin \" !@#&-- End VAR setup!@#&os.loadAPI( \" /lib/sysconf \" )!@#&shell.run( \" /bin/boot/loadapis \" )!@#&sleep(1)!@#&bar:triggerUpdate( \" Initializing Anal Capacitor \" )!@#&shell.setPath(shell.path() .. \" : \" .. path)!@#&if http then!@#& if update.ping() then!@#& udver = update.getVerNo()!@#& if linox.getVerNo() == udver then!@#& spd.setData( \" updates \" ,nil)!@#& else!@#& spd.setData( \" updates \" ,udver)!@#& end!@#& else!@#& spd.setData( \" updates \" ,nil)!@#& end!@#&else!@#&end!@#&!@#&terminate.disable()!@#&sleep(1)!@#&bar:triggerUpdate( \" Smoking detached big black cocks \" )!@#&fail = true!@#&sleep(1)!@#&bar:triggerUpdate( \" Raping the future \" )!@#&sleep(0.5)!@#&function loginScreen()!@#&term.setBackgroundColor(colors.lightGray)!@#&term.setTextColor(colors.black)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&quit = \" Stick finger in asshole to shutdown \" !@#&term.setBackgroundColor(colors.pink)!@#&write(string.rep( \" \" , w))!@#&term.setCursorPos(1,1)!@#&write(linox.getVerNo())!@#&term.setCursorPos(w-#quit, 1)!@#&write(quit)!@#&term.setTextColor(colors.white)!@#&term.setCursorPos(10, h/2-1)!@#&write( \" \" )!@#&term.setCursorPos(10, h/2+1)!@#&write( \" \" )!@#&term.setBackgroundColor(colors.brown)!@#&term.setCursorPos(1, h/2-1)!@#&write( \" Username: \" )!@#&term.setCursorPos(1, h/2+1)!@#&write( \" Password: \" )!@#&term.setCursorPos(w-15, h/2-1)!@#&write( \" ZudoHacks SUCKS \" )!@#&printc(motd[math.random(1,#motd)], h-1)!@#&term.setBackgroundColor(colors.yellow)!@#&term.setTextColor(colors.black)!@#&term.setCursorPos(11, h/2-1)!@#&un = read()!@#&term.setCursorPos(11, h/2+1)!@#&pw = read( \" 8===D \" )!@#&if linox.getLoginVerify(un, pw) then!@#& spd.setData( \" login \" , un)!@#& shell.setDir( \" /home \" )!@#& shell.run( \" /bin/shell \" )!@#&else!@#& loginScreen()!@#&end!@#&end!@#&loginScreen()!@#&end!@#&function enableTerm()!@#&a,b,c = rednet.receive()!@#&if b == \" linox_emergency_terminate \" then!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&print( \" YOU HAVE BEEN PWNED!!!!!! \" )!@#&error()!@#&end!@#&end!@#&function loadingBar()!@#&bar:run( true )!@#&end!@#&p2.waitForAny(loadingBar,mainBoot,enableTerm) -- I modified the original parallel API so you could not override the terminate API. MainBoot is the basis for the OS." , [ "PkgMake" ] = "sPackage = \" local pkg = %@1 local function makeFile(_path, _content) local file = fs.open(_path, \\ \" w \\ \" ) _content = _content:gsub( \\ \" \\ !@ \\ \" .. \\ \" #& \\ \" , \\ \" % \\ \\ n \\ \" ) _content = textutils.unserialize(_content) file.write(_content) file.close() end local function makeFolder(_path, _content) fs.makeDir(_path) for k,v in pairs(_content) do if type(v) == \\ \" table \\ \" then makeFolder(_path .. \\ \" / \\ \" .. k, v) else makeFile(_path .. \\ \" / \\ \" .. k, v) end end end local sDest = shell.resolve( \\ \" %@2 \\ \" ) or \\ \" / \\ \" if sDest == \\ \" root \\ \" then sDest = \\ \" / \\ \" end local tPackage = pkg makeFolder(sDest, tPackage) print( \\ \" Package Extracted to ' \\ \" .. sDest .. \\ \" '! \\ \" ) \" !@#&!@#&function addFile(_package, _path)!@#& if fs.getName(_path) == \" .DS_Store \" then!@#& return _package!@#& end!@#& local file, err = fs.open(_path, \" r \" )!@#& local content = file.readAll()!@#& content = content:gsub( \" % \\ n \" , \" \\ !@ \" .. \" #& \" )!@#& content = content:gsub( \" %% \" , \" %%%% \" )!@#& _package[fs.getName(_path)] = content!@#& file.close()!@#& print( \" Added file ' \" .._path.. \" ' \" )!@#& return _package!@#&end!@#&!@#&function addFolder(_package, _path)!@#& if string.sub(_path,1,string.len( \" rom \" ))== \" rom \" or string.sub(_path,1,string.len( \" /rom \" ))== \" /rom \" then!@#& print( \" Ignored 'rom' folder. ( \" .._path.. \" ) \" )!@#& return!@#& end!@#& _package = _package or {}!@#& for _,f in ipairs(fs.list(_path)) do!@#& local path = _path.. \" / \" ..f!@#& if fs.isDir(path) then!@#& _package[fs.getName(f)] = addFolder(_package[fs.getName(f)], path)!@#& else!@#& _package = addFile(_package, path)!@#& end!@#& end!@#& return _package!@#&end!@#&!@#&local tArgs = { ... }!@#&if #tArgs < 2 then!@#& print( \" Usage: PkgMake <source> <destination> \" )!@#& return!@#&end!@#&!@#&local sSource = shell.resolve( tArgs[1] )!@#&local sDest = shell.resolve( tArgs[2] )!@#&!@#&if fs.isDir( sDest ) then!@#& error( \" Destination must not be a folder. \" )!@#&end!@#&!@#&if sSource == sDest then!@#& error( \" Source can not be equal to destination. \" )!@#&end!@#&!@#&if fs.exists( sSource ) and fs.isDir( sSource ) then!@#& tPackage = {}!@#& tPackage = addFolder(tPackage, sSource)!@#& fPackage = fs.open(sDest, \" w \" )!@#&!@#& sPackage = string.gsub(sPackage, \" %%@2 \" , fs.getName(sSource))!@#& sPackage = string.gsub(sPackage, \" %%@1 \" , textutils.serialize(tPackage))!@#& fPackage.write(sPackage)!@#& fPackage.close()!@#& print( \" Package Done! (' \" .. sDest .. \" ') \" )!@#& print( \" Type ' \" .. sDest .. \" ' to run it. \" )!@#&else!@#& error( \" Source does not exist or is not a folder. \" )!@#&end" , [ ".Firewolf_Data" ] = { [ "server_software" ] = "!@#&-- !@#&-- Firewolf Server Software!@#&-- Created By GravityScore and 1lann!@#&-- License found here: https://raw.github.com/1lann/Firewolf/master/LICENSE !@#&--!@#&-- Orignal Idea from RednetExplorer 2.4.1!@#&-- RednetExplorer Made by ComputerCraftFan11!@#&-- !@#&!@#&!@#&-- -------- Variables!@#&!@#&-- Version!@#&local version = \" 2.4 \" !@#&local serverID = \" release \" !@#&!@#&-- Prevent Control-T!@#&os.pullEvent = os.pullEventRaw!@#&!@#&-- Updating!@#&local autoupdate = true!@#&!@#&-- Responding!@#&local enableSearch = true!@#&local enableResponse = true!@#&local enableRecording = true!@#&!@#&-- Download URLs!@#&local serverURL = \" https://raw.github.com/1lann/firewolf/master/server/server- \" .. serverID .. \" .lua \" !@#&!@#&-- Events!@#&local event_stopServer = \" firewolf_stopServerEvent \" !@#&!@#&-- Statistics!@#&local searches = 0!@#&local visits = 0!@#&!@#&-- Theme!@#&local theme = {}!@#&!@#&-- Databases!@#&local ignoreDatabase = {}!@#&local permantentIgnoreDatabase = {}!@#&local suspected = {}!@#&!@#&-- Server!@#&local w, h = term.getSize()!@#&local args = {...}!@#&local website = \" \" !@#&local dataLocation = \" \" !@#&local pages = {}!@#&local totalRecordLines = {}!@#&local recordLines = {}!@#&local serverPassword = nil!@#&local serverLocked = false!@#&!@#&-- Locations!@#&local rootFolder = \" /.Firewolf_Data \" !@#&local serverFolder = rootFolder .. \" /servers \" !@#&local statsLocation = rootFolder .. \" / \" .. website .. \" _stats \" !@#&local themeLocation = rootFolder .. \" /theme \" !@#&local defaultThemeLocation = rootFolder .. \" /default_theme \" !@#&local passwordDataLocation = rootFolder .. \" /. \" .. website .. \" _password \" !@#&local serverLocation = \" / \" .. shell.getRunningProgram()!@#&!@#&-- Parse Arguments!@#&if #args >= 2 then!@#& website = args[1]:gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" )!@#& dataLocation = args[2]:gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" )!@#& statsLocation = rootFolder .. \" / \" .. website .. \" _stats \" !@#& passwordDataLocation = rootFolder .. \" /. \" .. website .. \" _password \" !@#&else!@#& print( \" Invalid Arguments! D: \" )!@#& return!@#&end!@#&!@#&!@#&-- -------- Utility Functions!@#&!@#&local function isAdvanced()!@#& if term.isColor then return term.isColor()!@#& else return false end!@#&end!@#&!@#&local function oldPullEvent(ex)!@#& event, p1, p2, p3, p4, p5 = os.pullEventRaw(ex)!@#& if event == \" terminate \" then!@#& print( \" Terminated \" )!@#& error()!@#& else!@#& return event, p1, p2, p3, p4, p5!@#& end!@#&end!@#&!@#&local function printWithType(t, func)!@#& if type(t) == \" table \" then!@#& for k, v in pairs(t) do!@#& env.pcall(function() printWithType(v, func) end)!@#& end!@#& else!@#& func(tostring(t))!@#& end!@#&end!@#&!@#&local function centerWrite(text)!@#& local x, y = term.getCursorPos()!@#& printWithType(text, function(t)!@#& term.setCursorPos(math.ceil((w + 1)/2 - t:len()/2), y)!@#& write(t)!@#& end)!@#&end!@#&!@#&local function centerPrint(text)!@#& centerWrite(text)!@#& print()!@#&end!@#&!@#&local function leftWrite(text)!@#& local x, y = term.getCursorPos()!@#& printWithType(text, function(t)!@#& term.setCursorPos(1, y)!@#& write(text)!@#& end)!@#&end!@#&!@#&local function leftPrint(text)!@#& leftWrite(text)!@#& print()!@#&end!@#&!@#&local function rightWrite(text)!@#& local x, y = term.getCursorPos()!@#& printWithType(text, function(t)!@#& term.setCursorPos(w - text:len() + 1, y)!@#& write(text)!@#& end)!@#&end!@#&!@#&local function rightPrint(text)!@#& rightWrite(text)!@#& print()!@#&end!@#&!@#&local function clearPage(r)!@#& -- Site titles!@#& title = \" Hosting: rdnt:// \" .. website!@#&!@#& -- Address Bar!@#& term.setTextColor(colors[theme[ \" address-bar-text \" ]])!@#& term.setCursorPos(2, 1)!@#& term.setBackgroundColor(colors[theme[ \" address-bar-background \" ]])!@#& term.clearLine()!@#& term.setCursorPos(2, 1)!@#& if title:len() > 42 then title = title:sub(1, 39) .. \" ... \" end!@#& write(title)!@#&!@#& -- Records!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do!@#& term.setCursorPos(1, i + 7) !@#& centerWrite(string.rep( \" \" , 47)) !@#& end!@#& if r == true then!@#& for i, v in ipairs(recordLines) do!@#& term.setCursorPos(5, i + 8)!@#& write(v)!@#& end!@#& end!@#&!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& print( \" \" )!@#&end!@#&!@#&local function prompt(list)!@#& if isAdvanced() then!@#& for _, v in pairs(list) do!@#& if v.bg then term.setBackgroundColor(v.bg) end!@#& if v.tc then term.setTextColor(v.tc) end!@#& if v[2] == -1 then v[2] = math.ceil((w + 1)/2 - (v[1]:len() + 6)/2) end!@#&!@#& term.setCursorPos(v[2], v[3])!@#& write( \" [- \" .. v[1])!@#& term.setCursorPos(v[2] + v[1]:len() + 3, v[3])!@#& write( \" -] \" )!@#& end!@#&!@#& while true do!@#& local e, but, x, y = os.pullEvent()!@#& if e == \" mouse_click \" then!@#& for _, v in pairs(list) do!@#& if x >= v[2] and x <= v[2] + v[1]:len() + 5 and y == v[3] then!@#& return v[1]!@#& end!@#& end!@#& end!@#& end!@#& else!@#& for _, v in pairs(list) do!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& if v[2] == -1 then v[2] = math.ceil((w + 1)/2 - (v[1]:len() + 4)/2) end!@#&!@#& term.setCursorPos(v[2], v[3])!@#& write( \" \" .. v[1])!@#& term.setCursorPos(v[2] + v[1]:len() + 2, v[3])!@#& write( \" \" )!@#& end!@#&!@#& local key1 = 200!@#& local key2 = 208!@#& if dir == \" horizontal \" then!@#& key1 = 203!@#& key2 = 205!@#& end!@#&!@#& local curSel = 1!@#& term.setCursorPos(list[curSel][2], list[curSel][3])!@#& write( \" [ \" )!@#& term.setCursorPos(list[curSel][2] + list[curSel][1]:len() + 3, list[curSel][3])!@#& write( \" ] \" )!@#&!@#& while true do!@#& local e, key = os.pullEvent()!@#& term.setCursorPos(list[curSel][2], list[curSel][3])!@#& write( \" \" )!@#& term.setCursorPos(list[curSel][2] + list[curSel][1]:len() + 3, list[curSel][3])!@#& write( \" \" )!@#& if e == \" key \" and key == key1 and curSel > 1 then!@#& curSel = curSel - 1!@#& elseif e == \" key \" and key == key2 and curSel < #list then!@#& curSel = curSel + 1!@#& elseif e == \" key \" and key == 28 then!@#& return list[curSel][1]!@#& end!@#& term.setCursorPos(list[curSel][2], list[curSel][3])!@#& write( \" [ \" )!@#& term.setCursorPos(list[curSel][2] + list[curSel][1]:len() + 3, list[curSel][3])!@#& write( \" ] \" )!@#& end!@#& end!@#&end!@#&!@#&local function scrollingPrompt(list, x, y, len, width)!@#& local wid = width!@#& if wid == nil then wid = w - 3 end!@#&!@#& local function updateDisplayList(items, loc, len)!@#& local ret = {}!@#& for i = 1, len do!@#& local item = items[i + loc - 1]!@#& if item ~= nil then table.insert(ret, item) end!@#& end!@#& return ret!@#& end!@#&!@#& if isAdvanced() then!@#& local function draw(a)!@#& for i, v in ipairs(a) do!@#& term.setCursorPos(x, y + i - 1)!@#& write(string.rep( \" \" , wid))!@#& term.setCursorPos(x, y + i - 1)!@#& write( \" [ \" .. v:sub(1, wid - 5))!@#& term.setCursorPos(wid + x - 2, y + i - 1)!@#& write( \" ] \" )!@#& end!@#& end!@#&!@#& local loc = 1!@#& local disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& !@#& while true do!@#& local e, but, clx, cly = os.pullEvent()!@#& if e == \" key \" and but == 200 and loc > 1 then!@#& loc = loc - 1!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& elseif e == \" key \" and but == 208 and loc + len - 1 < #list then!@#& loc = loc + 1!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& elseif e == \" mouse_scroll \" and but > 0 and loc + len - 1 < #list then!@#& loc = loc + but!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& elseif e == \" mouse_scroll \" and but < 0 and loc > 1 then!@#& loc = loc + but!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& elseif e == \" mouse_click \" then!@#& for i, v in ipairs(disList) do!@#& if clx >= x and clx <= x + wid and cly == i + y - 1 then!@#& return v!@#& end!@#& end!@#& end!@#& end!@#& else!@#& local function draw(a)!@#& for i, v in ipairs(a) do!@#& term.setCursorPos(x, y + i - 1)!@#& write(string.rep( \" \" , wid))!@#& term.setCursorPos(x, y + i - 1)!@#& write( \" [ ] \" .. v:sub(1, wid - 5))!@#& end!@#& end!@#&!@#& local loc = 1!@#& local curSel = 1!@#& local disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& term.setCursorPos(x + 1, y + curSel - 1)!@#& write( \" x \" )!@#&!@#& while true do!@#& local e, key = os.pullEvent()!@#& term.setCursorPos(x + 1, y + curSel - 1)!@#& write( \" \" )!@#& if e == \" key \" and key == 200 then!@#& if curSel > 1 then!@#& curSel = curSel - 1!@#& elseif loc > 1 then!@#& loc = loc - 1!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& end!@#& elseif e == \" key \" and key == 208 then!@#& if curSel < #disList then!@#& curSel = curSel + 1!@#& elseif loc + len - 1 < #list then!@#& loc = loc + 1!@#& disList = updateDisplayList(list, loc, len)!@#& draw(disList)!@#& end!@#& elseif e == \" key \" and key == 28 then!@#& return list[curSel + loc - 1]!@#& end!@#& term.setCursorPos(x + 1, y + curSel - 1)!@#& write( \" x \" )!@#& end!@#& end!@#&end!@#&!@#&!@#&-- -------- Themes!@#&!@#&local defaultTheme = {[ \" address-bar-text \" ] = \" white \" , [ \" address-bar-background \" ] = \" gray \" , !@#& [ \" address-bar-base \" ] = \" lightGray \" , [ \" top-box \" ] = \" red \" , [ \" bottom-box \" ] = \" orange \" , !@#& [ \" text-color \" ] = \" white \" , [ \" background \" ] = \" gray \" }!@#&local originalTheme = {[ \" address-bar-text \" ] = \" white \" , [ \" address-bar-background \" ] = \" black \" , !@#& [ \" address-bar-base \" ] = \" black \" , [ \" top-box \" ] = \" black \" , [ \" bottom-box \" ] = \" black \" , !@#& [ \" text-color \" ] = \" white \" , [ \" background \" ] = \" black \" }!@#&!@#&local function loadTheme(path)!@#& if fs.exists(path) and not fs.isDir(path) then!@#& local a = {}!@#& local f = io.open(path, \" r \" )!@#& local l = f:read( \" *l \" )!@#& while l ~= nil do!@#& l = l:gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" )!@#& if l ~= \" \" and l ~= nil and l ~= \" \\ n \" then!@#& local b = l:find( \" = \" )!@#& if a and b then!@#& local c = l:sub(1, b - 1)!@#& local d = l:sub(b + 1, -1)!@#& if c == \" \" or d == \" \" then return nil!@#& else a[c] = d end!@#& else return nil end!@#& end!@#& l = f:read( \" *l \" )!@#& end!@#& f:close()!@#&!@#& return a!@#& else!@#& return nil!@#& end!@#&end!@#&!@#&!@#&-- -------- Filesystem!@#&!@#&local function download(url, path)!@#& for i = 1, 3 do!@#& local response = http.get(url)!@#& if response then!@#& local data = response.readAll()!@#& response.close()!@#& local f = io.open(path, \" w \" )!@#& f:write(data)!@#& f:close()!@#& return true!@#& end!@#& end!@#&!@#& return false!@#&end!@#&!@#&local function validateFilesystem()!@#& if not fs.exists(rootFolder) or not fs.exists(serverFolder) or not fs.exists(dataLocation) or!@#& not fs.exists(serverLocation) or not fs.exists(dataLocation .. \" /home \" ) then!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 1)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& centerPrint(string.rep( \" \" , 47))!@#& centerWrite(string.rep( \" \" , 47))!@#& centerPrint( \" Invalid Filesystem! \" )!@#& centerPrint(string.rep( \" \" , 47))!@#& print( \" \" )!@#&!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& centerPrint(string.rep( \" \" , 47))!@#& centerPrint( \" The files required to run this server \" )!@#& centerPrint( \" cannot be found! Run Firewolf to create \" )!@#& centerPrint( \" them! \" )!@#& centerPrint(string.rep( \" \" , 47))!@#& centerWrite(string.rep( \" \" , 47))!@#& if isAdvanced() then centerPrint( \" Click to exit... \" )!@#& else centerPrint( \" Press any key to exit... \" ) end!@#& centerPrint(string.rep( \" \" , 47))!@#&!@#& while true do!@#& local e = os.pullEvent()!@#& if e == \" key \" or e == \" mouse_click \" then break end!@#& end!@#&!@#& return false!@#& else!@#& return true!@#& end!@#&end!@#&!@#&local function updateClient()!@#& local updateLocation = rootFolder .. \" /server-update \" !@#& fs.delete(updateLocation)!@#&!@#& -- Update!@#& download(serverURL, updateLocation)!@#& local a = io.open(updateLocation, \" r \" )!@#& local b = io.open(serverLocation, \" r \" )!@#& local new = a:read( \" *a \" )!@#& local cur = b:read( \" *a \" )!@#& a:close()!@#& b:close()!@#&!@#& if cur ~= new then!@#& fs.delete(serverLocation)!@#& fs.move(updateLocation, serverLocation)!@#& shell.run(serverLocation, args[1], args[2])!@#& error()!@#& else!@#& fs.delete(updateLocation)!@#& end!@#&end!@#&!@#&!@#&-- -------- Loading!@#&!@#&local serverAPIContent = [[!@#&!@#&-- !@#&-- Custom Server API!@#&-- !@#&!@#&-- Notes:!@#&-- - These functions are called when events occur!@#&-- - Their names are required to be kept the same!@#&-- - These functions must be able to execute!@#&-- instantly, else your server may be DDoS-able!@#&!@#&!@#&uponSuccessfulRequest = function(page, id)!@#& -- Called when a request for a page is successful!@#&!@#& -- Your Code Here...!@#&end!@#&!@#&uponFailedRequest = function(page, id)!@#& -- Called when a request for a page is unsuccessful!@#&!@#& -- Your Code Here...!@#&end!@#&!@#&uponAnyOtherMessage = function(message, id)!@#& -- Called when any rendet message is received!@#& -- that is not requesting a page!@#&!@#& -- Your Code Here...!@#&end!@#&!@#&uponAnyMessage = function(message, id)!@#& -- Called when any rednet message is received!@#&!@#& -- Your Code Here...!@#&end!@#&!@#¶llelWithServer = function()!@#& -- Runs in a parallel alongside the server!@#&!@#& -- Your Code Here...!@#&end!@#&!@#&local function uponServerApiLoad()!@#& -- Called when this Server API is loaded!@#&!@#& -- Your Code Here...!@#&end!@#&!@#&uponServerApiLoad()!@#&!@#&]]!@#&!@#&local function loadServerAPI()!@#& if not fs.exists(dataLocation .. \" /serverapi \" ) then!@#& local f = io.open(dataLocation .. \" /serverapi \" , \" w \" )!@#& f:write(serverAPIContent)!@#& f:close()!@#& end!@#&!@#& shell.run(dataLocation .. \" /serverapi \" )!@#& if type(uponSuccessfulRequest) ~= \" function \" then!@#& uponSuccessfulRequest = nil!@#& end if type(uponFailedRequest) ~= \" function \" then!@#& uponFailedRequest = nil!@#& end if type(uponAnyOtherMessage) ~= \" function \" then!@#& uponAnyOtherMessage = nil!@#& end if type(uponAnyMessage) ~= \" function \" then!@#& uponAnyMessage = nil!@#& end if type(parallelWithServer) ~= \" function \" then!@#& parallelWithServer = nil!@#& end!@#&end!@#&!@#&local function loadPages(loc)!@#& local a = fs.list(loc)!@#& local p = {}!@#& for i = 1, #a do!@#& if not fs.isDir(loc .. \" / \" .. a[i]) then!@#& local f = io.open(loc .. \" / \" .. a[i])!@#& local cont = f:read( \" *a \" )!@#& f:close()!@#&!@#& p[loc .. \" / \" .. a[i]] = cont!@#& else!@#& local b = loadPages(loc .. \" / \" .. a[i])!@#& for x = 1, #b do!@#& table.insert(p, b[x])!@#& end!@#& end!@#& end!@#&!@#& return p!@#&end!@#&!@#&local function checkForModem()!@#& while true do!@#& local present = false!@#& for _, v in pairs(rs.getSides()) do!@#& if peripheral.getType(v) == \" modem \" then!@#& rednet.open(v)!@#& present = true!@#& break!@#& end!@#& end!@#&!@#& if not present then!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& centerPrint(string.rep( \" \" , 43))!@#& centerWrite(string.rep( \" \" , 43))!@#& centerPrint( \" No Modem Attached! D: \" )!@#& centerPrint(string.rep( \" \" , 43))!@#& print( \" \" )!@#&!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& centerPrint(string.rep( \" \" , 43))!@#& centerWrite(string.rep( \" \" , 43))!@#& centerPrint( \" No wireless modem was found on this \" )!@#& centerWrite(string.rep( \" \" , 43))!@#& centerPrint( \" computer, and Firewolf is not able to \" )!@#& centerWrite(string.rep( \" \" , 43))!@#& centerPrint( \" run without one! \" )!@#& centerPrint(string.rep( \" \" , 43))!@#& centerWrite(string.rep( \" \" , 43))!@#& centerPrint( \" Waiting for a modem to be attached... \" )!@#& centerWrite(string.rep( \" \" , 43))!@#& if isAdvanced() then centerPrint( \" Click to exit... \" )!@#& else centerPrint( \" Press any key to exit... \" ) end!@#& centerPrint(string.rep( \" \" , 43))!@#&!@#& while true do!@#& local e, id = os.pullEvent()!@#& if e == \" key \" or e == \" mouse_click \" then return false!@#& elseif e == \" peripheral \" then break end!@#& end!@#& else!@#& return true!@#& end!@#& end!@#&end!@#&!@#&!@#&-- -------- Respond to Messages!@#&!@#&local i = 1!@#&local function record(text)!@#& local oldX, oldY = term.getCursorPos()!@#& local a = tostring(i) .. \" : \" .. string.rep( \" \" , 4 - tostring(i):len()) .. text!@#& table.insert(totalRecordLines, a)!@#& if #recordLines > 8 then table.remove(recordLines, 1) end!@#& table.insert(recordLines, a)!@#&!@#& if enableRecording then clearPage(true) end!@#& i = i + 1!@#& term.setCursorPos(oldX, oldY)!@#& if enableRecording then!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& end!@#&end!@#&!@#&local function respondToEvents()!@#& if uponSuccessfulRequest == nil or uponFailedRequest == nil or uponAnyMessage == nil or !@#& uponAnyOtherMessage == nil or parallelWithServer == nil then!@#& record( \" Warning - Failed To Load Server API: \" )!@#& if uponSuccessfulRequest == nil then record( \" - uponSuccessfulRequest() \" ) end!@#& if uponFailedRequest == nil then record( \" - uponFailedRequest() \" ) end!@#& if uponAnyMessage == nil then record( \" - uponAnyMessage() \" ) end!@#& if uponAnyOtherMessage == nil then record( \" - uponAnyOtherMessage() \" ) end!@#& if parallelWithServer == nil then record( \" - parallelWithServer() \" ) end!@#& else record( \" Loaded Server API \" ) end!@#&!@#& local writingClock = os.clock()!@#& local ignoreClock = os.clock()!@#& while true do!@#& if os.clock() - ignoreClock < 6 then!@#& for k, v in pairs(suspected) do!@#& if v > 10 then table.insert(ignoreDatabase, tostring(k)) end!@#& end!@#& else!@#& ignoreDatabase = {}!@#& suspected = {}!@#& ignoreClock = os.clock()!@#& end!@#&!@#& local e, id, mes = os.pullEvent()!@#&!@#& local ignore = false!@#& for _, v in pairs(ignoreDatabase) do!@#& if tostring(id) == v then ignore = true break end!@#& end for _, v in pairs(permantentIgnoreDatabase) do!@#& if tostring(id) == v then ignore = true break end!@#& end!@#&!@#& if e == \" rednet_message \" and enableResponse == true and not ignore then!@#& if mes == website or mes == website .. \" / \" or mes == website .. \" /home \" then!@#& if suspected[tostring(id)] then suspected[tostring(id)] = suspected[tostring(id)] + 1!@#& else suspected[tostring(id)] = 1 end!@#& for i = 1, 3 do rednet.send(id, pages[dataLocation .. \" /home \" ]) end!@#& record( \" /home : \" .. tostring(id))!@#& visits = visits + 1!@#&!@#& if uponSuccessfulRequest ~= nil then uponSuccessfulRequest( \" /home \" , id) end!@#& elseif mes:find( \" / \" ) then!@#& local a = mes:sub(1, mes:find( \" / \" ) - 1)!@#& if a == website then!@#& if suspected[tostring(id)] then !@#& suspected[tostring(id)] = suspected[tostring(id)] + 1!@#& else suspected[tostring(id)] = 1 end!@#& local b = mes:sub(mes:find( \" / \" ), -1)!@#& local c = b!@#& if c:len() > 18 then c = c:sub(1, 15) .. \" ... \" end!@#& if pages[dataLocation .. b] and b ~= \" /serverapi \" then!@#& for i = 1, 3 do rednet.send(id, pages[dataLocation .. b]) end!@#& record(c .. \" : \" .. id)!@#& visits = visits + 1!@#&!@#& if uponSuccessfulRequest ~= nil then uponSuccessfulRequest(b, id) end!@#& else!@#& record( \" Failed - \" .. c .. \" : \" .. id)!@#& if uponFailedRequest ~= nil then uponFailedRequest(b, id) end!@#& end!@#& end!@#& elseif mes == \" firewolf.broadcast.dns.list \" then!@#& if suspected[tostring(id)] then suspected[tostring(id)] = suspected[tostring(id)] + 1!@#& else suspected[tostring(id)] = 1 end!@#& rednet.send(id, \" firewolf-site: \" .. website)!@#& searches = searches + 1!@#& else!@#& if uponAnyOtherMessage ~= nil then uponAnyOtherMessage(mes, id) end!@#& end!@#&!@#& if uponAnyMessage ~= nil then uponAnyMessage(mes, id) end!@#& elseif e == event_stopServer then!@#& return!@#& end!@#&!@#& -- Save stats!@#& if os.clock() - writingClock > 5 then!@#& local f = io.open(statsLocation, \" w \" )!@#& f:write(tostring(visits) .. \" \\ n \" .. tostring(searches) .. \" \\ n \" ..!@#& textutils.serialize(permantentIgnoreDatabase))!@#& f:close()!@#& writingClock = os.clock()!@#& end!@#& end!@#&end!@#&!@#&!@#&-- -------- Interface!@#&!@#&local function edit()!@#& openAddressBar = false!@#& local oldLoc = shell.dir()!@#& local commandHis = {}!@#& local dir = dataLocation!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1, 1)!@#& print( \" \" )!@#& print( \" Server Shell Editing \" )!@#& print( \" Type 'exit' to return to Firewolf. \" )!@#& print( \" The 'home' file is the index of your site \" )!@#& print( \" \" )!@#&!@#& local allowed = { \" move \" , \" mv \" , \" cp \" , \" copy \" , \" drive \" , \" delete \" , \" rm \" , \" edit \" , !@#& \" eject \" , \" exit \" , \" help \" , \" id \" , \" monitor \" , \" rename \" , \" alias \" , \" clear \" ,!@#& \" paint \" , \" firewolf \" , \" lua \" , \" redstone \" , \" rs \" , \" redprobe \" , \" redpulse \" , \" programs \" ,!@#& \" redset \" , \" reboot \" , \" hello \" , \" label \" , \" list \" , \" ls \" , \" easter \" , \" pastebin \" , \" dir \" }!@#& !@#& while true do!@#& shell.setDir(serverFolder .. \" / \" .. website)!@#& term.setBackgroundColor(colors.black)!@#& if isAdvanced() then term.setTextColor(colors.yellow)!@#& else term.setTextColor(colors.white) end!@#& write( \" > \" )!@#& term.setTextColor(colors.white)!@#& local line = read(nil, commandHis)!@#& table.insert(commandHis, line)!@#&!@#& local words = {}!@#& for m in string.gmatch(line, \" [^ \\ t]+ \" ) do!@#& local a = m:gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" )!@#& table.insert(words, a)!@#& end!@#&!@#& local com = words[1]!@#& if com == \" exit \" then!@#& break!@#& elseif com then!@#& local a = false!@#& for _, v in pairs(allowed) do!@#& if com == v then a = true break end!@#& end!@#&!@#& if a then!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& shell.run(com, unpack(words, 2))!@#& else!@#& term.setTextColor(colors.red)!@#& print( \" Program Not Allowed! \" )!@#& end!@#& end!@#& end!@#& shell.setDir(oldLoc)!@#&end!@#&!@#&local function interface()!@#& local opt = \" \" !@#& while true do!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 1)!@#& clearPage(true)!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& for i = 1, 4 do centerPrint(string.rep( \" \" , 47)) end!@#& print( \" \" )!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#&!@#& if enableResponse == false then p1 = \" Unpause Server \" end!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& if not serverLocked and not serverPassword then!@#& os.pullEvent = oldPullEvent!@#& opt = prompt({{ \" Add Lock \" , 5, 4}, { \" Edit \" , 5, 5}, { \" Manage \" , w - 15, 4}, !@#& { \" Stop \" , w - 13, 5}}, \" vertical \" )!@#& elseif not serverLocked and serverPassword then!@#& opt = prompt({{ \" Lock Server \" , 5, 4}, { \" Edit \" , 5, 5}, { \" Manage \" , w - 15, 4}, !@#& { \" Stop \" , w - 13, 5}}, \" vertical \" )!@#& elseif serverLocked then!@#& while true do!@#& enableRecording = true!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& for i = 1, 4 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(5, 4)!@#& print( \" Enter Password: \" )!@#& term.setCursorPos(5, 5)!@#& write( \" > \" )!@#& local enteredPassword = read( \" * \" )!@#& if enteredPassword == serverPassword then!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& for i = 1, 4 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(5, 4)!@#& write( \" Password Accepted! \" )!@#& opt = \" \" !@#& serverLocked = false!@#& os.pullEvent = oldPullEvent!@#& sleep(1.3)!@#& break!@#& else!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& for i = 1, 4 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(5, 4)!@#& write( \" Password Incorrect! \" )!@#& sleep(1.3)!@#& end!@#& end!@#& end!@#&!@#& if opt == p1 then!@#& enableResponse = not enableResponse!@#& elseif opt == \" Manage \" then!@#& while true do!@#& enableRecording = false!@#& clearPage()!@#& term.setCursorPos(1, 8)!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do centerPrint(string.rep( \" \" , 47)) end!@#&!@#& term.setCursorPos(5, 9)!@#& write( \" Visits: \" .. tostring(visits))!@#& term.setCursorPos(5, 10)!@#& write( \" Searches: \" .. tostring(searches))!@#& local opt = \" \" !@#& if serverPassword then!@#& opt = prompt({{ \" Manage Blocked IDs \" , 9, 12}, { \" Remove Password \" , 9, 13}, !@#& { \" Delete Server \" , 9, 14}, { \" Back \" , 9, 16}}, \" vertical \" )!@#& else!@#& opt = prompt({{ \" Manage Blocked IDs \" , 9, 12}, { \" Delete Server \" , 9, 13}, !@#& { \" Back \" , 9, 15}}, \" vertical \" )!@#& end!@#& if opt == \" Manage Blocked IDs \" then!@#& while true do!@#& clearPage()!@#& term.setCursorPos(1, 8)!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do centerPrint(string.rep( \" \" , 47)) end!@#&!@#& term.setCursorPos(5, 9)!@#& if isAdvanced() then write( \" Blocked IDs: (Click to Unblock) \" )!@#& else write( \" Blocked IDs: (Select to Unblock) \" ) end!@#& local a = { \" Back \" , \" Block New ID \" }!@#& for _, v in pairs(permantentIgnoreDatabase) do!@#& table.insert(a, v)!@#& end!@#&!@#& local b = scrollingPrompt(a, 5, 11, 7, 43)!@#& if b == \" Back \" then!@#& break!@#& elseif b == \" Block New ID \" then!@#& term.setCursorPos(5, 10)!@#& write( \" ID: \" )!@#& local c = read():gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" )!@#& local d = tonumber(c)!@#& local found = false!@#& for k, v in pairs(permantentIgnoreDatabase) do!@#& if v == tostring(d) then found = true break end!@#& end!@#& if d == nil then!@#& term.setCursorPos(1, 10)!@#& centerWrite(string.rep( \" \" , 47))!@#& term.setCursorPos(5, 10)!@#& write( \" Not a Valid ID! \" )!@#& sleep(1.1)!@#& elseif found == true then!@#& term.setCursorPos(1, 10)!@#& centerWrite(string.rep( \" \" , 47))!@#& term.setCursorPos(5, 10)!@#& write( \" ID Already Exists! \" )!@#& sleep(1.1)!@#& else!@#& term.setCursorPos(1, 10)!@#& centerWrite(string.rep( \" \" , 47))!@#& term.setCursorPos(5, 10)!@#& write( \" Blocked ID: \" .. c .. \" ! \" )!@#& table.insert(permantentIgnoreDatabase, tostring(d))!@#& sleep(1.1)!@#& end!@#& else!@#& for i, v in ipairs(permantentIgnoreDatabase) do!@#& if v == b then table.remove(permantentIgnoreDatabase, i) end!@#& end!@#& end!@#& end!@#& elseif opt == \" Delete Server \" then!@#& clearPage()!@#& term.setCursorPos(1, 8)!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(9, 11)!@#& centerPrint( \" Are you sure you want to delete the server? \" )!@#& centerPrint( \" This cannot be undone! \" )!@#& local opt = prompt({{ \" No \" , 11, 14}, { \" Yes \" , 35, 14}}, \" horizontal \" )!@#& if opt == \" Yes \" then!@#& fs.delete(dataLocation)!@#& os.queueEvent(event_stopServer)!@#& return!@#& end!@#& elseif opt == \" Remove Password \" then!@#& clearPage()!@#& term.setCursorPos(1, 8)!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(9, 11)!@#& print( \" Enter your old password: \" )!@#& term.setCursorPos(9, 12)!@#& write( \" > \" )!@#& local oldPass = read( \" * \" )!@#& if oldPass == serverPassword then!@#& fs.delete(passwordDataLocation)!@#& serverPassword = nil!@#& serverLocked = false!@#& term.setCursorPos(9, 14)!@#& print( \" Password Removed! \" )!@#& sleep(1.3)!@#& break!@#& else!@#& term.setCursorPos(9, 14)!@#& print( \" Password incorrect! Locking server... \" )!@#& os.pullEvent = os.pullEventRaw!@#& serverLocked = true!@#& sleep(1.3)!@#& break!@#& end!@#& elseif opt == \" Back \" then!@#& break!@#& end!@#& end!@#& !@#& enableRecording = true!@#& elseif opt == \" Edit \" then!@#& enableRecording = false!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1, 1)!@#& edit()!@#&!@#& term.clear()!@#& pages = loadPages(dataLocation)!@#& loadServerAPI()!@#& if uponSuccessfulRequest == nil or uponFailedRequest == nil or uponAnyMessage == nil or !@#& uponAnyOtherMessage == nil or parallelWithServer == nil then!@#& record( \" Warning - Failed To Load Server API: \" )!@#& if uponSuccessfulRequest == nil then record( \" - uponSuccessfulRequest() \" ) end!@#& if uponFailedRequest == nil then record( \" - uponFailedRequest() \" ) end!@#& if uponAnyMessage == nil then record( \" - uponAnyMessage() \" ) end!@#& if uponAnyOtherMessage == nil then record( \" - uponAnyOtherMessage() \" ) end!@#& if parallelWithServer == nil then record( \" - parallelWithServer() \" ) end!@#& else record( \" Re-Loaded Server API \" ) end!@#& enableRecording = true!@#& elseif opt == \" Add Lock \" then!@#& enableRecording = false!@#& clearPage()!@#& term.setCursorPos(1, 8)!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& for i = 1, 11 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(5, 9)!@#& write( \" Enter a password to secure your \" )!@#& term.setCursorPos(5, 10)!@#& write( \" server from being managed by others: \" )!@#& term.setCursorPos(5, 11)!@#& write( \" > \" )!@#& local newPassword = read( \" * \" )!@#& term.setCursorPos(5, 13)!@#& write( \" Enter the password again: \" )!@#& term.setCursorPos(5, 14)!@#& write( \" > \" )!@#& if read( \" * \" ) == newPassword then!@#& serverPassword = newPassword!@#& serverLocked = false!@#& local f = io.open(passwordDataLocation, \" w \" )!@#& f:write(newPassword)!@#& f:close()!@#& term.setCursorPos(5, 16)!@#& write( \" Password Set! \" )!@#& sleep(1.3)!@#& else!@#& term.setCursorPos(5, 16)!@#& print( \" Passwords did not match! \" )!@#& sleep(1.3)!@#& end!@#& enableRecording = false!@#& elseif opt == \" Lock Server \" then!@#& os.pullEvent = os.pullEventRaw!@#& serverLocked = true!@#& term.setCursorPos(1, 2)!@#& print( \" \" )!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& for i = 1, 4 do centerPrint(string.rep( \" \" , 47)) end!@#& term.setCursorPos(5, 4)!@#& print( \" Server Locked! \" )!@#& sleep(2)!@#& elseif opt == \" Stop \" then!@#& -- Stop server!@#& os.queueEvent(event_stopServer)!@#& return!@#& end!@#& end!@#&end!@#&!@#&!@#&-- -------- Main!@#&!@#&local function main()!@#& -- Logo!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 2)!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& leftPrint(string.rep( \" \" , 47))!@#& leftPrint([[ ______ ____ ____ ______ ]])!@#& leftPrint([[ ------- / ____// _// __ \\ / ____/ ]])!@#& leftPrint([[ ------ / /_ / / / /_/ // __/ ]])!@#& leftPrint([[ ----- / __/ _/ / / _ _// /___ ]])!@#& leftPrint([[ ---- / / /___//_/ |_|/_____/ ]])!@#& leftPrint([[ --- / / _ __ ____ __ ______ ]])!@#& leftPrint([[ -- /_/ | | / // __ \\ / / / ____/ ]])!@#& leftPrint([[ | | /| / // / / // / / /_ ]])!@#& leftPrint([[ | |/ |/ // /_/ // /___ / __/ ]])!@#& leftPrint([[ |__/|__/ \\ ____//_____//_/ ]])!@#& leftPrint(string.rep( \" \" , 47))!@#& print( \" \\ n \" )!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#&!@#& rightPrint(string.rep( \" \" , 27 + version:len()))!@#& rightPrint( \" Loading Firewolf Server \" .. version .. \" \" )!@#& rightPrint(string.rep( \" \" , 27 + version:len()))!@#&!@#& -- Filesystem!@#& if not validateFilesystem() then return end!@#&!@#& -- Update!@#& if autoupdate then updateClient() end!@#&!@#& -- Load!@#& pages = loadPages(dataLocation)!@#& loadServerAPI()!@#& if fs.exists(statsLocation) then!@#& local f = io.open(statsLocation, \" r \" )!@#& local a = tonumber(f:read( \" *l \" ))!@#& local b = tonumber(f:read( \" *l \" ))!@#& local c = f:read( \" *l \" )!@#& if a then visits = a end!@#& if b then searches = b end!@#& if c then permantentIgnoreDatabase = textutils.unserialize(c) end!@#& f:close()!@#& end!@#& if not checkForModem() then return end!@#&!@#& -- Start UI!@#& parallel.waitForAll(respondToEvents, interface, parallelWithServer)!@#&end!@#&!@#&local function startup()!@#& -- HTTP API!@#& if not http then!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 2)!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& leftPrint(string.rep( \" \" , 24))!@#& leftPrint( \" HTTP Not Enabled! \" )!@#& leftPrint(string.rep( \" \" , 24))!@#& print( \" \" )!@#&!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& rightPrint(string.rep( \" \" , 36))!@#& rightPrint( \" Firewolf is unable to run without \" )!@#& rightPrint( \" the HTTP Enabled! Please \" )!@#& rightPrint( \" enable it in your ComputerCraft \" )!@#& rightPrint( \" Config! \" )!@#& rightPrint(string.rep( \" \" , 36))!@#&!@#& if isAdvanced() then rightPrint( \" Click to exit... \" )!@#& else rightPrint( \" Press any key to exit... \" ) end!@#& rightPrint(string.rep( \" \" , 36))!@#&!@#& while true do!@#& local e, but, x, y = os.pullEvent()!@#& if e == \" mouse_click \" or e == \" key \" then break end!@#& end!@#&!@#& return false !@#& end!@#&!@#& -- Turtle!@#& if turtle then!@#& term.clear()!@#& term.setCursorPos(1, 2)!@#& centerPrint( \" Advanced Comptuer Required! \" )!@#& print( \" \\ n \" )!@#& centerPrint( \" This version of Firewolf requires \" )!@#& centerPrint( \" an Advanced Comptuer to run! \" )!@#& print( \" \" )!@#& centerPrint( \" Turtles may not be used to run \" )!@#& centerPrint( \" Firewolf! :( \" )!@#& print( \" \" )!@#& centerPrint( \" Press any key to exit... \" )!@#&!@#& os.pullEvent( \" key \" )!@#& return false!@#& end!@#&!@#& -- Run!@#& local _, err = pcall(main)!@#& if err and err ~= \" parallel:22: Terminated \" then!@#& term.setTextColor(colors[theme[ \" text-color \" ]])!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& term.clear()!@#& term.setCursorPos(1, 2)!@#& term.setCursorBlink(false)!@#& term.setBackgroundColor(colors[theme[ \" top-box \" ]])!@#& leftPrint(string.rep( \" \" , 27))!@#& leftPrint( \" Firewolf has Crashed! D: \" )!@#& leftPrint(string.rep( \" \" , 27))!@#& print( \" \" )!@#& term.setBackgroundColor(colors[theme[ \" background \" ]])!@#& print( \" \" )!@#& print( \" \" .. err)!@#& print( \" \" )!@#&!@#& term.setBackgroundColor(colors[theme[ \" bottom-box \" ]])!@#& rightPrint(string.rep( \" \" , 41))!@#& if autoupdate == \" true \" then!@#& rightPrint( \" Please report this error to 1lann or \" )!@#& rightPrint( \" GravityScore so we are able to fix it! \" )!@#& rightPrint( \" If this problem persists, try deleting \" )!@#& rightPrint( \" \" .. rootFolder .. \" \" )!@#& else!@#& rightPrint( \" Automatic updating is off! A new \" )!@#& rightPrint( \" version may have have been released \" )!@#& rightPrint( \" that may fix this error! \" )!@#& rightPrint( \" If you didn't turn auto updating \" )!@#& rightPrint( \" off, delete \" .. rootFolder .. \" \" )!@#& end!@#&!@#& rightPrint(string.rep( \" \" , 41))!@#& if isAdvanced() then rightPrint( \" Click to exit... \" )!@#& else rightPrint( \" Press any key to exit... \" ) end!@#& rightPrint(string.rep( \" \" , 41))!@#&!@#& while true do!@#& local e, but, x, y = os.pullEvent()!@#& if e == \" mouse_click \" or e == \" key \" then break end!@#& end!@#&!@#& return false!@#& end!@#&!@#& return true!@#&end!@#&!@#&-- Check If Read Only!@#&if fs.isReadOnly(serverLocation) or fs.isReadOnly(rootFolder) then!@#& print( \" Firewolf cannot modify itself or its root folder! \" )!@#& print( \" \" )!@#& print( \" This cold be caused by Firewolf being placed in \" )!@#& print( \" the rom folder, or another program may be \" )!@#& print( \" preventing the modification of Firewolf. \" )!@#&!@#& -- Reset Environment and Exit!@#& setfenv(1, oldEnv)!@#& error()!@#&end!@#&!@#&-- Theme!@#&if not isAdvanced() then !@#& theme = originalTheme!@#&else!@#& theme = loadTheme(themeLocation)!@#& if theme == nil then theme = defaultTheme end!@#&end!@#&!@#&-- Pasword!@#&if fs.exists(passwordDataLocation) then!@#& local f = io.open(passwordDataLocation, \" r \" )!@#& serverPassword = f:read( \" *l \" )!@#& f:close()!@#& serverLocked = true!@#&else!@#& serverLocked = false!@#&end!@#&!@#&-- Start!@#&startup()!@#&!@#&-- Clear!@#&term.setBackgroundColor(colors.black)!@#&term.setTextColor(colors.white)!@#&term.clear()!@#&term.setCursorPos(1, 1)!@#¢erPrint( \" Thank You for Using Firewolf Server \" .. version)!@#¢erPrint( \" Made by 1lann and GravityScore \" )!@#&term.setCursorPos(1, 3)!@#&!@#&-- Close Rednet!@#&for _, v in pairs(rs.getSides()) do !@#& if peripheral.getType(v) == \" modem \" then rednet.close(v) end!@#&end" , [ "servers" ] = { } , [ "user_whitelist" ] = "" , [ "cache" ] = { } , [ "website_data" ] = { } , [ "user_blacklist" ] = "" , [ "settings" ] = "" , } , [ "bin" ] = { [ "updates" ] = "udver = update.getVerNo()!@#&w,h = term.getSize()!@#&function printc(str,l)!@#& term.setCursorPos(w/2-#str/2,l)!@#& print(str)!@#&end!@#&!@#&term.setBackgroundColor(colors.lightGray)!@#&!@#&function upToDate()!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& term.setBackgroundColor(colors.white)!@#& write(string.rep( \" \" ,w))!@#& term.setTextColor(colors.black)!@#& printc( \" Your system is up to date \" ,1)!@#& term.setCursorPos(w-string.len( \" [Exit] \" ),1)!@#& x,_ = term.getCursorPos()!@#& write( \" [Exit] \" )!@#& x2,_ = term.getCursorPos()!@#& term.setBackgroundColor(colors.lightGray)!@#& term.setTextColor(colors.white)!@#& term.setCursorPos(2,10)!@#& write( \" Current Version: \" .. linox.getVerNo())!@#& term.setCursorPos(2,12)!@#& write( \" Latest Version: \" .. udver)!@#&end!@#&!@#&function updatesAvailable(smart)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& term.setBackgroundColor(colors.white)!@#& write(string.rep( \" \" ,w))!@#& term.setTextColor(colors.black)!@#& printc( \" Updates are available \" ,1)!@#& term.setCursorPos(w-string.len( \" [Exit] \" ),1)!@#& write( \" [Exit] \" )!@#& term.setBackgroundColor(colors.lightGray)!@#& term.setTextColor(colors.white)!@#& term.setCursorPos(2,10)!@#& write( \" Current Version: \" .. linox.getVerNo())!@#& term.setCursorPos(2,12)!@#& write( \" Latest Version: \" .. udver)!@#& term.setCursorPos(2,15)!@#& term.setBackgroundColor(colors.gray)!@#& if smart then!@#& write( \" X \" )!@#& else!@#& write( \" \" )!@#& end!@#& term.setBackgroundColor(colors.lightGray)!@#& write( \" Use SmartUpdate (beta) \" )!@#& term.setCursorPos(10,17)!@#& print( \" [Update] \" )!@#& x3,_ = term.getCursorPos()!@#&end!@#&!@#&function getClickPos()!@#& _,b,xpos,ypos = os.pullEvent( \" mouse_click \" )!@#& if xpos == x+1 or xpos == x+2 or xpos == x+3 or xpos == x+4 or xpos == x+5 or xpos == x2 then!@#& if ypos == 1 then!@#& return \" quit \" !@#& end!@#& elseif xpos == 2 then!@#& if ypos == 15 then!@#& return \" smart \" !@#& end!@#& elseif xpos == 10 or xpos == 11 or xpos == 12 or xpos == 13 or xpos == 14 or xpos == 15 or xpos == 16 or xpos == x3 then!@#& if ypos == 17 then!@#& return \" update \" !@#& end!@#& end!@#&end!@#&!@#&smart = false!@#&!@#&if spd.getData( \" updates \" ) then!@#& updatesAvailable(false)!@#&else!@#& upToDate()!@#&end!@#&!@#&while true do!@#& click = getClickPos()!@#& if click == \" quit \" then!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& error()!@#& elseif click == \" update \" then!@#& if smart then!@#& shell.run( \" gksu \" , \" /bin/uplib/smart \" )!@#& else!@#& shell.run( \" gksu \" , \" /bin/uplib/safe \" )!@#& end!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& print( \" This feature currently does not work. Use the manual update from http://linox-os.co.nr \" )!@#& error()!@#& elseif click == \" smart \" then!@#& if not smart then!@#& smart = true!@#& updatesAvailable(true)!@#& else!@#& smart = false!@#& updatesAvailable(false)!@#& end!@#& end!@#&end" , [ "browser" ] = "--[[!@#& Mouse File Browser!@#& by:!@#& Stiepen irc(Kilobyte)!@#& Cruor!@#& BigSHinyToys!@#& !@#& note: send link to nightin9ale on CC forums!@#&--]]!@#&!@#&local tArgs = {...}!@#&local ver = \" 1.4 \" !@#&local sTitle = \" File Browser \" !@#&local bugTest, norun, dir, showAll!@#&local _tArgs = {}!@#&local config = \" /etc/mfb/mouse.cfg \" !@#&!@#&local temp!@#&if shell and shell.getRunningProgram then!@#& temp = shell.getRunningProgram()!@#&end!@#&!@#&temp = temp or \" /bla \" !@#&local localPath = string.sub(temp,1,#temp-string.len(fs.getName(temp)))!@#&temp = nil -- just because not needed!@#&!@#&-- load config file!@#&!@#&local configSet = {}!@#&local cnf = {}!@#&!@#&if fs.exists(localPath.. \" / \" ..config) then!@#& local file = fs.open(localPath.. \" / \" ..config, \" r \" )!@#& if file then!@#& local item = file.readLine()!@#& while item do!@#& table.insert(cnf,item)!@#& item = file.readLine()!@#& end!@#& file.close()!@#& end !@#&end!@#&!@#&for i = 1,10 do!@#& local test,data = pcall(textutils.unserialize,cnf[i])!@#& if test then!@#& configSet[i] = data!@#& else!@#& configSet[i] = nil!@#& end!@#&end!@#&cnf = nil!@#&!@#&-- color configuration work in progress!@#&local titleBar = configSet[1] or {txt = colors.black,back = colors.blue}!@#&local addressBar = configSet[2] or {txt = colors.black,back = colors.lightGray}!@#&local itemWindo = configSet[3] or {txt = colors.black,back = colors.cyan}!@#&local rcmList = configSet[4] or {txt = colors.black,back = colors.lightGray} -- rcm = Right Click Menu List!@#&local rcmTitle = configSet[5] or {txt = colors.black,back = colors.blue}!@#&local dialogTitle = configSet[6] or {txt = colors.black,back = colors.blue}!@#&local dialogWindo = configSet[7] or {txt = colors.black,back = colors.white}!@#&local scrollCol = configSet[8] or {off = colors.gray, button = colors.gray,back = colors.lightGray}!@#&!@#&local tIcons = configSet[9] or {!@#& back = {tCol = \" lightGray \" ,bCol = \" blue \" ,txt = \" < \" },!@#& disk = {tCol = \" lime \" ,bCol = \" green \" ,txt = \" [*] \" },!@#& audio = {tCol = \" yellow \" ,bCol = \" red \" ,txt = \" (o) \" },!@#& folder = {tCol = \" lightGray \" ,bCol = \" blue \" ,txt = \" [=] \" },!@#& file = {tCol = nil ,bCol = nil ,txt = nil}!@#&}!@#&!@#&local customLaunch = configSet[10] or {!@#& [ \" Edit \" ] = \" rom/programs/edit \" ,!@#& [ \" Paint \" ] = \" rom/programs/color/paint \" !@#&}!@#&!@#&local function saveCFG(overWrite)!@#& if not fs.exists(localPath.. \" / \" ..config) or overWrite then!@#& local cnf = {}!@#& local file = fs.open(localPath.. \" / \" ..config, \" w \" )!@#& if file then!@#& file.write(textutils.serialize(titleBar).. \" \\ n \" )!@#& file.write(textutils.serialize(addressBar).. \" \\ n \" )!@#& file.write(textutils.serialize(itemWindo).. \" \\ n \" )!@#& file.write(textutils.serialize(rcmList).. \" \\ n \" )!@#& file.write(textutils.serialize(rcmTitle).. \" \\ n \" )!@#& file.write(textutils.serialize(dialogTitle).. \" \\ n \" )!@#& file.write(textutils.serialize(dialogWindo).. \" \\ n \" )!@#& file.write(textutils.serialize(scrollCol).. \" \\ n \" )!@#& file.write(textutils.serialize(tIcons).. \" \\ n \" )!@#& file.write(textutils.serialize(customLaunch).. \" \\ n \" )!@#& file.close()!@#& elseif overWrite then!@#& end!@#& end!@#&end!@#&!@#&saveCFG()!@#&!@#&-- end configuration!@#&!@#&local function help()!@#& print([[Usage: browser [-d] [-h] [-a] [-u] [--debug] [--help] [--dir <dir>] [--all] [--update]!@#&--debug or -d: enable debug mode!@#&--help or -h: display this screen!@#&--dir: define initial directory!@#&--all or -a: show hidden files!@#&--update -u: update]])!@#&end!@#&!@#&local function inBouwndry(clickX,clickY,boxX,boxY,width,hight)!@#& return ( clickX >= boxX and clickX < boxX + width and clickY >= boxY and clickY < boxY + hight )!@#&end!@#&!@#&local function update()!@#& print( \" Checking for Updates \" )!@#& local isHTTP = false!@#& local response!@#& if http then!@#& isHTTP = true!@#& print( \" http on \" )!@#& response = http.get( \" http://pastebin.com/raw.php?i=rLbnyM1U \" )!@#& end!@#& local flag = false!@#& local isNewFlag = false!@#& local newVerID!@#& if response and isHTTP then!@#& print( \" recived \" )!@#& local sInfo = response.readLine()!@#& print(sInfo)!@#& while sInfo do!@#& print(sInfo)!@#& if flag then!@#& if sInfo == ver then!@#& print( \" Mouse File Browser is up to date \" )!@#& break!@#& else!@#& newVerID = sInfo!@#& flag = false!@#& isNewFlag = true!@#& end!@#& elseif sInfo == sTitle then!@#& flag = true!@#& elseif isNewFlag then!@#& isNewFlag = sInfo!@#& response.close()!@#& break!@#& end!@#& sInfo = response.readLine()!@#& end!@#& if isNewFlag then!@#& print( \" New vershion avalible \" ..newVerID)!@#& print('downloading to \\ Browser')!@#& if fs.exists( \" Browser \" ) then!@#& write( \" Browser exists OverWrite Browser Y/N : \" )!@#& local input = string.lower(read())!@#& while input ~= \" y \" and input ~= \" n \" do!@#& print( \" y or n required \" )!@#& input = string.lower(read())!@#& end!@#& if input == \" y \" then!@#& print( \" Over Writeing Browser \" )!@#& print( \" Downloading new File \" )!@#& local response = http.get( \" http://pastebin.com/raw.php?i= \" ..isNewFlag)!@#& if response then!@#& print( \" file downloaded \" )!@#& print( \" installing \" )!@#& fs.delete( \" Browser \" )!@#& local handel = fs.open( \" Browser \" , \" w \" )!@#& if handel then!@#& handel.write(response.readAll())!@#& handel.close()!@#& print( \" Update Complete \" )!@#& end!@#& response.close()!@#& end!@#& else!@#& print( \" Update aborted \" )!@#& end!@#& else!@#& print( \" Downloading new File \" )!@#& local response = http.get( \" http://pastebin.com/raw.php?i= \" ..isNewFlag)!@#& if response then!@#& print( \" file downloaded \" )!@#& print( \" installing \" )!@#& local handel = fs.open( \" Browser \" , \" w \" )!@#& if handel then!@#& handel.write(response.readAll())!@#& handel.close()!@#& print( \" Update Complete \" )!@#& end!@#& response.close()!@#& end!@#& end!@#& end!@#& elseif isHTTP then!@#& print( \" Error downloading update file Please contact BigSHinyToys on the CC forums \" )!@#& print( \" http://www.computercraft.info/forums2/index.php?/topic/5509-advanced-computer-mouse-file-browser/ \" )!@#& elseif not isHTTP then!@#& print( \" HTTP API is turned off \" )!@#& print( \" Access Computer Craft Configer and change line \" )!@#& print([[enableapi_http {!@#&# Enable the \" http \" API on Computers!@#&general=false!@#&}!@#&TO THIS :!@#&enableapi_http {!@#&# Enable the \" http \" API on Computers!@#&general=true!@#&}]])!@#& end!@#& notCMD = false!@#& norun = true!@#&end!@#&!@#&for a = 1, #tArgs do!@#& if tArgs[a]:sub(1,2) == \" -- \" then!@#& local cmd = tArgs[a]:sub(3):lower()!@#& if cmd == \" debug \" then!@#& bugTest = true!@#& elseif cmd == \" help \" then!@#& help()!@#& norun = true!@#& elseif cmd == \" dir \" then!@#& dir = tArgs[a+1]!@#& a = a + 1!@#& elseif cmd == \" all \" then!@#& showAll = true!@#& elseif cmd == \" update \" then!@#& update()!@#& end!@#& elseif tArgs[a]:sub(1,1) == \" - \" then!@#& for b = 2, #tArgs[a] do!@#& cmd = tArgs[a]:sub(b, b)!@#& if cmd == \" d \" then!@#& bugTest = true!@#& elseif cmd == \" h \" then!@#& help()!@#& norun = true!@#& elseif cmd == \" p \" then!@#& dir = tArgs[a+1]!@#& a = a + 1!@#& elseif cmd == \" a \" then!@#& showAll = true!@#& elseif cmd == \" u \" then!@#& update()!@#& end!@#& end!@#& else!@#& table.insert(_tArgs, tArgs[a])!@#& end!@#&end!@#&!@#&if (not dir) and shell and shell.dir then!@#& dir = shell.dir()!@#&end!@#&!@#&if dir and shell and shell.resolve then!@#& dir = shell.resolve(dir)!@#&end!@#&!@#&dir = dir or \" / \" !@#&!@#&if bugTest then -- this is that the var is for testing!@#& print( \" Dir: \" ..dir)!@#& os.startTimer(4)!@#& os.pullEvent()!@#&end!@#&!@#&local function clear()!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorBlink(false)!@#& term.setCursorPos(1,1)!@#&end!@#&!@#&--[[!@#& Code thanks to Cruor !@#& http://www.computercraft.info/forums2/index.php?/topic/5802-support-for-shell/!@#&]]--!@#&!@#&local function fixArgs(...)!@#& local tReturn={}!@#& local str=table.concat({...}, \" \" )!@#& local sMatch!@#& while str and #str>0 do!@#& if string.sub(str,1,1)== \" \\ \" \" then!@#& sMatch, str=string.match(str, \" \\ \" (.-) \\ \" %s*(.*) \" )!@#& else!@#& sMatch, str=string.match(str, \" (%S+)%s*(.*) \" )!@#& end!@#& table.insert(tReturn,sMatch)!@#& end!@#& return tReturn!@#&end!@#&!@#&--[[ end Cruor function ]]--!@#&!@#&!@#&-- modified read made to play nice with coroutines!@#&!@#&local function readMOD( _sReplaceChar, _tHistory,_wdth)!@#& local sLine = \" \" !@#& term.setCursorBlink( true )!@#&!@#& local nHistoryPos = nil!@#& local nPos = 0!@#& if _sReplaceChar then!@#& _sReplaceChar = string.sub( _sReplaceChar, 1, 1 )!@#& end!@#& !@#& local sx, sy = term.getCursorPos() !@#&!@#& local w, h = term.getSize()!@#& if _wdth and type(_wdth) == \" number \" then!@#& w = sx + _wdth - 1!@#& end!@#& !@#& local function redraw( _sCustomReplaceChar )!@#& local nScroll = 0!@#& if sx + nPos >= w then!@#& nScroll = (sx + nPos) - w!@#& end!@#& !@#& term.setCursorPos( sx + _wdth - 1, sy )!@#& term.write( \" \" )!@#& term.setCursorPos( sx, sy )!@#& local sReplace = _sCustomReplaceChar or _sReplaceChar!@#& if sReplace then!@#& term.write( string.rep(sReplace,_wdth) )!@#& else!@#& term.write( string.sub( sLine, nScroll + 1 ,nScroll + _wdth) )!@#& end!@#& term.setCursorPos( sx + nPos - nScroll, sy )!@#& end!@#& !@#& while true do!@#& local sEvent, param = os.pullEvent()!@#& if sEvent == \" char \" then!@#& sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )!@#& nPos = nPos + 1!@#& redraw()!@#& !@#& elseif sEvent == \" key \" then!@#& !@#& if param == keys.left then!@#& -- Left!@#& if nPos > 0 then!@#& nPos = nPos - 1!@#& redraw()!@#& end!@#& !@#& elseif param == keys.right then!@#& -- Right !@#& if nPos < string.len(sLine) then!@#& nPos = nPos + 1!@#& redraw()!@#& end!@#& !@#& elseif param == keys.up or param == keys.down then!@#& -- Up or down!@#& if _tHistory then!@#& redraw( \" \" );!@#& if param == keys.up then!@#& -- Up!@#& if nHistoryPos == nil then!@#& if #_tHistory > 0 then!@#& nHistoryPos = #_tHistory!@#& end!@#& elseif nHistoryPos > 1 then!@#& nHistoryPos = nHistoryPos - 1!@#& end!@#& else!@#& -- Down!@#& if nHistoryPos == #_tHistory then!@#& nHistoryPos = nil!@#& elseif nHistoryPos ~= nil then!@#& nHistoryPos = nHistoryPos + 1!@#& end !@#& end!@#& !@#& if nHistoryPos then!@#& sLine = _tHistory[nHistoryPos]!@#& nPos = string.len( sLine ) !@#& else!@#& sLine = \" \" !@#& nPos = 0!@#& end!@#& redraw()!@#& end!@#& elseif param == keys.backspace then!@#& -- Backspace!@#& if nPos > 0 then!@#& redraw( \" \" );!@#& sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )!@#& nPos = nPos - 1 !@#& redraw()!@#& end!@#& elseif param == keys.home then!@#& -- Home!@#& nPos = 0!@#& redraw() !@#& elseif param == keys.delete then!@#& if nPos < string.len(sLine) then!@#& redraw( \" \" );!@#& sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 ) !@#& redraw()!@#& end!@#& elseif param == keys[ \" end \" ] then!@#& -- End!@#& nPos = string.len(sLine)!@#& redraw()!@#& end!@#& elseif sEvent == \" redraw \" then!@#& redraw()!@#& elseif sEvent == \" return \" then!@#& term.setCursorBlink( false )!@#& return sLine!@#& end!@#& end!@#& !@#& term.setCursorBlink( false )!@#& !@#& return sLine!@#&end!@#&!@#&-- end modified read!@#&!@#&local function printC(posX,posY,textCol,backCol,text)!@#& term.setCursorPos(posX,posY)!@#& term.setTextColor(colors[textCol] or textCol)!@#& term.setBackgroundColor(colors[backCol] or backCol)!@#& term.write(text)!@#&end!@#&!@#&local function InputBox(title)!@#& local boxW,boxH = 26,3!@#& local termX,termY = term.getSize()!@#& local ofsX,ofsY = math.ceil((termX/2) - (boxW/2)) , math.ceil((termY/2) - (boxH/2)) -- offset from top left!@#& local options = { \" ok \" , \" cancel \" }!@#& !@#& local selected = 1!@#& local space = 0!@#& local range = {}!@#& for i = 1,#options do!@#& range[i] = {s = space,f = space + string.len(options[i])}!@#& space = space + string.len(options[i])+3!@#& end!@#& local ofC = (boxW/2) - (space/2)!@#& !@#& local function drawBox()!@#& printC(ofsX,ofsY,colors.black,colors.blue,string.rep( \" \" ,boxW))!@#& printC(ofsX+1,ofsY,colors.black,colors.blue,(title or \" User Input \" ))!@#& printC(ofsX,ofsY+1,colors.black,colors.white,string.rep( \" \" ,boxW))!@#& printC(ofsX,ofsY+2,colors.black,colors.white,string.rep( \" \" ,boxW))!@#& printC(ofsX,ofsY+3,colors.black,colors.white,string.rep( \" \" ,boxW))!@#& !@#& for i = 1,#options do!@#& if i == selected then!@#& term.setBackgroundColor(colors.lightGray)!@#& term.setCursorPos(range[i].s + ofC + ofsX - 1,ofsY + 3)!@#& term.write( \" [ \" ..options[i].. \" ] \" )!@#& term.setBackgroundColor(colors.white)!@#& term.write( \" \" )!@#& else!@#& term.setCursorPos(range[i].s + ofC + ofsX - 1,ofsY + 3)!@#& term.write( \" \" ..options[i].. \" \" )!@#& end!@#& end!@#& !@#& printC(ofsX+2,ofsY+2,colors.black,colors.lightGray,string.rep( \" \" ,boxW-4))!@#& end!@#& drawBox()!@#& term.setCursorPos(ofsX+2,ofsY+2)!@#& local co = coroutine.create(function() return readMOD(nil,nil,boxW - 4) end)!@#& while true do!@#& local event = {os.pullEvent()}!@#& if event[1] == \" key \" or event[1] == \" char \" then!@#& if event[2] == 28 then!@#& local test,data = coroutine.resume(co, \" return \" )!@#& return data!@#& else!@#& coroutine.resume(co,unpack(event))!@#& end!@#& elseif event[1] == \" mouse_click \" then!@#& if event[4] == ofsY + 3 then!@#& for i = 1,#options do!@#& if event[3] >= range[i].s + ofC + ofsX - 1 and event[3] <= range[i].f + ofC + ofsX then!@#& if options[i] == \" ok \" then!@#& local test,data = coroutine.resume(co, \" return \" )!@#& return data!@#& elseif options[i] == \" cancel \" then!@#& return false!@#& end!@#& end!@#& end!@#& end!@#& end!@#& end!@#&end!@#&!@#&local function dialogBox(title,message,options, h, w)!@#& term.setCursorBlink(false)!@#& local selected = 1!@#& title = title or \" \" !@#& message = message or \" \" !@#& options = options or {}!@#& local boxW,boxH = (w or 26), (h or 3)!@#& local termX,termY = term.getSize()!@#& local ofsX,ofsY = math.ceil((termX/2) - (boxW/2)) , math.ceil((termY/2) - (boxH/2)) -- offset from top left!@#& !@#& local space = 0!@#& local range = {}!@#& for i = 1,#options do!@#& range[i] = {s = space,f = space + string.len(options[i])}!@#& space = space + string.len(options[i])+3!@#& end!@#& local ofC = math.ceil((boxW/2)) - math.ceil((space/2))!@#& !@#& local function drawBox()!@#& printC(ofsX,ofsY,dialogTitle.txt,dialogTitle.back, \" \" ..title..string.rep( \" \" ,boxW-#title-5).. \" _[] \" )!@#& term.setBackgroundColor(colors.red)!@#& term.setTextColor(colors.white)!@#& term.write( \" X \" )!@#& printC(ofsX,ofsY+1,dialogWindo.txt,dialogWindo.back,string.sub( \" \" ..message..string.rep( \" \" ,boxW),1,boxW))!@#& term.setCursorPos(ofsX,ofsY+2)!@#& term.write(string.rep( \" \" ,boxW))!@#& term.setCursorPos(ofsX,ofsY+3)!@#& term.write(string.rep( \" \" ,boxW))!@#& for i = 1,#options do!@#& if i == selected then!@#& printC(range[i].s + ofC + ofsX - 1,ofsY + 3, \" black \" , \" lightGray \" , \" [ \" ..options[i].. \" ] \" )!@#& term.setBackgroundColor(dialogWindo.back)!@#& term.setTextColor(dialogWindo.txt)!@#& term.write( \" \" )!@#& else!@#& term.setCursorPos(range[i].s + ofC + ofsX - 1,ofsY + 3)!@#& term.write( \" \" ..options[i].. \" \" )!@#& end!@#& end!@#& term.setCursorPos(ofsX + ofC + space,ofsY + 3)!@#& term.write(string.rep( \" \" ,boxW - (ofC + space)))!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white) !@#& end!@#& while true do!@#& drawBox()!@#& event = {os.pullEvent()}!@#& if event[1] == \" key \" then!@#& if event[2] == 203 then -- left!@#& selected = selected - 1!@#& if selected < 1 then!@#& selected = #options!@#& end!@#& elseif event[2] == 205 then -- right!@#& selected = selected + 1!@#& if selected > #options then!@#& selected = 1!@#& end!@#& elseif event[2] == 28 then -- enter!@#& return selected , options[selected]!@#& end!@#& elseif event[1] == \" mouse_click \" then!@#& !@#& if bugTest then term.write( \" M \" ..event[2].. \" X \" ..event[3].. \" Y \" ..event[4].. \" \" ) end!@#& !@#& if event[2] == 1 then!@#& if event[4] == ofsY + 3 then!@#& for i = 1,#options do!@#& if event[3] >= range[i].s + ofC + ofsX - 1 and event[3] <= range[i].f + ofC + ofsX then!@#& return i , options[i]!@#& end!@#& end!@#& end!@#& end!@#& end!@#& end!@#&end!@#&!@#&local flag = true!@#&local fSlash = \" / \" !@#&local path = {dir:match( \" [^/]+ \" )}!@#&local function stringPath() -- compacted this a lot!@#& return fSlash..table.concat(path,fSlash)!@#&end!@#&!@#&local function osRunSpaces(sFileLocation,...) -- getRunningProgram() [ \" shell \" ] = shell!@#& clear()!@#& if os.newThread then!@#& os.newThread(false,...)!@#& else!@#& local fProg,probblem = loadfile(sFileLocation)!@#& if fProg then!@#& local tEnv = {[ \" shell \" ] = {}}!@#& setmetatable(tEnv.shell,{ __index = shell})!@#& tEnv.shell.getRunningProgram = function()!@#& return sFileLocation!@#& end!@#& setmetatable(tEnv,{ __index = _G})!@#& setfenv(fProg,tEnv)!@#& local test,probblem = pcall(fProg,...)!@#& if not test then!@#& print(probblem)!@#& dialogBox( \" ERROR \" ,tostring(probblem),{ \" ok \" },3,30)!@#& else!@#& return true!@#& end!@#& else!@#& print(probblem)!@#& dialogBox( \" ERROR \" ,tostring(probblem),{ \" ok \" },3,30)!@#& end!@#& end!@#&end!@#&!@#&local function rClickMenu(title,tList,tItem,posX,posY)!@#&!@#& term.setCursorBlink(false)!@#& local BoxTitle = title!@#& local choices = {}!@#& local termX,termY = term.getSize()!@#& local offX,offY!@#& !@#& local width = #BoxTitle + 2!@#& local hight!@#& !@#& for k,v in pairs(tList) do!@#& if v ~= nil then!@#& table.insert(choices,k)!@#& end!@#& if width < #k + 2 then!@#& width = #k + 2!@#& end!@#& end!@#& !@#& if #choices == 0 then!@#& return!@#& end!@#& !@#& hight = #choices + 1!@#& table.sort(choices)!@#& !@#& offX,offY = math.ceil((termX/2) - (width/2)),math.ceil((termY/2) - (hight/2))!@#& !@#& if posX and posY then -- offX,offY = posX,posY!@#& if posX >= termX - width - 1 then!@#& offX = termX - width - 1!@#& else!@#& offX = posX!@#& end!@#& if posY >= termY - hight then!@#& offY = termY - hight!@#& else!@#& offY = posY!@#& end!@#& end!@#& !@#& local function reDrawer()!@#& printC(offX,offY,rcmTitle.txt,rcmTitle.back, \" \" ..BoxTitle..string.rep( \" \" ,width - #BoxTitle - 1))!@#& for i = 1,#choices do!@#& printC(offX,offY + i,rcmList.txt,rcmList.back, \" \" ..choices[i]..string.rep( \" \" ,width - #choices[i] - 1))!@#& end!@#& end!@#& !@#& while true do!@#& reDrawer()!@#& local event = {os.pullEvent()}!@#& if event[1] == \" mouse_click \" then!@#& if event[2] == 1 then -- event[3] = x event[4] = y!@#& if event[4] > offY and event[4] < hight + offY and event[3] >= offX and event[3] < width + offX then!@#& --dialogBox( \" ERROR: \" ,type(tList[choices[event[4] - offY]]),{ \" ok \" })!@#& if type(tList[choices[event[4] - offY]]) == \" function \" then!@#& return tList[choices[event[4] - offY]](tItem)!@#& elseif type(tList[choices[event[4] - offY]]) == \" table \" then!@#& return rClickMenu( \" Options \" ,tList[choices[event[4] - offY]],tItem,event[3],event[4])!@#& elseif type(tList[choices[event[4] - offY]]) == \" string \" then!@#& return osRunSpaces(!@#& unpack(!@#& fixArgs(!@#& tList[choices[event[4] - offY]].. \" \\ \" \" ..stringPath()..fSlash..tItem.n.. \" \\ \" \" !@#& )!@#& )!@#& )!@#& else!@#& dialogBox( \" ERROR: \" , \" somthing up with new rMenu \" ,{ \" ok \" })!@#& end!@#& else!@#& return!@#& end!@#& elseif event[2] == 2 then!@#& return!@#& end!@#& end!@#& end!@#& !@#&end!@#&!@#&local function preferences()!@#& local tItem = {!@#& {txt = \" Title Bar \" ,it = titleBar},!@#& {txt = \" Address Bar \" ,it = addressBar},!@#& {txt = \" Item Windo \" , it = itemWindo},!@#& {txt = \" Title Right Click Title \" ,it = rcmTitle},!@#& {txt = \" Right Click Menu \" ,it = rcmList},!@#& {txt = \" Title Dialog Box \" ,it = dialogTitle},!@#& {txt = \" Dialog Box \" ,it = dialogWindo},!@#& {txt = \" Scroll Bar \" ,it = scrollCol}!@#& }!@#& local topL,topR = 13,5!@#& local width,hight = 23,6!@#& local bottomL,bottomR = topL + width,topR + hight!@#& !@#& local listOffset = 0!@#& local sel = 1!@#& local otherSel = 1!@#& local otherItems = {}!@#& !@#& if tItem[sel] then!@#& for k,v in pairs(tItem[sel].it) do!@#& table.insert(otherItems,{txt = k,it = v})!@#& end!@#& end!@#& !@#& local function draw()!@#& printC(topL,topR,titleBar.txt,titleBar.back,string.sub( \" Preferences \" ..string.rep( \" \" ,width),1,width))!@#& for i = 0,12,4 do!@#& for a = 1,4 do!@#& --printC(topL + (a*12)-12 ,topR + ((i+4)/4),4,2^(a+i-1), \" \" ..tostring(2^(a+i-1)))!@#& printC(topL + a-1 ,topR + ((i+4)/4),4,2^(a+i-1), \" \" )!@#& end!@#& end!@#& local sSel = \" \" !@#& for i = 1,hight - 2 do!@#& if i == sel - listOffset then!@#& sSel = \" > \" !@#& end!@#& if tItem[i+listOffset] then!@#& printC(topL + 4 ,topR + i,colors.black,colors.white,string.sub(sSel..tItem[i+listOffset].txt..string.rep( \" \" ,width),1,width - 4))!@#& else!@#& printC(topL + 4 ,topR + i,colors.black,colors.white,sSel..string.rep( \" \" ,width-5))!@#& end!@#& if i == sel - listOffset then!@#& sSel = \" \" !@#& end!@#& end!@#& term.setCursorPos(topL,topR + hight - 1)!@#& local loop = 1!@#& local length = 0!@#& for i = 1,#otherItems do!@#& if otherSel == i then!@#& sSel = \" > \" !@#& end!@#& if colors.black == otherItems[i].it or colors.gray == otherItems[i].it then!@#& term.setTextColor(colors.white)!@#& else!@#& term.setTextColor(colors.black)!@#& end!@#& term.setBackgroundColor(otherItems[i].it)!@#& term.write(sSel..tostring(otherItems[i].txt).. \" \" )!@#& length = length + #otherItems[i].txt + 2!@#& if otherSel == i then!@#& sSel = \" \" !@#& end!@#& loop = loop+1!@#& end!@#& term.setBackgroundColor(colors.white)!@#& term.write(string.rep( \" \" ,width - length))!@#& end!@#& while true do!@#& draw()!@#& local event = {os.pullEvent()}!@#& if event[1] == \" mouse_click \" and event[2] == 1 then!@#& if inBouwndry(event[3],event[4],topL,topR,width,hight) then!@#& local inSideX,inSideY = event[3] - topL,event[4] - topR!@#& if inBouwndry(inSideX+1,inSideY,1,1,4,4) and tItem[sel] then!@#& --[[!@#& term.setCursorPos(1,1)!@#& term.setBackgroundColor(2^(inSideX + ((inSideY*4)-4)))!@#& print(2^(inSideX + ((inSideY*4)-4)), \" \" ,inSideX + ((inSideY*4)-4), \" \" )!@#& ]]--!@#& tItem[sel][ \" it \" ][otherItems[otherSel].txt] = (2^(inSideX + ((inSideY*4)-4)))!@#& end!@#& end!@#& elseif event[1] == \" key \" then!@#& if event[2] == 200 then!@#& sel = sel - 1!@#& elseif event[2] == 208 then!@#& sel = sel + 1!@#& elseif event[2] == 203 then!@#& otherSel = otherSel - 1!@#& elseif event[2] == 205 then!@#& otherSel = otherSel + 1!@#& elseif event[2] == 28 then!@#& if dialogBox( \" Confirm \" , \" Save prefrences? \" ,{ \" Yes \" , \" No \" }) == 1 then!@#& saveCFG(true)!@#& end!@#& return!@#& end!@#& end!@#& if sel < 1 then!@#& sel = 1!@#& elseif sel > #tItem then!@#& sel = #tItem!@#& end!@#& if sel > listOffset + hight - 2 then!@#& listOffset = listOffset + 1!@#& elseif sel - listOffset < 1 then!@#& listOffset = listOffset - 1!@#& end!@#& !@#& otherItems = {}!@#& if tItem[sel] then!@#& for k,v in pairs(tItem[sel].it) do!@#& table.insert(otherItems,{txt = k,it = v})!@#& end!@#& end!@#& !@#& if otherSel < 1 then!@#& otherSel = 1!@#& elseif otherSel > #otherItems then!@#& otherSel = #otherItems!@#& end!@#& !@#& if bugTest then!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.setCursorPos(1,1)!@#& term.clearLine()!@#& term.write( \" sel \" ..sel.. \" offset \" ..listOffset)!@#& end!@#& end!@#&end!@#&!@#&local function fileSelect(mode) -- save_file open_file browse < not yet implemented!@#& !@#& local title = sTitle.. \" \" ..ver!@#& local bRun = true!@#& local clipboard = nil!@#& local cut = false!@#& !@#& local termX,termY = term.getSize()!@#& local offsetX,offsetY = 1,1!@#& local hight,width = math.ceil(termY-2),math.ceil(termX-2)!@#& local oldHight,oldWidth!@#& !@#& -- offsets!@#& local boxOffX,boxOffY = offsetX,offsetY + 2!@#& local boxH,boxW = hight - 2 ,width - 2!@#& !@#& local barX,barY = offsetX + 1,offsetY + 2!@#& local barH,barW = 1,width - 1!@#& !@#& local tbarX,tbarY = offsetX + 1,offsetY + 1!@#& local tbarH,tbarW = 1,width - 1!@#& !@#& local exitX,exitY = offsetX + width - 1 ,offsetY + 1!@#& !@#& local pading = string.rep( \" \" ,boxW)!@#& local list!@#& !@#& local listOff = 0!@#& !@#& local sPath!@#& local tItemList = {}!@#& !@#& local function newList()!@#& listOff = 0!@#& flag = true!@#& tItemList = {{n = \" .. \" , id = \" back \" }} -- adds a back item at top of list!@#& sPath = stringPath()!@#& local folders = {}!@#& local files = {}!@#& local disks = {}!@#& if not fs.exists(sPath) then!@#& path = {}!@#& sPath = stringPath()!@#& dialogBox( \" ERROR: \" , \" Path no longer exists \" ,{ \" ok \" })!@#& end!@#& local test,list = pcall(fs.list,sPath) -- stopes fs.list crash!@#& if list == nil then!@#& list = {}!@#& dialogBox( \" ERROR : \" , \" fs.list crashed \" ,{ \" ok \" })!@#& end!@#& if #path == 0 then!@#& for i,v in pairs(rs.getSides()) do!@#& if disk.isPresent(v) then!@#& if disk.hasData(v) then!@#& table.insert(tItemList,{n = disk.getMountPath(v), id = \" disk \" ,s = v})!@#& disks[disk.getMountPath(v)] = true!@#& elseif disk.hasAudio(v) then!@#& table.insert(tItemList,{n = disk.getAudioTitle(v), id = \" audio \" ,s = v})!@#& end!@#& end!@#& end!@#& end!@#& for i,v in pairs(list) do!@#& if fs.isDir(sPath..fSlash..v) then!@#& table.insert(folders,v)!@#& else!@#& table.insert(files,v)!@#& end!@#& end!@#& table.sort(folders)!@#& table.sort(files)!@#& for i,v in pairs(folders) do!@#& if disks[v] == nil then!@#& table.insert(tItemList,{n = v, id = \" folder \" })!@#& end!@#& end!@#& for i,v in pairs(files) do!@#& table.insert(tItemList,{n = v, id = \" file \" })!@#& end!@#& end!@#& !@#& local function paste()!@#& if cut then!@#& local s, m = pcall(!@#& function()!@#& fs.move(clipboard[1]..fSlash..clipboard[2], stringPath()..fSlash..clipboard[2])!@#& cut = false!@#& clipboard = nil!@#& end)!@#& if not s then!@#& dialogBox( \" Error \" , (m or \" Couldn't move \" ), { \" ok \" }, 4, 30)!@#& end!@#& if bugTest then!@#& local x, y = term.getCursorPos()!@#& term.setCursorPos(1, ({term.getSize()})[2])!@#& write( \" from \" ..clipboard[1]..fSlash..clipboard[2].. \" to \" ..stringPath()..fSlash..clipboard[2])!@#& end!@#& else!@#& local s, m = pcall(function()!@#& if fs.exists(stringPath()..fSlash..clipboard[2]) then!@#& fs.copy(clipboard[1]..fSlash..clipboard[2], stringPath()..fSlash.. \" copy- \" ..clipboard[2])!@#& else!@#& fs.copy(clipboard[1]..fSlash..clipboard[2], stringPath()..fSlash..clipboard[2])!@#& end!@#& end)!@#& if not s then!@#& dialogBox( \" Error \" , (m or \" Couldn't copy \" ), { \" ok \" }, 4, 30)!@#& end!@#& if bugTest then!@#& local x, y = term.getCursorPos()!@#& term.setCursorPos(1, ({term.getSize()})[2])!@#& write( \" from \" ..clipboard[1]..fSlash..clipboard[2].. \" to \" ..stringPath()..fSlash..clipboard[2])!@#& end!@#& end!@#& newList()!@#& end!@#& !@#& -- this section bellow handles the right click menu!@#& !@#& local tmenu = {!@#& disk = {!@#& [ \" Open \" ] = function(tItem)!@#& table.insert(path,tItem.n)!@#& newList()!@#& end,!@#& [ \" Copy \" ] = function(tItem)!@#& clipboard = {stringPath(), tItem.n}!@#& cut = false!@#& end,!@#& [ \" Eject \" ] = function(tItem)!@#& if dialogBox( \" Confirm \" , \" Eject \" ..fSlash..tItem.n.. \" \" ..tItem.s,{ \" yes \" , \" no \" }) == 1 then!@#& disk.eject(tItem.s)!@#& newList()!@#& end!@#& end,!@#& [ \" ID label \" ] = function(tItem)!@#& dialogBox( \" ID label \" ,disk.getDiskID(tItem.s).. \" \" ..tostring(disk.getLabel(tItem.s)),{ \" ok \" })!@#& end,!@#& [ \" Set label \" ] = function(tItem)!@#& local name = InputBox( \" Label? \" )!@#& if name then!@#& disk.setLabel(tItem.s,name)!@#& end!@#& end,!@#& [ \" Clear label \" ] = function(tItem)!@#& if dialogBox( \" Confirm \" , \" Cleal Label from \" ..tItem.s,{ \" yes \" , \" no \" }) == 1 then!@#& disk.setLabel(tItem.s)!@#& end!@#& end!@#& },!@#& folder = {!@#& [ \" Open \" ] = function(temp)!@#& table.insert(path,temp.n)!@#& newList()!@#& end,!@#& [ \" Copy \" ] = function(tItem)!@#& clipboard = {stringPath(), tItem.n}!@#& cut = false!@#& end,!@#& [ \" Cut \" ] = function(tItem)!@#& clipboard = {stringPath(), tItem.n}!@#& cut = true!@#& end,!@#& [ \" Delete \" ] = function(tItem)!@#& if dialogBox( \" Confirm \" , \" Delete \" ..tItem.id.. \" \" ..tItem.n,{ \" yes \" , \" no \" }) == 1 then!@#& if fs.isReadOnly(stringPath()..fSlash..tItem.n) then!@#& dialogBox( \" ERROR \" ,tItem.id.. \" Is read Only \" ,{ \" ok \" })!@#& else!@#& fs.delete(stringPath()..fSlash..tItem.n)!@#& newList()!@#& end!@#& end!@#& end,!@#& [ \" Rename \" ] = function(tItem)!@#& local sName = InputBox( \" New Name \" )!@#& if type(sName) == \" string \" and sName ~= \" \" then!@#& local s, m = pcall(function()!@#& fs.move(stringPath()..fSlash..tItem.n,stringPath()..fSlash..sName)!@#& end)!@#& if not s then!@#& dialogBox( \" Error \" , (m or \" Rename failed \" ), { \" ok \" })!@#& end!@#& end!@#& newList()!@#& end!@#& },!@#& file = {!@#& [ \" Run \" ] = {!@#& [ \" Run \" ] = function(tItem)!@#& osRunSpaces(stringPath()..fSlash..tItem.n)!@#& end,!@#& [ \" Run CMD \" ] = function(tItem)!@#& local cmd = InputBox( \" Commands \" )!@#& if cmd then!@#& osRunSpaces(stringPath()..fSlash..tItem.n,unpack(fixArgs(cmd)))!@#& end!@#& end,!@#& },!@#& [ \" Open With \" ] = customLaunch,!@#& [ \" Rename \" ] = function(tItem)!@#& local sName = InputBox( \" New Name \" )!@#& if type(sName) == \" string \" and sName ~= \" \" then!@#& local s, m = pcall(function()!@#& fs.move(stringPath()..fSlash..tItem.n,stringPath()..fSlash..sName)!@#& end)!@#& if not s then!@#& dialogBox( \" Error \" , (m or \" Rename failed \" ), { \" ok \" })!@#& end!@#& end!@#& newList()!@#& end,!@#& [ \" Delete \" ] = function(tItem)!@#& if dialogBox( \" Confirm \" , \" Delete \" ..tItem.id.. \" \" ..tItem.n,{ \" yes \" , \" no \" }) == 1 then!@#& if fs.isReadOnly(stringPath()..fSlash..tItem.n) then!@#& dialogBox( \" ERROR \" ,tItem.id.. \" Is read Only \" ,{ \" ok \" })!@#& else!@#& fs.delete(stringPath()..fSlash..tItem.n)!@#& newList()!@#& end!@#& end!@#& end,!@#& [ \" Cut \" ] = function(tItem)!@#& clipboard = {stringPath(), tItem.n}!@#& cut = true!@#& end,!@#& [ \" Copy \" ] = function(tItem)!@#& clipboard = {stringPath(), tItem.n}!@#& cut = false!@#& end!@#& },!@#& audio = {!@#& [ \" Play \" ] = 1,!@#& [ \" Eject \" ] = 1!@#& },!@#& back = {!@#& },!@#& blank = { -- tmenu.blank.Paste = !@#& [ \" Paste \" ] = nil,!@#& [ \" New File \" ] = function()!@#& local name = InputBox()!@#& if name then!@#& if fs.exists(stringPath()..fSlash..name) then!@#& dialogBox( \" ERROR \" , \" Name exists \" ,{ \" ok \" })!@#& else!@#& local file = fs.open(stringPath()..fSlash..name, \" w \" )!@#& if file then!@#& file.write( \" \" )!@#& file.close()!@#& newList()!@#& else!@#& dialogBox( \" ERROR \" , \" File not created \" ,{ \" ok \" })!@#& end!@#& end!@#& end!@#& end,!@#& [ \" New Folder \" ] = function()!@#& local name = InputBox()!@#& if name then!@#& if fs.exists(stringPath()..fSlash..name) then!@#& dialogBox( \" ERROR \" , \" Name exists \" ,{ \" ok \" })!@#& else!@#& if pcall(fs.makeDir,stringPath()..fSlash..name) then!@#& newList()!@#& else!@#& dialogBox( \" ERROR \" , \" Access Denied \" ,{ \" ok \" })!@#& end!@#& end!@#& end!@#& end,!@#& [ \" Preferences \" ] = preferences!@#& },!@#& }!@#& !@#& -- end right click menu!@#& !@#& local function scrollBar(posX,posY)!@#& if posX == boxOffX+boxW+1 and posY > boxOffY and posY <= boxOffY+boxH then!@#& if #tItemList > boxH then!@#& if posY == boxOffY + 1 then!@#& listOff = 0!@#& elseif posY == boxOffY+boxH then!@#& listOff = #tItemList + 1 - boxH!@#& else!@#& listOff = math.ceil((posY - boxOffY - 1 )*(((#tItemList - boxH+2)/boxH)))!@#& end!@#& flag = true!@#& end!@#& end!@#& end!@#& !@#& newList()!@#& !@#& while bRun do!@#& if flag then!@#& flag = false!@#& -- clear!@#& if oldHight ~= hight and oldWidth ~= width then!@#& term.setBackgroundColor(colors.black)!@#& term.clear()!@#& oldHight,oldWidth = hight,width!@#& end!@#& -- draw top title bar!@#& local b = tbarW - #title -2!@#& if b < 0 then!@#& b = 0!@#& end!@#& printC(tbarX,tbarY,titleBar.txt,titleBar.back,string.sub( \" \" ..title,1,tbarW)..string.rep( \" \" ,b))!@#& term.setTextColor(colors.white)!@#& term.setBackgroundColor(colors.red)!@#& term.write( \" X \" )!@#& !@#& -- draw location bar!@#& local a = barW - #sPath - 1!@#& if a < 0 then!@#& a = 0!@#& end!@#& local tmppath = sPath!@#& if shell and shell.getDisplayName then!@#& tmppath = shell.getDisplayName(sPath)!@#& --dialogBox( \" yay \" )!@#& else!@#& --dialogBox( \" moop \" )!@#& end!@#& tmppath = tmppath or sPath!@#& local a = barW - #tmppath - 1!@#& if a < 0 then!@#& a = 0!@#& end!@#& printC(barX,barY,addressBar.txt,addressBar.back,string.sub( \" \" ..tmppath,1,barW)..string.rep( \" \" ,a))!@#& !@#& -- draw scroll bar!@#& if #tItemList > boxH then!@#& term.setBackgroundColor(scrollCol.back)!@#& for i = 1,boxH do!@#& term.setCursorPos(boxOffX+boxW+1,i + boxOffY)!@#& local scroll = math.floor( boxH* (listOff/(#tItemList-boxH+2)) )+1!@#& if i == scroll then!@#& term.setBackgroundColor(scrollCol.button)!@#& term.write( \" \" )!@#& term.setBackgroundColor(scrollCol.back)!@#& else!@#& term.write( \" \" )!@#& end!@#& end!@#& else!@#& term.setBackgroundColor(scrollCol.off)!@#& for i = 1,boxH do!@#& term.setCursorPos(boxOffX+boxW+1,i + boxOffY)!@#& term.write( \" \" )!@#& end!@#& end!@#& !@#& -- draw main section!@#&!@#& for i = 1,boxH do -- listOff!@#& local sel = i+listOff!@#& if tItemList[sel] then!@#& printC(1+boxOffX,i+boxOffY,(tIcons[tItemList[sel].id].tCol or itemWindo.txt),(tIcons[tItemList[sel].id].bCol or itemWindo.back),( tIcons[tItemList[sel].id].txt or \" \" ))!@#& printC(4+boxOffX,i+boxOffY,itemWindo.txt,itemWindo.back,string.sub( \" \" ..tItemList[sel].n..pading,1,boxW-3))!@#& else!@#& printC(1+boxOffX,i+boxOffY,itemWindo.txt,itemWindo.back,pading)!@#& end!@#& end!@#& !@#& if bugTest then!@#& printC(1,1, \" black \" , \" white \" ,listOff.. \" \" ..boxOffY.. \" \" ..boxH)!@#& end!@#& !@#& end!@#& !@#& -- react to events!@#& local event = {os.pullEvent()}!@#& !@#& if event[1] == \" mouse_click \" then!@#& if inBouwndry(event[3],event[4],boxOffX+1,boxOffY+1,boxW,boxH) then!@#& local selected = tItemList[event[4]+listOff-boxOffY]!@#& if selected and inBouwndry(event[3],event[4],boxOffX+1,event[4],#selected.n + 4,1) then!@#& if event[2] == 1 then -- left mouse!@#& if selected.id == \" back \" then!@#& table.remove(path,#path)!@#& newList()!@#& elseif selected.id == \" folder \" or selected.id == \" disk \" then!@#& table.insert(path,selected.n)!@#& newList()!@#& elseif selected.id == \" file \" then!@#& if dialogBox( \" Run file ? \" ,selected.n,{ \" yes \" , \" no \" }) == 1 then!@#& osRunSpaces(stringPath()..fSlash..selected.n)!@#& end!@#& flag = true!@#& end!@#& elseif event[2] == 2 then -- right mouse!@#& rClickMenu( \" Options \" ,tmenu[selected.id],selected,event[3],event[4])!@#& flag = true!@#& end!@#& elseif event[2] == 2 then -- right clicking not on object!@#& if clipboard then!@#& tmenu.blank.Paste = paste!@#& else!@#& tmenu.blank.Paste = nil!@#& end!@#& rClickMenu( \" Options \" ,tmenu[ \" blank \" ],selected,event[3],event[4])!@#& flag = true!@#& end!@#& elseif event[2] == 1 and event[3] == exitX and event[4] == exitY then!@#& if dialogBox( \" Confirm \" , \" Exit application \" ,{ \" yes \" , \" no \" }) == 1 then!@#& bRun = false!@#& end!@#& flag = true!@#& elseif event[2] == 1 then!@#& scrollBar(event[3],event[4])!@#& end!@#& elseif event[1] == \" mouse_scroll \" then -- flag this needs new math!@#& local old = listOff!@#& listOff = listOff + event[2]!@#& if listOff < 0 then!@#& listOff = 0!@#& end!@#& if #tItemList + 1 - boxH > 0 and listOff > #tItemList + 1 - boxH then!@#& listOff = #tItemList + 1 - boxH!@#& elseif listOff > 0 and #tItemList + 1 - boxH < 0 then!@#& listOff = 0!@#& end!@#& if listOff ~= old then!@#& flag = true!@#& end!@#& !@#& elseif event[1] == \" mouse_drag \" then -- scroll bar!@#& scrollBar(event[3],event[4])!@#& elseif event[1] == \" disk \" or event[1] == \" disk_eject \" then!@#& newList()!@#& elseif event[1] == \" window_resize \" then!@#& termX,termY = term.getSize()!@#& offsetX,offsetY = 1,1!@#& hight,width = math.ceil(termY-2),math.ceil(termX-2)!@#& !@#& boxOffX,boxOffY = offsetX,offsetY + 2!@#& boxH,boxW = hight - 2 ,width - 2!@#& !@#& barX,barY = offsetX + 1,offsetY + 2!@#& barH,barW = 1,width - 1!@#& !@#& tbarX,tbarY = offsetX + 1,offsetY + 1!@#& tbarH,tbarW = 1,width - 1!@#& !@#& exitX,exitY = offsetX + width - 1 ,offsetY + 1!@#& pading = string.rep( \" \" ,boxW)!@#& !@#& flag = true!@#& elseif event[1] == \" redraw \" then!@#& flag = true!@#& end!@#& end!@#&end!@#&!@#&local function main()!@#& if term.isColor() then!@#& clear()!@#& fileSelect()!@#& clear()!@#& else!@#& error( \" Not an Advanced Computer (gold) \" )!@#& end!@#&end!@#&!@#&local trash = (norun or main())" , [ "opts" ] = "" , [ "lmail" ] = "sel = sysconf.theme_sel!@#&desel = sysconf.theme_desel!@#&background = sysconf.theme_background" , [ "boot" ] = { [ "loadapis" ] = "list = fs.list( \" /lib/libapi/ \" )!@#&for i = 1,#list do!@#& api = os.loadAPI( \" /lib/libapi/ \" .. list[i])!@#&end" , } , [ "optlib" ] = { [ "usrs" ] = "local function createNew(un)!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& write( \" Password? \" )!@#& np = read( \" * \" )!@#& usrs[un] = hash.sha256(np)!@#& nf = textutils.serialize(usrs)!@#& sv = fs.open( \" /lib/usr/users \" , \" w \" )!@#& sv.writeLine(nf)!@#& sv.close()!@#& print( \" OK! \" )!@#& sleep(2)!@#& os.reboot()!@#&end!@#&!@#&local function modify(un)!@#& term.setBackgroundColor(colors.black)!@#& term.setTextColor(colors.white)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& write( \" New password? \" )!@#& np = read( \" * \" )!@#& usrs[un] = hash.sha256(np)!@#& nf = textutils.serialize(usrs)!@#& sv = fs.open( \" /lib/usr/users \" , \" w \" )!@#& sv.writeLine(nf)!@#& sv.close()!@#& print( \" OK! \" )!@#& sleep(2)!@#& os.reboot()!@#&end!@#&!@#&usrs = linox.getUserFile()!@#&term.setBackgroundColor(colors.black)!@#&term.setTextColor(colors.white)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&print( \" Please enter the name of a user (it doesn't need to exist) or type exit to exit. \" )!@#&user = read()!@#&if user == \" exit \" then!@#& os.reboot()!@#&end!@#&if not usrs[user] then!@#& createNew(user)!@#&else!@#& modify(user)!@#&end" , [ "opts" ] = "if not sudo.isAdmin() then!@#& print( \" Privs not sufficient. \" )!@#& write( \" For more information go to \" )!@#& term.setTextColor(colors.yellow)!@#& print( \" http://zudohackz.kd.io \" )!@#& term.setTextColor(colors.white)!@#& error()!@#&end!@#&!@#&w,h = term.getSize()!@#&function printc(str,l)!@#& term.setCursorPos(w/2-#str/2,l)!@#& print(str)!@#&end!@#&!@#&term.setBackgroundColor(colors.lightGray)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&term.setBackgroundColor(colors.white)!@#&write(string.rep( \" \" ,w))!@#&term.setTextColor(colors.black)!@#&printc( \" System Settings \" ,1)!@#&quit = \" [Quit] \" !@#&term.setCursorPos(w-#quit,1)!@#&print(quit)!@#&term.setTextColor(colors.white)!@#&term.setCursorPos(3,8)!@#&term.setBackgroundColor(colors.red)!@#&print( \" \" )!@#&term.setCursorPos(3,9)!@#&print( \" PC Name \" )!@#&term.setCursorPos(3,10)!@#&print( \" \" )!@#&term.setBackgroundColor(colors.lime)!@#&term.setCursorPos(20,8)!@#&print( \" \" )!@#&term.setCursorPos(20,9)!@#&print( \" Users \" )!@#&term.setCursorPos(20,10)!@#&print( \" \" )!@#&function getClickPos()!@#& _,b,xpos,ypos = os.pullEvent( \" mouse_click \" )!@#& if ypos == 8 or ypos == 9 or ypos == 10 then!@#& if xpos == 3 or xpos == 4 or xpos == 5 or xpos == 6 or xpos == 7 or xpos == 8 or xpos == 9 or xpos == 10 or xpos == 11 or xpos == 12 then!@#& return \" pcname \" !@#& elseif xpos == 20 or xpos == 21 or xpos == 22 or xpos == 23 or xpos == 24 or xpos == 25 or xpos == 26 or xpos == 27 or xpos == 28 or xpos == 29 then!@#& return \" users \" !@#& end!@#& elseif ypos == 1 then!@#& if xpos == w-#quit or xpos == w-#quit+1 or xpos == w-#quit+2 or xpos == w-#quit+3 or xpos == w-#quit+4 or xpos == w-#quit+5 or w-#quit+6 then!@#& os.reboot()!@#& end!@#& end!@#&end!@#&!@#&while true do!@#& option = getClickPos()!@#& if option == \" pcname \" then!@#& term.setBackgroundColor(colors.black)!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& write( \" New Name: \" )!@#& os.setComputerLabel(read())!@#& shell.run( \" opts \" )!@#& elseif option == \" users \" then!@#& shell.run( \" /bin/optlib/usrs \" )!@#& end!@#&end" , } , [ "clearc" ] = "if term.isColor() then!@#& term.setTextColor(colors.white)!@#& term.setBackgroundColor(colors.black)!@#&end!@#&term.clear()!@#&term.setCursorPos(1,1)" , [ "plist" ] = "" , [ "gksu" ] = "args = {...}!@#&if not sudo.isAdmin() then!@#&term.setCursorPos(w/2-l/2,h/2-2)!@#&term.setBackgroundColor(colors.red)!@#&print( \" \" )!@#&term.setCursorPos(w/2-l/2,h/2-1)!@#&print( \" Password: \" )!@#&term.setCursorPos(w/2-l/2,h/2)!@#&print( \" \" )!@#&term.setCursorPos(w/2-l/2,h/2+1)!@#&print( \" \" )!@#&term.setCursorPos(w/2-l/2,h/2+2)!@#&print( \" \" )!@#&term.setCursorPos(w/2-l/2+2,h/2)!@#&pswd = read( \" * \" )!@#&term.setBackgroundColor(colors.black)!@#&term.clear()!@#&term.setCursorPos(1,1)!@#&if pswd == \" \" then!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& error()!@#&end!@#&if sudo.getAdminPrivs(pswd) then!@#& fail = false!@#&else!@#& term.clear()!@#& term.setCursorPos(1,1)!@#& error()!@#&end!@#&end!@#&shell.run( \" sudo \" , args[1])" , [ "luaide" ] = "!@#&-- !@#&-- Lua IDE!@#&-- Made by GravityScore!@#&-- !@#&!@#&!@#&-- -------- Variables!@#&!@#&-- Version!@#&local version = \" 1.0 \" !@#&local args = {...}!@#&!@#&-- Editing!@#&local w, h = term.getSize()!@#&local tabWidth = 2!@#&!@#&local autosaveInterval = 20!@#&local allowEditorEvent = true!@#&local keyboardShortcutTimeout = 0.4!@#&!@#&-- Clipboard!@#&local clipboard = nil!@#&!@#&-- Theme!@#&local theme = {}!@#&!@#&-- Language!@#&local languages = {}!@#&local curLanguage = {}!@#&!@#&-- Events!@#&local event_distract = \" luaide_distractionEvent \" !@#&!@#&-- Locations!@#&local updateURL = \" https://raw.github.com/GravityScore/LuaIDE/master/luaide.lua \" !@#&local ideLocation = \" / \" .. shell.getRunningProgram()!@#&local themeLocation = \" /.LuaIDE-Theme \" !@#&!@#&local function isAdvanced() return term.isColor and term.isColor() end!@#&!@#&!@#&-- -------- Utilities!@#&!@#&local function modRead(properties)!@#& local w, h = term.getSize()!@#& local defaults = {replaceChar = nil, history = nil, visibleLength = nil, textLength = nil, !@#& liveUpdates = nil, exitOnKey = nil}!@#& if not properties then properties = {} end!@#& for k, v in pairs(defaults) do if not properties[k] then properties[k] = v end end!@#& if properties.replaceChar then properties.replaceChar = properties.replaceChar:sub(1, 1) end!@#& if not properties.visibleLength then properties.visibleLength = w end!@#&!@#& local sx, sy = term.getCursorPos()!@#& local line = \" \" !@#& local pos = 0!@#& local historyPos = nil!@#&!@#& local function redraw(repl)!@#& local scroll = 0!@#& if properties.visibleLength and sx + pos > properties.visibleLength + 1 then !@#& scroll = (sx + pos) - (properties.visibleLength + 1)!@#& end!@#&!@#& term.setCursorPos(sx, sy)!@#& local a = repl or properties.replaceChar!@#& if a then term.write(string.rep(a, line:len() - scroll))!@#& else term.write(line:sub(scroll + 1, -1)) end!@#& term.setCursorPos(sx + pos - scroll, sy)!@#& end!@#&!@#& local function sendLiveUpdates(event, ...)!@#& if type(properties.liveUpdates) == \" function \" then!@#& local ox, oy = term.getCursorPos()!@#& local a, data = properties.liveUpdates(line, event, ...)!@#& if a == true and data == nil then!@#& term.setCursorBlink(false)!@#& return line!@#& elseif a == true and data ~= nil then!@#& term.setCursorBlink(false)!@#& return data!@#& end!@#& term.setCursorPos(ox, oy)!@#& end!@#& end!@#&!@#& term.setCursorBlink(true)!@#& while true do!@#& local e, but, x, y, p4, p5 = os.pullEvent()!@#&!@#& if e == \" char \" then!@#& local s = false!@#& if properties.textLength and line:len() < properties.textLength then s = true!@#& elseif not properties.textLength then s = true end!@#&!@#& local canType = true!@#& if not properties.grantPrint and properties.refusePrint then!@#& local canTypeKeys = {}!@#& if type(properties.refusePrint) == \" table \" then!@#& for _, v in pairs(properties.refusePrint) do!@#& table.insert(canTypeKeys, tostring(v):sub(1, 1))!@#& end!@#& elseif type(properties.refusePrint) == \" string \" then!@#& for char in properties.refusePrint:gmatch( \" . \" ) do!@#& table.insert(canTypeKeys, char)!@#& end!@#& end!@#& for _, v in pairs(canTypeKeys) do if but == v then canType = false end end!@#& elseif properties.grantPrint then!@#& canType = false!@#& local canTypeKeys = {}!@#& if type(properties.grantPrint) == \" table \" then!@#& for _, v in pairs(properties.grantPrint) do!@#& table.insert(canTypeKeys, tostring(v):sub(1, 1))!@#& end!@#& elseif type(properties.grantPrint) == \" string \" then!@#& for char in properties.grantPrint:gmatch( \" . \" ) do!@#& table.insert(canTypeKeys, char)!@#& end!@#& end!@#& for _, v in pairs(canTypeKeys) do if but == v then canType = true end end!@#& end!@#&!@#& if s and canType then!@#& line = line:sub(1, pos) .. but .. line:sub(pos + 1, -1)!@#& pos = pos + 1!@#& redraw()!@#& end!@#& elseif e == \" key \" then!@#& if but == keys.enter then break!@#& elseif but == keys.left then if pos > 0 then pos = pos - 1 redraw() end!@#& elseif but == keys.right then if pos < line:len() then pos = pos + 1 redraw() end!@#& elseif (but == keys.up or but == keys.down) and properties.history then!@#& redraw( \" \" )!@#& if but == keys.up then!@#& if historyPos == nil and #properties.history > 0 then !@#& historyPos = #properties.history!@#& elseif historyPos > 1 then !@#& historyPos = historyPos - 1!@#& end!@#& elseif but == keys.down then!@#& if historyPos == #properties.history then historyPos = nil!@#& elseif historyPos ~= nil then historyPos = historyPos + 1 end!@#& end!@#&!@#& if properties.history and historyPos then!@#& line = properties.history[historyPos]!@#& pos = line:len()!@#& else!@#& line = \" \" !@#& pos = 0!@#& end!@#&!@#& redraw()!@#& local a = sendLiveUpdates( \" history \" )!@#& if a then return a end!@#& elseif but == keys.backspace and pos > 0 then!@#& redraw( \" \" )!@#& line = line:sub(1, pos - 1) .. line:sub(pos + 1, -1)!@#& pos = pos - 1!@#& redraw()!@#& local a = sendLiveUpdates( \" delete \" )!@#& if a then return a end!@#& elseif but == keys.home then!@#& pos = 0!@#& redraw()!@#& elseif but == keys.delete and pos < line:len() then!@#& redraw( \" \" )!@#& line = line:sub(1, pos) .. line:sub(pos + 2, -1)!@#& redraw()!@#& local a = sendLiveUpdates( \" delete \" )!@#& if a then return a end!@#& elseif but == keys[ \" end \" ] then!@#& pos = line:len()!@#& redraw()!@#& elseif properties.exitOnKey then !@#& if but == properties.exitOnKey or (properties.exitOnKey == \" control \" and !@#& (but == 29 or but == 157)) then !@#& term.setCursorBlink(false)!@#& return nil!@#& end!@#& end!@#& end!@#& local a = sendLiveUpdates(e, but, x, y, p4, p5)!@#& if a then return a end!@#& end!@#&!@#& term.setCursorBlink(false)!@#& if line ~= nil then line = line:gsub( \" ^%s*(.-)%s*$ \" , \" %1 \" ) end!@#& return line!@#&end!@#&!@#&!@#&-- -------- Themes!@#&!@#&local defaultTheme = {!@#& background = \" gray \" ,!@#& backgroundHighlight = \" lightGray \" ,!@#& prompt = \" cyan \" ,!@#& promptHighlight = \" lightBlue \" ,!@#& err = \" red \" ,!@#& errHighlight = \" pink \" ,!@#&!@#& editorBackground = \" gray \" ,!@#& editorLineHightlight = \" lightBlue \" ,!@#& editorLineNumbers = \" gray \" ,!@#& editorLineNumbersHighlight = \" lightGray \" ,!@#& editorError = \" pink \" ,!@#& editorErrorHighlight = \" red \" ,!@#&!@#& textColor = \" white \" ,!@#& conditional = \" yellow \" ,!@#& constant = \" orange \" ,!@#& [ \" function \" ] = \" magenta \" ,!@#& string = \" red \" ,!@#& comment = \" lime \" !@#&}!@#&!@#&local normalTheme = {!@#& background = \" black \" ,!@#& backgroundHighlight = \" black \" ,!@#& prompt = \" black \" ,!@#& promptHighlight = \" black \" ,!@#& err = \" black \" ,!@#& errHighlight = \" black \" ,!@#&!@#& editorBackground = \" black \" ,!@#& editorLineHightlight = \" black \" ,!@#& editorLineNumbers = \" black \" ,!@#& editorLineNumbersHighlight = \" white \" ,!@#& editorError = \" black \" ,!@#& editorErrorHighlight = \" black \" ,!@#&!@#& textColor = \" white \" ,!@#& conditional = \" white \" ,!@#& constant = \" white \" ,!@#& [ \" function \" ] = \" white \" ,!@#& string = \" white \" ,!@#& comment = \" white \" !@#&}!@#&!@#&local availableThemes = {!@#& { \" Water (Default) \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/default.txt \" },!@#& { \" Fire \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/fire.txt \" },!@#& { \" Sublime Text 2 \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/st2.txt \" },!@#& { \" Midnight \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/midnight.txt \" },!@#& { \" TheOriginalBIT \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/bit.txt \" },!@#& { \" Superaxander \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/superaxander.txt \" },!@#& { \" Forest \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/forest.txt \" },!@#& { \" Night \" , \" https://raw.github.com/GravityScore/LuaIDE/master/themes/night.txt \" },!@#& { \" Or