Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Blaze Email Client
- -- Created By DannySMc
- -- Platform: Lua Virtual Machine
- -- API Functions (Internal)
- function saveConfig(table, file)
- fConfig = fs.open(file, "w") or error("Cannot open file "..file, 2)
- fConfig.write(textutils.serialize(table))
- fConfig.close()
- end
- function loadConfig(file)
- fConfig = fs.open(file, "r")
- ret = textutils.unserialize(fConfig.readAll())
- return ret
- end
- function findPeripheral(Perihp) --Returns side of first matching peripheral matching passed string
- for _,s in ipairs(rs.getSides()) do
- if peripheral.isPresent(s) and peripheral.getType(s) == Perihp then
- return s
- end
- end
- return false
- end
- -- Common Draw Functions
- function cs()
- term.clear()
- term.setCursorPos(1,1)
- return
- end
- function setCol(textColour, backgroundColour)
- if textColour and backgroundColour then
- if term.isColour() then
- term.setTextColour(colours[textColour])
- term.setBackgroundColour(colours[backgroundColour])
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function resetCol()
- if term.isColour then
- term.setTextColour(colours.white)
- term.setBackgroundColour(colours.black)
- return true
- else
- return false
- end
- end
- function printC(Text, Line, NextLine, Color, BkgColor) -- print centered
- local x, y = term.getSize()
- x = x/2 - #Text/2
- term.setCursorPos(x, Line)
- if Color then setCol(Color, BkgColor) end
- term.write(Text)
- if NextLine then
- term.setCursorPos(1, NextLine)
- end
- if Color then resetCol(Color, BkgColor) end
- return true
- end
- function printL(Text, Line, NextLine, Color, BkgColor) -- print line
- local x, y = term.getSize()
- if ((term.isColor) and (term.isColor() == false) and (Text == " ")) then Text = "-" end
- for i = 1, x do
- term.setCursorPos(i, Line)
- if Color then setCol(Color, BkgColor) end
- term.write(Text)
- end
- if NextLine then
- term.setCursorPos(1, NextLine)
- end
- if Color then resetCol(Color, BkgColor) end
- return true
- end
- function printA(Text, xx, yy, NextLine, Color, BkgColor) -- print anywhere
- term.setCursorPos(xx,yy)
- if Color then setCol(Color, BkgColor) end
- term.write(Text)
- if NextLine then
- term.setCursorPos(1, NextLine)
- end
- if Color then resetCol(Color, BkgColor) end
- return true
- end
- function clearLine(Line, NextLine) -- May seem a bit odd, but it may be usefull sometimes
- local x, y = term.getSize()
- for i = 1, x do
- term.setCursorPos(i, Line)
- term.write(" ")
- end
- if not NextLine then
- x, y = term.getCursorPos()
- term.setCursorPos(1, y+1)
- end
- return true
- end
- function drawBox(StartX, lengthX, StartY, lengthY, Text, Color, BkgColor) -- does what is says on the tin.
- local x, y = term.getSize()
- if Color then setCol(Color, BkgColor) end
- if not Text then Text = "*" end
- lengthX = lengthX - 1
- lengthY = lengthY - 1
- EndX = StartX + lengthX
- EndY = StartY + lengthY
- term.setCursorPos(StartX, StartY)
- term.write(string.rep(Text, lengthX))
- term.setCursorPos(StartX, EndY)
- term.write(string.rep(Text, lengthX))
- for i = StartY, EndY do
- term.setCursorPos(StartX, i)
- term.write(Text)
- term.setCursorPos(EndX, i)
- term.write(Text)
- end
- resetCol(Color, BkgColor)
- return true
- end
- db = {}
- db.__index = db
- function db.delete(Filename)
- if fs.exists(Filename) then
- fs.delete(Filename)
- return true
- end
- return false
- end
- function db.load(Filename)
- if not fs.exists(Filename) then
- local F = fs.open(Filename, "w")
- F.write("{}")
- F.close()
- end
- local F = fs.open(Filename, "r")
- local Data = F.readAll()
- F.close()
- Data = textutils.unserialize(Data)
- return Data
- end
- function db.save(Filename, ATable)
- local Data = textutils.serialize(ATable)
- local F = fs.open(Filename, "w")
- F.write(Data)
- F.close()
- return true
- end
- function db.search(searchstring, ATable)
- for i, V in pairs(ATable) do
- if tostring(ATable[i]) == tostring(searchstring) then
- return i
- end
- end
- return 0
- end
- function db.removeString(Filename, AString)
- local TempT = db.load(Filename)
- if type(TempT) ~= "table" then return false end
- local Pos = db.search(AString, TempT)
- if Pos > 0 then
- table.remove(TempT, Pos)
- db.save(Filename, TempT)
- return true
- else
- return false
- end
- end
- function db.insertString(Filename, AString)
- local TempT = db.load(Filename)
- if type(TempT) ~= "table" then TempT = {} end
- table.insert(TempT, AString)
- db.save(Filename, TempT)
- return true
- end
- function serialGen(digits)
- local serial
- for i = 1, digits do
- if i == 1 then
- serial = math.random(9)
- else
- serial = serial.. math.random(9)
- end
- end
- serial = tonumber(serial)
- return serial
- end
- function wordwrap(str, limit)
- limit = limit or 72
- local here = 1
- local buf = ""
- local t = {}
- str:gsub("(%s*)()(%S+)()",
- function(sp, st, word, fi)
- if fi-here > limit then
- --# Break the line
- here = st
- table.insert(t, buf)
- buf = word
- else
- buf = buf..sp..word --# Append
- end
- end)
- --# Tack on any leftovers
- if(buf ~= "") then
- table.insert(t, buf)
- end
- return t
- end
- function time()
- local nTime = textutils.formatTime(os.time(), true)
- os.startTimer(1)
- return nTime
- end
- -- SHA256 Hashing Algorithm:
- local MOD = 2^32
- local MODM = MOD-1
- local function memoize(f)
- local mt = {}
- local t = setmetatable({}, mt)
- function mt:__index(k)
- local v = f(k)
- t[k] = v
- return v
- end
- return t
- end
- local function make_bitop_uncached(t, m)
- local function bitop(a, b)
- local res,p = 0,1
- while a ~= 0 and b ~= 0 do
- local am, bm = a % m, b % m
- res = res + t[am][bm] * p
- a = (a - am) / m
- b = (b - bm) / m
- p = p*m
- end
- res = res + (a + b) * p
- return res
- end
- return bitop
- end
- local function make_bitop(t)
- local op1 = make_bitop_uncached(t,2^1)
- local op2 = memoize(function(a) return memoize(function(b) return op1(a, b) end) end)
- return make_bitop_uncached(op2, 2 ^ (t.n or 1))
- end
- local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4})
- local function bxor(a, b, c, ...)
- local z = nil
- if b then
- a = a % MOD
- b = b % MOD
- z = bxor1(a, b)
- if c then z = bxor(z, c, ...) end
- return z
- elseif a then return a % MOD
- else return 0 end
- end
- local function band(a, b, c, ...)
- local z
- if b then
- a = a % MOD
- b = b % MOD
- z = ((a + b) - bxor1(a,b)) / 2
- if c then z = bit32_band(z, c, ...) end
- return z
- elseif a then return a % MOD
- else return MODM end
- end
- local function bnot(x) return (-1 - x) % MOD end
- local function rshift1(a, disp)
- if disp < 0 then return lshift(a,-disp) end
- return math.floor(a % 2 ^ 32 / 2 ^ disp)
- end
- local function rshift(x, disp)
- if disp > 31 or disp < -31 then return 0 end
- return rshift1(x % MOD, disp)
- end
- local function lshift(a, disp)
- if disp < 0 then return rshift(a,-disp) end
- return (a * 2 ^ disp) % 2 ^ 32
- end
- local function rrotate(x, disp)
- x = x % MOD
- disp = disp % 32
- local low = band(x, 2 ^ disp - 1)
- return rshift(x, disp) + lshift(low, 32 - disp)
- end
- local k = {
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
- }
- local function str2hexa(s)
- return (string.gsub(s, ".", function(c) return string.format("%02x", string.byte(c)) end))
- end
- local function num2s(l, n)
- local s = ""
- for i = 1, n do
- local rem = l % 256
- s = string.char(rem) .. s
- l = (l - rem) / 256
- end
- return s
- end
- local function s232num(s, i)
- local n = 0
- for i = i, i + 3 do n = n*256 + string.byte(s, i) end
- return n
- end
- local function preproc(msg, len)
- local extra = 64 - ((len + 9) % 64)
- len = num2s(8 * len, 8)
- msg = msg .. "\128" .. string.rep("\0", extra) .. len
- assert(#msg % 64 == 0)
- return msg
- end
- local function initH256(H)
- H[1] = 0x6a09e667
- H[2] = 0xbb67ae85
- H[3] = 0x3c6ef372
- H[4] = 0xa54ff53a
- H[5] = 0x510e527f
- H[6] = 0x9b05688c
- H[7] = 0x1f83d9ab
- H[8] = 0x5be0cd19
- return H
- end
- local function digestblock(msg, i, H)
- local w = {}
- for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end
- for j = 17, 64 do
- local v = w[j - 15]
- local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))
- v = w[j - 2]
- w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))
- end
- local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]
- for i = 1, 64 do
- local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))
- local maj = bxor(band(a, b), band(a, c), band(b, c))
- local t2 = s0 + maj
- local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))
- local ch = bxor (band(e, f), band(bnot(e), g))
- local t1 = h + s1 + ch + k[i] + w[i]
- h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2
- end
- H[1] = band(H[1] + a)
- H[2] = band(H[2] + b)
- H[3] = band(H[3] + c)
- H[4] = band(H[4] + d)
- H[5] = band(H[5] + e)
- H[6] = band(H[6] + f)
- H[7] = band(H[7] + g)
- H[8] = band(H[8] + h)
- end
- function sha256(msg)
- msg = preproc(msg, #msg)
- local H = initH256({})
- for i = 1, #msg, 64 do digestblock(msg, i, H) end
- return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..
- num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))
- end
- function colourScreen()
- term.setCursorPos(1,1)
- setCol("white", "white")
- count1 = 1
- repeat
- term.setCursorPos(1, count1)
- write(" ")
- count1 = count1 + 1
- until count1 == 20
- end
- -- End API Functions
- --[[
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- #
- ]]
- -- Set Globals, Variables and Placeholders
- _BLAZEUSER = nil
- _BLAZEPASS = nil
- _BLAZECMDS = {"login", "getInbox", "register", "delete", "send",}
- _BLAZEURLS = {"http://dannysmc.com/files/php/emailsystem.php",}
- -- Set Defaults
- tc = "black"
- bc = "lightGrey"
- nVer = 1.1
- -- BLAZE API
- function BlazeLogin(username, password)
- local req = http.post(_BLAZEURLS[1], "command="..textutils.urlEncode(tostring(_BLAZECMDS[1])).."&".."username="..textutils.urlEncode(tostring(username)).."&".."password="..textutils.urlEncode(tostring(password)))
- return req
- end
- function BlazeInbox(username, password)
- local req = http.post(_BLAZEURLS[1], "command="..textutils.urlEncode(tostring(_BLAZECMDS[2])).."&".."username="..textutils.urlEncode(tostring(username)).."&".."password="..textutils.urlEncode(tostring(password)))
- return req
- end
- function BlazeSend(username, password, recipient, subject, message)
- local req = http.post(_BLAZEURLS[1], "command="..textutils.urlEncode(tostring(_BLAZECMDS[5])).."&".."username="..textutils.urlEncode(tostring(username)).."&".."password="..textutils.urlEncode(tostring(password)).."&".."recipient="..textutils.urlEncode(tostring(recipient)).."&".."subject="..textutils.urlEncode(tostring(subject)).."&".."message="..textutils.urlEncode(tostring(message)))
- return req
- end
- function BlazeDelete(username, password, msgid)
- local req = http.post(_BLAZEURLS[1], "command="..textutils.urlEncode(tostring(_BLAZECMDS[4])).."&".."username="..textutils.urlEncode(tostring(username)).."&".."password="..textutils.urlEncode(tostring(password)).."&".."messageid="..textutils.urlEncode(tostring(msgid)))
- return req
- end
- function BlazeRegister(username, password, email)
- local req = http.post(_BLAZEURLS[1], "command="..textutils.urlEncode(tostring(_BLAZECMDS[3])).."&".."username="..textutils.urlEncode(tostring(username)).."&".."password="..textutils.urlEncode(tostring(password)).."&".."email="..textutils.urlEncode(tostring(email)))
- return req
- end
- -- Main Code
- function blaze_main()
- if term.isColor() then
- blaze_login()
- end
- end
- function drawPopup(sText)
- drawBox(1, 51, 7, 1, " ", "lime", "red")
- printC(">> "..sText.." <<", 7, false, "lime", "red")
- end
- function blaze_login()
- -- Start Login
- local tInfo = {"Welcome to the new Blaze Email Client", "The pocket, turtle editions are on their way!",}
- cs()
- colourScreen()
- drawBox(1, 51, 1, 2, " ", tc, bc)
- printA("Blaze Email Client", 1, 1, false, tc, bc)
- printA(time(), 47, 1, false, tc, bc)
- printC(">> Login <<", 2, false, tc, bc)
- -- Login Boxes
- drawBox(1, 51, 3, 1, " ", tc, "grey")
- printC(" REGISTER < - > [ LOGIN ] ", 3, false, "white", "grey")
- drawBox(8, 35, 5, 3, " ", tc, bc)
- drawBox(8, 35, 9, 3, " ", tc, bc)
- printC(">> Username <<", 5, false, tc, bc)
- printC(">> Password <<", 9, false, tc, bc)
- term.setCursorPos(1, 17)
- setCol("black", "white")
- printA("Please use your username and password to login to", 1, 17, false, "black", "white")
- printA(" the email client. Don't have an account? Simple ", 1, 18, false, "black", "white")
- printA("press 'REGISTER' to get an email account!", 1, 19, false, "black", "white")
- term.setCursorPos(1,1)
- drawBox(1, 51, 16, 1, " ", tc, bc)
- printC(">> Help <<", 16, false, tc, bc)
- drawBox(19, 13, 13, 1, " ", tc, bc)
- printC(">> LOGIN <<", 13, false, tc, bc)
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- clearLine(1, false)
- drawBox(1, 51, 1, 2, " ", tc, bc)
- printA("Blaze Email Client", 1, 1, false, tc, bc)
- printA(time(), 47, 1, false, tc, bc)
- printC(">> Login <<", 2, false, tc, bc)
- elseif args[1] == "mouse_click" then
- if (args[3] >= 9 and args[3] <= 42) and (args[4] == 6) then
- term.setCursorPos(9, 6)
- setCol("lime", "white")
- write(": ")
- username = tostring(read())
- elseif (args[3] >= 9 and args[3] <= 42) and (args[4] == 10) then
- term.setCursorPos(9, 10)
- setCol("lime", "white")
- write(": ")
- password = tostring(read("*"))
- password = sha256(password)
- elseif (args[3] >= 20 and args[3] <= 31) and (args[4] == 13) then
- local status = BlazeLogin(username, password)
- if status.readAll() == '"true"' then
- drawPopup("This action was successful")
- sleep(1.5)
- blaze_inbox(1)
- else
- drawPopup("Login Failed!")
- sleep(1.5)
- blaze_login()
- end
- elseif (args[3] >= 1 and args[3] <= 25) and (args[4] == 3) then
- blaze_register()
- end
- elseif args[1] == "char" then
- if args[2] == "u" then
- term.setCursorPos(9, 6)
- setCol("lime", "white")
- write(": ")
- username = tostring(read())
- elseif args[2] == "p" then
- term.setCursorPos(9, 10)
- setCol("lime", "white")
- write(": ")
- password = tostring(read("*"))
- password = sha256(password)
- elseif args[2] == "r" then
- blaze_register()
- break
- elseif args[2] == "l" then
- local status = BlazeLogin(username, password)
- if status.readAll() == '"true"' then
- drawPopup("This action was successful")
- sleep(1.5)
- blaze_inbox(1)
- else
- drawPopup("Login Failed!")
- sleep(1.5)
- blaze_login()
- end
- end
- end
- end
- end
- function addressBook(pageNumber)
- local texttc = "black"
- local textbc = "white"
- local gridtc = "white"
- local gridbc = "grey"
- local menutc = "blue"
- local menubc = "lightGrey"
- fs.makeDir("blazeCore/")
- abPath = "blazeCore/addresses"
- if fs.exists(abPath) then
- addresses = db.load(abPath)
- else
- aTable = {
- {
- "Creator",
- },
- {
- "dannysmc95",
- }
- }
- saveConfig(aTable, abPath)
- addresses = loadConfig(abPath)
- end
- cs()
- colourScreen()
- drawMenuBar()
- -- Views all users on the database
- drawBox(1, 51, 2, 18, " ", "black", "black")
- drawBox(2, 49, 3, 16, " ", gridtc, gridbc)
- drawBox(2, 49, 5, 1, " ", gridtc, gridbc)
- drawBox(26, 1, 3, 16, " ", gridtc, gridbc)
- drawBox(3, 23, 4, 1, " ", menutc, menubc)
- drawBox(27, 23, 4, 1, " ", menutc, menubc)
- printA("Custom Name", 4, 4, false, menutc, menubc)
- printA("Username Address", 28, 4, false, menutc, menubc)
- drawBox(4, 5, 18, 1, " ", menutc, menubc)
- printA("ADD", 5, 18, false, menutc, menubc)
- drawBox(28, 21, 18, 1, " ", menutc, menubc)
- printA("Right-Click Deletes", 29, 18, false, menutc, menubc)
- countY = 6
- for k, v in ipairs(addresses[1]) do
- printA(v, 3, countY, false, texttc, textbc)
- countY = countY + 1
- end
- countY = 6
- for k, v in ipairs(addresses[2]) do
- printA(v, 27, countY, false, texttc, textbc)
- countY = countY + 1
- end
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawMenuBar()
- end
- if args[1] == "mouse_click" then
- if (args[3] >= 2 and args[3] <= 6) and (args[4] == 1) then
- drawDropdown("new")
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 2) then
- blaze_send()
- break
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 3) then
- addressBook("view")
- break
- elseif (args[3] >= 8 and args[3] <= 14) and (args[4] == 1) then
- blaze_inbox(1)
- break
- elseif (args[3] >= 16 and args[3] <= 25) and (args[4] == 1) then
- blaze_options()
- break
- elseif (args[3] >= 27 and args[3] <= 32) and (args[4] == 1) then
- blaze_help()
- break
- end
- if args[2] == 1 then
- -- Do touch buttons here
- if (args[3] >= 3 and args[3] <= 49) and (args[4] >= 6 and args[4] <= 17) then
- -- Option 1
- intPos = args[4] - 5
- if #addresses[2] == intPos then
- sendRecipient = addresses[2][intPos]
- blaze_send()
- break
- end
- elseif (args[3] >= 4 and args[3] <= 9) and (args[4] == 18) then
- cs()
- colourScreen()
- term.setCursorPos(1,1)
- setCol(texttc, textbc)
- print("Address Book -> Add User")
- print(" ")
- print("> Custom Name: ")
- write(": ")
- local customName = tostring(read())
- print("> Address Name: ")
- write(": ")
- local addressName = tostring(read())
- table.insert(addresses[1], customName)
- table.insert(addresses[2], addressName)
- saveConfig(addresses, abPath)
- addressBook()
- end
- elseif args[2] == 2 then
- if (args[3] >= 4 and args[3] <= 8) and (args[4] >= 6 and args[4] <= 17) then
- intPos = args[4] - 5
- if #addresses[2] == intPos then
- table.remove(addresses[1], intPos)
- table.remove(addresses[2], intPos)
- saveConfig(addresses, abPath)
- addressBook()
- end
- end
- end
- end
- end
- end
- function blaze_register()
- -- Draws register menu
- cs()
- colourScreen()
- drawBox(1, 51, 1, 2, " ", tc, bc)
- printA("Blaze Email Client", 1, 1, false, tc, bc)
- printA(time(), 47, 1, false, tc, bc)
- printC(">> Register <<", 2, false, tc, bc)
- -- Login Boxes
- drawBox(1, 51, 3, 1, " ", tc, "grey")
- printC(" [ REGISTER ] < - > LOGIN ", 3, false, "white", "grey")
- drawBox(8, 35, 5, 7, " ", tc, bc)
- printC(">> Username <<", 5, false, tc, bc)
- drawBox(8, 35, 7, 1, " ", tc, bc)
- printC(">> Password <<", 7, false, tc, bc)
- drawBox(8, 35, 9, 1, " ", tc, bc)
- printC(">> Email Address <<", 9, false, tc, bc)
- drawBox(15, 21, 13, 1, " ", tc, bc)
- printC(" >> REGISTER <<", 13, false, tc, bc)
- drawBox(1, 51, 17, 1, " ", tc, bc)
- printC(">> Information <<", 17, false, tc, bc)
- printA("Your email address is stored so you can recover", 1, 18, false, tc, "white")
- printA("your account!", 1, 19, false, tc, "white")
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawBox(1, 51, 1, 2, " ", tc, bc)
- printA("Blaze Email Client", 1, 1, false, tc, bc)
- printA(time(), 47, 1, false, tc, bc)
- printC(">> Register <<", 2, false, tc, bc)
- elseif args[1] == "mouse_click" then
- if (args[3] >= 9 and args[3] <= 42) and (args[4] == 6) then
- setCol("lime", "white")
- term.setCursorPos(9, 6)
- write(": ")
- username = tostring(read())
- elseif (args[3] >= 9 and args[3] <= 42) and (args[4] == 8) then
- setCol("lime", "white")
- term.setCursorPos(9, 8)
- write(": ")
- password = tostring(read("*"))
- password = sha256(password)
- elseif (args[3] >= 9 and args[3] <= 42) and (args[4] == 10) then
- setCol("lime", "white")
- term.setCursorPos(9, 10)
- write(": ")
- email = tostring(read())
- elseif (args[3] >= 18 and args[3] <= 33) and (args[4] == 13) then
- local status = BlazeRegister(username, password, email)
- if status.readAll() == '"true"' then
- drawPopup("This action was successful")
- sleep(1.5)
- _BLAZEUSER = username
- _BLAZEPASS = password
- blaze_login()
- else
- drawPopup("Login Failed!")
- sleep(1.5)
- blaze_login()
- end
- elseif (args[3] >= 28 and args[3] <= 51) and (args[4] == 3) then
- blaze_login()
- end
- elseif args[1] == "char" then
- if args[2] == "l" then
- blaze_login()
- break
- elseif args[2] == "u" then
- setCol("lime", "white")
- term.setCursorPos(9, 6)
- write(": ")
- username = tostring(read())
- elseif args[2] == "p" then
- setCol("lime", "white")
- term.setCursorPos(9, 8)
- write(": ")
- password = tostring(read("*"))
- password = sha256(password)
- elseif args[2] == "e" then
- setCol("lime", "white")
- term.setCursorPos(9, 10)
- write(": ")
- email = tostring(read())
- elseif args[2] == "r" then
- local status = BlazeRegister(username, password, email)
- if status.readAll() == '"true"' then
- drawPopup("This action was successful")
- sleep(1.5)
- _BLAZEUSER = username
- _BLAZEPASS = password
- blaze_login()
- else
- drawPopup("Login Failed!")
- sleep(1.5)
- blaze_login()
- end
- end
- end
- end
- end
- function drawMenuBar()
- menutc = "blue"
- menubc = "lightGrey"
- selectedtc = "lime"
- inboxbc = "white"
- gridbc = "grey"
- drawBox(1, 51, 1, 1, " ", tc, gridbc)
- drawBox(2, 5, 1, 1, " ", menutc, menubc)
- printA("NEW", 3, 1, false, menutc, menubc)
- drawBox(8, 7, 1, 1, " ", menutc, menubc)
- printA("INBOX", 9, 1, false, menutc, menubc)
- drawBox(16, 10, 1, 1, " ", menutc, menubc)
- printA("SETTINGS", 17, 1, false, menutc, menubc)
- drawBox(27, 6, 1, 1, " ", menutc, menubc)
- printA("HELP", 28, 1, false, menutc, menubc)
- drawBox(44, 7, 1, 1, " ", menutc, menubc)
- printA(time(), 45, 1, false, menutc, menubc)
- end
- function blaze_inbox(inboxNumber)
- refreshCount = 300
- menutc = "blue"
- menubc = "lightGrey"
- selectedtc = "lime"
- inboxbc = "white"
- gridbc = "grey"
- cs()
- colourScreen()
- printA("No Message Selected!", 28, 11, false, "black", "white")
- drawMenuBar()
- drawBox(8, 7, 1, 1, " ", menutc, menubc)
- printA("INBOX", 9, 1, false, selectedtc, menubc)
- -- Attempt to grab the users inbox:
- local tData = BlazeInbox(username, password)
- inbox = tData
- inbox = inbox.readAll()
- inbox = textutils.unserialize(inbox)
- local status, err = pcall(function() test123 = #inbox end)
- if status then
- inboxEmpty = false
- else
- inboxEmpty = true
- end
- -- Draw Inbox Grid
- drawBox(20, 1, 2, 18, " ", tc, gridbc)
- drawBox(1, 20, 2, 1, " ", tc, gridbc)
- drawBox(1, 20, 6, 1, " ", tc, gridbc)
- drawBox(1, 20, 10, 1, " ", tc, gridbc)
- drawBox(1, 20, 14, 1, " ", tc, gridbc)
- drawBox(1, 20, 18, 1, " ", tc, gridbc)
- drawBox(1, 20, 19, 1, " ", tc, gridbc)
- drawBox(2, 4, 19, 1, " ", menutc, menubc)
- drawBox(16, 4, 19, 1, " ", menutc, menubc)
- printA("<-", 3, 19, false, menutc, menubc)
- printA("->", 17, 19, false, menutc, menubc)
- -- Draw refresh timer
- drawBox(34, 5, 1, 1, " ", menutc, menubc)
- printA(tostring(refreshCount), 35, 1, false, menutc, menubc)
- -- Page Logic Counter
- if inboxEmpty == false then
- inboxCount = #inbox
- if inboxCount >= 1 then
- inboxPages = 1
- elseif inboxCount > 4 and inboxCount <= 8 then
- inboxPages = 2
- elseif inboxCount > 8 and inboxCount <= 12 then
- inboxPages = 3
- elseif inboxCount > 12 and inboxCount <= 16 then
- inboxPages = 4
- elseif inboxCount > 16 and inboxCount <= 20 then
- inboxPages = 5
- end
- if inboxNumber == 1 then
- if inboxCount == 1 then
- printA(inbox[1][1], 1, 3, false, selectedtc, inboxbc)
- printA(inbox[1][3], 1, 4, false, menutc, inboxbc)
- printA(inbox[1][4], 1, 5, false, menutc, inboxbc)
- end
- if inboxCount >= 2 then
- printA(inbox[2][1], 1, 7, false, selectedtc, inboxbc)
- printA(inbox[2][3], 1, 8, false, menutc, inboxbc)
- printA(inbox[2][4], 1, 9, false, menutc, inboxbc)
- end
- if inboxCount >= 3 then
- printA(inbox[3][1], 1, 11, false, selectedtc, inboxbc)
- printA(inbox[3][3], 1, 12, false, menutc, inboxbc)
- printA(inbox[3][4], 1, 13, false, menutc, inboxbc)
- end
- if inboxCount >= 4 then
- printA(inbox[4][1], 1, 15, false, selectedtc, inboxbc)
- printA(inbox[4][3], 1, 16, false, menutc, inboxbc)
- printA(inbox[4][4], 1, 17, false, menutc, inboxbc)
- end
- elseif inboxNumber == 2 then
- -- Draw Page 1
- if inboxCount >= 5 then
- printA(inbox[5][1], 1, 3, false, selectedtc, inboxbc)
- printA(inbox[5][3], 5, 4, false, menutc, inboxbc)
- printA(inbox[5][4], 5, 5, false, menutc, inboxbc)
- end
- if inboxCount >= 6 then
- printA(inbox[6][1], 1, 7, false, selectedtc, inboxbc)
- printA(inbox[6][3], 1, 8, false, menutc, inboxbc)
- printA(inbox[6][4], 1, 9, false, menutc, inboxbc)
- end
- if inboxCount >= 7 then
- printA(inbox[7][1], 1, 11, false, selectedtc, inboxbc)
- printA(inbox[7][3], 1, 12, false, menutc, inboxbc)
- printA(inbox[7][4], 1, 13, false, menutc, inboxbc)
- end
- if inboxCount >= 8 then
- printA(inbox[8][1], 1, 15, false, selectedtc, inboxbc)
- printA(inbox[8][3], 1, 16, false, menutc, inboxbc)
- printA(inbox[8][4], 1, 17, false, menutc, inboxbc)
- end
- elseif inboxNumber == 3 then
- -- Draw Page 1
- if inboxCount >= 9 then
- printA(inbox[9][1], 1, 3, false, selectedtc, inboxbc)
- printA(inbox[9][3], 5, 4, false, menutc, inboxbc)
- printA(inbox[9][4], 5, 5, false, menutc, inboxbc)
- end
- if inboxCount >= 10 then
- printA(inbox[10][1], 1, 7, false, selectedtc, inboxbc)
- printA(inbox[10][3], 1, 8, false, menutc, inboxbc)
- printA(inbox[10][4], 1, 9, false, menutc, inboxbc)
- end
- if inboxCount >= 11 then
- printA(inbox[11][1], 1, 11, false, selectedtc, inboxbc)
- printA(inbox[11][3], 1, 12, false, menutc, inboxbc)
- printA(inbox[11][4], 1, 13, false, menutc, inboxbc)
- end
- if inboxCount >= 12 then
- printA(inbox[12][1], 1, 15, false, selectedtc, inboxbc)
- printA(inbox[12][3], 1, 16, false, menutc, inboxbc)
- printA(inbox[12][4], 1, 17, false, menutc, inboxbc)
- end
- elseif inboxNumber == 4 then
- -- Draw Page 1
- if inboxCount >= 13 then
- printA(inbox[13][1], 1, 3, false, selectedtc, inboxbc)
- printA(inbox[13][3], 5, 4, false, menutc, inboxbc)
- printA(inbox[13][4], 5, 5, false, menutc, inboxbc)
- end
- if inboxCount >= 14 then
- printA(inbox[14][1], 1, 7, false, selectedtc, inboxbc)
- printA(inbox[14][3], 1, 8, false, menutc, inboxbc)
- printA(inbox[14][4], 1, 9, false, menutc, inboxbc)
- end
- if inboxCount >= 15 then
- printA(inbox[15][1], 1, 11, false, selectedtc, inboxbc)
- printA(inbox[15][3], 1, 12, false, menutc, inboxbc)
- printA(inbox[15][4], 1, 13, false, menutc, inboxbc)
- end
- if inboxCount >= 16 then
- printA(inbox[16][1], 1, 15, false, selectedtc, inboxbc)
- printA(inbox[16][3], 1, 16, false, menutc, inboxbc)
- printA(inbox[16][4], 1, 17, false, menutc, inboxbc)
- end
- elseif inboxNumber == 5 then
- -- Draw Page 1
- if inboxCount >= 17 then
- printA(inbox[17][1], 1, 3, false, selectedtc, inboxbc)
- printA(inbox[17][3], 5, 4, false, menutc, inboxbc)
- printA(inbox[17][4], 5, 5, false, menutc, inboxbc)
- end
- if inboxCount >= 18 then
- printA(inbox[18][1], 1, 7, false, selectedtc, inboxbc)
- printA(inbox[18][3], 1, 8, false, menutc, inboxbc)
- printA(inbox[18][4], 1, 9, false, menutc, inboxbc)
- end
- if inboxCount >= 19 then
- printA(inbox[19][1], 1, 11, false, selectedtc, inboxbc)
- printA(inbox[19][3], 1, 12, false, menutc, inboxbc)
- printA(inbox[19][4], 1, 13, false, menutc, inboxbc)
- end
- if inboxCount >= 20 then
- printA(inbox[20][1], 1, 15, false, selectedtc, inboxbc)
- printA(inbox[20][3], 1, 16, false, menutc, inboxbc)
- printA(inbox[20][4], 1, 17, false, menutc, inboxbc)
- end
- end
- end
- drawBox(8, 6, 19, 1, " ", menutc, menubc)
- printA(inboxNumber.."/5", 9, 19, false, menutc, menubc)
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawBox(44, 7, 1, 1, " ", menutc, menubc)
- printA(time(), 45, 1, false, menutc, menubc)
- drawBox(34, 5, 1, 1, " ", menutc, menubc)
- printA(tostring(refreshCount), 35, 1, false, menutc, menubc)
- refreshCount = refreshCount - 1
- if refreshCount == 0 then
- refreshCount = 300
- blaze_inbox(1)
- end
- elseif args[1] == "mouse_click" then
- if (args[3] >= 2 and args[3] <= 6) and (args[4] == 1) then
- drawDropdown("new")
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 2) then
- blaze_send()
- break
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 3) then
- addressBook("view")
- break
- elseif (args[3] >= 8 and args[3] <= 14) and (args[4] == 1) then
- blaze_inbox(1)
- break
- elseif (args[3] >= 16 and args[3] <= 25) and (args[4] == 1) then
- blaze_options()
- break
- elseif (args[3] >= 27 and args[3] <= 32) and (args[4] == 1) then
- blaze_help()
- break
- elseif (args[3] >= 3 and args[3] <= 48) and (args[4] == 7) then
- -- Do Update
- blaze_update()
- break
- elseif (args[3] >= 16 and args[3] <= 19) and (args[4] == 19) then
- if inboxNumber <= 4 then
- blaze_inbox(inboxNumber + 1)
- end
- elseif (args[3] >= 2 and args[3] <= 5) and (args[4] == 19) then
- if inboxNumber >= 2 then
- blaze_inbox(inboxNumber - 1)
- end
- elseif (args[3] >= 23 and args[3] <= 29) and (args[4] == 18) then
- sendRecipient = inbox[msgID1][3]
- blaze_send()
- break
- elseif (args[3] >= 42 and args[3] <= 48) and (args[4] == 18) then
- BlazeDelete(username, password, msgID)
- blaze_inbox(1)
- break
- end
- -- Do Inbox Logic
- if inboxNumber == 1 then
- if (args[3] >= 1 and args[3] <= 19) and (args[4] >= 3 and args[4] <= 5) then
- openMessage(1)
- msgID = inbox[1][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 7 and args[4] <= 9) then
- openMessage(2)
- msgID = inbox[2][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 11 and args[4] <= 13) then
- openMessage(3)
- msgID = inbox[3][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 15 and args[4] <= 17) then
- openMessage(4)
- msgID = inbox[4][1]
- end
- elseif inboxNumber == 2 then
- -- Allow Message Choosing for Page 2
- if (args[3] >= 1 and args[3] <= 19) and (args[4] >= 3 and args[4] <= 5) then
- openMessage(5)
- msgID = inbox[5][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 7 and args[4] <= 9) then
- openMessage(6)
- msgID = inbox[6][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 11 and args[4] <= 13) then
- openMessage(7)
- msgID = inbox[7][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 15 and args[4] <= 17) then
- openMessage(8)
- msgID = inbox[8][1]
- end
- elseif inboxNumber == 3 then
- -- Allow Message Choosing for Page 3
- if (args[3] >= 1 and args[3] <= 19) and (args[4] >= 3 and args[4] <= 5) then
- openMessage(9)
- msgID = inbox[9][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 7 and args[4] <= 9) then
- openMessage(10)
- msgID = inbox[10][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 11 and args[4] <= 13) then
- openMessage(11)
- msgID = inbox[11][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 15 and args[4] <= 17) then
- openMessage(12)
- msgID = inbox[12][1]
- end
- elseif inboxNumber == 4 then
- -- Allow Message Choosing for Page 4
- if (args[3] >= 1 and args[3] <= 19) and (args[4] >= 3 and args[4] <= 5) then
- openMessage(13)
- msgID = inbox[13][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 7 and args[4] <= 9) then
- openMessage(14)
- msgID = inbox[14][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 11 and args[4] <= 13) then
- openMessage(15)
- msgID = inbox[15][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 15 and args[4] <= 17) then
- openMessage(16)
- msgID = inbox[16][1]
- end
- elseif inboxNumber == 5 then
- -- Allow Message Choosing for Page 5
- if (args[3] >= 1 and args[3] <= 19) and (args[4] >= 3 and args[4] <= 5) then
- openMessage(17)
- msgID = inbox[17][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 7 and args[4] <= 9) then
- openMessage(18)
- msgID = inbox[18][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 11 and args[4] <= 13) then
- openMessage(19)
- msgID = inbox[19][1]
- elseif (args[3] >= 1 and args[3] <= 19) and (args[4] >= 15 and args[4] <= 17) then
- openMessage(20)
- msgID = inbox[20][1]
- end
- end
- end
- end
- end
- function openMessage(intID)
- msgID1 = intID
- local texttc = "black"
- local textbc = "white"
- local gridtc = "white"
- local gridbc = "grey"
- local menutc = "blue"
- local menubc = "lightGrey"
- setCol(texttc, textbc)
- local count1 = 2
- repeat
- term.setCursorPos(21, count1)
- write(" ")
- count1 = count1 + 1
- until count1 == 19
- drawBox(21, 31, 2, 18, " ", "black", "black")
- drawBox(22, 29, 3, 16, " ", gridtc, gridbc)
- drawBox(22, 29, 7, 1, " ", gridtc, gridbc)
- drawBox(22, 29, 18, 1, " ", gridtc, gridbc)
- drawBox(23, 7, 18, 1, " ", menutc, menubc)
- drawBox(42, 8, 18, 1, " ", menutc, menubc)
- drawBox(31, 1, 4, 3, " ", gridtc, gridbc)
- printA("REPLY", 24, 18, false, menutc, menubc)
- printA("DELETE", 43, 18, false, menutc, menubc)
- printA("Sender:", 23, 4, false, texttc, textbc)
- printA("Subject:", 23, 5, false, texttc, textbc)
- printA(inbox[intID][3], 32, 4, false, texttc, textbc)
- local count1 = 5
- local tSubject = wordwrap(inbox[intID][4], 18)
- for _, v in ipairs(tSubject) do
- term.setCursorPos(32, count1)
- write(v)
- count1 = count1 + 1
- end
- printA(inbox[intID][4], 32, 5, false, texttc, textbc)
- setCol(texttc, textbc)
- local count1 = 8
- local tMessage = wordwrap(inbox[intID][5], 27)
- for _,v in ipairs(tMessage) do
- term.setCursorPos(23, count1)
- write(v)
- count1 = count1 + 1
- end
- printA("Message ID: "..inbox[intID][1], 23, 3, false, "lime", gridbc)
- end
- function drawDropdown(sMenu, intY)
- if sMenu == "new" then
- drawBox(2, 9, 2, 2, " ", menutc, menubc)
- printA("Message", 3, 2, false, menutc, menubc)
- printA("Contact", 3, 3, false, menutc, menubc)
- end
- end
- function blaze_send()
- gridtc = "white"
- gridbc = "grey"
- texttc = "black"
- textbc = "white"
- menutc = "blue"
- menubc = "lightgrey"
- cs()
- colourScreen()
- drawMenuBar()
- printA("NEW", 3, 1, false, selectedtc, menubc)
- drawBox(1, 51, 4, 1, " ", gridtc, gridbc)
- drawBox(12, 1, 2, 3, " ", gridtc, gridbc)
- printA("To:", 1, 2, false, texttc, textbc)
- if sendRecipient then
- printA(sendRecipient, 14, 2, false, texttc, textbc)
- end
- sendSubject = nil
- printA("Subject:", 1, 3, false, texttc, textbc)
- printC("Message Contents (MAX 200 CHARS)", 4, false, gridtc, gridbc)
- drawBox(46, 1, 2, 3, " ", gridtc, gridbc)
- printA("MAX:1", 47, 2, false, texttc, textbc)
- printA("<= 16", 47, 3, false, texttc, textbc)
- drawBox(1, 51, 19, 1, " ", gridtc, gridbc)
- drawBox(2, 6, 19, 1, " ", menutc, menubc)
- printA("SEND", 3, 19, false, menutc, menubc)
- drawBox(10, 7, 19, 1, " ", menutc, menubc)
- printA("CLEAR", 11, 19, false, menutc, menubc)
- drawBox(42, 8, 19, 1, " ", menutc, menubc)
- printA("CANCEL", 43, 19, false, menutc, menubc)
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawMenuBar()
- printA("NEW", 3, 1, false, selectedtc, menubc)
- elseif args[1] == "mouse_click" then
- if (args[3] >= 42 and args[3] <= 50) and (args[4] == 19) then
- blaze_inbox(1)
- break
- elseif (args[3] >= 2 and args[3] <= 8) and (args[4] == 19) then
- BlazeSend(username, password, sendRecipient, sendSubject, sendMessage)
- drawPopup("Message Sent")
- sleep(1.5)
- blaze_inbox(1)
- break
- elseif args[1] == "mouse_click" then
- if (args[3] >= 2 and args[3] <= 6) and (args[4] == 1) then
- drawDropdown("new")
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 2) then
- blaze_send()
- break
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 3) then
- addressBook("view")
- break
- elseif (args[3] >= 8 and args[3] <= 14) and (args[4] == 1) then
- blaze_inbox(1)
- break
- elseif (args[3] >= 16 and args[3] <= 25) and (args[4] == 1) then
- blaze_options()
- break
- elseif (args[3] >= 27 and args[3] <= 32) and (args[4] == 1) then
- blaze_help()
- break
- elseif (args[3] >= 3 and args[3] <= 48) and (args[4] == 7) then
- -- Do Update
- blaze_update()
- break
- elseif (args[3] >= 23 and args[3] <= 29) and (args[4] == 18) then
- -- Do Back button
- blaze_inbox(1)
- break
- elseif (args[3] >= 13 and args[3] <= 45) and (args[4] == 2) then
- -- Start Recipient Input
- if sendRecipientExist then
- setCol(texttc, textbc)
- term.setCursorPos(13,2)
- write(" ")
- end
- setCol(texttc, textbc)
- term.setCursorPos(14,2)
- sendRecipient = read()
- sendRecipientExist = true
- elseif (args[3] >= 13 and args[3] <= 45) and (args[4] == 3) then
- -- Start Subject Input
- if sendSubjectExist then
- setCol(texttc, textbc)
- term.setCursorPos(13,3)
- write(" ")
- end
- setCol(texttc, textbc)
- term.setCursorPos(14,3)
- sendSubject = read()
- sendSubjectExist = true
- elseif (args[3] >= 1 and args[3] <= 51) and (args[4] >= 5 and args[4] <= 18) then
- -- Start Message Input
- if sendMessageExist then
- count2 = 5
- repeat
- term.setCursorPos(1, count2)
- setCol("white", "white")
- write(" ")
- count2 = count2 + 1
- until count2 == 19
- end
- setCol("black", "white")
- term.setCursorPos(1, 5)
- sendMessage = read()
- sendMessageExist = true
- term.setCursorPos(1, 5)
- for _, v in ipairs(wordwrap(sendMessage)) do
- print(v)
- end
- end
- end
- end
- end
- end
- function blaze_options()
- texttc = "black"
- textbc = "white"
- selectedtc = "lime"
- gridtc = "white"
- gridbc = "grey"
- menutc = "blue"
- menubc = "lightGrey"
- cs()
- colourScreen()
- drawMenuBar()
- drawBox(16, 10, 1, 1, " ", menutc, menubc)
- printA("SETTINGS", 17, 1, false, selectedtc, menubc)
- local tOptions = {"1. Register New User", "2. Update Blaze"}
- drawBox(1, 51, 2, 18, " ", "black", "black")
- drawBox(2, 49, 3, 16, " ", gridtc, gridbc)
- drawBox(35, 1, 3, 13, " ", gridtc, gridbc)
- drawBox(2, 49, 15, 1, " ", gridtc, gridbc)
- drawBox(2, 49, 5, 1, " ", gridtc, gridbc)
- drawBox(3, 32, 4, 1, " ", menutc, menubc)
- drawBox(36, 14, 4, 1, " ", menutc, menubc)
- printA("OPTION/FUNCTION NAME", 4, 4, false, menutc, menubc)
- printA("VALUE", 37, 4, false, menutc, menubc)
- printA(tOptions[1], 4, 6, false, menubc, textbc)
- printA(tOptions[2], 4, 7, false, texttc, textbc)
- printA("N/A", 37, 6, false, texttc, textbc)
- printA("N/A", 37, 7, false, texttc, textbc)
- printA("Greyed out options are not yet functional.", 3, 16, false, texttc, textbc)
- printA("N/A applies to functions that can't be changed.", 3, 17, false, texttc, textbc)
- printA(" BACK ", 23, 18, false, menutc, menubc)
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawMenuBar()
- drawBox(16, 10, 1, 1, " ", menutc, menubc)
- printA("SETTINGS", 17, 1, false, selectedtc, menubc)
- settings1 = true
- elseif args[1] == "mouse_click" then
- if (args[3] >= 2 and args[3] <= 6) and (args[4] == 1) then
- if settings1 then
- settings1 = false
- drawDropdown("new")
- end
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 2) then
- if settings1 then
- settings1 = false
- blaze_send()
- break
- end
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 3) then
- if settings1 then
- settings1 = false
- addressBook("view")
- break
- end
- elseif (args[3] >= 8 and args[3] <= 14) and (args[4] == 1) then
- if settings1 then
- settings1 = false
- blaze_inbox(1)
- break
- end
- elseif (args[3] >= 16 and args[3] <= 25) and (args[4] == 1) then
- if settings1 then
- settings1 = false
- blaze_options()
- break
- end
- elseif (args[3] >= 27 and args[3] <= 32) and (args[4] == 1) then
- if settings1 then
- settings1 = false
- blaze_help()
- break
- end
- elseif (args[3] >= 3 and args[3] <= 48) and (args[4] == 7) then
- -- Do Update
- if settings1 then
- settings1 = false
- blaze_update()
- break
- end
- elseif (args[3] >= 23 and args[3] <= 29) and (args[4] == 18) then
- -- Do Back button
- if settings1 then
- settings1 = false
- blaze_inbox(1)
- break
- end
- end
- end
- end
- end
- function blaze_update()
- cs()
- colourScreen()
- -- Do Update Stuff Here
- bartc = "blue"
- barbc = "lightGrey"
- texttc = "black"
- textbc = "white"
- drawBox(1, 51, 1, 2, " ", bartc, barbc)
- printA("Blaze Email Client", 1, 1, false, bartc, barbc)
- printC("UPDATING BLAZE", 2, false, bartc, barbc)
- term.setCursorPos(1,4)
- setCol(texttc, textbc)
- print("> Update in progress, please wait")
- sleep(1)
- print("> Grabbing Blaze")
- shell.run("pastebin get VehDCxwR updateBlaze")
- print("> Deleting old file")
- fs.delete("blaze")
- print("> Saving new file")
- shell.run("mv updateBlaze blaze")
- print("> Restarting...")
- sleep(1.5)
- os.reboot()
- end
- function blaze_help()
- texttc = "black"
- textbc = "white"
- selectedtc = "lime"
- gridtc = "white"
- gridbc = "grey"
- menutc = "blue"
- menubc = "lightGrey"
- cs()
- colourScreen()
- drawMenuBar()
- drawBox(27, 6, 1, 1, " ", menutc, menubc)
- printA("HELP", 28, 1, false, selectedtc, menubc)
- drawBox(1, 51, 2, 18, " ", "black", "black")
- drawBox(2, 49, 3, 16, " ", gridtc, gridbc)
- local sHelp1 = "Created and hosted by DannySMc, Contacts: danny.smc95@gmail.com, Website: http://dannysmc.com. Questions? Contact Danny! Want to use the API? Check on my blog to when it is published. Passwords are secured with SHA265 Hashing algorithm for extra security. This is a beta, so there will likely be many bugs! Please submit them on the ComputerCraft Forums post in the comments."
- local tHelp1 = wordwrap(sHelp1, 47)
- drawBox(22, 6, 3, 1, " ", menutc, menubc)
- printA("HELP", 23, 3, false, menutc, menubc)
- setCol(texttc, textbc)
- local count1 = 4
- for _,v in ipairs(tHelp1) do
- term.setCursorPos(3, count1)
- write(v)
- count1 = count1 + 1
- end
- while true do
- local args = { os.pullEvent() }
- if args[1] == "timer" then
- drawMenuBar()
- drawBox(27, 6, 1, 1, " ", menutc, menubc)
- printA("HELP", 28, 1, false, selectedtc, menubc)
- elseif args[1] == "mouse_click" then
- if (args[3] >= 2 and args[3] <= 6) and (args[4] == 1) then
- drawDropdown("new")
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 2) then
- blaze_send()
- break
- elseif (args[3] >= 2 and args[3] <= 11) and (args[4] == 3) then
- addressBook("view")
- break
- elseif (args[3] >= 8 and args[3] <= 14) and (args[4] == 1) then
- blaze_inbox(1)
- break
- elseif (args[3] >= 16 and args[3] <= 25) and (args[4] == 1) then
- blaze_options()
- break
- elseif (args[3] >= 27 and args[3] <= 32) and (args[4] == 1) then
- blaze_help()
- break
- elseif (args[3] >= 3 and args[3] <= 48) and (args[4] == 7) then
- -- Do Update
- blaze_update()
- break
- elseif (args[3] >= 23 and args[3] <= 29) and (args[4] == 18) then
- -- Do Back button
- blaze_inbox(1)
- break
- end
- end
- end
- end
- blaze_login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement