1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <cstdio>
#include <windows.h>
#include <cstdlib>
#include <time.h>
using namespace std;
int staticLoad() // Exterior function
{
cout << "Loading";
Sleep(100); // A more simple delay that works by milliseconds. It goes along with the Windows header
cout << ".";
Sleep(100);
cout << ".";
Sleep(100);
cout << ".";
Sleep(800);
system("cls");
cout << "Loading";
Sleep(100);
cout << ".";
Sleep(100);
cout << ".";
Sleep(100);
cout << "." << flush; // Flush just clears the input buffer. Its not needed but is a good thing to use every now and then.
system("cls");
return 0;
}
int WriteToText()
{
/////// Variables
const int SIZE =100;
char chNewUsername[SIZE]; // for a new username
char chNewPassword[SIZE];// for a new password
system("cls");
cin.clear();
ofstream WriteFile; // write to a file
cout << "Type in your username or type in a new one.\n -";
cin >> chNewUsername;
system("cls");
cout << "Type in your new password.\n -";
cin >> chNewPassword;
WriteFile.open(chNewUsername); // makes new file
WriteFile << chNewPassword;// saves password to file
WriteFile.close();
return 0;
}
int main(int nNumberofArgs, char* pszArgs[])
{
system("cls");
system("title Grace Assembly of God - Login");
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0); //not windows 7 for some reason... Not sure if it will work because of my limitations of OS.
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
staticLoad();
system("color a"); // Simple system color [green]
time_t rawtime; // time stamp stuff so that the time the program is executed is logged in an external text file.
time ( &rawtime );
string szTime = ctime (&rawtime); // Set the timestamp equal to a alpha variable.
string szUsername;
string line;
string szPassword;
cout << "Type in your username.\n -";
cin >> szUsername;
if (szUsername == "new" || szUsername == "New" || szUsername == "update" || szUsername == "Update")
{
WriteToText();// previous function
}
ofstream ofLogFile;
ofLogFile.open("C:\\Program Files\\PasswordLog\\log.txt",ios::app);
ofLogFile << "[ACCESS ENTRY]\n\nDATE: " << szTime << "\nUSERNAME: " << szUsername;
ofLogFile.close();
if (szUsername != "new" || szUsername != "New" || szUsername != "update" || szUsername != "update")
{
ifstream ReadFile;
ReadFile.open(szUsername.c_str());
if ( ReadFile.good() ) // if it finds it
{
system("cls");
getline (ReadFile,line);
cout << "Type your password.\n -";
cin >> szPassword;
ofLogFile << "\nPASSWORD: " << szPassword << "\n\n\n";
ofLogFile.close();
if(szPassword == line)
{
system("cls");
cout << "Correct";
Sleep(200);
return 0;
}
if (szPassword != line)
{
system("cls");
cout << "Wrong password, shutting down in 60 seconds";
Sleep(2000);
ReadFile.close();
}
}
if (ReadFile.bad())// if it can't find it
{
cout << "Cannnot be opened";
system("pause>nul");
}
}
}
|