Posted 15 October 2013 - 06:26 AM
Ok so after doing some research I decided I wanted my login and system manager to be set server-side while being able to be accessed via wireless modem by any computer that chooses to access it but I am having trouble figuring out the best way to do this since both the login and manager were originally built without networking in mind not to mention all options are menu based rather than simple text input from the user.
I managed to test on how to have one computer tell another to open a program which in turn displays some text or even a simple question but aside from that I am completely lost! Any help would be greatly appreciated! I will post my login program as an example to base your answers by. Please keep in mind that though the login DOES work it may be a little sloppy.
Thank you in advance!
::EDIT::
Just to clarify the files need to be on the server, run from the clients and displayed on the client side systems rather than the server.
I managed to test on how to have one computer tell another to open a program which in turn displays some text or even a simple question but aside from that I am completely lost! Any help would be greatly appreciated! I will post my login program as an example to base your answers by. Please keep in mind that though the login DOES work it may be a little sloppy.
Spoiler
local function readN(len, replaceChar)
len = len or 12
local input=""
local key = 0
term.setCursorBlink(true)
repeat
local e,p1 = os.pullEvent()
if e=="char" then
if #input < len then
input = input .. p1
term.write(replaceChar or p1)
end
elseif e=="key" and p1==keys.backspace and #input > 0 then
input = input:sub(1,#input-1)
local x,y = term.getCursorPos()
term.setCursorPos(x-1,y)
term.write(" ")
term.setCursorPos(x-1,y)
end
until p1==keys.enter
term.setCursorBlink(false)
return input
end
sid = 0
lockdown = 0
actc = ""
actpw = ""
actpc = ""
userlog = ""
userpas = ""
puselog = ""
prog = 0
function clear()
term.clear()
term.setCursorPos(1,1)
end
function menu(id, text)
if sid == id then
write">> "
else
write" "
end
print(text)
end
if not fs.exists("pending") then
shell.run("mkdir pending")
if not fs.exists("users") then
shell.run("mkdir users")
else
end
elseif not fs.exists("users") then
shell.run("mkdir users")
end
clear()
while prog == 0 do
--os.pullEvent = os.pullEventRaw
rep1 = 0
rep2 = 0
rep3 = 0
rep4 = 0
rep5 = 0
rep6 = 0
ioerror = 0
term.setCursorPos(1, 12)
term.clearLine()
term.setCursorPos(1, 13)
term.clearLine()
term.setCursorPos(1, 14)
term.clearLine()
term.setCursorPos(1, 15)
term.clearLine()
term.setCursorPos(1, 16)
term.clearLine()
term.setCursorPos(1, 17)
term.clearLine()
term.setCursorPos(1,1)
print("|################################################|")
print("| BOUTECH SYSTEM LOGIN |")
print("| OS Version : 1.3 |")
print("|################################################|")
term.setCursorPos(13,7)
print("|------------------------|")
term.setCursorPos(13,8)
print("| |")
term.setCursorPos(13,9)
print("| |")
term.setCursorPos(13,10)
print("| |")
term.setCursorPos(13,11)
print("|------------------------|")
term.setCursorPos(16,8)
menu(0, "Login")
term.setCursorPos(16,9)
menu(1, "Create Account")
term.setCursorPos(16,10)
menu(2, "Shutdown")
event, key = os.pullEvent("key")
if key == 200 then
if sid == 0 then
sid = sid+2
elseif sid == 1 then
sid = sid-1
elseif sid == 2 then
sid = sid-1
end
elseif key == 208 then
if sid == 2 then
sid = sid-2
elseif sid == 1 then
sid = sid+1
elseif sid == 0 then
sid = sid+1
end
elseif key == 28 then
if sid == 0 then
term.setCursorPos(13, 12)
print("| Enter Credentials. |")
term.setCursorPos(13, 13)
print("| |")
term.setCursorPos(13, 14)
print("| |")
term.setCursorPos(13, 15)
print("| |")
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(13, 17)
print("|------------------------|")
while rep5 == 0 do
term.setCursorPos(1, 14)
term.clearLine()
term.setCursorPos(1, 16)
term.clearLine()
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(13, 14)
print("| |")
term.setCursorPos(15, 14)
write("Username: ")
userlog = readN()
if userlog == "adminovrride" then
rnd = math.random(100, 500)
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos (17, 18)
print("Override Code: ".. rnd)
apass = tostring((rnd + 11) * 83)
term.setCursorPos(1, 16)
term.clearLine()
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(15, 16)
write("Password: ")
ovrpass = readN(12, "*")
if ovrpass == apass then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print("Override Successful...")
sleep(3)
term.clear()
term.setCursorPos(1, 1)
rep5 = rep5+1
rep6 = rep6+1
prog = prog+1
else
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print(" Override Failed...")
sleep(1)
rep5 = rep5+1
rep6 = rep6+1
sid = 0
end
else
if userlog == "" then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(18, 18)
print("Invalid Username")
sleep(1)
ioerror = ioerror+1
if ioerror == 3 then
rep5 = rep5+1
rep6 = rep6+1
sid = 0
else
end
else
ioerror = 0
ulog = fs.exists("users/".. userlog)
if ulog == true then
term.setCursorPos(1, 16)
term.clearLine()
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(15, 16)
write("Password: ")
userpas = readN(12, "*")
if userpas == "" then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print("Invalid Password Entry")
sleep(1)
ioerror = ioerror+1
term.setCursorPos(1, 18)
term.clearLine()
if ioerror == 3 then
rep5 = rep5+1
sid = 0
else
end
else
ulog = io.open("users/".. userlog, "r") or nil
pass = ulog and ulog:read()
ulog:close()
if (pass and pass==userpas) then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(16, 18)
print(" Login Success...")
currentw = fs.open("current", "w")
accessr = fs.open("users/".. userlog, "r")
accessl = accessr.readLine() and accessr.readLine()
currentw.writeLine(userlog)
currentw.writeLine(accessl)
currentw.close()
accessr.close()
rep5 = rep5+1
rep6 = rep6+1
prog = prog+1
sid = 0
sleep(2)
shell.run("system")
else
if lockdown < 2 then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(16, 18)
print(" Wrong Password")
sleep(1)
if userlog == puselog then
lockdown = lockdown+1
else
lockdown = 0
puselog = userlog
lockdown = lockdown+1
end
else
while rep6 == 0 do
term.setCursorPos(15, 18)
rnd = tostring(math.random(101, 999))
if not fs.exists("pending/".. rnd) then
fs.move("users/".. userlog, "pending/".. rnd)
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print(" Lockdown Ref #: "..rnd)
sleep(1)
ulog = fs.open("pending/".. rnd, "a")
ulog.writeLine("Username: ".. userlog)
ulog.close()
rep6 = rep6+1
rep5 = rep5+1
sid = 0
else
end
end
end
end
end
else
term.setCursorPos(14, 18)
print(" Bad/Unknown Username")
sleep(1)
end
end
end
end
elseif sid == 1 then
term.setCursorPos(13, 12)
print("| Submit Account Info. |")
term.setCursorPos(13, 13)
print("| |")
term.setCursorPos(13, 14)
print("| |")
term.setCursorPos(13, 15)
print("| |")
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(13, 17)
print("|------------------------|")
while rep1 == 0 do
term.setCursorPos(1, 14)
term.clearLine()
term.setCursorPos(13, 14)
print("| |")
term.setCursorPos(15, 14)
write("Username: ")
input = readN()
actc = input
actex = fs.exists("users/".. actc)
if input == "adminovrride" then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(18, 18)
print("Invalid Username")
sleep(1)
ioerror = ioerror+1
if ioerror == 3 then
rep1 = 1
rep2 = 1
rep3 = 1
sid = 0
else
end
else
if input == "" then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(18, 18)
print("Invalid Username")
sleep(1)
ioerror = ioerror+1
if ioerror == 3 then
rep1 = 1
rep2 = 1
rep3 = 1
sid = 0
else
end
elseif actex == true then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print (" Username Unavailable")
sleep(1)
else
ioerror = 0
rep1 = 1
end
end
end
while rep2 == 0 do
while rep3 == 0 do
term.setCursorPos(15, 15)
write("Password: ")
input = readN(12, "*")
if input == "" then
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print("Invalid Password Entry")
sleep(1)
ioerror = ioerror+1
if ioerror == 3 then
rep1 = 1
rep2 = 1
rep3 = 1
else
end
else
ioerror = 0
actpw = input
rep3 = 1
rep2 = 1
end
end
term.setCursorPos(13, 16)
print("| |")
term.setCursorPos(15, 16)
write("Confirm : ")
input = readN(12, "*")
actpc = input
if (actpc) == (actpw) then
while rep4 == 0 do
rnd = tostring(math.random(1011, 9999))
if not fs.exists("pending/".. rnd) then
file = fs.open("pending/".. rnd, "w")
file.writeLine(actc)
file.writeLine(actpw)
file.close()
rep4 = rep4+1
else
end
end
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(13, 18)
print(" Pending... Ref #: ", rnd)
sleep(1)
ioerror = 0
rep2 = 1
sid = 0
else
term.setCursorPos(1, 18)
term.clearLine()
term.setCursorPos(15, 18)
print("Password Doesn't Match")
sleep(1)
rep2 = 0
ioerror = ioerror+1
if ioerror == 3 then
rep1 = 1
rep2 = 1
rep3 = 1
else
end
end
end
elseif sid == 2 then
term.setCursorPos(13,14)
print("|########################|")
term.setCursorPos(13,15)
print("# SYSTEM SHUTTING DOWN!! #")
term.setCursorPos(13,16)
print("|########################|")
sleep(3)
os.shutdown()
end
end
end
Thank you in advance!
::EDIT::
Just to clarify the files need to be on the server, run from the clients and displayed on the client side systems rather than the server.