Advertisement
shadowkat1010

BBS

Jan 12th, 2013
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. function readFileLines(filename)
  2.  file = fs.open(filename,"r")
  3.  local tLines = {}
  4.  repeat
  5.   line = file.readLine()
  6.   table.insert(tLines,line)
  7.  until line == nil
  8.  file.close()
  9.  return tLines
  10. end
  11. function verifyUser(username,password)
  12.  line = readFileLines("/usernames")
  13.  num = 1
  14.  repeat
  15.   num = num + 1
  16.   if lines[num] == username then userver = true
  17.  until lines[num] == username or lines[num] == nil
  18.  line = readFileLines("/passwords")
  19.  num = 1
  20.  repeat
  21.   num = num + 1
  22.   if lines[num] == password then passver = true
  23.  until lines[num] == password or lines[num] == nil
  24.  if passver == true and userver == true then
  25.  return true
  26.  end
  27. end
  28.  
  29. function bbs()
  30.  term.clear()
  31.  term.setCursorPos(1,1)
  32.  print " ** LOGIN TO SKS-BBS **"
  33.  print "Options:"
  34.  print "[1] Login\n[2] Create Account\n[3] Exit"
  35.  while true do
  36.  event,param1 = os.pullEventRaw()
  37.  if event == "key" and param1 == 2 then selection = 1
  38.  if event == "key" and param1 == 3 then selection = 2
  39.  if event == "key" and param1 == 4 then selection = 3
  40.  end
  41.  if selection == 1 then
  42.   print " ** LOGIN TO SKS-BBS **"
  43.   print "--------\nUSERNAME:"
  44.   write "? "
  45.   user = read()
  46.   print "--------\PASSWORD:"
  47.   write "? "
  48.   pass = read()
  49.   print "--------"
  50.   if verifyUser then
  51.    print "ACCESS GRANTED!"
  52.    login = true
  53.   end
  54.  end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement