Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Commit

Permalink
2.3.17 - Add support for new donation key formats.
Browse files Browse the repository at this point in the history
  • Loading branch information
moyitpro committed May 15, 2018
1 parent b226a8c commit fc06ef4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
8 changes: 8 additions & 0 deletions MAL Updater OS X.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@
91A8DD5E1E736814006E3566 /* NSNumberFormatterNumberOnly.m in Sources */ = {isa = PBXBuildFile; fileRef = 91A8DD5C1E736814006E3566 /* NSNumberFormatterNumberOnly.m */; };
91A9B6691EA918FB00645690 /* MAL_Updater_OS_XTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 91A9B6681EA918FB00645690 /* MAL_Updater_OS_XTests.m */; };
91A9B6701EA9192D00645690 /* testdata.json in Resources */ = {isa = PBXBuildFile; fileRef = 9115DA401EA911A300CAEF4E /* testdata.json */; };
F84F3D3920AB248A00B9250F /* DonationCheck_KeyOnly.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; };
F84F3D3A20AB249900B9250F /* DonationCheck_KeyOnly.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; };
F84F3D3B20AB249900B9250F /* DonationCheck_KeyOnly.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -251,6 +254,7 @@
91206C1F1E75F5AD0050E9C5 /* MASPreferences.framework in CopyFiles */,
2D3CBE4A1F1532950085888D /* XMLReader.framework in CopyFiles */,
2D63136F1EDA287200C3CB6B /* DetectionKit.framework in CopyFiles */,
F84F3D3B20AB249900B9250F /* DonationCheck_KeyOnly.framework in CopyFiles */,
91A609F51EA3E77C00EF40AB /* CocoaOniguruma.framework in CopyFiles */,
2D6522711F7B50CD00A65BF8 /* GBPing.framework in CopyFiles */,
2D6313731EDA293B00C3CB6B /* Reachability.framework in CopyFiles */,
Expand Down Expand Up @@ -497,6 +501,7 @@
91A9B6661EA918FB00645690 /* MAL Updater OS XTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MAL Updater OS XTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
91A9B6681EA918FB00645690 /* MAL_Updater_OS_XTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MAL_Updater_OS_XTests.m; sourceTree = "<group>"; };
91A9B66A1EA918FB00645690 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DonationCheck_KeyOnly.framework; path = Frameworks/DonationCheck_KeyOnly.framework; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -545,6 +550,7 @@
91206C1E1E75F5AD0050E9C5 /* MASPreferences.framework in Frameworks */,
9149EBE21E75F8A700B1AA22 /* MASShortcut.framework in Frameworks */,
2D6313721EDA293B00C3CB6B /* Reachability.framework in Frameworks */,
F84F3D3920AB248A00B9250F /* DonationCheck_KeyOnly.framework in Frameworks */,
2D6522751F7B50FC00A65BF8 /* MSWeakTimer_macOS.framework in Frameworks */,
91A609F31EA3E77400EF40AB /* CocoaOniguruma.framework in Frameworks */,
2D9C3AE11E6A0BC7007D8F68 /* EasyNSURLConnection.framework in Frameworks */,
Expand All @@ -565,6 +571,7 @@
2D63136E1EDA287200C3CB6B /* DetectionKit.framework in Frameworks */,
9161B2011E90246200FBF52F /* Fabric.framework in Frameworks */,
5C2B9DFC1221EB25006DEF0D /* CoreData.framework in Frameworks */,
F84F3D3A20AB249900B9250F /* DonationCheck_KeyOnly.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -629,6 +636,7 @@
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */,
2D6522741F7B50F700A65BF8 /* MSWeakTimer_macOS.framework */,
2D65226F1F7B50C700A65BF8 /* GBPing.framework */,
2D65226E1F7B50C600A65BF8 /* PingNotifier.framework */,
Expand Down
4 changes: 2 additions & 2 deletions MAL_Updater_OS_X-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.3.16</string>
<string>2.3.17</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.3.16</string>
<string>2.3.17</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
3 changes: 2 additions & 1 deletion MAL_Updater_OS_XAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ - (IBAction)showaboutwindow:(id)sender{
[copyrightstr appendFormat:@"This copy is registered to: MAL Library User"];
}
else {
[copyrightstr appendFormat:@"This copy is registered to: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
[copyrightstr appendFormat:@"This copy is registered to: %@\r", [[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
[copyrightstr appendFormat:@"Donation Key: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"]];
}
}
else {
Expand Down
72 changes: 45 additions & 27 deletions Utility.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#import <EasyNSURLConnection/EasyNSURLConnection.h>
#import <CocoaOniguruma/OnigRegexp.h>
#import <CocoaOniguruma/OnigRegexpUtility.h>
#ifdef oss
#else
#import <DonationCheck_KeyOnly/DonationKeyVerify.h>
#endif

@implementation Utility
+ (int)checkMatch:(NSString *)title
Expand Down Expand Up @@ -85,32 +89,35 @@ + (NSString *)urlEncodeString:(NSString *)string{
}
+ (void)donateCheck:(MAL_Updater_OS_XAppDelegate*)delegate{
if ([NSUserDefaults.standardUserDefaults boolForKey:@"MacAppStoreMigrated"]) {
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"MacAppStoreMigrated"];
return;
}
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"]) {
[Utility setReminderDate];
}
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"] timeIntervalSinceNow] < 0) {
if (((NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"donated"]).boolValue) {
int validkey = [Utility checkDonationKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"] name:[[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
if (validkey == 1) {
//Reset check
[Utility setReminderDate];
}
else if (validkey == 2) {
//Try again when there is internet access
}
else {
//Invalid Key
[Utility showsheetmessage:@"Donation Key Error" explaination:@"This key has been revoked. Please contact the author of this program or enter a valid key." window:nil];
[Utility showDonateReminder:delegate];
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
}
if (((NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"donated"]).boolValue) {
int validkey = [Utility checkDonationKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"] name:[[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
if (validkey == 1) {
//Reset check
[Utility setReminderDate];
return;
}
else if (validkey == 2) {
//Try again when there is internet access
return;
}
else {
//Invalid Key
[Utility showsheetmessage:@"Donation Key Error" explaination:@"This key has been revoked. Please contact the author of this program or enter a valid key." window:nil];
[Utility showDonateReminder:delegate];
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
return;
}
}
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"] timeIntervalSinceNow] < 0) {
[Utility showDonateReminder:delegate];
}
}
+ (void)showDonateReminder:(MAL_Updater_OS_XAppDelegate*)delegate{
// Shows Donation Reminder
Expand Down Expand Up @@ -147,23 +154,34 @@ + (void)setReminderDate{
[[NSUserDefaults standardUserDefaults] setObject:reminderdate forKey:@"donatereminderdate"];
}
+ (int)checkDonationKey:(NSString *)key name:(NSString *)name{
//Set Search API
NSURL *url = [NSURL URLWithString:@"https://licensing.malupdaterosx.moe/keycheck.php"];
EasyNSURLConnection *request = [[EasyNSURLConnection alloc] initWithURL:url];
[request addFormData:name forKey:@"name"];
[request addFormData:key forKey:@"key"];
//Ignore Cookies
[request setUseCookies:NO];
//Perform Search
[request startJSONFormRequest:EasyNSURLConnectionJsonType];
// Get Status Code
long statusCode = [request getStatusCode];
// Check Cocoafob Keys
bool valid = [DonationKeyVerify checkMALULicense:name withDonationKey:key];
if (valid) {
return 1;
}
// Checks Donation Key validatity
NSURL *url = [NSURL URLWithString:@"https://licensing.malupdaterosx.moe/keycheck.php"];
EasyNSURLConnection *request = [[EasyNSURLConnection alloc] initWithURL:url];
[request addFormData:name forKey:@"name"];
[request addFormData:key forKey:@"key"];
//Ignore Cookies
[request setUseCookies:NO];
//Perform Search
[request startJSONFormRequest:EasyNSURLConnectionJsonType];
// Get Status Code
long statusCode = [request getStatusCode];
if (statusCode == 200) {
NSError* jerror;
NSDictionary *d = [NSJSONSerialization JSONObjectWithData:request.response.responsedata options:nil error:&jerror];
int valid = ((NSNumber *)d[@"valid"]).intValue;
if (valid == 1) {
// Valid Key
if (d[@"newlicense"]) {
[[NSUserDefaults standardUserDefaults] setObject:d[@"newlicense"] forKey:@"donatekey"];
}
else {
[[NSUserDefaults standardUserDefaults] setObject:key forKey:@"donatekey"];
}
return 1;
}
else {
Expand Down

0 comments on commit fc06ef4

Please sign in to comment.