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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
#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;
string szNewUsername; // for a new username
string szNewPassword;// 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 >> szNewUsername;
system("cls");
cout << "Type in your new password.\n -";
cin >> szNewPassword;
string WritePath;
WritePath = "C:\\Usernames\\";
string szNewTogether;
szNewTogether == WritePath + szNewUsername;
cout << szNewTogether;
system("pause>nul");
WriteFile.open(szNewTogether); // makes new file // szNewTogether.c_str() <-Makes string act like char
if (WriteFile.fail())
{
system("cls");
cout << "error";
}
WriteFile << szNewPassword;// 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
return 0;
}
ofstream ofLogFile;
ofLogFile.open("C:\\Password Log\\log.txt",ios::app);
ofLogFile << "\n[ACCESS ENTRY]\nDATE: " << szTime << "\nUSERNAME: " << szUsername;
ofLogFile.close();
if (szUsername != "new" || szUsername != "New" || szUsername != "update" || szUsername != "update")// Does not equal
{
string szExistingTogether;
szExistingTogether == "C:\\Usernames\\" + szUsername;
cout << szExistingTogether;
ifstream ReadFile;
ReadFile.open(szExistingTogether.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";
if(szPassword == line)
{
system("cls");
cout << "Correct";
Sleep(200);
return 0;
};
if (szPassword != line)
{
system("cls");
cout << "Wrong password, logging off in 60 seconds";
ofLogFile << "^^^^^^^^^Password wrong\n\n\n";
system("shutdown /f /t 60");
Sleep(2000);
ReadFile.close();
};
};
if (ReadFile.fail())// if it can't find it
{
system("cls");
cout << "Cannnot be opened";
Sleep(2000);
ofLogFile << "^^^^^^^^^Username wrong, no password entry\n\n\n";
system("shutdown /f /t 60");
system("pause>nul");
return 0;
}
}
ofLogFile.close();
return 0;
}
|