// author:	Daniel Gonzalez Nothnagel
// file:	main.cpp
// date:	20.08.07

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <windows.h>

using namespace std;

// create global Variables
const int max = 50;			// Max Count of Admins and Groups
int AdminCount = 0;			// Count of Admins used
string AdminName[max];		// Names for the Admins
string AdminAuth[max];		// Auth Type of the Admins
string AdminIdent[max];		// The Identity of the Admins
string AdminPassword[max];	// The Password of the Admins
string AdminGroup[max];		// The Group of the Admins
string AdminFlags[max];		// The Flags of the Admins

int GroupCount = 0;			// Count of Groups used
string GroupName[max];		// Name for the Groups
string GroupFlags[max];		// The Flags for the Groups
string GroupImmunity[max];	// The Immunity for the Groups

// define Functions
int OptionMenu(int Action);

void createAdmin();
void editAdmin();
void delAdmin();

void createGroup();
void editGroup();
void delGroup();

void listAdmins(int Form);
void listGroups(int Form);
void listFlags();

void writeAdmins();
void writeGroups();

void save();
void load();

int main()
{
	// Variable for the choosen Menu Option
	int Action;
	
	// load data if exists
	load();
	
	do
	{
		// open menu
		Action = OptionMenu(Action);
		
		// check for choosen menu action and continue the program
		switch (Action)
		{
			case (0):
				createAdmin();
				break;
			case (1):
				editAdmin();
				break;
			case (2):
				delAdmin();
				break;
			case (3):
				createGroup();
				break;
			case (4):
				editGroup();
				break;
			case (5):
				delGroup();
				break;
			case (6):
				load();
				break;
			case (7):
				save();
				break;
			case (8):
				system("cls");
				listAdmins(0);
				cout << endl;
				listGroups(0);
				cout << endl;
				system("pause");
				break;
		}
	} while (Action >= 0);

	// beenden
	writeAdmins();
	writeGroups();
	return 0;
}

int OptionMenu(int Action)
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	do
	{
		// clear Screen
		system("cls");
		
		//Show Menu
		cout << "1. Admin anlegen" << endl
			 << "2. Admin editieren" << endl
			 << "3. Admin loeschen" << endl
			 << "4. Gruppe anlegen" << endl
			 << "5. Gruppe editieren" << endl
			 << "6. Gruppe loeschen" << endl
			 << "7. Laden" << endl
			 << "8. Speichern" << endl
			 << "9. Admins und Gruppen anzeigen" << endl
			 << "0. Beenden" << endl
			 << ": ";
		
		cin >> Action;
		Action--;
		
		// make error message if needed
		if ((Action < -1) || (Action > 8))
		{
			SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
			cout << "Ungueltige Option gewaehlt!" << endl;
			SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
			system("pause");
		}
	} while ((Action < -1) || (Action > 8));	// loop while an error is found
	
	return Action;
}

void createAdmin()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// clear Screen
	system("cls");
	
	// add the new admin to the Admin count
	AdminCount++;
	
	if (AdminCount < max)
	{
		cout << "Neuen Admin anlegen:" << endl << endl;
		
		// enter Name
		do
		{
			cout << "Name: ";
			cin >> AdminName[AdminCount - 1];
			
			if (AdminName[AdminCount - 1] == "help")
				cout << "\011Beliebigen Namen fuer den Admin" << endl;
		} while (AdminName[AdminCount - 1] == "help");
		
		// enter Auth
		do
		{
			cout << "Identifikationsart: ";
			cin	>> AdminAuth[AdminCount - 1];
			
			if (AdminAuth[AdminCount - 1] == "help")
			{
				cout << "\011erlaubte Werte:" << endl
					 << "\011\011steam\011- Steam ID fuer Identifikation" << endl
					 << "\011\011name\011- Name fuer Identifikation" << endl
					 << "\011ip\011- IP fuer Identifikation" << endl;
			}
		} while (AdminAuth[AdminCount - 1] == "help");
		
		// enter identity
		do
		{
			cout << "Identitaet: ";
			cin >> AdminIdent[AdminCount - 1];
			
			if (AdminIdent[AdminCount - 1] == "help")
				cout << "\011Steam ID, Name oder IP, je nach Identifikationsart" << endl;
		} while (AdminIdent[AdminCount - 1] == "help");
		
		// enter password
		do
		{
			cout << "Passwort: ";
			cin >> AdminPassword[AdminCount - 1];
			
			if (AdminPassword[AdminCount - 1] == "help")
				cout << "\011Optional, wenn nicht benutzt 'empty' eingeben" << endl;
		} while (AdminPassword[AdminCount - 1] == "help");
		
		// enter group
		do
		{
			cout << "Gruppe: ";
			cin >> AdminGroup[AdminCount - 1];
			
			if (AdminGroup[AdminCount - 1] == "help")
			{
				listGroups(0);
				cout << "\011Nur EINE Gruppe kann gewaehlt werden!" << endl
					 << "\011Wenn keine Gruppe benutzt wird 'empty' eingeben" << endl;
			}	
		} while (AdminGroup[AdminCount - 1] == "help");
		
		// enter flags
		do
		{
			cout << "Rechte: ";
			cin >> AdminFlags[AdminCount - 1];
			
			if (AdminFlags[AdminCount - 1] == "help")
			{
				cout << "\011Verfuegbare Rechte:" << endl;
				listFlags();
				cout << "\011Rechte bitte in eine Zeile OHNE leerzeichen oder sontiges!" << endl
					 << "\011Wenn keine Rechte vergeben werden 'empty' eingeben" << endl;
			}
		} while (AdminFlags[AdminCount - 1] == "help");
	}
	else
	{
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
		cout << "Admin Speicher voll! es können keine neuen Admins angelegt werden!" << endl;
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
		
		// reset AdminCount
		AdminCount--;
		
		// make a pause to make error readable
		system("pause");
	}
}

void editAdmin()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// create choose variable
	int choose;
	
	// clear Screen
	system("cls");
	
	// list the available Admins
	listAdmins(1);
	
	// choose an admin
	if (AdminCount > 0)
	{
		do
		{
			cout << "Bitte Nummer des gewuenschten Admins eingeben: ";
			cin >> choose;
			choose--;
			
			// error checking
			if ((choose < -1) || (choose >= AdminCount))
			{
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
				cout << "Gewuenschter Admin existiert nicht!" << endl;
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
				system("pause");
				system("cls");
				
				listAdmins(1);
			}
		} while ((choose < -1) || (choose >= AdminCount));	// loop as long as choosen admin could not being recognised
		
		// clear Screen
		system("cls");
		
		// if the choosen option was 0, don´t edit
		if (choose >= 0)
		{
			cout << "Admin editieren:" << endl << endl;
			
			// new name
			do
			{
				cout << "Alter Name: " << AdminName[choose] << endl
					 << "Neuer Name: ";
				cin >> AdminName[choose];
				
				if (AdminName[choose] == "help")
					cout << "\011Beliebigen Namen fuer den Admin" << endl;
			} while (AdminName[choose] == "help");
			
			// new Auth
			do
			{
				cout << "Alte Identifikationsart: " << AdminAuth[choose] << endl
					 << "Neue Identifikationsart: ";
				cin	>> AdminAuth[choose];
				
				if (AdminAuth[choose] == "help")
					{
						cout << "\011erlaubte Werte:" << endl
							 << "\011\011steam\011- Steam ID fuer Identifikation" << endl
							 << "\011\011name\011- Name fuer Identifikation" << endl
							 << "\011ip\011- IP fuer Identifikation" << endl;
					}
			} while (AdminAuth[choose] == "help");
			
			// new identity
			do
			{
				cout << "Alte Identitaet: " << AdminIdent[choose] << endl
					 << "Neue Identitaet: ";
				cin >> AdminIdent[choose];
				
				if (AdminIdent[choose] == "help")
					cout << "\011Steam ID, Name oder IP, je nach Identifikationsart" << endl;
			} while (AdminIdent[choose] == "help");
			
			// new password
			do
			{
				cout << "Altes Passwort: " << AdminPassword[choose] << endl
					 << "Neues Passwort: ";
				cin >> AdminPassword[choose];
				
				if (AdminPassword[choose] == "help")
					cout << "\011Optional, wenn nicht benutzt 'empty' eingeben" << endl;
			} while (AdminPassword[choose] == "help");
			
			// new group
			do
			{
				cout << "Alte Gruppe: " << AdminGroup[choose] << endl
					 << "Neue Gruppe: ";
				cin >> AdminGroup[choose];
				
				if (AdminGroup[choose] == "help")
				{
					listGroups(0);
					cout << "\011Nur EINE Gruppe kann gewaehlt werden!" << endl
						 << "\011Wenn keine Gruppe benutzt wird 'empty' eingeben" << endl;
				}
			} while (AdminGroup[choose] == "help");
			
			// new flags
			do
			{
				cout << "Alte Rechte: " << AdminFlags[choose] << endl
					 << "Neue Rechte: ";
				cin >> AdminFlags[choose];
				
				if (AdminFlags[choose] == "help")
				{
					cout << "\011Verfuegbare Rechte:" << endl;
					listFlags();
					cout << "\011Rechte bitte in eine Zeile OHNE leerzeichen oder sontiges!" << endl
						 << "\011Wenn keine Rechte vergeben werden 'empty' eingeben" << endl;
				}
			} while (AdminFlags[choose] == "help");
		}
	}
	else
	{
		// make a pause to make error readable
		system("pause");
	}
}

void delAdmin()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// create variables
	int choose, sure;
	
	// clear Screen
	system("cls");
	
	// list the available Admins
	listAdmins(1);
	
	// choose an admin
	if (AdminCount > 0)
	{
		do
		{
			cout << "Bitte Nummer des gewuenschten Admins eingeben: ";
			cin >> choose;
			choose--;
			
			// error checking
			if ((choose < -1) || (choose >= AdminCount))
			{
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
				cout << "Gewuenschter Admin existiert nicht!" << endl;
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
				system("pause");
				system("cls");
				
				listAdmins(1);
			}
		} while ((choose < -1) || (choose >= AdminCount));	// loop as long as choosen admin could not being recognised
		
		// if the choosen option was 0, don´t delete
		if (choose >= 0)
		{
			// affirmation for the deleting
			cout << "Soll " << AdminName[choose] << " wirklich geloescht werden? " << endl
				 << "1 - Ja" << endl
				 << "0 - Nein" <<endl
				 << ": ";
			cin >> sure;
			
			// delete the admin
			if (sure > 0)
			{
				for (int i = choose; i < (AdminCount - 1); i++)
				{
					AdminName[i] = AdminName[i + 1];
					AdminAuth[i] = AdminAuth[i + 1];
					AdminIdent[i] = AdminIdent[i + 1];
					AdminPassword[i] = AdminPassword[i + 1];
					AdminGroup[i] = AdminGroup[i + 1];
					AdminFlags[i] = AdminFlags[i + 1];
				}
				
				// reset Admin Count
				AdminCount--;
			}
			else
			{
				cout << "Admin " << AdminName[choose] << "wurde nicht geloescht." << endl;
				system("pause");
			}
		}
	}
}
void createGroup()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// clear Screen
	system("cls");
	
	// add the new admin to the Admin count
	GroupCount++;
	
	if (GroupCount < max)
	{
		cout << "Neue Gruppe anlegen:" << endl << endl;
		
		// enter Name
		do
		{
			cout << "Name: ";
			cin >> GroupName[GroupCount - 1];
			
			if (GroupName[GroupCount - 1] == "help")
				cout << "\011Beliebigen Namen fuer die Gruppe" << endl;
		} while (GroupName[GroupCount - 1] == "help");

		// enter flags
		do
		{
			cout << "Rechte: ";
			cin >> GroupFlags[GroupCount - 1];
			
			if (GroupFlags[GroupCount - 1] == "help")
			{
				cout << "\011Verfuegbare Rechte:" << endl;
				listFlags();
				cout << "\011Rechte bitte in eine Zeile OHNE leerzeichen oder sontiges!" << endl
					 << "\011Wenn keine Rechte vergeben werden 'empty' eingeben" << endl;
			}
		} while (GroupFlags[GroupCount - 1] == "help");
		
		// enter immunity
		do
		{
			cout << "Immunitaet: ";
			cin >> GroupImmunity[GroupCount - 1];
			
			if (GroupImmunity[GroupCount - 1] == "help")
			{
				cout << "\011Gueltige Werte:" << endl
					 << "'*' - Globale Immunitaet" << endl
					 << "'$' - Normale Immunitaet" << endl
					 << "'" << endl;
					listGroups(0); cout << endl
					 << "' - Immunitaet gegen bestimmte Gruppe" << endl
					 << "\011Wenn keine Immunitaet benutzt wird 'empty' eingeben" << endl;
			}
		} while (GroupImmunity[GroupCount - 1] == "help");
	}
	else
	{
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
		cout << "Gruppen Speicher voll! es können keine neuen Gruppen angelegt werden!" << endl;
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
		
		// reset Group Count
		GroupCount--;
		
		// make a pause to make error readable
		system("pause");
	}
}

void editGroup()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// create choose variable
	int choose;
	
	// clear Screen
	system("cls");
	
	// list the available Groups
	listGroups(1);
	
	// choose a Group
	if (GroupCount > 0)
	{
		do
		{
			cout << "Bitte Nummer der gewuenschten Gruppe eingeben: ";
			cin >> choose;
			choose--;
			
			// error checking
			if ((choose < -1) || (choose >= GroupCount))
			{
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
				cout << "Gewuenschte Gruppe existiert nicht!" << endl;
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
				system("pause");
				system("cls");
				
				listGroups(1);
			}
		} while ((choose < -1) || (choose >= GroupCount));	// loop as long as choosen group could not being recognised
		
		// clear Screen
		system("cls");
		
		// if the choosen option was 0, don´t edit
		if (choose >= 0)
		{
			cout << "Gruppe editieren:" << endl << endl;
			
			// new Name
			do
			{
				cout << "Alter Name: " << GroupName[choose] << endl
					 << "Neuer Name: ";
				cin >> GroupName[choose];
				
				if (GroupName[choose] == "help")
					cout << "\011Beliebigen Namen fuer die Gruppe" << endl;
			} while (GroupName[choose] == "help");
			
			// new flags
			do
			{
				cout << "Alte Rechte: " << GroupFlags[choose] << endl
					 << "Neue Rechte: ";
				cin >> GroupFlags[choose];
				
				if (GroupFlags[choose] == "help")
				{
					cout << "\011Verfuegbare Rechte:" << endl;
					listFlags();
					cout << "\011Rechte bitte in eine Zeile OHNE leerzeichen oder sontiges!" << endl
						 << "\011Wenn keine Rechte vergeben werden 'empty' eingeben" << endl;
				}
			} while (GroupFlags[choose] == "help");
			
			// new immunity
			do
			{
				cout << "Alte Immunitaet: " << GroupImmunity[choose] << endl
					 << "Neue Immunitaet: ";
				cin >> GroupImmunity[choose];
				
				if (GroupImmunity[choose] == "help")
				{
					cout << "\011Gueltige Werte:" << endl
						 << "'*' - Globale Immunitaet" << endl
						 << "'$' - Normale Immunitaet" << endl
						 << "'" << endl;
						listGroups(0); cout << endl
						 << "' - Immunitaet gegen bestimmte Gruppe" << endl
						 << "\011Wenn keine Immunitaet benutzt wird 'empty' eingeben" << endl;
				}
			} while (GroupImmunity[choose] == "help");
		}
	}
	else
	{
		// make a apause to make arror readable
		system("pause");
	}
}

void delGroup()
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	// create variables
	int choose, sure;
	
	// clear Screen
	system("cls");
	
	// list the available Groups
	listGroups(1);
	
	// choose a group
	if (GroupCount > 0)
	{
		do
		{
			cout << "Bitte Nummer der gewuenschten Gruppe eingeben: ";
			cin >> choose;
			choose--;
			
			// error checking
			if ((choose < 0) || (choose >= GroupCount))
			{
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
				cout << "Gewuenschte Gruppe existiert nicht!" << endl;
				SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
				system("pause");
				system("cls");
				
				listGroups(1);
			}
		} while ((choose < 0) || (choose >= GroupCount));	// loop as long as choosen group could not be recognised
		
		// if the choosen option was 0, don´t delete
		if (choose >= 0)
		{
			// affirmation for the deleting
			cout << "Soll " << GroupName[choose] << " wirklich geloescht werden? " << endl
				 << "1 - Ja" << endl
				 << "0 - Nein" <<endl
				 << ": ";
			cin >> sure;
			
			// delete the group
			if (sure > 0)
			{
				for (int i = choose; i < (GroupCount - 1); i++)
				{
					GroupName[i] = GroupName[i + 1];
					GroupFlags[i] = GroupFlags[i + 1];
					GroupImmunity[i] = GroupImmunity[i + 1];
				}
				
				// reset Group Count
				GroupCount--;
			}
			else
			{
				cout << "Gruppe " << GroupName[choose] << "wurde nicht geloescht." << endl;
				system("pause");
			}
		}
	}
}
void listAdmins(int Form)
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	cout << "Admins:" << endl;
	
	if (AdminCount > 0)
	{
		if (Form == 0)
		{
			for (int i = 0; i < AdminCount; i++)
			{
				cout << AdminName[i] << endl;
			}
		}
		else if (Form == 1)
		{
			for (int i = 0; i < AdminCount; i++)
			{
				cout << i + 1 << ". " << AdminName[i] << endl;
			}
		}
	}
	else
	{
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
		cout << "Kein Admin vorhanden!" << endl;
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
	}
}

void listGroups(int Form)
{
	// init color
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	
	cout << "Gruppen:" << endl;
	
	if (GroupCount > 0)
	{
		if (Form == 0)
		{
			for (int i = 0; i < GroupCount; i++)
			{
				cout << GroupName[i] << endl;
			}
		}
		else if (Form == 1)
		{
			for (int i = 0; i < GroupCount; i++)
			{
				cout << i + 1 << ". " << GroupName[i] << endl;
			}
		}
	}
	else
	{
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED); // color red
		cout << "Keine Gruppen vorhanden!" << endl;
		SetConsoleTextAttribute(hStdout,FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); // color white
	}
}

void listFlags()
{
	cout << "a\011Reserved slots" << endl
		 << "b\011Standart Admin" << endl
		 << "c\011andere Spieler kicken" << endl
		 << "d\011andere Spieler bannen" << endl
		 << "e\011Bans rueckgaengig machen" << endl
		 << "f\011andere Spieler Slayen" << endl
		 << "g\011Map wechseln" << endl
		 << "h\011Cvars aendern" << endl
		 << "i\011Configs veraendern" << endl
		 << "j\011Sonder Chat Rechte" << endl
		 << "k\011Voting" << endl
		 << "l\011Server mit einem Passwort versehen" << endl
		 << "m\011Fernsteuerung (rcon)" << endl
		 << "n\011sv_cheats befehle aendern" << endl
		 << "o\011Custom1" << endl
		 << "p\011Custom2" << endl
		 << "q\011Custom3" << endl
		 << "r\011Custom4" << endl
		 << "s\011Custom5" << endl
		 << "t\011Custom6" << endl
		 << "z\011Root (Zugriff auf Alles!)" << endl;
}

void writeAdmins()
{
	// only write if there is an admin
	if (AdminCount > 0)
	{
		// create filestream
		fstream admins;
		admins.open("admins.cfg", ios::out);
		
		// write base
		admins << "Admins" << endl << "{" << endl;
		
		// write the admins
		for (int i = 0; i < AdminCount; i++)
		{
			admins << "\011\042" << AdminName[i] << "\042" << endl << "\011{" << endl;
			admins << "\011\011\042auth\042\011\011\011\042" << AdminAuth[i] << "\042" << endl;
			admins << "\011\011\042identity\042\011\011\042" << AdminIdent[i] << "\042" << endl;
			if (AdminPassword[i] != "empty")
				admins << "\011\011\042password\042\011\011\042" << AdminPassword[i] << "\042" << endl;
			if (AdminGroup[i] != "empty")
				admins << "\011\011\042group\042\011\011\011\042" << AdminGroup[i] << "\042" << endl;
			if (AdminFlags[i] != "empty")
				admins << "\011\011\042flags\042\011\011\011\042" << AdminFlags[i] << "\042" << endl;
			admins << "\011}" << endl;
		}
		
		// write end
		admins << "}";
		
		// close filestream
		admins.close();
	}
}

void writeGroups()
{
	// only write if there is a group
	if (GroupCount > 0)
	{
		// create filestream
		fstream groups;
		groups.open("admin_groups.cfg", ios::out);
		
		// write base
		groups << "Groups" << endl << "{" << endl;
		
		// write the groups
		for (int i = 0; i < GroupCount; i++)
		{
			groups << "\011\042" << GroupName[i] << "\042" << endl << "\011{" << endl;
			groups << "\011\011\042flags\042\011\011\011\042" << GroupFlags[i] << "\042" << endl;
			groups << "\011\042immunity\042\011\011\042" << GroupImmunity[i] << "\042" << endl;
			groups << "\011}" << endl;
		}
		
		// write end
		groups << "}";
		
		// close filestream
		groups.close();
	}
}

void save()
{
	//create filestream
	fstream save;
	save.open("AdminManager.save", ios::out);
	
	// save count of admins and groups
	save << AdminCount << " " << GroupCount << endl;
	
	// save admins
	for (int i = 0; i < AdminCount; i++)
	{
		save << AdminName[i] << " " << AdminAuth[i] << " " << AdminIdent[i] <<  " " << AdminPassword[i] <<  " " << AdminGroup[i] <<  " " << AdminFlags[i] << endl;
	}
	// save groups
	for (i = 0; i < GroupCount; i++)
	{
		save << GroupName[i] <<  " " << GroupFlags[i] <<  " " << GroupImmunity[i] << endl;
	}
	
	// close filestream
	save.close();
}

void load()
{
	//create filestream
	fstream load;
	load.open("AdminManager.save", ios::in);
	
	// load count of admins and groups
	load >> AdminCount >> GroupCount;
	
	// load admins
	for (int i = 0; i < AdminCount; i++)
	{
		load >> AdminName[i] >> AdminAuth[i] >> AdminIdent[i] >> AdminPassword[i] >> AdminGroup[i] >> AdminFlags[i];
	}
	// load groups
	for (i = 0; i < GroupCount; i++)
	{
		load >> GroupName[i] >> GroupFlags[i] >> GroupImmunity[i];
	}
	
	// close filestream
	load.close();
}