PHP Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <ctime> //some of these are for future use
using namespace std;
int mainMenuRepeat = 1; //temporarily here. I hope to move this into
//int main() but caused errors. ?
//For error handling
int Error(int errorCode)
{
switch (errorCode) {
case 1: //Menu selection error
system("cls");
cout << " Error!" << endl
<< " -> Menu item does not exist or is currently unavailable" << endl
<< " ->You are being returned to the main menu" << endl;
system("pause");
break;
case 2: //Menu repeat error
system("cls");
cout << " Error!" << endl
<< " -> Menu repeat or program exit error" << endl
<< " ->You are being returned to the main menu" << endl;
system("pause");
break;
case 3: //"Run next program?" error
cout << " Error!" << endl
<< " -> Invalid input. Please reply \"y\" or \"n\"." << endl << endl;
break;
default: //Unrecognized error
cout << " Error!" <<endl
<< " -> Error code not recognized!" << endl
<< " ->Error code passed: " << errorCode << endl
<< " ->You are being return to the main menu" << endl;
system("pause");
break;
};
};
//For handling output
void Output(int spaceBefore, string textString, int textStringLength, int pausesBetween, int lineBreaks, int sleepAfter)
{
int lengthOfText = textString.length();
if(textStringLength != 0){lengthOfText = textStringLength;};
for(int x=0; x<spaceBefore; x++)
{cout << " ";};
for(int x=0; x<lengthOfText; x++)
{
cout << textString[x];
Sleep(pausesBetween);
};
for(int x=0; x<lineBreaks; x++)
{cout << endl;};
Sleep(sleepAfter);
};
//For creating and editing documents
int Notepad()
{
int choice;
int repeat = 1;
do{
system("cls");
cout << "Notepad started." << endl << "What would you like to do?" << endl
<< "(X) Start a new doc" << endl
<< "(X) Open a previous document" << endl
<< "(X) Delete a document" <<endl
<< "(4) Exit notepad" << endl;
cin >> choice;
switch (choice) {
case 4:
repeat = 0;
break;
default:
Error(1);
break;
};
}while(repeat == 1);
};
//Purely visual entertainment
int Hack()
{
system("cls");
string running = "Running Application";
string comp = "Complete!";
string init = "Initialized!";
string success = "Success!";
string dots = "................................";
string initializing = "Initializing:";
string ioStream = "User I/O stream";
string winInterface = "Win32 API Interface";
string WNI = "Windows Network Interfaces:";
string WLANb = "WLAN 802.11b";
string WLANg = "WLAN 802.11g";
string WLANn = "WLAN 802.11n";
string Wired = "Wired Connection";
string testInter = "Testing Interfaces";
string identNetwork = "Identifying Local Network";
string identInternet = "Identifying Internet Connection";
string initSuccess = "Application Initialized Successfully!";
Output(0, running, 0, 50, 1, 75);
Output(0, initializing, 0, 50, 1, 75);
Output(13, winInterface, 0, 50, 0, 50);
Output(0, dots, 10, 475, 0, 0);
cout << init << endl; Sleep(75);
Output(13, ioStream, 0, 50, 0, 50);
Output(0, dots, 14, 150, 0, 0);
cout << init << endl; Sleep(75);
Output(13, WNI, 0, 85, 1, 75);
Output(30, WLANb, 0, 50, 0, 0);
Output(0, dots, 11, 150, 0, 0);
cout << init << endl; Sleep(75);
Output(30, WLANg, 0, 50, 0, 0);
Output(0, dots, 11, 150, 0, 0);
cout << init << endl; Sleep(75);
Output(30, WLANn, 0, 50, 0, 0);
Output(0, dots, 11, 150, 0, 0);
cout << init << endl; Sleep(75);
Output(30, Wired, 0, 50, 0, 0);
Output(0, dots, 7, 250, 0, 0);
cout << init << endl; Sleep(75);
Output(30, testInter, 0, 80, 0, 0);
Output(0, dots, 5, 750, 0, 0);
cout << init << endl; Sleep(75);
Output(13, identNetwork, 0, 50, 0, 0);
Output(0, dots, 15, 200, 0, 0);
cout << "LAN identified!" << endl; Sleep(75);
Output(13, identInternet, 0, 50, 0, 0);
Output(0, dots, 9, 200, 0, 0);
cout << "Connection Established!" << endl; Sleep(75);
cout << endl << endl;
Output(0, initSuccess, 0, 50, 1, 2300);
//Find host, drive enumeration, etc. will go here
/*REWRITE for new Output() REWRITE for new Output()
//Pretends to count up a drives size
mystring = "Checking HDD size";
for(x=0; x<17; x++){Output(mystring[x], 50);};
Sleep(150);
for(x=0; x<5; x++){Output(dots[x],250);};
cout << endl;
int z=0;
int w;
int y=(rand()%100) + 15000;
for(x=0; x<y; x++)
{
w=rand()*5;
z+=w;
cout << "\r";
cout << z;
Sleep(1);
};
*/
cout << endl;
cout << "Application End" << endl;
int repeatError = 1; //sets 'error' as the default state
do{
char repetition = 1;
cout << "Run another app? (y or n)" << endl;
cin >> repetition;
if(repetition == 'y'){repeatError = 0; mainMenuRepeat = 1;}
else if(repetition == 'n'){repeatError = 0; mainMenuRepeat = 0;}
else {repeatError = 1; Error(3);}
}while(repeatError == 1);
};
//For testing code without necessarily having to rely on another section
int currentTest()
{
};
//For checking error handling
int causeError()
{
system("cls");
cout << "Input desired error code: ";
int errorNumber;
cin >> errorNumber;
Error(errorNumber);
cout << endl; system("pause");
return 1;
}
//Exit the program
int Exit()
{
system("cls");
//int x;
string exitString = "Thank you for using The Toolbox";
string exiting = "Now exiting";
string Dots = "..................";
Output(0, exitString, 0, 35, 1, 75);
//for(x=0; x<31; x++){Output(exitString[x],35);};
//cout << endl;
//Sleep(75);
Output(0, exiting, 0, 35, 0, 75);
Output(0, Dots, 10, 75, 0, 350);
//for(x=32; x<43; x++){Output(exitString[x],35);};
//for(x=0; x<10; x++){Output(Dots[x],75);};
//Sleep(250);
return 0;
};
//The for() loops above are how I originally handled output throughout
//the program. I eliminated about 90 lines of code using the new method
//Welcome Screen
int mainMenu()
{
srand((unsigned int)time(0));
int choice;
do{
system("cls");
cout << "Welcome to The Toolbox" << endl << "Please select a tool:" << endl
<< "(X) Encryptor" <<endl
<< "(X) Notepad" <<endl
<< "(X) Game" <<endl
<< "(X) Options" <<endl
<< "(5) Hack" << endl
<< "(X) Calculator" << endl
<< "(7) Current Test" << endl
<< "(8) Error Maker" << endl
<< "(9) Exit" <<endl;
cin >> choice;
switch (choice){
case 1:
//Encryptor
Error(1);
break;
case 2:
//Notepad
Notepad();
break;
case 3:
//Game
Error(1);
break;
case 4:
//Options
Error(1);
break;
case 5:
Hack();
break;
case 6:
//Calc
Error(1);
break;
case 7:
//Current Test
currentTest();
break;
case 8:
//Error maker
causeError();
break;
case 9:
//Exit;
return Exit();
default:
Error(1);
break;
};
if(mainMenuRepeat != 1){if(mainMenuRepeat != 0){mainMenuRepeat = 1; Error(2);};};
}while(mainMenuRepeat == 1);
return 0;
};
int main(int argc, char *argv[])
{
mainMenu();
return EXIT_SUCCESS;
}