-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEGLicenseApi.cs
127 lines (113 loc) · 4.38 KB
/
EGLicenseApi.cs
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System.Text;
using System.Runtime.InteropServices;
using RGiesecke.DllExport;
using System.Net;
using System.IO;
using Newtonsoft.Json.Linq;
using System;
public class EGLicenseAPI
{
[DllExport("RVExtensionVersion", CallingConvention = CallingConvention.Winapi)]
public static void RvExtensionVersion(StringBuilder output, int outputSize)
{
output.Append("Life-Codes.net API v1.0");
}
[DllExport("RVExtension", CallingConvention = CallingConvention.Winapi)]
public static void RvExtension(StringBuilder output, int outputSize,
[MarshalAs(UnmanagedType.LPStr)] string licKey)
{
bool result = false;
try
{
string communityUrl = "https://YOURDOMAINHERE.COM/api/index.php?/nexus/lkey/";
string licenseKey = licKey;
string endpoint = "&key=MY_IPBOARD_APIKEY";
string html = string.Empty;
string url = communityUrl + licenseKey + endpoint;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AutomaticDecompression = DecompressionMethods.GZip;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}
JObject json = JObject.Parse(html);
string productName = json.SelectToken("name").ToString();
string expires = json.SelectToken("expires").ToString();
string canceled = json.SelectToken("canceled").ToString();
string isActive = json.SelectToken("active").ToString();
string steam64ID = json.SelectToken("customFields.1").ToString();
result = true;
output.Append(result);
}
catch
{
output.Append(result);
}
}
[DllExport("RVExtensionArgs", CallingConvention = CallingConvention.Winapi)]
public static int RvExtensionArgs(StringBuilder output, int outputSize,
[MarshalAs(UnmanagedType.LPStr)] string function,
[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 4)] string[] args, int argCount)
{
bool result = false;
string lickey = "";
string playerUID = "";
int index = 0;
foreach (var arg in args)
{
switch (index)
{
case 0:
lickey = arg;
break;
case 1:
playerUID = arg;
break;
}
index++;
}
using (WebClient wc = new WebClient())
{
try
{
string communityUrl = "https://YOURDOMAINHERE.COM/api/index.php?/nexus/lkey/";
string licenseKey = lickey;
string endpoint = "&key=MY_IPBOARD_APIKEY";
string url = communityUrl + licenseKey + endpoint;
var jsonStr = wc.DownloadString(url);
JObject json = JObject.Parse(jsonStr);
//string productName = json.SelectToken("name").ToString();
//string expires = json.SelectToken("expires").ToString();
string canceled = json.SelectToken("canceled").ToString();
string isActive = json.SelectToken("active").ToString();
string steam64ID = json.SelectToken("customFields.1").ToString();
if (steam64ID == playerUID)
{
if (isActive == "true" && canceled == "false")
{
//License is okey
result = true;
output.Append(result);
return 1;
}
else
{
output.Append(result);
return 0;
}
}
else
{
output.Append(result);
return 0;
}
} catch (Exception er)
{
output.Append(result);
return 0;
}
}
}
}