-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.cpp
More file actions
108 lines (92 loc) · 3.02 KB
/
Copy pathadmin.cpp
File metadata and controls
108 lines (92 loc) · 3.02 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <QString>
#include <QTextEdit> // Nous allons tout de même afficher le contenu du fichier ^^
#include <QFile> // Pour utiliser le fichier
#include <QString> // Stocke le contenu du fichier
#include <QTextStream> // Flux sortant du fichier
#include <stdlib.h>
#include <string>
#include <QDateTime>
#include <QVector>
#include <iostream>
#include "admin.h"
#include "MySocketClient.h"
admin::admin()
{
QVector<std::string> temp;
temp.append("Dan");
temp.append("admin");
listAdmin.append(temp);
}
//FONCTION DE RECUPERATION MOT DE PASSE ET ID
void admin::findId(QVector<QString> array)
{
std::string formLigne;
for(int i=0;i<array.size();i++)
{
//on parcours toutes les lignes de la requetes pour trouver le mot "usr"
std::string tempLigne = array[i].toStdString();
int found = tempLigne.find("usr");
if(found!=std::string::npos)
{
std::cout << " DEMANDE DE DROITS DETECTEE : " << array[i].toStdString() << std::endl;
formLigne = array[i].toStdString();//on récupère la ligne contenant l'identifiant et le mot de passe
}
}
int posi1 = formLigne.find("=");
int posi2 = formLigne.find("&");
user = formLigne.substr(posi1+1,posi2-posi1-1);//On ne recupere que l'identifiant
formLigne = formLigne.substr(posi2+1,std::string::npos);
posi1 = formLigne.find("=");
mdp = formLigne.substr(posi1+1,std::string::npos);//On ne recupere que le mot de passe
}
//FONCTION DE VERIFICATION ACTIVATION/DESACTIVATTION SERVEUR
void admin::findActivate(QVector<QString> array)
{
std::string formLigne;
for(int i=0;i<array.size();i++)
{
//on parcours toutes les lignes de la requetes pour trouver le mot "activate"...
std::string tempLigne = array[i].toStdString();
int found = tempLigne.find("activate");
if(found!=std::string::npos)
{
formLigne = array[i].toStdString();
}
//... ou le mot "vider le cache"
int foundcache = tempLigne.find("vider+le+cache");
if(foundcache!=std::string::npos)
{
formLigne = array[i].toStdString();
}
}
int posi1 = formLigne.find("=");
int posi2 = formLigne.find("&");
std::string testActivate;
testActivate = formLigne.substr(posi1+1,posi2-posi1-1);
formLigne = formLigne.substr(posi2+1,std::string::npos);
if (!testActivate.compare("activate"))
{
std::cout << " ACTIVATION OU DESACTIVATION DU SERVEUR : " << std::endl;
MySocketClient::activate = !MySocketClient::activate;
}
if ( !testActivate.compare("vider+le+cache")){
MyFileCache::EmptyCache();
}
}
//FONCTION TESTANT LE MOT DE PASSE ET L'IDENTIFIANT
int admin::testMdp()
{
for(int i=0;i<listAdmin.size();i++)
{
if(listAdmin[i][0].compare(user)==0)
{
if(listAdmin[i][1].compare(mdp)==0)
{
return 1;
}
else
return 0;
}
}
return 0;
}