This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
kei_k's profile picture

User Server

Started by kei_k, 18 October 2012 - 07:59 AM
kei_k #1
Posted 18 October 2012 - 09:59 AM
I am having problems on this application, it's supposed to be an "account" editor but everytime i log in, it just kills itself and shuts down the system, must have at least a 3x3 monitor on the top, rednet modem on the back
Spoiler
--Union Tech Corp
--Server Database Entry Editor
function searchuser()
utapi.clearT()
header()
print("Search User:")
write("Search: ")
sear1 = read()
if fs.exists("utcorp/users/" .. sear1 .. "/username.usr") and fs.isDir("utcorp/users/" .. sear1 .. "/username.usr")then
utapi.clearT()
header()
print("User Found!")
fs.open("utcorp/users/" .. sear1 .. "/username.usr")
temppass = file:readAll()
file:close("utcorp/users/" .. sear1 .. "/username.usr")
print("Info:")
print(sear1)
print(temppass)
temppass = nil
wait = read()
start()
else
print("Error -  06")
print("Cannot Find Specified User: " .. sear1)
end
end
function adduser()
utapi.clearT()
header()
print("Add User:")
print("Username:")
print("Password:")
term.setCursorPos(1,5)
write("Username: ")
newuser = read()
term.setCursorPos(1,6)
write("Password: ")
newpass = read()
if fs.exists("utcorp/users/" .. newuser .. "/username.usr") and fs.isDir("utcorp/users/" .. newuser .. "/username.usr")then
print("Error - 07")
print("User: " .. newuser .. " Already Exists")
newuser = nil
newpass = nil
start()
end
file = io.open("utcorp/users/" .. newuser .. "/username.usr",w)
file:write(newpass)
file:close()
end
function editpass()
utapi.clearT()
header()
print("Password Editing Mode")
newpass1 = write("Username: ")
io.read()
utapi.clearT()
header()
print("Password Editing Mode")
if fs.exists("utcorp/users/" .. newpass1 .. "/username.usr") and fs.isDir("utcorp/users/" .. newpass1 .. "/username.usr")then
print("User Found!")
print("Enter New Password:")
write("Password: ")
newpass2 = read()
file = io.open("utcorp/users/" .. newpass1 .. "/username.usr","w+")
file:write(newpass2)
file:close("utcorp/users/" .. newpass1 .. "/username.usr")
print("New Password Implemented!")
sleep(2)
start()
else
print("Error -  08")
print("The User you Have Specified Does not Exist...")
sleep(3)
start()
end
end
function deluser()
utapi.clearT()
header()
print("User Deletion Mode")
write("Username: ")
deluser = read()
if fs.exists("utcorp/users/" .. deluser .. "/username.usr") and fs.isDir("utcorp/users/" .. deluser .. "/username.usr")then
fs.delete("utcorp/users/" .. deluser)
print("User Sucessfully Deleted!")
sleep(2)
start()
else
end
end
local function header()
utapi.cent("Union Tech Corp",1)
utapi.cent("Account Server Database",2)
utapi.divider("-",3)
end
function start()
rednet.broadcast("uniontechmaintenance")
utapi.clearT()
header()
print("Welcome Back! " .. usrnm1)
print("1 - Search User")
print("2 - Add User")
print("3 - Edit Password")
print("4 - Delete User")
print("5 - Reboot Console")
print("6 - Server Mode")
print("7 - Shutdown Terminal")
print("Enter Command:")
write("COM:>")
command01 = read()
if command01 == "1" then
searchuser()
elseif command01 == "2" then
adduser()
elseif command01 == "3" then
editpass()
elseif command01 == "4" then
deluser()
elseif command01 == "5" then
shell.run("reboot")
elseif command01 == "6" then
shell.run("UAD-Server")
elseif command01 == "7" then
shell.run("shutdown")
end
end
function login()
utapi.clearT()
header()
print("Authentication Required:")
print("Username: ")
print("Password: ")
term.setCursorPos(1,5)
write("Username: ")
usernm1 = read()
term.setCursorPos(1,6)
write("Password: ")
passwr1 = read("*")
if usernm1 == "herpa" and passwr1 == "derpa" then
term.redirect("top")
print("Admin Has Accessed The System!")
term.restore()
start()
else
term.redirect("top")
print("An unauthorised user has accessed the system")
term.restore()
print("Error Omega")
print("Wrong Username and/or Password!")
sleep(3)
shell.run("reboot")
end
end
login()
I wish i could get it working but im a bit tied up at the moment :P/>/>

Edit:
I think it's centered around the login() @ line "139" to start() @ line "96"
remiX #2
Posted 18 October 2012 - 01:37 PM
What does the error say exactly?
ChunLing #3
Posted 18 October 2012 - 07:38 PM
There's no error, there's an option that shuts down the computer, and it gets auto-selected improperly. Or the reboot is happening because the login fails. But I think that the former is the case described.
remiX #4
Posted 18 October 2012 - 08:47 PM
Are you sure you're typing the username and password as lower case?
ChunLing #5
Posted 19 October 2012 - 02:30 AM
Also, do you get kicked out on attempting to log in or after you log in? Like, does it flash the "Welcome Back! " message and menu at you?