//Zugang zu einem Passwortgesichertem Serverraum
//10.01.2006 (c) by Marco Franke
#include <iostream.h>
#include <string.h>
#include <windows.h>
// Für Linux einfach ma in die ncurses Bibliothek schauen
int main()
{
int i,length=9;
char pw[9]="8 Kb Ram", passwort[9];
// Wird gebraucht um Text farbig auszugeben
HANDLE hStdout;
// Handle holen
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
for(i=3;i>0;i--)
{
cout<<"\n\tSie haben noch "<<i<<" Versuche!";
cout<<"\n\tBitte geb dein 'Passwort' ein: ";
cin.getline(passwort,length);
if(strcmp(passwort, pw) == 0)
{
// Farbe setzen
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN);
cout<<"\n\tAccess Granted!"<<endl;
// Und zurück setzen
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
cout<<"\tSie wurden erfolgreich eingeloggt!"<<endl<<endl;
cin.ignore();
}
else
{
// Siehe oben
SetConsoleTextAttribute(hStdout, FOREGROUND_RED);
cout<<"\n\tAccess Denied!"<<endl<<endl;
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
}
if(i==0)
{
cout<<"\n\tIhre Karte wird nun eingezogen!";
cout<<"\n\tBitte wenden sie sich an den Administrator!"<<endl<<endl;
}
return 1;
}