Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - -- Load API
 - os.loadAPI("sha256")
 - os.loadAPI("gui")
 - local textStart = gui.textStart
 - local diskSide = "bottom"
 - local serverId = 3
 - local withdrawId = 14
 - local version = "GAB-0.1"
 - local url = "http://147.135.59.131/index.php"
 - local all = "0123456789abcdefghijklmnopqrstuvwxyz"
 - -- Import GUI functions
 - local drawHeader, drawButtons, drawButton, drawError, center = gui.drawHeader, gui.drawButtons, gui.drawButton, gui.drawError, gui.center
 - local waitForMouse, waitForButton, waitForChar, waitForKey, waitForEnter = gui.waitForMouse, gui.waitForButton, gui.waitForChar, gui.waitForKey, gui.waitForEnter
 - local waitForDisk = gui.waitForDisk
 - function otherAmount()
 - local amount = ""
 - term.clear() drawHeader()
 - term.setCursorPos(center(textStart, "Amount : $ ") + 12, textStart)
 - return read()
 - end
 - function balance(acc, pin)
 - term.clear() drawHeader() drawButtons()
 - drawButton(4, "Cancel")
 - drawButton(5, "Galleon Dollars")
 - local mult = nil
 - while true do
 - local button = waitForButton()
 - if button == 4 then return
 - elseif button == 5 then mult = 1 break
 - end
 - end
 - request = http.post(url, "command="..textutils.urlEncode(tostring("balance")).."&".."username="..textutils.urlEncode(tostring(acc)))--.."&".."password="..textutils.urlEncode(tostring(crypt.hashPassword(pin))))
 - response = request.readAll()
 - term.clear() drawHeader() drawButtons()
 - drawButton(8, "OK")
 - if response ~= "-" then
 - local displayBalance = math.floor(tonumber(response) * mult * 100) / 100
 - center(textStart, "Balance: $" .. displayBalance .. " Galleons.")
 - else
 - drawError("Transaction Error")
 - end
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - end
 - function register()
 - local accname, accpin
 - term.clear() drawHeader()
 - center(textStart, "Insert keycard or press ENTER")
 - center(textStart + 1, "to transact without a keycard")
 - parallel.waitForAny(waitForEnter, waitForDisk)
 - term.clear() drawHeader()
 - for i = 1, 10 do
 - r = math.random(#all)
 - e = e.. string.sub(all, r, r)
 - end
 - term.setCursorPos(center(textStart, "Account No : "..e.."") + 13, textStart)
 - accname = e
 - if disk.hasData(diskSide) then
 - disk.setLabel(diskSide,accname)
 - else
 - end
 - term.setCursorPos(center(textStart + 1, "PIN : ") + 6, textStart + 1)
 - accpin = read("*")
 - request = http.post(url, "command="..textutils.urlEncode(tostring("register")).."&".."username="..textutils.urlEncode(tostring(e)).."&".."password="..textutils.urlEncode(tostring(sha256.sha256(accpin))))
 - response = request.readAll()
 - term.clear() drawHeader() drawButtons()
 - drawButton(8, "OK")
 - if response == "Saved!" then
 - center(textStart, "Added User: " .. accname .."")
 - sleep(3)
 - disk.eject(diskSide)
 - os.reboot()
 - else
 - drawError("ERROR")
 - end
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - end
 - function deposit(acc, pin)
 - term.clear() drawHeader() drawButtons()
 - drawButton(4, "Cancel")
 - local mult = nil
 - --while true do
 - -- local button = waitForButton()
 - -- if button == 4 then return
 - -- end
 - -- end
 - request = http.post(url, "command="..textutils.urlEncode(tostring("deposit")).."&".."username="..textutils.urlEncode(tostring(acc)))
 - response = request.readAll()
 - term.clear() drawHeader() drawButtons()
 - drawButton(8, "OK")
 - redstone.setOutput("back",true)
 - center(textStart, "Now Accepting:")
 - center(textStart + 1, "Gold Blocks, Ingots, Nuggets ")
 - center(textStart + 2, "Please Close Terminal.")
 - center(textStart + 3, "Then drop stacks of items ONLY")
 - sleep(10)
 - -- if response ~= "-" then
 - -- local displayBalance = math.floor(tonumber(response) * mult * 100) / 100
 - --center(textStart, "Balance: $" .. displayBalance .. " Galleons.")
 - -- else
 - -- drawError("Transaction Error")
 - -- end
 - while true do
 - local button = waitForButton()
 - if button == 8 then redstone.setOutput("back",false) return end
 - end
 - end
 - function transfer(acc, pin)
 - term.clear() drawHeader() drawButtons()
 - drawButton(1, "$100")
 - drawButton(2, "$200")
 - drawButton(3, "$500")
 - drawButton(5, "$1000")
 - drawButton(6, "$2000")
 - drawButton(7, "$5000")
 - drawButton(4, "Cancel")
 - drawButton(8, "Other Amount")
 - local amountS = nil
 - while true do
 - local button = waitForButton()
 - if button == 1 then amountS = "100" break
 - elseif button == 2 then amountS = "200" break
 - elseif button == 3 then amountS = "500" break
 - elseif button == 5 then amountS = "1000" break
 - elseif button == 6 then amountS = "2000" break
 - elseif button == 7 then amountS = "5000" break
 - elseif button == 4 then return
 - elseif button == 8 then amountS = otherAmount() break
 - end
 - end
 - term.clear() drawHeader() drawButtons()
 - local amount = tonumber(amountS)
 - if amount ~= nil and (amount % 1) == 0 then
 - term.clear() drawHeader()
 - term.setCursorPos(center(textStart, "Amount : $ ") + 12, textStart)
 - term.write(amountS)
 - term.setCursorPos(center(textStart + 1, "Account : ") + 10, textStart + 1)
 - local account = read()
 - drawButtons()
 - drawButton(4, "Cancel")
 - drawButton(8, "Confirm")
 - while true do
 - local button = waitForButton()
 - if button == 4 then return
 - elseif button == 8 then break
 - end
 - end
 - --local senderId, response = nil, nil
 - --rednet.open(modemSide)
 - -- rednet.send(serverId, version .. textutils.serialize( { "TRANSFER", acc, crypt.hashPassword(pin), account, amountS } ) )
 - -- while true do
 - -- senderId, response = rednet.receive(5)
 - -- if senderId == serverId then break end
 - -- end
 - -- rednet.close(modemSide)
 - -- request = http.post(url, "command="..textutils.urlEncode(tostring("transfer")).."&".."username="..textutils.urlEncode(tostring(acc)).."&".."password="..textutils.urlEncode(tostring(sha256.sha256(pin)).."&".."account="..textutils.urlEncode(tostring(account)).."&".."amountS="..textutils.urlEncode(tostring(amountS))))
 - request = http.post(url,"command="..textutils.urlEncode(tostring("trans")).."&".."username="..textutils.urlEncode(tostring(acc)).."&".."account="..textutils.urlEncode(tostring(account)).."&".."amount="..textutils.urlEncode(tostring(amount)).."&".."password="..textutils.urlEncode(tostring(sha256.sha256(pin))))
 - term.clear() drawHeader() drawButtons()
 - response = request.readAll()
 - if response == "sendok" then
 - center(textStart, "Transfer Successful")
 - else
 - drawError("Transaction Error")
 - end
 - else
 - term.clear() drawHeader() drawButtons()
 - drawError("Invalid Amount")
 - --[[
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - --]]
 - end
 - drawButton(8, "OK")
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - end
 - function withdraw(acc, pin)
 - term.clear() drawHeader() drawButtons()
 - drawButton(1, "$100")
 - drawButton(2, "$200")
 - drawButton(3, "$500")
 - drawButton(5, "$1000")
 - drawButton(6, "$2000")
 - drawButton(7, "$5000")
 - drawButton(4, "Cancel")
 - drawButton(8, "Other Amount")
 - local amountS = nil
 - while true do
 - local button = waitForButton()
 - if button == 1 then amountS = "100" break
 - elseif button == 2 then amountS = "200" break
 - elseif button == 3 then amountS = "500" break
 - elseif button == 5 then amountS = "1000" break
 - elseif button == 6 then amountS = "2000" break
 - elseif button == 7 then amountS = "5000" break
 - elseif button == 4 then return
 - elseif button == 8 then amountS = otherAmount() break
 - end
 - end
 - term.clear() drawHeader() drawButtons()
 - local amount = tonumber(amountS)
 - if amount ~= nil and (amount % 100) == 0 then
 - term.clear() drawHeader()
 - term.setCursorPos(center(textStart, "Amount : MC$ ") + 12, textStart)
 - term.write(amountS)
 - drawButtons()
 - drawButton(4, "Cancel")
 - drawButton(8, "Confirm")
 - while true do
 - local button = waitForButton()
 - if button == 4 then return
 - elseif button == 8 then break
 - end
 - end
 - local senderId, response = nil, nil
 - rednet.open(modemSide)
 - rednet.send(serverId, version .. textutils.serialize( { "WITHDRAW", acc, crypt.hashPassword(pin), amountS } ) )
 - while true do
 - senderId, response = rednet.receive(5)
 - if senderId == serverId then break end
 - end
 - rednet.close(modemSide)
 - term.clear() drawHeader()
 - if response ~= "-" then
 - center(textStart, "Withdrawing " .. (amount) .. " MC$")
 - rednet.open(modemSide)
 - rednet.send(withdrawId, version .. textutils.serialize( { "WITHDRAW", (amount) .. "" } ) )
 - while true do
 - senderId, response = rednet.receive(5)
 - if senderId == withdrawId then break end
 - end
 - rednet.close(modemSide)
 - term.clear() drawHeader()
 - if response ~= "-" then
 - center(textStart, "Please take your cash")
 - sleep(2)
 - return
 - else
 - drawButtons()
 - drawError("Withdrawal Error")
 - end
 - else
 - drawError("Transaction Error")
 - end
 - else
 - term.clear() drawHeader() drawButtons()
 - drawError("Invalid Amount")
 - --[[
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - --]]
 - end
 - drawButton(8, "OK")
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - end
 - function bank(acc, pin)
 - while true do
 - term.clear() drawHeader() drawButtons()
 - drawButton(4, "Return Card")
 - drawButton(5, "Balance Check")
 - drawButton(6, "Withdrawal")
 - drawButton(7, "Deposit")
 - drawButton(8, "Transfer")
 - local button = waitForButton()
 - if button == 4 then return
 - elseif button == 5 then balance(acc, pin)
 - elseif button == 6 then withdraw(acc, pin)
 - elseif button == 7 then deposit(acc, pin)
 - elseif button == 8 then transfer(acc, pin)
 - end
 - end
 - end
 - function begin()
 - local acc, pin
 - term.clear() drawHeader()
 - drawButtons()
 - drawButton(4, "Login")
 - drawButton(8, "Open Account")
 - while true do
 - local button = waitForButton()
 - if button == 4 then break
 - elseif button == 8 then register()
 - end
 - end
 - --while true do
 - center(textStart, "Insert keycard or press ENTER")
 - center(textStart + 1, "to transact without a keycard")
 - parallel.waitForAny(waitForEnter, waitForDisk)
 - term.clear() drawHeader()
 - term.setCursorPos(center(textStart, "Account No : ") + 13, textStart)
 - -- local button = waitForButton()
 - -- if button == 4 then return
 - -- elseif button == 8 then
 - -- os.reboot()
 - -- end
 - if disk.hasData(diskSide) then
 - acc = disk.getLabel(diskSide)
 - term.write(acc)
 - else
 - acc = read()
 - end
 - term.setCursorPos(center(textStart + 1, "PIN : ") + 6, textStart + 1)
 - pin = read("*")
 - sleep(1)
 - request = http.post(url, "command="..textutils.urlEncode(tostring("login")).."&".."username="..textutils.urlEncode(tostring(acc)).."&".."password="..textutils.urlEncode(tostring(sha256.sha256(pin))))
 - response = request.readAll()
 - term.clear() drawHeader()
 - if response == "true" then
 - bank(acc, pin)
 - term.clear() drawHeader()
 - disk.eject(diskSide)
 - center(textStart, "Thank you for banking with GA")
 - center(textStart + 1, "Please take your keycard")
 - sleep(6)
 - os.reboot()
 - else
 - drawError("Login Error")
 - sleep(4)
 - os.reboot()
 - end
 - while true do
 - local button = waitForButton()
 - if button == 8 then return end
 - end
 - end
 - while true do
 - begin()
 - end
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment