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
|
#include <sstream>
#include <string>
#include <iostream>
#include "stdafx.h"
#include "Interface.h"
#include "DlgIdentification.h"
#include "DlgIdentifRate.h"
#include "DlgChoixTest.h"
extern bool bonne_identification ;
void CDlgIdentification::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CDlgChoixTest DlgTest;
CDlgIdentifRate DlgIdentif;
OnOK();
if (CDlgIdentification::Verification(m_strIdent,m_strPasswd) == TRUE){
DlgTest.DoModal();
}else{
DlgIdentif.DoModal();
}
}
bool CDlgIdentification::Verification(CString ident, CString passwd){
//Faire la vérification de l'identifiant et du mot de passe
FILE *file;
errno_t err;
char list[26];
int numread;
int i=0;
if((err = fopen_s( &file, "C:\\Temp\\essai.txt", "w" )) ==0){
//Parcourir le fichier et vérifier que l'identification est bonne
istringstream iss( "mot1;mot2" );
Cstring mot;
Cstring tousutilisateurs[1024];
while ( std::getline( iss, mot, ';' ) )
{
tousutilisateurs[i]=mot;
i++;
}
i=0;
while (tousutilisateurs[i]!=NULL){
if (tousutilisateurs[i] == ident){
if (tousutilisateurs[i+1] == passwd){
bonne_identification = TRUE;
fclose(file);
return bonne_identification;
}
}
i = i+2;
}
bonne_identification = FALSE;
}else{
bonne_identification = FALSE;
}
return bonne_identification;
} |
Partager