Advertisement
Guest User

Untitled

a guest
Mar 25th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <vector>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <string>
  6. #include <stdio.h>
  7. #include "functions.h"
  8.  
  9.  
  10. using namespace std;
  11.  
  12. int main(){
  13. initUserCheck(); // Checks to make sure that a user is registered, if not creates a new one.
  14.  
  15. Login:
  16. string usrname;
  17. string psword;
  18. string rpsword;
  19. string path;
  20. string ext = ".DTBF";
  21. int adminLevel = 0;
  22.  
  23. printf("Username: ");
  24. cin >> usrname;
  25. printf("Password: ");
  26. cin >> psword;
  27.  
  28. const char *appdata = std::getenv ( "APPDATA" );
  29. path = appdata;
  30. path += "\\myprogram\\files\\users\\" + usrname + ext;
  31.  
  32. ifstream readUser(path.c_str());
  33. readUser >> rpsword;
  34.  
  35. if(!readUser){
  36.  
  37. if(usrname == "Guest" or "guest"){
  38.  
  39. printf("You are a guest. \n");
  40. goto MainProgram;
  41.  
  42. }
  43. printf("Incorrect Username or Password. \n");
  44. system("PAUSE");
  45. printf("\n");
  46. goto Login;
  47.  
  48. }
  49.  
  50. if(psword != rpsword){
  51.  
  52. printf("Incorrect Username or Password. \n");
  53. printf("Please press any key, and then retry the login.\n");
  54. cin.get();
  55. goto Login;
  56.  
  57. }
  58.  
  59. if (usrname == "admin" or usrname == "Admin"){
  60.  
  61. adminLevel = 1;
  62.  
  63. }
  64.  
  65. MainProgram:
  66. //MainCode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement