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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#include <iostream>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <cstdlib>
#include <time.h>
#include <windows.h>
#include <fstream>
#include <string>
#include <tchar.h>
#include <windows.h>
#define entuser "Enter Username [20] : "
#define entpw "Enter Password : "
#define noticepw " This is your Password, Keep it safe."
#define pathexistfile "The Directory You Entered is Actually a File."
#define errorfile1 "Unable to open file."
#define direxist "The Directory Exists."
#define dirnoexist "The Directory Is Non-Existant."
using namespace std;
int main()
{
char yesno;
int opt1;
string information;
string line;
time_t seconds;
time(&seconds);
srand((unsigned int) seconds);
string strPath;
string password;
string username;
string entpassword;
string filename4;
string filename3;
string filename2;
string folderfind = "C:/u/" + username;
string filename4 = "C:/u/" + username + "/password.txt";
bhere:
strPath = "c:/u";
if ( access( strPath.c_str(), 0 ) == 0 )
{
struct stat status;
stat( strPath.c_str(), &status );
if ( status.st_mode & S_IFDIR )
{
cout << direxist << endl; //the path exists
goto login;
}
else
{
cout << pathexistfile << endl; //the path is actually a file
}}
cout << dirnoexist << endl; //folder u does not exists
system("pause >nul");
goto foldercreation;
foldercreation:
cout << "Creating Folder..." << endl;
CreateDirectory("c:/u", NULL); //create folder
goto usercreation;
login:
cout << "Do you have a username? (Y/N)" << endl;
cin >> yesno;
if (yesno = 'Y')
{
goto logintwo;
}
if (yesno = 'N')
{
cin.ignore(yesno,10);
goto usercreation;
}
else
{
goto login;
}
logintwo:
cout << entuser << endl;
cin.ignore(yesno,10),
cin >> username;
if ( access(folderfind.c_str(), 0 ) == 0 )
{
struct stat status;
stat(folderfind.c_str(), &status );
if (status.st_mode & S_IFDIR )
{
cout << direxist << endl; //the path exists
goto loginthree;
}
else
{
cout << dirnoexist << endl; //the path is actually a file
}}
loginthree:
cout << entpw << endl;
cin >> entpassword;
ifstream myfilo (filename4.c_str());
if (myfilo.is_open())
{
while (! myfilo.eof() )
{
getline (myfilo,line);
cout << line << endl;
myfilo.close();
}
}
else
{
cout << errorfile1;
}
optioncon:
cout << "Enter a 1 if you would like to write information.\n Enter a 2 if you would like to read information.\n 3. If you would like to signout.\n" << endl;
cin >> opt1;
if (opt1 = '1')
{
{
string filename2 = "C:/u/" + username + "/information.txt";
ofstream myfile;
myfile.open(filename2.c_str());
myfile << cin << information << endl;
myfile.close();
goto optioncon;
}
if (opt1 = '2')
{
string filename3 = "C:/u/" + username + "/information.txt";
ifstream myfilx (filename3.c_str());
if (myfilx.is_open())
{
while (! myfilx.eof() )
{
getline (myfilx,line);
cout << line << endl;
myfilx.close();
system("pause");
goto optioncon;
}
}
if (opt1 = '3')
{
goto bhere;
}
else
{
cout << errorfile1;
system("pause");
goto optioncon;
}
}
usercreation:
cout << entuser;
cin >> username; //create a username
string path = "c:/u/" + username;
CreateDirectoryA(path.c_str(), NULL); //make a folder with set username
string filename = "C:/u/" + username + "/password.txt"; //sets the filename to password directory
ofstream myfily;
myfily.open(filename.c_str()); //create that file
myfily << rand() << endl; //assign a random integer to password.txt
myfily.close();
ifstream myfilo (filename.c_str());
if (myfilo.is_open())
{
while (! myfilo.eof() )
{
getline (myfilo,line);
cout << line << endl;
myfilo.close();
}
}
else
{
cout << errorfile1;
}
cout << noticepw << endl; //this is your password
return 0;
}
}
| |