Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <wininet.h>
- #include <iostream>
- #include <vector>
- #pragma comment(lib, "wininet.lib")
- vector<string> RAWTRANSLATION;
- char* langage::rawchar;
- int langage::rawrequest() {
- RAWTRANSLATION.clear();
- HINTERNET hInternet = InternetOpenW(L"WinINet Example", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
- if (!hInternet) {
- cerr << "Failed to open internet handle" << endl;
- return 1;
- }
- HINTERNET hConnection = InternetConnectW(hInternet, L"raw.githubusercontent.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
- if (!hConnection) {
- cerr << "Failed to connect to internet" << endl;
- InternetCloseHandle(hInternet);
- return 1;
- }
- HINTERNET hRequest = nullptr;
- if (rawchar == "VF")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/VF.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (rawchar == "CHINESES")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/CHINESES.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (rawchar == "RUSSE")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/RUSSE.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (rawchar == "SPANISH")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/SPANISH.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (rawchar == "UKRAINIEN")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/UKRAINIEN.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (rawchar == "VO")
- {
- hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/VO.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
- if (!hRequest) {
- cerr << "Failed to open HTTP request" << endl;
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- }
- if (!HttpSendRequestW(hRequest, NULL, 0, NULL, 0)) {
- cerr << "Failed to send HTTP request" << endl;
- InternetCloseHandle(hRequest);
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 1;
- }
- const int BUFFER_SIZE = 1024;
- char buffer[BUFFER_SIZE];
- DWORD bytesRead = 0;
- string currentLine = "";
- while (InternetReadFile(hRequest, buffer, BUFFER_SIZE, &bytesRead) && bytesRead != 0) {
- for (int i = 0; i < bytesRead; i++) {
- if (buffer[i] == '\n') {
- // Add current line to vector
- RAWTRANSLATION.push_back(currentLine);
- currentLine = "";
- }
- else {
- currentLine += buffer[i];
- }
- }
- }
- // Add last line to vector (if there is one)
- if (!currentLine.empty()) {
- RAWTRANSLATION.push_back(currentLine);
- }
- InternetCloseHandle(hRequest);
- InternetCloseHandle(hConnection);
- InternetCloseHandle(hInternet);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement