This repository has been archived by the owner on Jan 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Survey.cpp
executable file
·75 lines (65 loc) · 1.75 KB
/
Survey.cpp
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
#include "Survey.hpp"
void Welcome (Curl *Site);
void Surveys (Curl *Site);
std::string Finish (Curl *Site);
//GetFreshPreCode
std::string GetFreshPreCode (std::string URL)
{
Curl Site;
Site.SetHost (URL);
Site.Set (CURLOPT_SSL_VERIFYHOST, 0);
Site.Set (CURLOPT_SSL_VERIFYPEER, 0);
Welcome (&Site);
Surveys (&Site);
return Finish (&Site);
}//GetFreshPreCode
//Welcome
void Welcome (Curl *Site)
{
//These requests are required to get alle cookies and set the server internal
//variables of the cookie session
Site->SetPath ("");
Site->Perform ();
Site->SetPath ("Index.aspx?AspxAutoDetectCookieSupport=1");
Site->Perform ();
std::vector<std::pair<std::string,std::string> > Post;
Post.push_back (std::make_pair ("FIP", ""));
Post.push_back (std::make_pair ("JavaScriptEnabled", "1"));
Site->SetPath ("Survey.aspx");
Site->SetPost (Post);
Site->Perform ();
Site->Perform ();
}//Welcome
//Surveys
void Surveys (Curl *Site)
{
std::string Content;
while (1)
{
Content = Site->Perform ();
try
{
Content = Cut<char> (Content, "IoNF\" value=\"", 1, 0);
}
catch (Err)
{
break; //If the IoNF value could be not found
}
Content = Cut<char> (Content, "\"", 0, 0);
std::vector<std::pair<std::string,std::string> > Post;
Post.push_back (std::make_pair ("IoNF", Content));
Site->SetPost (Post);
}
//Check for the finish forwarding
if (Content.find ("Finish.aspx") == std::string::npos)
throw Err ("No IoNF value");
}//Surveys
//Finish
std::string Finish (Curl *Site)
{
Site->SetPath ("Finish.aspx");
std::string Content = Site->Perform ();
Content = Cut<char> (Content, "ValCode\">", 1, 0);
Content = Cut<char> (Content, ": ", 1, 0).substr (0, 2);
return Content;
}//Finish