Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. names = {}
  2. emails= []
  3.  
  4. def first():
  5.     f = file('user','w')
  6.     print "This is your first time. This account will be made administrator."
  7.     a = raw_input ("Enter your desired username : ")
  8.     b = raw_input ("Enter your desired password : ")
  9.     global a
  10.     global b
  11.     f.write(a+','+b)
  12.     names[a]=b
  13.     f.close()
  14.  
  15.  
  16. def load():
  17.     f = file('user','r')
  18.     for line in f:
  19.         list2 = line.split(',')
  20.         names[list2[0]]=list2[1]
  21.     f.close()
  22.    
  23. def emailadd():
  24.     f = file(existuser,'w')
  25.     emailadd = raw_input("Enter your email: ")
  26.     emails.append(emailadd)
  27.     f.write(emailadd)
  28.     f.close()
  29.  
  30.  
  31. def normal():
  32.     while True:
  33.         menuchoice = raw_input("Press e to add your email, v to view your current email and q to logout : ")
  34.         if menuchoice == "e":
  35.                 emailadd()
  36.         if menuchoice == "v":
  37.             try:
  38.                 f = file(existuser,'r')
  39.                 for lines in f:
  40.                     print lines
  41.             except IOError:
  42.                 print "You have no email yet, press e to add one"
  43.         if menuchoice =="q":
  44.             break
  45.  
  46. def create():
  47.     f = file("user","a")
  48.     newuser = raw_input ("Enter your desired username: ")
  49.     newpass = raw_input ("Enter your desired password: ")
  50.     names[newuser]=newpass
  51.     f.write('\n'+ newuser+','+newpass)
  52.     print names
  53.     f.close()
  54.    
  55. def admin():
  56.     f = file('user','w')
  57.     while True:
  58.         deletepeople = raw_input ("Press d to delete someone and v to look at the names \nPress q to log out.:")
  59.         if deletepeople == "d":
  60.             deletereal = raw_input("Who would you like to delete? :")
  61.             del names[deletereal]
  62.             print "Sucessfully deleted"
  63.         if deletepeople == "v":
  64.             print names
  65.         if deletepeople == "q":
  66.             break
  67.     f.close()
  68.        
  69.    
  70. try:
  71.     load()
  72. except:
  73.     first()
  74.    
  75. load()
  76. while True:
  77.     f = file("user",'r')
  78.     print "Welcome to Xerotics competition's login system."
  79.     decide = raw_input("Please choose what you want to do. \n1)Create new user :\n2)Login to existing user :\n 1/2:")
  80.     print names
  81.     if decide == '1':
  82.         create()
  83.     if decide == '2':
  84.         existuser = raw_input ("Enter your username :")
  85.         existpass = raw_input ("Enter your password :")
  86.         if existpass in names[existuser]:
  87.             print "Congratulations, you have logged in."
  88.             global existuser
  89.             f.close()
  90.             if existuser == a and existpass == b:
  91.                 admin()
  92.             else:
  93.                 normal()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement