// Functions.cpp
#include "Functions.h"
fstream f;
void SaveTheme()
{
f.open(global::themeFile, ios::out);
f << global::colorsBuffer;
f.close();
}
bool LoadTheme()
{
f.open(global::themeFile, ios::in);
int themes;
f >> themes;
f.close();
return themes;
}
void SaveLanguage()
{
f.open(global::languageFile, ios::out);
f << global::languagesBuffer;
f.close();
}
int LoadLanguage()
{
f.open(global::languageFile, ios::in);
int languages;
f >> languages;
f.close();
return languages;
}
string& Convert_String_to_string(System::String^ s, string& os)
{
using namespace Runtime::InteropServices;
const char* chars =
(const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
return os;
}
bool ChekID(string login)
{
f.open(global::loginfile, ios::in);
string info;
f >> info;
while (!f.eof())
{
if (login == info)
{
f.close();
return false;
}
f >> info;
}
f.close();
return true;
}
string generator_word(int size)
{
srand(time(0));
string str;
for (int i = 0, j = 0; i < size; i++)
{
j = rand() % 10 + 1;
if (j > size - i) j = size - i;
i += j;
for (int k = 0; k < j; k++) {
str += (char)(rand() % 26 + 97);
}
}
return str;
}
String^ Convert_string_to_String(std::string& os) {
System::String^ s = gcnew System::String(os.c_str());
return s;
}
bool ChekUsers(string login, string password)
{
fstream fl, fp;
fl.open(global::loginfile, ios::in);
fp.open(global::pswrdsfile, ios::in);
string infoLogin, infoPassword;
fl >> infoLogin;
fp >> infoPassword;
while (!fl.eof())
{
if (login == infoLogin && password == infoPassword)
{
fl.close();
fp.close();
return true;
}
fl >> infoLogin;
fp >> infoPassword;
}
fl.close();
fp.close();
return false;
}
void Registration(string login, string password)
{
f.open(global::loginfile, ios::app);
f << login << ' ';
f.close();
f.open(global::pswrdsfile, ios::app);
f << password << ' ';
f.close();
}
// Functions.h
#pragma once
#ifndef _FUNCTIONS_H_
#define _FUNCTIONS_H_
#include <fstream>
#include <string>
#include <iostream>
#include <windows.h>
#include "AdminMenu.h"
#include <time.h>
using namespace System;
using namespace std;
void SaveTheme();
bool LoadTheme();
void SaveLanguage();
int LoadLanguage();
string& Convert_String_to_string(System::String^, string&);
bool ChekID(string);
string generator_word(int);
String^ Convert_string_to_String(std::string& os);
bool ChekUsers(string, string);
void Registration(string, string);
namespace global {
static int colorsBuffer = LoadTheme();
static int languagesBuffer = LoadLanguage();
static string loginfile = "D:\\Влад\\Дисциплины\\ОАиП\\2_Семестр лабы\\registration\\registration\\Information\\loginsUsers.txt",
pswrdsfile = "D:\\Влад\\Дисциплины\\ОАиП\\2_Семестр лабы\\registration\\registration\\Information\\passwordsUsers.txt",
themeFile = "D:\\Влад\\Дисциплины\\ОАиП\\2_Семестр лабы\\registration\\registration\\Information\\theme.bin",
languageFile = "D:\\Влад\\Дисциплины\\ОАиП\\2_Семестр лабы\\registration\\registration\\Information\\language.bin";
}
#endif