Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
axstin
GitHub Repository: axstin/rbxfpsunlocker
Path: blob/master/Source/version.cpp
259 views
1
#include "rfu.h"
2
3
#include <Windows.h>
4
5
#pragma comment(lib, "WinInet.lib")
6
#include <WinInet.h>
7
8
#include <string>
9
#include <regex>
10
11
bool HttpRequest(const char *url, std::string &response)
12
{
13
if (HINTERNET internet = InternetOpenA("axstin/rbxfpsunlocker", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL))
14
{
15
if (HINTERNET request = InternetOpenUrlA(internet, url, NULL, 0, INTERNET_FLAG_NO_UI | INTERNET_FLAG_NO_CACHE_WRITE, NULL))
16
{
17
char buffer[1024];
18
DWORD bytes_read;
19
20
while (InternetReadFile(request, buffer, sizeof(buffer), &bytes_read) && bytes_read > 0)
21
{
22
response.append(buffer, bytes_read);
23
}
24
25
InternetCloseHandle(internet);
26
InternetCloseHandle(request);
27
return true;
28
}
29
else
30
{
31
InternetCloseHandle(internet);
32
return false;
33
}
34
}
35
36
return false;
37
}
38
39
bool RFU::CheckForUpdates()
40
{
41
std::string response;
42
if (!HttpRequest("https://api.github.com/repos/" RFU_GITHUB_REPO "/releases/latest", response))
43
{
44
MessageBoxA(NULL, "Failed to connect to Github", "Update Check", MB_OK);
45
return false;
46
}
47
48
std::smatch matches;
49
std::regex_search(response, matches, std::regex(R"x("tag_name":\s*"v?([^"]+))x")); // "tag_name":\s*"v?(.+)"
50
51
if (matches.size() <= 1)
52
{
53
printf("Response: %s\n", response.c_str());
54
MessageBoxA(NULL, "Invalid response", "Update Check", MB_OK);
55
return false;
56
}
57
58
std::string latest_version = matches[1].str();
59
60
if (latest_version != RFU_VERSION)
61
{
62
char buffer[256];
63
sprintf_s(buffer, "A new version of Roblox FPS Unlocker is available.\n\nCurrent Version: %s\nLatest Version: %s\n\nVisit download page?", RFU_VERSION, latest_version.c_str());
64
65
if (MessageBoxA(NULL, buffer, "Update Check", MB_YESNOCANCEL | MB_ICONEXCLAMATION) == IDYES)
66
{
67
ShellExecuteA(NULL, "open", "https://github.com/" RFU_GITHUB_REPO "/releases", NULL, NULL, SW_SHOWNORMAL);
68
return true;
69
}
70
}
71
72
return false;
73
}
74